void* runWatcher(void* pArgs) { StoreWatcher* lWatcher = (StoreWatcher*) pArgs; Store* lStore = lWatcher->mStore; JavaVM* lJavaVM = lWatcher->mJavaVM; JNIEnv* lEnv = getJNIEnv(lJavaVM); if (lEnv == NULL) goto ERROR; int32_t lRunning = 1; while (lRunning) { sleep(SLEEP_DURATION); StoreEntry* lEntry = lWatcher->mStore->mEntries; int32_t lScanning = 1; while (lScanning) { // Critical section begining, one thread at a time. // Entries cannot be added or modified. (*lEnv)->MonitorEnter(lEnv, lWatcher->mStoreFront); lRunning = (lWatcher->mState == STATE_OK); StoreEntry* lEntryEnd = lWatcher->mStore->mEntries + lWatcher->mStore->mLength; lScanning = (lEntry < lEntryEnd); if (lRunning && lScanning) { processEntry(lEnv, lWatcher, lEntry); } // Critical section end. (*lEnv)->MonitorExit(lEnv, lWatcher->mStoreFront); // Goes to next element. ++lEntry; } } ERROR: (*lJavaVM)->DetachCurrentThread(lJavaVM); pthread_exit(NULL); }
static int processSection(xmlElement *element, xml2lpc_context *ctx) { xmlNode *cur_node = NULL; xmlNode *cur_attr = NULL; const char *name = NULL; for (cur_attr = (xmlNode *)element->attributes; cur_attr; cur_attr = cur_attr->next) { dumpAttr(cur_attr, ctx); if(strcmp((const char*)cur_attr->name, "name") == 0) { name = (const char*)cur_attr->children->content; } } if(name != NULL) { for (cur_node = element->children; cur_node; cur_node = cur_node->next) { dumpNode(cur_node, ctx); if (cur_node->type == XML_ELEMENT_NODE) { if(strcmp((const char*)cur_node->name, "entry") == 0 ) { processEntry((xmlElement*)cur_node, name, ctx); } } } } else { xml2lpc_log(ctx, XML2LPC_WARNING, "ignored section with no \"name\" attribute, line:%d", xmlGetLineNo((xmlNode*)element)); } return 0; }
void extractAccsFromGb(char *gbFile, boolean missingOk, char *accFile, char **accNames, int accCount) /* Parse records of genBank file and print ones that match accession names. */ { FILE *out = stdout; struct hash *accTbl = hashNew(0); struct lineFile *lf; struct dyString* headLines = dyStringNew(4096); int i; if (accFile != NULL) loadAccs(accFile, accTbl); for (i = 0; i < accCount; i++) addAcc(accTbl, accNames[i]); /* process file */ lf = lineFileOpen(gbFile, TRUE); while (seekLocus(lf)) processEntry(lf, accTbl, headLines, out); lineFileClose(&lf); /* flush and check for errors */ carefulClose(&out); if (!missingOk) checkMissedAccs(accTbl); }
int main (int argc, char *argv[]) { MrfEntry *currEntry; int mode; if (argc != 3) { usage ("%s <file.annotation> <include|exclude>",argv[0]); } intervalFind_addIntervalsToSearchSpace (argv[1],0); if (strEqual (argv[2],"include")) { mode = MODE_INCLUDE; } else if (strEqual (argv[2],"exclude")) { mode = MODE_EXCLUDE; } else { usage ("%s <file.annotation> <include|exclude>",argv[0]); } mrf_init ("-"); puts (mrf_writeHeader ()); while (currEntry = mrf_nextEntry ()) { processEntry (currEntry,mode); } mrf_deInit (); return 0; }
int main (int argc, char *argv[]) { MrfEntry *currEntry; char *targetName; int targetStart,targetEnd; WordIter w; int count=0; int currCount=0; if (argc != 2) { usage ("%s <targetName:targetStart-targetEnd>",argv[0]); } w = wordIterCreate (argv[1],":- ",0); targetName = hlr_strdup (wordNext (w)); targetStart = atoi (wordNext (w)); targetEnd = atoi (wordNext (w)); wordIterDestroy (w); mrf_init ("-"); while (currEntry = mrf_nextEntry ()) { currCount = processEntry (currEntry,targetName,targetStart,targetEnd); count = currCount+count; } printf("Count for %s:%d-%d = %d\n", targetName, targetStart, targetEnd, count); mrf_deInit (); hlr_free (targetName); return 0; }
int main (int argc, char *argv[]) { MrfEntry *currEntry; char *targetName; int targetStart,targetEnd; WordIter w; if (argc != 2) { usage ("%s <targetName:targetStart-targetEnd>",argv[0]); } w = wordIterCreate (argv[1],":- ",0); targetName = hlr_strdup (wordNext (w)); targetStart = atoi (wordNext (w)); targetEnd = atoi (wordNext (w)); wordIterDestroy (w); mrf_init ("-"); puts (mrf_writeHeader ()); while (currEntry = mrf_nextEntry ()) { processEntry (currEntry,targetName,targetStart,targetEnd); } mrf_deInit (); hlr_free (targetName); return 0; }
static void processSection_cb(const char *entry, struct __processSectionCtx *ctx) { if(ctx->ret == 0) { const char *comment = "#"; xmlNode *node; xmlAttr *name_attr; if (strncmp(comment, entry, strlen(comment)) == 0) { lpc2xml_log(ctx->ctx, LPC2XML_WARNING, "Skipped commented entry %s", entry); ctx->ret = 0; return; } node = xmlNewChild(ctx->node, NULL, (const xmlChar *)"entry", NULL); if(node == NULL) { lpc2xml_log(ctx->ctx, LPC2XML_ERROR, "Can't create \"entry\" element"); ctx->ret = -1; return; } name_attr = xmlSetProp(node, (const xmlChar *)"name", (const xmlChar *)entry); if(name_attr == NULL) { lpc2xml_log(ctx->ctx, LPC2XML_ERROR, "Can't create name attribute for \"entry\" element"); ctx->ret = -1; return; } ctx->ret = processEntry(ctx->section, entry, node, ctx->ctx); } }
QSharedPointer<SyncObject> DatabaseSync<SO>::syncEntries() { qDebug() << "Running sync for type: " + getType(); // make sure root groups are the same.It has to be if we are syncing the same // database Q_ASSERT(db1->rootGroup()->uuid() == db2->rootGroup()->uuid()); entries1 = getEntriesMap(db1); entries2 = getEntriesMap(db2); QList<SO *> missingEntries; Q_FOREACH(SO * cloudEntry, entries2) { if (!processEntry(db2, cloudEntry)) continue; // remote entry also exists in local database if (entries1.contains(cloudEntry->uuid())) { SO *localEntry = entries1[cloudEntry->uuid()]; syncEntry(localEntry, cloudEntry); syncLocation(localEntry, cloudEntry); } // entry exists only in remote database else { missingEntries.append(cloudEntry); } } if (missingEntries.length() > 0) addMissingEntries(missingEntries); // count whether any unique entry exist in local database // to further decide whether we need to update remote db Q_FOREACH(SO * localEntry, entries1) { if (!processEntry(db1, localEntry)) continue; if (!entries2.contains(localEntry->uuid())) { bool isRemoved = Tools::hasChild(db1->metadata()->recycleBin(), localEntry); if (isRemoved) { // entry should be created and removed to recycle bin in remote database getSyncObject()->increase(getObjectType(), SRemoved(), SRemote()); } else { // entry is missing in remote database getSyncObject()->increase(getObjectType(), SMissing(), SRemote()); } } } return DatabaseSync::syncObject; }
static void metaDataProcess(struct sqlConnection *conn, struct gbStatusTbl* statusTbl, char* raPath, HGID faFileId, HGID pepFaId) /* Parse a ra file looking for accessions to add to the database. If the * ra entry matches the status->selectProc object, it will be saved for * loading. */ { /* parse and save all ra records, in assending file offset order */ gbMDParseOpen(raPath, conn, gOptions, gTmpDir); while (processEntry(conn, statusTbl, faFileId, pepFaId)) continue; /* loop filler */ gbMDParseClose(); }
void SoundQueue::processEntries() { _state = 0; processEntry(kSoundType1); processEntry(kSoundType2); }