int IOClose( int closehandle ) { long handle; int index; // if( !MayRelinquishControl ) return( -1 ); index = closehandle - FIRST_HANDLE; if( index < 0 || index > NUM_FILES ) return( 0 ); handle = Files[ index ].handle; Files[ index ].handle = 0; _DBG_IO(( "Closing file %8x", handle )); if( index < 0 || index >= NUM_FILES || Files[ index ].file_type == FILE_INVALID ) { BadFile(); } switch( Files[ index ].file_type ) { case FILE_DOS: ccode = INWDOSClose( handle ); break; case FILE_SERVER: ccode = CloseFile(0, 1, handle ); break; } _DBG_IO(( " RC(%d)\r\n", ccode )); return( ccode ? ErrorCode() : 0 ); }
int IOCreat( char *name ) { LONG handle; my_file *p; // if( !MayRelinquishControl ) return( -1 ); _DBG_IO(( "Creating %s. Open RC(%d)\r\n", name, ccode )); ccode = OpenServer( OpenFile, name, &handle, FILE_ATTRIB_MASK, FILE_OPEN_PRIVS ); if( ccode == 0 ) { ccode = WriteFile( 0, handle, 0, 0, "" ); } else { ccode = OpenServer( CreateFile, name, &handle, 0, 0 ); _DBG_IO(( "Creating %s. Create RC(%d)\r\n", name, ccode )); } if( ccode == 0 ) { p = FindFile(); p->handle = handle; p->routine = ReadServer; p->seekpos = 0; p->filesize = 0; p->file_type = FILE_SERVER; } return( ccode ? ErrorCode() : ( p->handlenum + FIRST_HANDLE ) ); }
long IOSeek( int seekhandle, int seekmode, long seekpos ) { long pos; int index; // if( !MayRelinquishControl ) return( -1 ); index = seekhandle - FIRST_HANDLE; if( index < 0 || index >= NUM_FILES || Files[ index ].file_type == FILE_INVALID ) { BadFile(); } pos = Files[ index ].seekpos; switch( seekmode ) { case SEEK_SET: pos = seekpos; break; case SEEK_CUR: pos += seekpos; break; case SEEK_END: pos = Files[ index ].filesize + seekpos; break; } if( pos < 0 ) { return( ccode ? ErrorCode() : -1 ); } else { Files[ index ].seekpos = pos; return( pos ); } }
ErrorCode FromPublicApi(FABRIC_DATA_LOSS_MODE const & publicMode, __out Enum & mode) { switch (publicMode) { case FABRIC_DATA_LOSS_MODE_PARTIAL: mode = Partial; break; case FABRIC_DATA_LOSS_MODE_FULL: mode = Full; break; case FABRIC_DATA_LOSS_MODE_INVALID: return ErrorCode(ErrorCodeValue::InvalidArgument, wformatString("{0}", FASResource::GetResources().DataLossModeInvalid)); default: return ErrorCode(ErrorCodeValue::InvalidArgument, wformatString("{0}", FASResource::GetResources().DataLossModeUnknown)); } return ErrorCode(ErrorCodeValue::Success); }
ErrorCode FromPublicApi(FABRIC_RESTART_PARTITION_MODE const & publicMode, __out Enum & mode) { switch (publicMode) { case FABRIC_RESTART_PARTITION_MODE_ALL_REPLICAS_OR_INSTANCES: mode = AllReplicasOrInstances; break; case FABRIC_RESTART_PARTITION_MODE_ONLY_ACTIVE_SECONDARIES: mode = OnlyActiveReplicas; break; case FABRIC_RESTART_PARTITION_MODE_INVALID: return ErrorCode(ErrorCodeValue::InvalidArgument, wformatString("{0}", FASResource::GetResources().RestartPartitionModeInvalid)); default: return ErrorCode(ErrorCodeValue::InvalidArgument, wformatString("{0}", FASResource::GetResources().RestartPartitionModeUnknown)); } return ErrorCode(ErrorCodeValue::Success); }
ResourceManager::ResourceManager(std::string assetsFile) { int rc; rc = sqlite3_open(assetsFile.c_str(), &mDB); if(rc != SQLITE_OK){ std::cerr << "Could not open database: " << sqlite3_errmsg(mDB) << std::endl; throw ErrorCode(EC_DB_FAILURE); } }
sf::Font* ResourceManager::getFont(std::string filename) { if (mFonts.count(filename) > 0) { return mFonts.at(filename); } int rc; std::string query = "SELECT bytes FROM files " "WHERE name='" + filename + "';"; sqlite3_stmt *stmt; rc = sqlite3_prepare_v2(mDB, query.c_str(), -1, &stmt, NULL); if(rc != SQLITE_OK){ std::cerr << "Could not prepare query: " << sqlite3_errmsg(mDB) << std::endl; sqlite3_finalize(stmt); throw ErrorCode(EC_DB_FAILURE); } rc = sqlite3_step(stmt); if(rc != SQLITE_ROW){ std::cerr << "Could not execute query: " << sqlite3_errmsg(mDB) << std::endl; sqlite3_finalize(stmt); throw ErrorCode(EC_DB_FAILURE); } const void* data = sqlite3_column_blob(stmt, 0); size_t data_size = sqlite3_column_bytes(stmt, 0); // // Apparently, sf::Font::loadFromFile() doesn't copy the data // memcpy(fontBuffer, data, data_size); sf::Font* font = new sf::Font(); if (!font->loadFromMemory(fontBuffer, data_size)) { throw ErrorCode(EC_FONT_FAILURE); } mFonts[filename] = font; sqlite3_finalize(stmt); return font; }
sf::SoundBuffer* ResourceManager::getSoundBuffer(std::string filename) { if (mSoundBuffers.count(filename) > 0) { return mSoundBuffers.at(filename); } int rc; std::string query = "SELECT bytes FROM files " "WHERE name='" + filename + "';"; sqlite3_stmt *stmt; rc = sqlite3_prepare_v2(mDB, query.c_str(), -1, &stmt, NULL); if(rc != SQLITE_OK){ std::cerr << "Could not prepare query: " << sqlite3_errmsg(mDB) << std::endl; sqlite3_finalize(stmt); throw ErrorCode(EC_DB_FAILURE); } rc = sqlite3_step(stmt); if(rc != SQLITE_ROW){ std::cerr << "Could not execute query: " << sqlite3_errmsg(mDB) << std::endl; sqlite3_finalize(stmt); throw ErrorCode(EC_DB_FAILURE); } const void* data = sqlite3_column_blob(stmt, 0); size_t data_size = sqlite3_column_bytes(stmt, 0); sf::SoundBuffer* soundBuffer = new sf::SoundBuffer(); if (!soundBuffer->loadFromMemory(data, data_size)) { throw ErrorCode(EC_AUDIO_FAILURE); } mSoundBuffers[filename] = soundBuffer; sqlite3_finalize(stmt); return soundBuffer; }
void ResourceManager::loadSprite(GameObject* go, int index, std::string name, int x, int y) { int rc; std::string query = "SELECT left, top, width, height " "FROM sprites " "WHERE name='" + name + "';"; sqlite3_stmt *stmt; rc = sqlite3_prepare_v2(mDB, query.c_str(), -1, &stmt, NULL); if (rc != SQLITE_OK) { std::cerr << "Could not prepare query: " << sqlite3_errmsg(mDB) << std::endl; sqlite3_finalize(stmt); throw ErrorCode(EC_DB_FAILURE); } rc = sqlite3_step(stmt); if(rc != SQLITE_ROW){ std::cerr << "Could not execute query: " << sqlite3_errmsg(mDB) << std::endl; sqlite3_finalize(stmt); throw ErrorCode(EC_DB_FAILURE); } int l = sqlite3_column_int(stmt, 0); int t = sqlite3_column_int(stmt, 1); int w = sqlite3_column_int(stmt, 2); int h = sqlite3_column_int(stmt, 3); sqlite3_finalize(stmt); go->mVertices[index*4+0].position = sf::Vector2f(x, y); go->mVertices[index*4+1].position = sf::Vector2f(x+w, y); go->mVertices[index*4+2].position = sf::Vector2f(x+w, y+h); go->mVertices[index*4+3].position = sf::Vector2f(x, y+h); go->mVertices[index*4+0].texCoords = sf::Vector2f(l, t); go->mVertices[index*4+1].texCoords = sf::Vector2f(l+w, t); go->mVertices[index*4+2].texCoords = sf::Vector2f(l+w, t+h); go->mVertices[index*4+3].texCoords = sf::Vector2f(l, t+h); }
HttpInfo::HttpInfo(const QByteArray &data, PackageType type): m_httpVersion("HTTP/1.1"), m_errorCode(NoError) { m_url.setScheme("http"); QStringList list = QString::fromUtf8(data).split("\r\n"); if(!list.isEmpty()){ QByteArrayList tmp = list.first().toUtf8().split(' '); if(tmp.count() == 3){ if(type == Request){ setMethod(tmp[0]); QByteArray path = tmp[1].split('?').first(); m_url.setPath(path); if(path.count() < tmp[1].count()) m_url.setQuery(tmp[1].mid(path.count() + 1)); setHttpVersion(tmp[2]); }else{ setHttpVersion(tmp[0]); setError(ErrorCode(tmp[1].toInt())); setErrorString(tmp[2]); } }else{ setError(BadRequest); setErrorString(QString("%1 Bad Request").arg(BadRequest)); return; } int i = 1; for(; i < tmp.count(); ++i){ tmp = list[i].toUtf8().split(':'); if(tmp.count() == 2){ setRawHeader(tmp.first(), tmp.last().trimmed()); if(tmp.first() == "Host") m_url.setHost(tmp.last().trimmed()); }else{ setError(BadRequest); setErrorString(QString("%1 Bad Request").arg(BadRequest)); return; } } }else{ setError(BadRequest); setErrorString(QString("%1 Bad Request").arg(BadRequest)); return; } }
ErrorCode ComponentManager::LoadLibrary( const char *name ) { TRACE_BEGIN( LOG_LVL_INFO ); IModule *mod = NULL; ErrorCode result = kNoError; LOG_NOTICE( "Opening Library: %s", name ); ErrorCode (*LoadLibrary)( IComponentManager *mgr ); IModule *(*GetModule)(); void *handle = dlopen( name, RTLD_LAZY ); if ( handle == NULL ) { result = kLoadFailed; LOG_WARN( "Failed to open shared lib \"%s\": %s", name, dlerror() ); } else { LoadLibrary = (ErrorCode (*)(IComponentManager *mgr))dlsym( handle, "JHCOM_LibraryEntry" ); GetModule = (IModule *(*)())dlsym( handle, "JHCOM_GetModule" ); if ( GetModule == NULL || LoadLibrary == NULL ) { result = kLoadFailed; LOG_WARN( "Failed to get symbol" ); } else { LOG( "LoadLibrary is %p", LoadLibrary ); LOG( "RegisterServices is %p", GetModule ); result = LoadLibrary( this ); if ( result == kNoError ) { mod = GetModule(); mod->AddRef(); mod->loadComponents(); ModuleInfo *info = jh_new ModuleInfo( name, mod, handle ); mModules.push_back( info ); } } } return result; }
/*---------------------------------------------------------------------------*/ void TestGainSpan_ATCommands(void) { bool send = true; const uint8_t match[] = "AT\r\r\nOK\r\n\n\r\n"; uint8_t in[sizeof(match)]; uint8_t pos; uint8_t c; uint32_t start; DisplayLCD(LCD_LINE2, "GS ATCmd"); /* Reset the connection by flushing any waiting data */ start = MSTimerGet(); while (MSTimerDelta(start) < 500) { if (GainSpan_SPI_ReceiveByte(SPI_WIFI_CHANNEL, &c)) { Console_UART_SendByte(c); start = MSTimerGet(); } } start = MSTimerGet(); while (1) { /* Infitine loop */ if (send) { /* Do AT commands as fast as possible. */ GainSpan_SPI_SendData("AT\r\n", 4); send = false; pos = 0; start += 10; } if (GainSpan_SPI_ReceiveByte(SPI_WIFI_CHANNEL, &c)) { if (c != GAINSPAN_SPI_CHAR_IDLE) { in[pos++] = c; Console_UART_SendByte(c); if (pos == (sizeof(match) - 1)) { if (memcmp(match, in, sizeof(match) - 1) != 0) { Console_UART_SendByte('_'); ErrorCode(3); } send = true; } } } } }
int IOOpen( char *openname, int openmode ) { BYTE isdos; LONG handle; BYTE filename[14]; BYTE loadpath[256]; my_file *p; LONG filesize; struct find_t dta; // if( !MayRelinquishControl ) return( -1 ); if( openmode == O_RDONLY ) { ccode = OpenFileUsingSearchPath( (BYTE *)openname, &handle, &isdos, loadpath, filename, FALSE, 0 ); AppendStr( (char *)loadpath, (char *)filename ); _DBG_IO(( ( ccode==0 ? "Opened %s." : "" ), loadpath )); } else { ccode = OpenServer( OpenFile, openname, &handle, FILE_ATTRIB_MASK, FILE_OPEN_PRIVS ); _DBG_IO(( "Opened %s.", openname )); isdos = FALSE; } _DBG_IO(( " RC(%d). Handle=%8x\r\n", ccode, handle )); if( ccode == 0 ) { p = FindFile(); p->handle = handle; p->seekpos = 0; p->file_type = isdos ? FILE_DOS : FILE_SERVER; if( isdos ) { p->routine = ReadDOS; ccode = INWDOSFindFirstFile( loadpath, 0, &dta ); p->filesize = dta.size; } else { ccode = GetFileSize( 0, p->handle, &filesize ); p->routine = ReadServer; p->filesize = filesize; } if( openmode != O_RDONLY ) { p->routine = NULL; } _DBG_IO(( ( ccode != 0 ? " Size failed - ccode %d\r\n" : "" ), ccode )); _DBG_IO(( ( ccode == 0 ? " Size is %d\r\n" : "" ), p->filesize )); } return( ccode ? ErrorCode() : ( p->handlenum + FIRST_HANDLE ) ); }
int IOWrite( int writehandle, char *buff, int buff_len ) { my_file *p; int index; int written; // if( !MayRelinquishControl ) return( -1 ); index = writehandle - FIRST_HANDLE; if( index < 0 || index >= NUM_FILES || Files[ index ].file_type != FILE_SERVER ) { BadFile(); } p = &Files[ index ]; written = WriteServer( p->handle, p->seekpos, buff, buff_len ); if( written != buff_len ) { written = ErrorCode(); } return( written ); }
char * scsi_error(int code) { static char text[80], *cp; if (code == 0) return "No error"; if (code == ComeAgain) return "Busy"; switch (ErrorClass(code)) { case ErrorClass(SenseKey): return senseTab[code & 0x0F]; case ErrorClass(ExtendedError): switch (senseMode) { case TDC3600: sprintf(text, "Error code: %s", find_error(tdc3600ercd, ErrorCode(code))); break; default: sprintf(text, "Additional sense code: %02X", ErrorCode(code)); } break; case ErrorClass(StatusError): sprintf(text, "Target status: %s", find_error(targetStatusTab, ErrorCode(code))); break; case ErrorClass(DriverError): sprintf(text, "Operation not implemented"); break; case ErrorClass(SystemError): cp = strerror(ErrorCode(code)); if (cp) strcpy(text, cp); else sprintf(text, "System error: %u", ErrorCode(code)); break; case ErrorClass(HostError): sprintf(text, "Host adapter error: %u", ErrorCode(code)); break; default: sprintf(text, "Other error: %04X", code); break; } return text; }
ErrorCode MainLoop::PackFile() { std::set<PackerType> readyPackersVt; const auto& sourceFileBuff = file_utils::readFile(srcFilePath_.c_str()); std::vector<uint8_t> outFileBuffer; bool bNotAllParsersProcessed; do { bNotAllParsersProcessed = false; for (auto& packer : packersVt_) { if (PackerIsReady(packer->GetPackerType(), readyPackersVt)) { ProcessPacker(packer, sourceFileBuff, outFileBuffer); readyPackersVt.insert(packer->GetPackerType()); } else { bNotAllParsersProcessed = true; } } // dummy check for testing /// todo(azerg): remove me plz static int antiInfiniteLoop{}; if (antiInfiniteLoop > 100) { throw std::runtime_error("infinite mainloop detected"); } ++antiInfiniteLoop; } while (bNotAllParsersProcessed); return ErrorCode(); }
ExecError(int aExitStatus, std::string aErrorMessage) : Error(ErrorCode(aExitStatus), aErrorMessage) {};
SerialCommError(SerialCommErrors aError, std::string aErrorMessage) : Error(ErrorCode(aError), aErrorMessage) {};
ExecError(int aExitStatus) : Error(ErrorCode(aExitStatus)) {};
JsonError(ErrorCodes aError) : Error(ErrorCode(aError), json_tokener_error_desc(aError)) {};
SerialCommError(SerialCommErrors aError) : Error(ErrorCode(aError)) {};
OQError(ErrorCodes aError) : Error(ErrorCode(aError)) {};
void APISetStatus (IO_REQ_PTR Req, // Request structure APIStatus Status, // Status TerminateCode Terminal, // Is this the terminal (Notify completion) AutosenseCode IsSenseable) // Auto sense allowed? { static U8 REQStats[]={ SRB_STATUS_PENDING, SRB_STATUS_PENDING, SRB_STATUS_ABORTED, SRB_STATUS_BAD_FUNCTION, SRB_STATUS_INVALID_REQUEST, SRB_STATUS_NO_HBA, SRB_STATUS_DATA_OVERRUN, SRB_STATUS_SELECTION_TIMEOUT, SRB_STATUS_INVALID_TARGET_ID, SRB_STATUS_INVALID_LUN }; static U8 ADStats[]={ SRB_STATUS_NO_HBA, SRB_STATUS_BUSY, SRB_STATUS_UNEXPECTED_BUS_FREE, SRB_STATUS_PHASE_SEQUENCE_FAILURE, SRB_STATUS_BUS_RESET, SRB_STATUS_AUTOSENSE_VALID, SRB_STATUS_ERROR}; // Make sure the high numbers match what this module knows of: #if S_LAST_S_REQ != 0x09 #err #endif #if S_LAST_S_AD != 0x06 #err #endif #if S_LAST_S_SYS != 0 #err #endif switch (ErrorClass(Status)) { case RequestClass: DEBUG(0, if (Status == S_REQ_ABORT) TRACE(0, ("APISetStatus(): Set Req (%x) status to aborted\n")) ); Req->SrbStatus = REQStats[ErrorCode(Status)]; break; case AdapterClass: Req->SrbStatus = ADStats[ErrorCode(Status)]; break; case TargetClass: Req->ScsiStatus = ErrorCode(Status); switch (ErrorCode(Status)) { case STATUS_CKCOND: ReqDataCount(Req) = ReqSavedIndex(Req); #if defined(AUTOSENSE) if ((IsSenseable == Senseable) && ReqSenseCount(Req)) { Terminal = NonTerminal; QueueInternalRequest(ReqAdapterPtr(Req), Req, RTAutoSenseReq); } else #endif Req->SrbStatus = SRB_STATUS_ERROR; break; case STATUS_GOOD: case STATUS_CONDMET: case STATUS_INTGOOD: case STATUS_INTCONDMET: Req->SrbStatus = SRB_STATUS_SUCCESS; if (ReqDataCount(Req) > ReqSavedIndex(Req)) { Req->SrbStatus = SRB_STATUS_DATA_OVERRUN; // Update number of bytes transferred. // ReqSavedIndex is the number of bytes successfully transfered // One thing the NT people will have to address is zero latency // xfers. How will number of bytes xfered be represented // on an error, when the xfer has holes? ReqDataCount(Req) = ReqSavedIndex(Req); } break; default: Req->SrbStatus = SRB_STATUS_ERROR; break; } TRACE(4, ("APISetStatus(): Setting target status to %02x\n", Req->ScsiStatus)); break; } TRACE(4, ("APISetStatus(): Setting request status to %02x\n", Req->SrbStatus)); if (Terminal != NonTerminal) { TRACE(3, ("APISetStatus(): Notifying completion\n")); Notify(ReqAdapterPtr(Req), Req); } }
SQError(SQErrors aError) : Error(ErrorCode(aError)) {};
HueCommError(HueCommErrors aError) : Error(ErrorCode(aError)) {};
void PromiseResolver::ResolvePromise(Environment* ev) { CMValue value = fSU->GetCurValue(ev); ODValueRefCon* theRefCon = (ODValueRefCon *) this->GetPromiseInfo(value); if (theRefCon) { ODStorageUnitView* destSUView = kODNULL; ODVolatile(destSUView); TRY fResolvingPromiseInfo = theRefCon; // First we must remove the refCon to stop any recursion this->SetPromiseInfo(value, kODNULL); // Create a view for this storage unit destSUView = fSU->CreateView(ev); #ifdef _PLATFORM_MACINTOSH_ ODDragAndDrop* dragAndDrop = fSU->GetSession(ev)->GetDragAndDrop(ev); if (dragAndDrop->GetDragReference(ev) == 0) { Boolean sameProcess; #else ODBoolean sameProcess = kODTrue; #endif OSErr result; ProcessSerialNumber thePSN; #if defined(_PLATFORM_WIN32_)||defined(_PLATFORM_OS2_)||defined(_PLATFORM_AIX_) result = 0; #else result = GetCurrentProcess(&thePSN); THROW_IF_ERROR(result); result = SameProcess(&(theRefCon->sourcePSN), &thePSN, &sameProcess); THROW_IF_ERROR(result); #endif if (sameProcess) { ODPart* sourcePart = theRefCon->sourcePart; if (sourcePart) sourcePart->FulfillPromise(ev, destSUView); } else { WARNMSG(WARN_INDEX(AMSG_410),"Cannot fulfill promise in another process."); } #ifdef _PLATFORM_MACINTOSH_ } else { fSU->GetSession(ev)->GetDragAndDrop(ev)->GetPromiseFromDragManager(ev, theRefCon->sourcePart, destSUView); } #endif destSUView->SetOffset(ev, 0); delete destSUView; ODPart* sourcePart = theRefCon->sourcePart; if (sourcePart) { ODReleaseObject(ev, sourcePart); } ODDisposePtr(theRefCon); this->DecrementPromiseCount(); CATCH_ALL if (destSUView) delete destSUView; fResolvingPromiseInfo = kODNULL; if (ErrorCode() != kODErrUnfocusedStorageUnit) RERAISE; ENDTRY fResolvingPromiseInfo = kODNULL; } }
ErrorCode XposedPatcher::error() const { return ErrorCode(); }
SocketCommError(ErrorCodes aError) : Error(ErrorCode(aError)) {};
SsdpError(SsdpErrors aError) : Error(ErrorCode(aError)) {};
SsdpError(SsdpErrors aError, std::string aErrorMessage) : Error(ErrorCode(aError), aErrorMessage) {};