void deleteAllElements(){ GSErrCode err; GS::Array<API_Guid> elemList; err = ACAPI_Element_GetElemList(API_ZombieElemID, &elemList); if (hasError(err)){ quit(); return; } if (elemList.GetSize() > 0){ int size = elemList.GetSize(); API_Elem_Head* headList = new API_Elem_Head[size]; API_Elem_Head* toDelete; for (int i = 0; i < size; i++){ API_Element el; el.header.guid = elemList.Get(i); headList[i] = el.header; /* err = ACAPI_Element_Get(&el); toDelete = &el.header; ACAPI_Element_Delete(&toDelete, 1); if (hasError(err)){ quit(); return; } */ } ACAPI_Element_Delete(&headList, size); if (hasError(err)){ quit(); return; } } }
void doOnlineStoreFile(ClientThreadResource * res , ListenSocket clientSocket , RuntimeErrorValidator * validator){ int handleId = callKssOperationOpenFile(res->heapHandler, res->argument , OPENING_MODE_WRITE , validator); FileBlock * block = buildEmptyFileBlock(res->heapHandler); block->sector1.dataLength = receiveBytes(clientSocket , block->sector1.data , sizeof(block->sector1.data)); block->sector2.dataLength = receiveBytes(clientSocket , block->sector2.data , sizeof(block->sector2.data)); while ( (block->sector1.dataLength + block->sector2.dataLength) > 0) { callKssOperationWrite(res->heapHandler , handleId , block , validator); if(hasError(validator)){ break; } cleanBlock(block); block->sector1.dataLength = receiveBytes(clientSocket , block->sector1.data , sizeof(block->sector1.data)); block->sector2.dataLength = receiveBytes(clientSocket , block->sector2.data , sizeof(block->sector2.data)); } callKssOperationCloseFile(res->heapHandler , handleId , validator); if (!hasError(validator)) { res->resultMessage = buildResponseMessageType226(res->heapHandler); } else { res->resultMessage = buildResponseMessageType426(res->heapHandler); } }
QList<Task*> WorkflowRunFromCMDLineBase::onSubTaskFinished( Task* subTask ) { assert( subTask != NULL ); QList<Task*> res; propagateSubtaskError(); if( hasError() || isCanceled() ) { return res; } assert( !hasError() ); // if error, we won't be here if( loadTask == subTask ) { Schema * schema = loadTask->getSchema(); assert( schema != NULL ); remapping = loadTask->getRemapping(); setSchemaCMDLineOptions( schema, optionsStartAt ); if( schema->getDomain().isEmpty() ) { QList<QString> domainsId = WorkflowEnv::getDomainRegistry()->getAllIds(); assert(!domainsId.isEmpty()); if(!domainsId.isEmpty()) { schema->setDomain(domainsId.first()); } } QStringList l; bool good = WorkflowUtils::validate(*schema, l); if(!good) { QString schemaHelpStr = QString("\n\nsee 'ugene --help=%1' for details").arg(schemaName); setError("\n\n" + l.join("\n\n") + schemaHelpStr); return res; } workflowRunTask = getWorkflowRunTask(); res << workflowRunTask; } return res; }
bool CCTCPSocket::recvFromSock() { // basic check if (m_inBufLen >= kCCSocketInputBufferDefaultSize || m_sock == kCCSocketInvalid) { return false; } // max byte can be hold by read buffer and the write position // for the first read operation int savelen, savepos; if(m_inBufStart + m_inBufLen < kCCSocketInputBufferDefaultSize){ savelen = kCCSocketInputBufferDefaultSize - (m_inBufStart + m_inBufLen); } else { savelen = kCCSocketInputBufferDefaultSize - m_inBufLen; } // read to buffer end savepos = (m_inBufStart + m_inBufLen) % kCCSocketInputBufferDefaultSize; int inlen = recv(m_sock, m_inBuf + savepos, savelen, 0); if(inlen > 0) { m_inBufLen += inlen; if (m_inBufLen > kCCSocketInputBufferDefaultSize) { return false; } // read second if has more if(inlen == savelen && m_inBufLen < kCCSocketInputBufferDefaultSize) { int savelen = kCCSocketInputBufferDefaultSize - m_inBufLen; int savepos = (m_inBufStart + m_inBufLen) % kCCSocketInputBufferDefaultSize; inlen = recv(m_sock, m_inBuf + savepos, savelen, 0); if(inlen > 0) { m_inBufLen += inlen; if (m_inBufLen > kCCSocketInputBufferDefaultSize) { return false; } } else if(inlen == 0) { destroy(); return false; } else { if (hasError()) { destroy(); return false; } } } } else if(inlen == 0) { destroy(); return false; } else { if (hasError()) { destroy(); return false; } } return true; }
int Compiler::linkModule(llvm::Module *moduleWith) { if (llvm::Linker::LinkModules(mModule, moduleWith, llvm::Linker::DestroySource, &mError) != 0) { return hasError(); } // Everything for linking should be settled down here with no error occurs mHasLinked = true; return hasError(); }
Task::ReportResult GTest_UHMM3SearchCompare::report() { assert( !hasError() ); setAndCheckArgs(); if( hasError() ) { return ReportResult_Finished; } UHMM3SearchResult trueRes; try { trueRes = getOriginalSearchResult( trueOutFilename ); } catch( const QString& ex ) { stateInfo.setError( ex ); } catch(...) { stateInfo.setError( "undefined_error_occurred" ); } if( hasError() ) { return ReportResult_Finished; } switch( algo ) { case GENERAL_SEARCH:{ assert( NULL != generalTask ); QList<UHMM3SearchResult> res = generalTask->getResult(); if(res.size() < 1){ stateInfo.setError("no result"); return ReportResult_Finished; } generalCompareResults(res.first() , trueRes, stateInfo ); break; } case SEQUENCE_WALKER_SEARCH: { QList<UHMM3SWSearchTaskDomainResult> result; if( NULL != swTask ) { result = swTask->getResults(); } else { assert( false ); } qSort(trueRes.domainResList.begin(), trueRes.domainResList.end(), searchResultLessThan); swCompareResults( result, trueRes, stateInfo ); } break; default: assert( 0 && "unknown_algo_type" ); } return ReportResult_Finished; }
void testDeleting(){ RuntimeErrorValidator * validator = buildErrorSuccessValidator(); deleteFile("VDA1" , "archivo1.txt" , validator); if(hasError(validator)){ error(validator->errorDescription); return ; } deleteFile("VDA1" , "archivo2.txt" , validator); if(hasError(validator)){ error(validator->errorDescription); return ; } }
bool updateSingle() { double elapsed = m_stopwatch.msF(); if (m_transitionState == TransitionState::FadeOut && elapsed >= m_transitionTimeMillisec) { m_current = nullptr; m_current = m_factories[m_nextState](); if (hasError()) { return false; } m_currentState = m_nextState; m_transitionState = TransitionState::FadeIn; m_stopwatch.restart(); elapsed = 0.0; } if (m_transitionState == TransitionState::FadeIn && elapsed >= m_transitionTimeMillisec) { m_stopwatch.reset(); m_transitionState = TransitionState::Active; } switch (m_transitionState) { case TransitionState::FadeIn: assert(m_transitionTimeMillisec); m_current->updateFadeIn(elapsed / m_transitionTimeMillisec); return !hasError(); case TransitionState::Active: m_current->update(); return !hasError(); case TransitionState::FadeOut: assert(m_transitionTimeMillisec); m_current->updateFadeOut(elapsed / m_transitionTimeMillisec); return !hasError(); default: return false; } }
void * runShellServiceThread(void * arg){ if(isInfoEnabled()){ info("Quedando a la espera de conecciones Shell"); } ServerSocket * serverSocket = openServerConnection(getShellPort()); setShellServerSocket(serverSocket); ListenSocket listenSocket; ClientConnection * clientConnection; Thread thread; RuntimeErrorValidator * validator = NULL; do{ listenSocket = acceptConnection(serverSocket); validator = buildErrorSuccessValidator(); doHandshake(listenSocket , SHELL_HANDSHAKE , validator); if(!hasError(validator)){ clientConnection = buildClientConnection(listenSocket); pthread_create(&thread , NULL , runServiceShellThread , clientConnection); clientConnection->servingThread = thread; }else{ error("No se pudo lograr el handhsake entre el kss y el proceso remoto Shell"); } }while(isKssRunningStatus()); close(getShellServerSocket()); return EXIT_SUCCESS; }
void GTest_UHMM3SearchCompare::setAndCheckArgs() { assert( !hasError() ); if( searchTaskCtxName.isEmpty() ) { stateInfo.setError( "search_task_ctx_name_is_empty" ); return; } if( trueOutFilename.isEmpty() ) { stateInfo.setError( "true_out_filename_is_empty" ); return; } trueOutFilename = env->getVar( "COMMON_DATA_DIR" ) + "/" + trueOutFilename; Task* searchTask = getContext<Task>( this, searchTaskCtxName ); if( NULL == searchTask ) { stateInfo.setError( tr( "No search task in test context" ) ); return; } generalTask = qobject_cast< UHMM3LoadProfileAndSearchTask* >( searchTask ); swTask = qobject_cast< UHMM3SWSearchTask* >( searchTask ); if( NULL != generalTask ) { algo = GENERAL_SEARCH; } else if (NULL != swTask) { algo = SEQUENCE_WALKER_SEARCH; } else { assert( 0 && "cannot_cast_task_to_search_task" ); } }
char * coreOperationOpenFile(char * path , char * openingMode, RuntimeErrorValidator * validator){ Iterator * tokens = buildIterator(tokenize(path , '/')); char * vdaName = hasMoreElements(tokens) ? next(tokens) : NULL; char * fileName = hasMoreElements(tokens) ? next(tokens) : NULL; if( !isOpeningModeDelete(openingMode) && !isOpeningModeRead(openingMode) && !isOpeningModeWrite(openingMode)){ setError(validator , "El parametro de modo de apertura de archivo no es valido"); return NULL; } if(fileName == NULL || vdaName == NULL){ setError(validator , "La ruta al archivo no tiene el formato valido"); return NULL; } int hdId = openFileInTdd(vdaName , fileName , openingMode , validator); if(hasError(validator) || hdId < 0){ return NULL; }else{ return itoa(hdId); } }
void TSReader::handleError() { if (isComment()) return; if (hasError() && error() == CustomError) // raised by readContents return; const QString loc = QString::fromLatin1("at %3:%1:%2") .arg(lineNumber()).arg(columnNumber()).arg(m_cd.m_sourceFileName); switch (tokenType()) { case NoToken: // Cannot happen default: // likewise case Invalid: raiseError(QString::fromLatin1("Parse error %1: %2").arg(loc, errorString())); break; case StartElement: raiseError(QString::fromLatin1("Unexpected tag <%1> %2").arg(name().toString(), loc)); break; case Characters: { QString tok = text().toString(); if (tok.length() > 30) tok = tok.left(30) + QLatin1String("[...]"); raiseError(QString::fromLatin1("Unexpected characters '%1' %2").arg(tok, loc)); } break; case EntityReference: raiseError(QString::fromLatin1("Unexpected entity '&%1;' %2").arg(name().toString(), loc)); break; case ProcessingInstruction: raiseError(QString::fromLatin1("Unexpected processing instruction %1").arg(loc)); break; } }
bool CalcSetColor::calc() { if(hasError()) return false; getIndicatorVariables(); mData->rewind(); if(1 == mIns.size()) { // Format "<Foo> = SETCOLOR(<Color>)" while(mData->next()) { mData->setColor(mOuts.at(0), mIns.at(0)); } } else { // Format "<Foo> = SETCOLOR(<Variable>, <TrueColor>, <FalseColor>)" double var; while(mData->next()) { if(!mData->getValue(mIns.at(0), var)) {/* error */} if(var > 0.0) mData->setColor(mOuts.at(0), mIns.at(1)); else mData->setColor(mOuts.at(0), mIns.at(2)); } } return true; }
void launch(){ RuntimeErrorValidator * validator = NULL; if(isInfoEnabled()) info("Quedando a la espera de peticiones para realizar operaciones FSS"); MpsMessage * request = NULL; while(isFssRunningStatus()){ validator = buildErrorSuccessValidator(); request = receiveMpsMessage(getFileSystemSocket(), validator); if(request == NULL || hasError(validator)){ error("Se produjo un error en la recepcion, finalizando la aplicacion"); close(getFileSystemSocket()); exit(1); } if(isDebugEnabled()) debug("Reciviendo peticion MPS"); if(isDebugEnabled()) debug(concatAll(3 , "Header.DescriptorId: '" , strndup(request->descriptorId , 16) , "'")); if(isDebugEnabled()) debug( concatAll(3 , "Payload.Arguments: '" , formatListToPreetyString(request->commands) , "'")); if(isDebugEnabled()) debug(concatAll(3 , "Payload.OperationName: '" , request->operationName , "'")); executeOperation(getFileSystemSocket() , request , validator); } }
bool CCTCPSocket::flush() { // basic checking if (m_sock == kCCSocketInvalid) { return false; } if(m_outBufLen <= 0) { return true; } // send int outsize; outsize = send(m_sock, m_outBuf, m_outBufLen, 0); if(outsize > 0) { // move cursor if(m_outBufLen - outsize > 0) { memcpy(m_outBuf, m_outBuf + outsize, m_outBufLen - outsize); } m_outBufLen -= outsize; // any more? if (m_outBufLen < 0) { return false; } } else { if (hasError()) { destroy(); return false; } } return true; }
QList<Task*> DnaAssemblyTaskWithConversions::onSubTaskFinished(Task *subTask) { QList<Task*> result; CHECK(!subTask->hasError(), result); CHECK(!hasError(), result); ConvertFileTask *convertTask = dynamic_cast<ConvertFileTask*>(subTask); if (NULL != convertTask) { SAFE_POINT_EXT(conversionTasksCount > 0, setError("Conversions task count error"), result); if (convertTask->getSourceURL() == settings.refSeqUrl) { settings.refSeqUrl = convertTask->getResult(); } for (QList<ShortReadSet>::Iterator i=settings.shortReadSets.begin(); i != settings.shortReadSets.end(); i++) { if (convertTask->getSourceURL() == i->url) { i->url = convertTask->getResult(); } } conversionTasksCount--; if (0 == conversionTasksCount) { assemblyTask = new DnaAssemblyMultiTask(settings, viewResult, justBuildIndex); result << assemblyTask; } } return result; }
size_t UpdaterClass::writeStream(Stream &data) { size_t written = 0; size_t toRead = 0; if(hasError() || !isRunning()) return 0; while(remaining()) { toRead = FLASH_SECTOR_SIZE - _bufferLen; toRead = data.readBytes(_buffer + _bufferLen, toRead); if(toRead == 0){ //Timeout _error = UPDATE_ERROR_STREAM; _currentAddress = (_startAddress + _size); #ifdef DEBUG_UPDATER printError(DEBUG_UPDATER); #endif return written; } _bufferLen += toRead; if((_bufferLen == remaining() || _bufferLen == FLASH_SECTOR_SIZE) && !_writeBuffer()) return written; written += toRead; yield(); } return written; }
size_t UpdaterClass::write(uint8_t *data, size_t len) { size_t left = len; if(hasError() || !isRunning()) return 0; if(len > remaining()) len = remaining(); while((_bufferLen + left) > FLASH_SECTOR_SIZE) { size_t toBuff = FLASH_SECTOR_SIZE - _bufferLen; memcpy(_buffer + _bufferLen, data + (len - left), toBuff); _bufferLen += toBuff; if(!_writeBuffer()){ return len - left; } left -= toBuff; yield(); } //lets see whats left memcpy(_buffer + _bufferLen, data + (len - left), left); _bufferLen += left; if(_bufferLen == remaining()){ //we are at the end of the update, so should write what's left to flash if(!_writeBuffer()){ return len - left; } } return len; }
bool start(ttstr const &target, const tjs_char *param=0, const tjs_char *folder=0) { if (hasError()) return false; ttstr cmd(L"\""); // 吉里吉里サーチパス上にある場合はそちらを優先 if (TVPIsExistentStorage(target)) { ttstr tmp = TVPGetPlacedPath(target); TVPGetLocalName(tmp); /**/cmd += tmp + L"\""; } else cmd += target + L"\""; if (param && wcslen(param) > 0) cmd += L" " + ttstr(param); LPWSTR cmdline = (LPWSTR)cmd.c_str(); // 子プロセス作成 STARTUPINFO si; ::ZeroMemory(&si, sizeof(si)); si.cb = sizeof(si); si.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW; si.hStdOutput = hOW; si.hStdInput = hIR; si.hStdError = hEW; si.wShowWindow = SW_HIDE; if (!::CreateProcessW(0, cmdline, 0, 0, TRUE, CREATE_DEFAULT_ERROR_MODE | CREATE_NEW_CONSOLE | CREATE_NEW_PROCESS_GROUP, 0, folder, &si, &pi)) { error = ERR_PROC; return false; } return true; }
void executeOperationRead(ListenSocket ls , MpsMessage * aReq , RuntimeErrorValidator * validator) { Iterator * ite = buildIterator(aReq->commands); char * fileId = hasMoreElements(ite) ? next(ite) : NULL; /* Se recibe como parametro. * Es una buena practica obtenerlo de esta forma y no mantener un estado aunq * el enunciado no dice nada. * En ultima instancia hay q mantener el estado de las peticiones para este cliente y * de esta manera el ultimo sector consumido. */ char * lastSectorSended = hasMoreElements(ite) ? next(ite) : NULL; FileBlock * block = coreOperationReadFile(fileId , lastSectorSended , validator); if(hasError(validator)) { replyValidationError(ls , aReq , validator); return; } List blockList = NULL; if(hasTwoSectors(block)) { blockList = buildStringsListWithValues(4 , itoa(block->sector1.sector) , block->sector1.data , itoa(block->sector2.sector) , block->sector2.data ); } else { blockList = buildStringsListWithValues(2 , itoa(block->sector1.sector) , block->sector1.data); } MpsMessage * response = buildMpsMessage(aReq->descriptorId , MPS_RESPONSE_STATUS_CODE_SUCCESS , aReq->operationName , blockList); sendMpsMessage(response , ls , validator); }
void testFreeingSectors(){ RuntimeErrorValidator * validator = buildErrorSuccessValidator(); Bool aSortingCriteria(int * i , int * x){ return (*i < *x); } Bool equalityCriteria(int * a , int * b){ return (*a == *b); } List lista = createList(NULL , (Bool (*)(void* , void*))equalityCriteria, (Bool (*)(void* , void*))aSortingCriteria); addNode(lista , newInteger(18)); addNode(lista , newInteger(20)); addNode(lista , newInteger(2)); addNode(lista , newInteger(11)); addNode(lista , newInteger(13)); addNode(lista , newInteger(1)); addNode(lista , newInteger(17)); freeSectors("VDA1" , lista , validator); if(hasError(validator)){ error(validator->errorDescription); return ; } }
void configure(RuntimeErrorValidator * v){ setupConfiguration(v); closingEvents(); if(hasError(v)){ return; } //setLoggingLevelEnabled(LOGGING_LEVEL_INFO); setFssRunningStatus(TRUE); setupDirectoryIndexes(); if(isInfoEnabled()) info("Conectando con modulo KSS"); ListenSocket s = openClientConnection(getKssHost() , getKssPort()); if(s == INVALID_SOCKET){ setError(v , "no se puede abrir la coneccion"); return; } MpsHandshake * handshake = buildMpsHandhake(generateRandomKey(16) , FSS_HANDSHAKE); handshake = sendAndReceiveMpsHandshake(handshake , s , v); if(handshake != NULL && handshake->statusCode == MPS_RESPONSE_STATUS_CODE_SUCCESS ){ info(concatAll(2 , "Handshake realizado satisfactoriamente con DescriptorId: " , handshake->descriptorId)); setFileSystemSocket(s); }else{ setError(v , "Hubo un problema y no se pudo realizar el handshake"); return; } }
QCharsetMatch QCharsetDetector::detect() { // Just call QCharsetDetector::detectAll() and take the first // match here instead of using ucsdet_detect() to get only a // single match. The list returned by ucsdet_detectAll() maybe // tweaked a bit in QCharsetDetector::detectAll() to improve // the quality of the detection. Therefore, the first element // of the list returned by QCharsetDetector::detectAll() may // differ from the single match returned by ucsdet_detect(). Q_D(QCharsetDetector); QList<QCharsetMatch> qCharsetMatchList = detectAll(); if(hasError()) { qWarning() << __PRETTY_FUNCTION__ << errorString(); return QCharsetMatch(); } if (qCharsetMatchList.isEmpty()) { // should never happen, because detectAll() already sets an // error if no matches are found which the previous // if(hasError()) should detect. d->_status = U_CE_NOT_FOUND_ERROR; qWarning() << __PRETTY_FUNCTION__ << "no matches found at all" << errorString(); return QCharsetMatch(); } return qCharsetMatchList.first(); }
Task::ReportResult BgzipTask::report() { if (hasError() || isCanceled()) { QDir outputDir(bgzfUrl.dirPath()); outputDir.remove(bgzfUrl.getURLString()); } return ReportResult_Finished; }
uint32_t HPACKDecoder::decode(Cursor& cursor, uint32_t totalBytes, headers_t& headers) { uint32_t emittedSize = 0; HPACKDecodeBuffer dbuf(getHuffmanTree(), cursor, totalBytes); while (!hasError() && !dbuf.empty()) { emittedSize += decodeHeader(dbuf, &headers); if (emittedSize > maxUncompressed_) { LOG(ERROR) << "exceeded uncompressed size limit of " << maxUncompressed_ << " bytes"; err_ = DecodeError::HEADERS_TOO_LARGE; return dbuf.consumedBytes(); } } if (version_ != Version::HPACK05) { return dbuf.consumedBytes(); } emittedSize += emitRefset(headers); // the emitted bytes from the refset are bounded by the size of the table, // but adding the check just for uniformity if (emittedSize > maxUncompressed_) { LOG(ERROR) << "exceeded uncompressed size limit of " << maxUncompressed_ << " bytes"; err_ = DecodeError::HEADERS_TOO_LARGE; } return dbuf.consumedBytes(); }
/// <summary> /// シーンを更新します。 /// </summary> /// <returns> /// シーンの更新に成功した場合 true, それ以外の場合は false /// </returns> bool updateScene() { if (hasError()) { return false; } if (!m_current) { if (!m_first) { return true; } else if (!init(m_first.value())) { return false; } } if (m_crossFade) { return updateCross(); } else { return updateSingle(); } }
QString MStringSearchPrivate::errorString() const { if (hasError()) return QString(u_errorName(_status)); else return QString(); }
void deleteElements(){ API_Element element; elementidlist elementsToDelete; GSErr err; char buffer[256]; readDelimitedFrom(getClientSocket(), &elementsToDelete); BNZeroMemory(&element, sizeof(API_Element)); API_Elem_Head* test; for (int i = 0; i < elementsToDelete.guid_size(); i++){ element.header.guid = APIGuidFromString(elementsToDelete.guid(i).c_str()); if (ACAPI_Element_Get(&element) == NoError){ layermsg layerMsg; layerMsg.set_name(searchLayers(element.header.layer)); bool hidden = hiddenLayer(layerMsg); if (hidden){ controlLayer(layerMsg, true); } test = &element.header; err = ACAPI_Element_Delete(&test, 1); if (hidden){ controlLayer(layerMsg, false); } if (hasError(err)){ quit(); return; } } } }
Task::ReportResult GzipDecompressTask::report() { if (hasError() || isCanceled()) { QDir outputDir(unzippedUrl.dirPath()); outputDir.remove(unzippedUrl.getURLString()); } return ReportResult_Finished; }
bool CGameSocket::Flush() { if (m_sockClient == INVALID_SOCKET) return false; if (m_nOutBufLen <= 0) return true; int nOutSize = send(m_sockClient, m_outBuf, m_nOutBufLen, 0); //CCLOG("send size: %d", nOutSize); if (nOutSize > 0) { if (m_nOutBufLen - nOutSize > 0) { memcpy(m_outBuf, m_outBuf + nOutSize, m_nOutBufLen - nOutSize); } m_nOutBufLen -= nOutSize; assert(m_nOutBufLen >= 0); return Flush(); } else { if (hasError()) { Destory(); return false; } return true; } }