WaylandInterface readInterface(QXmlStreamReader &xml) { WaylandInterface interface; interface.name = byteArrayValue(xml, "name"); interface.version = intValue(xml, "version", 1); while (xml.readNextStartElement()) { if (xml.name() == "event") interface.events << readEvent(xml, false); else if (xml.name() == "request") interface.requests << readEvent(xml, true); else if (xml.name() == "enum") interface.enums << readEnum(xml); else xml.skipCurrentElement(); } return interface; }
criterion_t readCriterion(lua_State* luaSt, const char* name) { return (criterion_t) readEnum(luaSt, criterionOptions, name); }
void * PayloadSearchManager<WriterType>::hbfQueryThread(void *caller) { PayloadSearchManager<WriterType> *_this (reinterpret_cast<PayloadSearchManager<WriterType> *>(caller)); // initialize read enumerator StrftimeReadEnumerator readEnum(_this->_inputDir, "%Y/%m/%d/hbf_%H", _this->_startTime, _this->_endTime); if (!readEnum) { _this->_error = true; _this->_errorMsg.assign("StrftimeReadEnumerator: "); _this->_errorMsg.append(readEnum.error()); // lock results lock if (pthread_mutex_lock(&(_this->_resultsLock)) != 0) { // error _this->_error = true; _this->_errorMsg.assign("Unable to lock _resultsLock"); return NULL; } _this->_hbfRunning = false; // signal condition for correlator thread if (pthread_cond_signal(&(_this->_resultsCondition)) != 0) { _this->_error = true; _this->_errorMsg.assign("Unable to signal _resultsCondition"); return NULL; } // unlock results lock if (pthread_mutex_unlock(&(_this->_resultsLock)) != 0) { // error _this->_error = true; _this->_errorMsg.assign("Unable to unlock _resultsLock"); return NULL; } return NULL; } HBFQueryProcessor <FlatFileReader <ZlibCompressedHBF>, SetWriter <HBFResult> > processor; FlatFileReader <ZlibCompressedHBF> reader; std::set <HBFResult> *curResults; // for each file for (StrftimeReadEnumerator::const_iterator it(readEnum.begin()); it != readEnum.end(); ++it) { // initialize FlatFileReader if (reader.open(*it) != E_SUCCESS) { _this->_error = true; _this->_errorMsg.assign("FlatFileReader error"); // lock results lock if (pthread_mutex_lock(&(_this->_resultsLock)) != 0) { // error _this->_error = true; _this->_errorMsg.assign("Unable to lock _resultsLock"); return NULL; } _this->_hbfRunning = false; // signal condition for correlator thread if (pthread_cond_signal(&(_this->_resultsCondition)) != 0) { _this->_error = true; _this->_errorMsg.assign("Unable to signal _resultsCondition"); return NULL; } // unlock results lock if (pthread_mutex_unlock(&(_this->_resultsLock)) != 0) { // error _this->_error = true; _this->_errorMsg.assign("Unable to unlock _resultsLock"); return NULL; } return NULL; } // initialize SetWriter curResults = new std::set <HBFResult>; SetWriter <HBFResult> writer(*curResults); // initialize HBFQuery <FlatFileReader, SetWriter> processor.init(&reader, &writer, _this->_queryString, _this->_queryLength, _this->_matchLength, _this->_flowMatcher, _this->_maxMTU, _this->_maxFlows, _this->_hbfThreadCount); // hbfQuery.run() if (processor.run() != 0) { _this->_error = true; _this->_errorMsg.assign("HBFQueryProcessor: "); _this->_errorMsg.append(processor.error()); // lock results lock if (pthread_mutex_lock(&(_this->_resultsLock)) != 0) { // error _this->_error = true; _this->_errorMsg.assign("Unable to lock _resultsLock"); return NULL; } _this->_hbfRunning = false; // signal condition for correlator thread if (pthread_cond_signal(&(_this->_resultsCondition)) != 0) { _this->_error = true; _this->_errorMsg.assign("Unable to signal _resultsCondition"); return NULL; } // unlock results lock if (pthread_mutex_unlock(&(_this->_resultsLock)) != 0) { // error _this->_error = true; _this->_errorMsg.assign("Unable to unlock _resultsLock"); return NULL; } return NULL; } // lock results lock if (pthread_mutex_lock(&(_this->_resultsLock)) != 0) { // error _this->_error = true; _this->_errorMsg.assign("Unable to lock _resultsLock"); return NULL; } // push_back set into _results _this->_results.push(curResults); // signal condition for correlator thread if (pthread_cond_signal(&(_this->_resultsCondition)) != 0) { _this->_error = true; _this->_errorMsg.assign("Unable to signal _resultsCondition"); return NULL; } // unlock results lock if (pthread_mutex_unlock(&(_this->_resultsLock)) != 0) { // error _this->_error = true; _this->_errorMsg.assign("Unable to unlock _resultsLock"); return NULL; } reader.close(); } // lock results lock if (pthread_mutex_lock(&(_this->_resultsLock)) != 0) { // error _this->_error = true; _this->_errorMsg.assign("Unable to lock _resultsLock"); return NULL; } _this->_hbfRunning = false; // signal condition for correlator thread if (pthread_cond_signal(&(_this->_resultsCondition)) != 0) { _this->_error = true; _this->_errorMsg.assign("Unable to signal _resultsCondition"); return NULL; } // unlock results lock if (pthread_mutex_unlock(&(_this->_resultsLock)) != 0) { // error _this->_error = true; _this->_errorMsg.assign("Unable to unlock _resultsLock"); return NULL; } return NULL; }