int WaveOut::Write(char * lpData,size_t len) { if(len<=0){ return 0; } m_whdr[m_whdrPtr].dwBufferLength=len; m_whdr[m_whdrPtr].dwUser=0; m_whdr[m_whdrPtr].dwFlags=0; m_whdr[m_whdrPtr].dwBytesRecorded=0; m_whdr[m_whdrPtr].dwLoops=1; m_whdr[m_whdrPtr].reserved=0; m_whdr[m_whdrPtr].lpNext=NULL; m_whdr[m_whdrPtr].lpData=lpData; m_nRet=waveOutPrepareHeader(m_hWaveOut,&m_whdr[m_whdrPtr],sizeof(m_whdr)); if(m_nRet!=MMSYSERR_NOERROR){ //Error("waveOutPrepareHeader"); FormatError("Error when OutPrepareHeader,in WaveOut::Write,Code %d ",(int)m_nRet); return 0; } m_nRet=waveOutWrite(m_hWaveOut,&m_whdr[m_whdrPtr],sizeof(m_whdr)); if(m_nRet!=MMSYSERR_NOERROR){ //Error("waveOutWrite"); FormatError("Error when OutWrite ,in WaveOut.cpp , Code : %d ",(int)m_nRet); return 0; } m_whdrPtr=(m_whdrPtr+1)%6; return 1; }
void ChiPlotDataSet::load_data(std::istream &f) { string graph_title = trim_label(read_line(f)); string x_label = trim_label(read_line(f)); string y_label = trim_label(read_line(f)); string line = read_line(f); string::size_type pos = line.find(','); if (pos != string::npos) line[pos] = ' '; int n_points, n_ycols; int r = sscanf(line.c_str(), "%d %d", &n_points, &n_ycols); if (r == 1) n_ycols = 1; else if (r != 2) throw FormatError("expected number(s) in line 4"); if (n_points <= 0 || n_ycols <= 0) throw FormatError("expected positive number(s) in line 4"); vector<VecColumn*> cols(n_ycols + 1); for (size_t i = 0; i != cols.size(); ++i) cols[i] = new VecColumn; try { for (int i = 0; i != n_points; ++i) { line = read_line(f); const char* p = line.c_str(); for (int j = 0; j != n_ycols + 1; ++j) { char *endptr = NULL; while (isspace(*p) || *p == ',') ++p; double val = strtod(p, &endptr); if (endptr == p) throw FormatError("line " + S(5+i) + ", column " + S(j+1)); cols[j]->add_val(val); p = endptr; } } } catch (std::exception&) { purge_all_elements(cols); throw; } Block *blk = new Block; blk->set_name(graph_title); cols[0]->set_name(x_label); cols[1]->set_name(y_label); for (size_t i = 0; i != cols.size(); ++i) blk->add_column(cols[i]); add_block(blk); }
/* * This routine checks the error value and calls the WSA Windows Sockets * Error message function GetWSAErrorMessage below if it's within that range * since those messages are not available in the system error messages. */ char * NTstrerror(int err, BOOL *bfreebuf) { char *retmsg = NULL; /* Copy the error value first in case of other errors */ DWORD errval = err; *bfreebuf = FALSE; /* Get the Winsock2 error messages */ if (errval >= WSABASEERR && errval <= (WSABASEERR + 1015)) { retmsg = GetWSAErrorMessage(errval); if (retmsg != NULL) return (retmsg); } /* * If it's not one of the standard Unix error codes, * try a system error message */ if (errval > (DWORD) _sys_nerr) { *bfreebuf = TRUE; return (FormatError(errval)); } else { return (strerror(errval)); } }
// Error_1101_MissingProperty //------------------------------------------------------------------------------ /*static*/ void Error::Error_1101_MissingProperty( const BFFIterator & iter, const Function * function, const AString & name ) { FormatError( iter, 1101u, function, "Missing required property '%s'.", name.Get() ); }
// Error_1100_AlreadyDefined //------------------------------------------------------------------------------ /*static*/ void Error::Error_1100_AlreadyDefined( const BFFIterator & iter, const Function * function, const AString & name ) { FormatError( iter, 1100u, function, "Target '%s' already defined.", name.Get() ); }
// Error_1302_MissingPCHCompilerOption //------------------------------------------------------------------------------ /*static*/ void Error::Error_1302_MissingPCHCompilerOption( const BFFIterator & iter, const Function * function, const char * option, const char * property ) { FormatError( iter, 1302u, function, "Missing Precompiled Header option '%s' in '%s'.", option, property ); }
// Error_1301_AlreadyDefinedPCH //------------------------------------------------------------------------------ /*static*/ void Error::Error_1301_AlreadyDefinedPCH( const BFFIterator & iter, const Function * function, const char * pch ) { FormatError( iter, 1301u, function, "Precompiled Header target '%s' has already been defined.", pch ); }
// Error_1303_PCHCreateOptionOnlyAllowedOnPCH //------------------------------------------------------------------------------ /*static*/ void Error::Error_1303_PCHCreateOptionOnlyAllowedOnPCH( const BFFIterator & iter, const Function * function, const char * option, const char * property ) { FormatError( iter, 1303u, function, "Precompiled Header option '%s' in '%s' invalid. Only allowed on Precompiled Header.", option, property ); }
// Error_1002_MatchingClosingTokenNotFound //------------------------------------------------------------------------------ /*static*/ void Error::Error_1002_MatchingClosingTokenNotFound( const BFFIterator & iter, const Function * function, char expectedChar ) { FormatError( iter, 1002u, function, "Matching closing token %c not found.", expectedChar ); }
// Error_1004_EmptyStringPropertyNotAllowed //------------------------------------------------------------------------------ /*static*/ void Error::Error_1004_EmptyStringPropertyNotAllowed( const BFFIterator & iter, const Function * function, const char * propertyName ) { FormatError( iter, 1004u, function, "Empty string not allowed for property '%s'.", propertyName ); }
void ImageDecoder::initialize() { // set default color format pixelInfo.pGUIDPixFmt = &pDecoder->guidPixFormat; Call(PixelFormatLookup(&pixelInfo, LOOKUP_FORWARD)); Call(PixelFormatLookup(&pixelInfo, LOOKUP_BACKWARD_TIF)); // color transcoding if (IsEqualGUID(*pixelInfo.pGUIDPixFmt, GUID_PKPixelFormat8bppGray) || IsEqualGUID(*pixelInfo.pGUIDPixFmt, GUID_PKPixelFormat16bppGray)) { // ** => Y transcoding pDecoder->guidPixFormat = *pixelInfo.pGUIDPixFmt; pDecoder->WMP.wmiI.cfColorFormat = Y_ONLY; } else if (IsEqualGUID(*pixelInfo.pGUIDPixFmt, GUID_PKPixelFormat24bppRGB) && pDecoder->WMP.wmiI.cfColorFormat == CMYK) { // CMYK = > RGB pDecoder->WMP.wmiI.cfColorFormat = CF_RGB; pDecoder->guidPixFormat = *pixelInfo.pGUIDPixFmt; pDecoder->WMP.wmiI.bRGB = 1; // RGB } PixelFormatLookup(&pixelInfo, LOOKUP_FORWARD); // alpha if (!!(pixelInfo.grBit & PK_pixfmtHasAlpha)) { pDecoder->WMP.wmiSCP.uAlphaMode = 2; // default is image & alpha for formats with alpha } else { pDecoder->WMP.wmiSCP.uAlphaMode = 0; // otherwise, 0 } // copy properties from PixelInfo to Decoder pDecoder->WMP.wmiI.cfColorFormat = pixelInfo.cfColorFormat; pDecoder->WMP.wmiI.bdBitDepth = pixelInfo.bdBitDepth; pDecoder->WMP.wmiI.cBitsPerUnit = pixelInfo.cbitUnit; // skip thumbnails pDecoder->WMP.wmiI.cThumbnailWidth = pDecoder->WMP.wmiI.cWidth; pDecoder->WMP.wmiI.cThumbnailHeight = pDecoder->WMP.wmiI.cHeight; pDecoder->WMP.wmiI.bSkipFlexbits = FALSE; // no region decoding pDecoder->WMP.wmiI.cROILeftX = 0; pDecoder->WMP.wmiI.cROITopY = 0; pDecoder->WMP.wmiI.cROIWidth = pDecoder->WMP.wmiI.cWidth; pDecoder->WMP.wmiI.cROIHeight = pDecoder->WMP.wmiI.cHeight; // other default values pDecoder->WMP.wmiSCP.bfBitstreamFormat = SPATIAL; pDecoder->WMP.wmiSCP.sbSubband = SB_ALL; pDecoder->WMP.bIgnoreOverlap = FALSE; pDecoder->WMP.wmiI.oOrientation = O_NONE; pDecoder->WMP.wmiI.cPostProcStrength = 0; pDecoder->WMP.wmiSCP.bVerbose = FALSE; // finished initializing return; Cleanup: throw FormatError("ERROR: Unable to initialize decoder."); }
ErrNo Calculus::GetStart_D(int iSelectIndex) { PCTSTR pErrInfo; TCHAR szBuffer[MAXSIZE]; int nLength; ErrNo err; //获取间隔大小 if(err = GetLine_Double(GetDlgItem(hDlg,EditControlID_D[0]),&interval)) { pErrInfo = FormatError(err); _sntprintf_s(szBuffer,_countof(szBuffer),MAXSIZE,TEXT("错误ID:%d\r\n错误信息:%s\r\n补充信息:输入间隔大小数据错误"),err,pErrInfo); MessageBox(hDlg,szBuffer,TEXT("错误"),MB_ICONERROR); return err; } //获取所求点 if(err = GetLine_Double(GetDlgItem(hDlg,EditControlID_D[1]),&value)) { pErrInfo = FormatError(err); _sntprintf_s(szBuffer,_countof(szBuffer),MAXSIZE,TEXT("错误ID:%d\r\n错误信息:%s\r\n补充信息:输入所求点数据错误"),err,pErrInfo); MessageBox(hDlg,szBuffer,TEXT("错误"),MB_ICONERROR); return err; } //获取函数表达式 if(!(nLength = Edit_GetText(GetDlgItem(hDlg,EditControlID_D[2]),expression,MAXSIZE))) { err = NO_DATA_INPUT; pErrInfo = FormatError(err); _sntprintf_s(szBuffer,_countof(szBuffer),MAXSIZE,TEXT("错误ID:%d\r\n错误信息:%s\r\n补充信息:未输入微分计算所需的表达式"),err,pErrInfo); MessageBox(hDlg,szBuffer,TEXT("错误"),MB_ICONERROR); return err; } //复制一份函数表达式 nLength = _tcslen(expression) + 1; for(int i=0;i<nLength;i++) exp_store[i] = expression[i]; //算法选择 err = Algorithm_Choice_D(iSelectIndex); //输出结果 OutputResult_D(iSelectIndex,err); return 0; }
// Error_1033_ErrorReadingInclude //------------------------------------------------------------------------------ /*static*/ void Error::Error_1033_ErrorReadingInclude( const BFFIterator & iter, const AString & include, uint32_t errorCode ) { FormatError( iter, 1033u, nullptr, "Error reading include '%s' (Error: %u).", include.Get(), errorCode ); }
// Error_1029_VariableForSubstitutionIsNotAString //------------------------------------------------------------------------------ /*static*/ void Error::Error_1029_VariableForSubstitutionIsNotAString( const BFFIterator & iter, const AString & variableName, BFFVariable::VarType varType ) { FormatError( iter, 1029u, nullptr, "Variable for substitution '%s' is not a string (Type: <%s>).", variableName.Get(), BFFVariable::GetTypeName( varType ) ); }
void CLuaScript::Init() { int status; SCRIPTPARAMS sp; CHashString name(m_ScriptName.c_str()); sp.fileName = &name; if (m_ScriptBody == NULL) { // get script based on the file name static DWORD msgHash_GetScript = CHashString(_T("GetScript")).GetUniqueID(); if (m_EngineToolBox->SendMessage(msgHash_GetScript, sizeof(SCRIPTPARAMS), &sp) == MSG_HANDLED) { // extract script body m_ScriptBody = sp.scriptData; assert(m_pThreadState); assert(m_ScriptBody); status = luaL_loadbuffer(m_pThreadState, m_ScriptBody, strlen(m_ScriptBody), "Console"); if (status) { // log error! FormatError(); return; } } } if (m_bAutoStart && m_ScriptBody != NULL) { SINGLETONINSTANCE(CLuaManager)->SetScriptObjectName(GetName()); SINGLETONINSTANCE(CLuaManager)->SetScriptObjectParentName(GetParentName()); status = lua_pcall(m_pThreadState, lua_gettop(m_pThreadState)-1, 0, 0); SINGLETONINSTANCE(CLuaManager)->SetScriptObjectName(NULL); SINGLETONINSTANCE(CLuaManager)->SetScriptObjectParentName(NULL); if (status) { // log error! FormatError(); return; } } }
rose_addr_t SgAsmElfSection::calculate_sizes(size_t r32size, size_t r64size, /*size of required parts*/ const std::vector<size_t> &optsizes, /*size of optional parts and number of parts parsed*/ size_t *entsize, size_t *required, size_t *optional, size_t *entcount) const { size_t struct_size = 0; size_t extra_size = 0; size_t entry_size = 0; size_t nentries = 0; SgAsmElfFileHeader *fhdr = get_elf_header(); /* Assume ELF Section Table Entry is correct for now for the size of each entry in the table. */ ROSE_ASSERT(get_section_entry()!=NULL); entry_size = get_section_entry()->get_sh_entsize(); /* Size of required part of each entry */ if (0==r32size && 0==r64size) { /* Probably called by four-argument SgAsmElfSection::calculate_sizes and we don't know the sizes of the required parts * because there isn't a parser for this type of section, or the section doesn't contain a table. In the latter case * the ELF Section Table has a zero sh_entsize and we'll treat the section as if it were a table with one huge entry. * Otherwise we'll assume that the struct size is the same as the sh_entsize and there's no optional data. */ struct_size = entry_size>0 ? entry_size : get_size(); } else if (4==fhdr->get_word_size()) { struct_size = r32size; } else if (8==fhdr->get_word_size()) { struct_size = r64size; } else { throw FormatError("bad ELF word size"); } /* Entire entry should be at least large enough for the required part. This also takes care of the case when the ELF * Section Table Entry has a zero-valued sh_entsize */ entry_size = std::max(entry_size, struct_size); /* Size of optional parts. If we've parsed the table then use the largest optional part, otherwise assume the entry from * the ELF Section Table is correct. */ nentries = optsizes.size(); if (nentries>0) { for (size_t i=0; i<nentries; i++) { extra_size = std::max(extra_size, optsizes[i]); } entry_size = std::min(entry_size, struct_size+extra_size); } else { extra_size = entry_size - struct_size; nentries = entry_size>0 ? get_size() / entry_size : 0; } /* Return values */ if (entsize) *entsize = entry_size; if (required) *required = struct_size; if (optional) *optional = extra_size; if (entcount) *entcount = nentries; return entry_size * nentries; }
// Error_1104_MissingTarget //------------------------------------------------------------------------------ /*static*/ void Error::Error_1104_TargetNotDefined( const BFFIterator & iter, const Function * function, const char * propertyName, const AString & name ) { FormatError( iter, 1104u, function, "'%s' ('%s') is not defined.", propertyName, name.Get() ); }
// Error_1031_UnexpectedCharFollowingDirectiveName //------------------------------------------------------------------------------ /*static*/ void Error::Error_1031_UnexpectedCharFollowingDirectiveName( const BFFIterator & iter, const AString & directive, char expectedChar ) { FormatError( iter, 1031u, nullptr, "Unknown char '%c' following '%s' directive. (Expected '%c').", *iter, directive.Get(), expectedChar ); }
void TriggerWarning(const char *filename, unsigned int line, const std::string &txt) { std::string err = FormatError(filename, line, txt); std::cerr << "! " << err << std::endl; #ifdef ANDROID __android_log_print(ANDROID_LOG_WARN, "Warmux", err.c_str()); #endif }
void ImageDecoder::selectFrame(unsigned int frameNum) { Call(pDecoder->SelectFrame(pDecoder, frameNum)); return; Cleanup: std::stringstream msg; msg << "ERROR: Unable to select frame " << frameNum; std::string errMsg = msg.str(); throw FormatError(errMsg); }
// Error_1008_VariableOfWrongType //------------------------------------------------------------------------------ /*static*/ void Error::Error_1008_VariableOfWrongType( const BFFIterator & iter, const Function * function, BFFVariable::VarType expectedType, BFFVariable::VarType foundType ) { FormatError( iter, 1008u, function, "Expected a variable of type '%s', but got '%s'.", BFFVariable::GetTypeName( expectedType ), BFFVariable::GetTypeName( foundType ) ); }
/** Given a symbol, return its index in this symbol table. */ size_t SgAsmElfSymbolSection::index_of(SgAsmElfSymbol *symbol) { for (size_t i=0; i<p_symbols->get_symbols().size(); i++) { if (p_symbols->get_symbols()[i]==symbol) return i; } throw FormatError("symbol is not in symbol table"); }
// Error_1106_MissingRequiredToken //------------------------------------------------------------------------------ /*static*/ void Error::Error_1106_MissingRequiredToken( const BFFIterator & iter, const Function * function, const char * propertyName, const char * token ) { FormatError( iter, 1106u, function, "Property '%s' is missing required token '%s'.", propertyName, token ); }
// Error_1027_CannotModify //------------------------------------------------------------------------------ /*static*/ void Error::Error_1027_CannotModify( const BFFIterator & iter, const AString & variableName, BFFVariable::VarType dstType, BFFVariable::VarType srcType ) { FormatError( iter, 1027u, nullptr, "Cannot use <%s> to modify <%s> for Variable '%s'.", BFFVariable::GetTypeName( srcType ), BFFVariable::GetTypeName( dstType ), variableName.Get() ); }
// Error_1054_IntegerOutOfRange //------------------------------------------------------------------------------ /*static*/ void Error::Error_1054_IntegerOutOfRange( const BFFIterator & iter, const Function * function, const char * propertyName, int rangeMin, int rangeMax ) { FormatError( iter, 1054u, function, "Integer '%s' must be in range %i to %i.", propertyName, rangeMin, rangeMax ); }
Resolution ImageDecoder::getResolution() { float rX = 0.0, rY = 0.0; Resolution res; Call(pDecoder->GetResolution(pDecoder, &rX, &rY)); res.X = rX; res.Y = rY; return res; Cleanup: throw FormatError("ERROR: Could not get decoder resolution"); }
// Error_1105_PathNotAllowed //------------------------------------------------------------------------------ /*static*/ void Error::Error_1105_PathNotAllowed( const BFFIterator & iter, const Function * function, const char * propertyName, const AString & propertyValue ) { FormatError( iter, 1105u, function, "Path not allowed for '%s' ('%s').", propertyName, propertyValue.Get() ); }
// Error_1103_NotAFile //------------------------------------------------------------------------------ /*static*/ void Error::Error_1103_NotAFile( const BFFIterator & iter, const Function * function, const char * propertyName, const AString & name, Node::Type foundType ) { FormatError( iter, 1103u, function, "'%s' ('%s') is a '%s', which does not describe a file.", propertyName, name.Get(), Node::GetTypeName( foundType ) ); }
// Error_1005_UnsupportedNodeType //------------------------------------------------------------------------------ /*static*/ void Error::Error_1005_UnsupportedNodeType( const BFFIterator & iter, const Function * function, const char * propertyName, const AString & nodeName, Node::Type nodeType ) { FormatError( iter, 1005u, function, "Unsupported node type in '%s'. (Node: '%s', Type: '%s')", propertyName, nodeName.Get(), Node::GetTypeName( nodeType ) ); }
// Error_1204_LoopVariableLengthsDiffer //------------------------------------------------------------------------------ /*static*/ void Error::Error_1204_LoopVariableLengthsDiffer( const BFFIterator & iter, const Function * function, const char * variableName, uint32_t foundSize, uint32_t expectedSize ) { FormatError( iter, 1204u, function, "Variable '%s' contains %u elements, but loop is for %u elements.", variableName, foundSize, expectedSize ); }