/** * SAX parser - End of Element */ void irEndElement(void * context, const xmlChar * name) { IR_CONTEXT *ctx = (IR_CONTEXT *)context; int rc = 0; UINT32 padding = 0; int pad_len; if (!strcmp((char *)name, "stuff:Objects")) { /* Event finish, let's print out */ ctx->event_index++; /* set the event structure */ if (ctx->event == NULL) { LOG(LOG_ERR, "internal error\n"); ctx->sax_error++; } else { if (ctx->binary == 0) { /* text */ fprintf(ctx->fp, "%5d %2d 0x%08x ", ctx->event_index, ctx->event->ulPcrIndex, ctx->event->eventType); fprintHex(ctx->fp, ctx->event->rgbPcrValue, 20); fprintf(ctx->fp, " ["); fprintEventData(ctx->fp, ctx->event->eventType, ctx->event->ulEventLength, ctx->event->rgbEvent); fprintf(ctx->fp, "]\n"); } else { /* binary */ if (ctx->endian == 0) { // TODO check rc rc = fwrite((BYTE *)&ctx->event->ulPcrIndex, 1, 4, ctx->fp); // PCR index rc = fwrite((BYTE *)&ctx->event->eventType, 1, 4, ctx->fp); // Event type rc = fwrite(ctx->event->rgbPcrValue, 1, 20, ctx->fp); // PCR rc = fwrite((BYTE *)&ctx->event->ulEventLength, 1, 4, ctx->fp); // EventData length rc = fwrite(ctx->event->rgbEvent, 1, ctx->event->ulEventLength, ctx->fp); // EventData } else { /* convert endian */ // TODO used htonl() UINT32 u; u = econv(ctx->event->ulPcrIndex); rc = fwrite((BYTE *)&u, 1, 4, ctx->fp); // PCR index u = econv(ctx->event->eventType); rc = fwrite((BYTE *)&u, 1, 4, ctx->fp); // Event type rc = fwrite(ctx->event->rgbPcrValue, 1, 20, ctx->fp); // PCR u = econv(ctx->event->ulEventLength); rc = fwrite((BYTE *)&u, 1, 4, ctx->fp); // EventData length rc = fwrite(ctx->event->rgbEvent, 1, ctx->event->ulEventLength, ctx->fp); // EventData } /* padding */ if (ctx->aligned > 0) { // TODO base64 IR already contains padding? // DEBUG("padding\n"); pad_len = ctx->event->ulEventLength % ctx->aligned; if (pad_len > 0) { /* add padding */ rc = fwrite((BYTE *)&padding, 1, pad_len, ctx->fp); // Padding LOG(LOG_TODO, "%d mod %d => %d\n", ctx->event->ulEventLength, ctx->aligned, pad_len); } } } /* extend to eTPM */ extend( ctx->event->ulPcrIndex, ctx->event->rgbPcrValue); ctx->event = NULL; } } else if (!strcmp((char *)name, "SnapshotCollection")) { /* snapshot finish */ } else if (!strcmp((char *)name, "pcrindex")) { ctx->buf[ctx->char_size] = 0; ctx->event->ulPcrIndex = atoi(ctx->buf); } else if (!strcmp((char *)name, "stuff:Hash")) { ctx->buf[ctx->char_size] = 0; ctx->event->rgbPcrValue = decodeBase64( (char *)ctx->buf, ctx->char_size, (int *)&ctx->event->ulPcrValueLength); if (ctx->event->rgbEvent == NULL) { // LOG(LOG_ERR, ) ctx->event->ulPcrValueLength = 0; } } else if (!strcmp((char *)name, "eventtype")) { ctx->buf[ctx->char_size] = 0; ctx->event->eventType = atoi(ctx->buf); } else if (!strcmp((char *)name, "eventdata")) { ctx->buf[ctx->char_size] = 0; // null terminate ctx->event->rgbEvent = decodeBase64( (char *)ctx->buf, ctx->char_size, (int *)&ctx->event->ulEventLength); if (ctx->event->rgbEvent == NULL) { // LOG(LOG_ERR, ) ctx->event->ulEventLength = 0; } } else if (!strcmp((char *)name, "PcrHash")) { /* PCR value */ ctx->buf[ctx->char_size] = 0; // null terminate // decodeBase64(ctx->pcr, (unsigned char *)ctx->buf, ctx->char_size); /* Check with PCR in TPM */ // rc = checkTpmPcr2(&pctx->tpm, ctx->pcr_index, ctx->pcr); if (rc != 0) { LOG(LOG_ERR, "ERROR PCR[%d] != IML\n", ctx->pcr_index); ctx->sax_error = 1; } else { /* IML and PCR are consistent :-) */ // DEBUG_FSM("PCR[%d] == IML\n", ctx->pcr_index); // TODO(munetoh) add property? tpm.pcr.N.snapshot.N.integrity=valid #if 0 /* update pcrs, used by validatePcrCompositeV11 */ if (pctx->conf->iml_mode == 0) { if (pcrs == NULL) { /* malloc OPENPTS_PCRS */ // LOG(LOG_ERR, "PCR is not intialized - No QuoteData element\n"); pcrs = xmalloc(sizeof(OPENPTS_PCRS)); if (pcrs == NULL) { return; } memset(pcrs, 0, sizeof(OPENPTS_PCRS)); pctx->pcrs = pcrs; } pcrs->pcr_select[ctx->pcr_index] = 1; memcpy(pcrs->pcr[ctx->pcr_index], ctx->pcr, 20); // TODO pcr size } else { // DEBUG("iml.mode!=tss, skip pcr copy to PCRS\n"); } #endif } } else if (!strcmp((char *)name, "ValueSize")) { DEBUG("ignore ValueSize\n"); } else if (!strcmp((char *)name, "PcrValue")) { DEBUG("ignore PcrValue\n"); } else if (!strcmp((char *)name, "SignatureValue")) { DEBUG("ignore SignatureValue\n"); } else if (!strcmp((char *)name, "KeyValue")) { DEBUG("ignore KeyValue\n"); } else if (!strcmp((char *)name, "QuoteData")) { DEBUG("ignore QuoteData\n"); } else { /* Else? */ DEBUG("END ELEMENT [%s] ", name); } ctx->sax_state = IR_SAX_STATE_IDOL; }
int slave() { modbus_t *ctx; modbus_mapping_t *mb_mapping; int rc; uint8_t *query; uint8_t *raw_rsp; uint8_t *con_rsp; uint16_t *raw_rd_rsp; uint16_t *rd_rsp; int header_length; int year,month,day,hour,minute,second; int i,j; int rsp_length; int set_date[6]; mb_mapping = modbus_mapping_new( UT_BITS_ADDRESS + UT_BITS_NB, UT_INPUT_BITS_ADDRESS + UT_INPUT_BITS_NB, UT_REGISTERS_ADDRESS + UT_REGISTERS_NB, UT_INPUT_REGISTERS_ADDRESS + UT_INPUT_REGISTERS_NB); if (mb_mapping == NULL) { modbus_free(ctx); return -1; } ctx = modbus_new_rtu("/dev/ttyS2", 9600, 'N', 8, 1); modbus_set_slave(ctx, 1); query = malloc(MODBUS_RTU_MAX_ADU_LENGTH); raw_rsp = malloc(MODBUS_RTU_MAX_ADU_LENGTH); con_rsp = malloc(MODBUS_RTU_MAX_ADU_LENGTH); raw_rd_rsp = malloc(MODBUS_RTU_MAX_ADU_LENGTH); rd_rsp = malloc(MODBUS_RTU_MAX_ADU_LENGTH); header_length = modbus_get_header_length(ctx); modbus_set_debug(ctx, TRUE); start: rc = modbus_connect(ctx); if (rc == -1) { modbus_free(ctx); return -1; } for (;;) { rc = modbus_receive(ctx, query); if (rc == -1) { break; } //Send the raw message to SDL if(extend(query[2],query[3]) == 5152) { raw_rsp = raw_data_command(&rsp_length,rc,query); if(raw_rsp == NULL){printf("SDL is sleeping\n");goto close;} for(i=6;i<rsp_length;i++) { con_rsp[i-6]=raw_rsp[i]; } modbus_send_raw_request(ctx, con_rsp, (rsp_length-6)*sizeof(uint8_t)); } if(extend(query[2],query[3]) == 5168) { raw_rsp = raw_data_command(&rsp_length,rc,query); if(raw_rsp == NULL){printf("SDL is sleeping\n");goto close;} for(i=6;i<rsp_length;i++) { con_rsp[i-6]=raw_rsp[i]; } modbus_send_raw_request(ctx, con_rsp, (rsp_length-6)*sizeof(uint8_t)); } if(extend(query[2],query[3]) == 16384) { raw_rsp = sdl_read_buffsize(&rsp_length); if(raw_rsp == NULL){printf("SDL is sleeping\n");goto close;} for(i=0;i<2;i++) { con_rsp[i] = query[i]; } con_rsp[2] = 0x4; for(i=0,j=3;i<rsp_length;i++) { con_rsp[j]=raw_rsp[i]; j++; } modbus_send_raw_request(ctx, con_rsp, 7*sizeof(uint8_t)); } if(extend(query[2],query[3]) == 16386) { raw_rsp = sdl_read_data(&rsp_length,16); if(raw_rsp == NULL){printf("SDL is sleeping\n");goto close;} for(i=0;i<2;i++) { con_rsp[i] = query[i]; } con_rsp[2] = 0x40; for(i=0,j=3;i<rsp_length;i++) { con_rsp[j]=raw_rsp[i]; j++; } modbus_send_raw_request(ctx, con_rsp, 67*sizeof(uint8_t)); } if(extend(query[2],query[3]) == 1400) { rc = modbus_reply(ctx, query, rc, mb_mapping); set_date[0] = extend(query[7],query[8])+2000; set_date[1] = extend(query[9],query[10]); set_date[2]= extend(query[11],query[12]); set_date[3] = extend(query[13],query[14]); set_date[4] = extend(query[15],query[16]); set_date[5] = extend(query[17],query[18]); set_time(&set_date); //printf("%d %d %d %d %d %d\n",set_date[0],set_date[1],set_date[2],set_date[3],set_date[4],set_date[5]); } } close: goto start; modbus_mapping_free(mb_mapping); free(query); modbus_free(ctx); return 0; }
ompl::base::PlannerStatus ompl::geometric::TRRTConnect::solve(const base::PlannerTerminationCondition &ptc) { //Basic error checking checkValidity(); //Goal information base::GoalSampleableRegion *goal(dynamic_cast<base::GoalSampleableRegion*> (pdef_->getGoal().get())); if (!goal) { OMPL_ERROR("%s: Unknown type of goal",getName().c_str()); return base::PlannerStatus::UNRECOGNIZED_GOAL_TYPE; } //Input States //Loop through valid input states and add to tree while (const base::State *st = pis_.nextStart()) { //Create a motion Motion *motion(new Motion(si_)); si_->copyState(motion->state,st); motion->root = motion->state; //Add motion to the tree tStart_->add(motion); si_->copyState(tStart_.root,motion->root); //Check if now the tree has a motion inside BoxZos if (!tStart_.stateInBoxZos_) { tStart_.stateInBoxZos_ = ((ompl::base::FOSOptimizationObjective*)opt_.get())-> boxZosDistance(motion->state) < DBL_EPSILON; if (tStart_.stateInBoxZos_) tStart_.temp_ = initTemperature_; } //Update frontier nodes and non frontier nodes count ++tStart_.frontierCount_;//Participates in the tree expansion } //Check that input states exist if (tStart_->size() == 0) { OMPL_ERROR("%s: Motion planning start tree could not be initialized!", getName().c_str()); return base::PlannerStatus::INVALID_START; } //Check that goal states exist if (!goal->couldSample()) { OMPL_ERROR("%s: Insufficient states in sampleable goal region", getName().c_str()); return base::PlannerStatus::INVALID_GOAL; } //Create state sampler if the first run if (!sampler_) sampler_ = si_->allocStateSampler(); OMPL_INFORM("%s: Starting planning with %d states already in datastructure", getName().c_str(),int(tStart_->size() + tGoal_->size())); Motion *rmotion(new Motion(si_)); base::State *rstate(rmotion->state); TreeGrowingInfo tgi; tgi.xstate = si_->allocState(); bool startTree(true); bool solved(false); double temp(0.0); unsigned int iter(0); extendCount = 0; connectCount = 0; //Begin sampling while (!ptc) { //Choose tree to extend TreeData &tree(startTree ? tStart_ : tGoal_); startTree = !startTree; TreeData &otherTree(startTree ? tStart_ : tGoal_); if (((2*pis_.getSampledGoalsCount()) < (tGoal_->size())) || (tGoal_->size() == 0)) { const base::State *st((tGoal_->size() == 0) ? pis_.nextGoal(ptc) : pis_.nextGoal()); if (st) { //Create a motion Motion *motion(new Motion(si_)); si_->copyState(motion->state,st); motion->root = motion->state; //Add motion to the tree tGoal_->add(motion); si_->copyState(tGoal_.root,motion->root); //Check if now the tree has a motion inside BoxZos if (!tGoal_.stateInBoxZos_) { tGoal_.stateInBoxZos_ = ((ompl::base::FOSOptimizationObjective*)opt_.get())-> boxZosDistance(motion->state) < DBL_EPSILON; if (tGoal_.stateInBoxZos_) tGoal_.temp_ = initTemperature_; } //Update frontier nodes and non frontier nodes count ++tGoal_.frontierCount_;//Participates in the tree expansion } if (tGoal_->size() == 0) { OMPL_ERROR("%s: Unable to sample any valid states for goal tree", getName().c_str()); break; } } //Sample random state if (rng_.uniform01() < 0.05) { si_->copyState(rstate,otherTree.root); } else { sampler_->sampleUniform(rstate); } //Extend tree ExtendResult extendResult(extend(tree,tgi,rmotion)); temp += tree.temp_; iter++; if (extendResult != TRAPPED) { //Remember which motion was just added Motion *addedMotion(tgi.xmotion); //If reached, it means we used rstate directly, no need to copy again if (extendResult == ADVANCED) si_->copyState(rstate,tgi.xstate); //Attempt to connect trees otherTree.temp_ *= tempChangeFactor_; bool connected(connect(otherTree,tgi,rmotion)); otherTree.temp_ /= tempChangeFactor_; Motion *startMotion(startTree ? tgi.xmotion : addedMotion); Motion *goalMotion(startTree ? addedMotion : tgi.xmotion); //If we connected the trees in a valid way (start and goal pair is valid) if (connected && goal->isStartGoalPairValid(startMotion->root, goalMotion->root)) { //It must be the case that either the start tree or the goal tree //has made some progress so one of the parents is not NULL. //We go one step 'back' to avoid having a duplicate state //on the solution path if (startMotion->parent) { startMotion = startMotion->parent; } else { goalMotion = goalMotion->parent; } connectionPoint_ = std::make_pair(startMotion->state,goalMotion->state); //Construct the solution path Motion *solution(startMotion); std::vector<Motion*> mpath1; while (solution) { mpath1.push_back(solution); solution = solution->parent; } solution = goalMotion; std::vector<Motion*> mpath2; while (solution) { mpath2.push_back(solution); solution = solution->parent; } //Set the solution path PathGeometric *path(new PathGeometric(si_)); path->getStates().reserve(mpath1.size() + mpath2.size()); for (int i(mpath1.size() - 1); i >= 0; --i) { path->append(mpath1[i]->state); } for (std::size_t i(0); i < mpath2.size(); ++i) { path->append(mpath2[i]->state); } pdef_->addSolutionPath(base::PathPtr(path),false,0.0); solved = true; break; } } } //Clean up si_->freeState(tgi.xstate); si_->freeState(rstate); delete rmotion; OMPL_INFORM("%s: Created %u states (%u start + %u goal)",getName().c_str(), tStart_->size()+tGoal_->size(),tStart_->size(),tGoal_->size()); OMPL_INFORM("%s: Average temperature %f ",getName().c_str(),temp/double(iter)); //std::cout << extendCount << " " << connectCount << " " << iter << std::endl; double costs(0); std::vector<Motion*> start; tStart_->list(start); for (unsigned int i = 0; i < start.size(); ++i) { if (start.at(i)->parent) { costs += opt_->motionCost(start.at(i)->parent->state,start.at(i)->state).value() /si_->distance(start.at(i)->parent->state,start.at(i)->state); } } std::vector<Motion*> data; tGoal_->list(data); for (unsigned int i = 0; i < data.size(); ++i) { if (data.at(i)->parent) { costs += opt_->motionCost(data.at(i)->state,data.at(i)->parent->state).value() /si_->distance(data.at(i)->parent->state,data.at(i)->state); } } //std::cout << "avg cost " << costs/double(start.size()+data.size()-2) << std::endl; return solved ? base::PlannerStatus::EXACT_SOLUTION : base::PlannerStatus::TIMEOUT; }
void addArrayListElement (ArrayList *array, void *elem){ if (array->length >= array->allocatedSize) extend (array); array->data[array->length] = elem; array->length++; }
/* Create a signal frame for thread 'tid'. */ void VG_(sigframe_create) ( ThreadId tid, Addr sp_top_of_frame, const vki_siginfo_t *siginfo, void *handler, UInt flags, const vki_sigset_t *mask, void *restorer ) { ThreadState* tst; Addr sp; struct hacky_sigframe* frame; Int sigNo = siginfo->si_signo; Int __NR_FAKE_SIGRETURN = __NR_AIX5_FAKE_SIGRETURN; vg_assert(VG_IS_16_ALIGNED(sizeof(struct hacky_sigframe))); sp_top_of_frame &= ~0xf; sp = sp_top_of_frame - sizeof(struct hacky_sigframe); tst = VG_(get_ThreadState)(tid); if (!extend(tst, sp, sp_top_of_frame - sp)) return; vg_assert(VG_IS_16_ALIGNED(sp)); frame = (struct hacky_sigframe *) sp; /* clear it (very conservatively) */ VG_(memset)(&frame->lower_guardzone, 0, 1024); VG_(memset)(&frame->gst, 0, sizeof(VexGuestPPC64State)); VG_(memset)(&frame->gshadow, 0, sizeof(VexGuestPPC64State)); /* save stuff in frame */ frame->gst = tst->arch.vex; frame->gshadow = tst->arch.vex_shadow; frame->sigNo_private = sigNo; frame->magicPI = 0x31415927; /* Set up stack frame pointer */ sp += 512; vg_assert(sp == (Addr)&frame->lower_guardzone[512]); VG_TRACK( pre_mem_write, Vg_CoreSignal, tid, "signal handler frame", sp, sizeof(UWord) ); *(Addr*)sp = tst->arch.vex.guest_GPR1; VG_TRACK( post_mem_write, Vg_CoreSignal, tid, sp, sizeof(UWord) ); /* Set regs for the handler */ SET_SIGNAL_GPR(tid, 1, sp); SET_SIGNAL_GPR(tid, 2, ((UWord*)handler)[1]); SET_SIGNAL_GPR(tid, 3, sigNo); SET_SIGNAL_GPR(tid, 4, 0); /* XXX: the siginfo* */ SET_SIGNAL_GPR(tid, 5, 0); /* XXX: the ucontext* */ tst->arch.vex.guest_CIA = ((UWord*)handler)[0]; /* set up return trampoline */ vg_assert(__NR_FAKE_SIGRETURN >= 10000); vg_assert(__NR_FAKE_SIGRETURN <= 32767); frame->tramp[0] = 0x38400000U + __NR_FAKE_SIGRETURN; /* li 2,__NR_FAKE_SIGRETURN */ frame->tramp[1] = 0x44000002U; /* sc */ /* invalidate any translation of this area */ VG_(discard_translations)( (Addr64)(Addr)&frame->tramp[0], sizeof(frame->tramp), "sigframe tramp" ); /* set the signal handler to return to the trampoline */ SET_SIGNAL_LR(tst, (Addr) &frame->tramp[0]); VG_TRACK(post_mem_write, Vg_CoreSignal, tst->tid, (Addr)&frame->tramp, sizeof(frame->tramp)); if (0) { VG_(printf)("pushed signal frame for sig %d; R1 now = %p, " "next %%CIA = %p, status=%d\n", sigNo, sp, tst->arch.vex.guest_CIA, tst->status); VG_(printf)("trampoline is at %p\n", &frame->tramp[0]); } }
bool VACVariable::averaging() { Cost Top = wcsp->getUb(); bool change = false; EnumeratedVariable* x; EnumeratedVariable* y; Constraint* ctr = NULL; ConstraintList::iterator itc = getConstrs()->begin(); if(itc != getConstrs()->end()) ctr = (*itc).constr; while(ctr) { if(ctr->arity() == 2 && !ctr->isSep()) { BinaryConstraint* bctr = (BinaryConstraint*) ctr; x = (EnumeratedVariable*) bctr->getVarDiffFrom( (Variable*) this ); for (iterator it = begin(); it != end(); ++it) { Cost cu = getCost(*it); Cost cmin = Top; for (iterator itx = x->begin(); itx != x->end(); ++itx) { Cost cbin = bctr->getCost(this,x,*it,*itx); if(cbin < cmin) cmin = cbin; } assert(cmin < Top); Double mean = to_double(cmin + cu) / 2.; Double extc = to_double(cu) - mean; if(abs(extc) >= 1) { Cost costi = (Long) extc; for (iterator itx = x->begin(); itx != x->end(); ++itx) { bctr->addcost(this,x,*it,*itx,costi); } if(mean > to_double(cu)) project(*it, -costi); else extend(*it, costi); change = true; } } } else if(ctr->arity() == 3 && !ctr->isSep()) { TernaryConstraint* tctr = (TernaryConstraint*) ctr; x = (EnumeratedVariable*) tctr->getVar( 0 ); if(x == this) x = (EnumeratedVariable*) tctr->getVar( 1 ); y = (EnumeratedVariable*) tctr->getVarDiffFrom((Variable*) this, (Variable*)x); for (iterator it = begin(); it != end(); ++it) { Cost cu = getCost(*it); Cost cmin = Top; for (iterator itx = x->begin(); itx != x->end(); ++itx) { for (iterator ity = y->begin(); ity != y->end(); ++ity) { Cost ctern = tctr->getCost(this,x,y,*it,*itx,*ity); if(ctern < cmin) cmin = ctern; }} assert(cmin < Top); Double mean = to_double(cmin + cu) / 2.; Double extc = to_double(cu) - mean; if(abs(extc) >= 1) { Cost costi = (Long) extc; for (iterator itx = x->begin(); itx != x->end(); ++itx) { for (iterator ity = y->begin(); ity != y->end(); ++ity) { tctr->addCost(this,x,y,*it,*itx,*ity,costi); }} if(mean > to_double(cu)) project(*it, -costi); else extend(*it, costi); change = true; } } } else if(ctr->arity() >= 4 && ctr->extension() && !ctr->isSep()) { NaryConstraint* nctr = (NaryConstraint*) ctr; for (iterator it = begin(); it != end(); ++it) { Cost cu = getCost(*it); Cost cmin = Top; int tindex = nctr->getIndex(this); String tuple; Cost cost; Long nbtuples = 0; nctr->first(); while (nctr->next(tuple,cost)) { nbtuples++; if (toValue(tuple[tindex] - CHAR_FIRST)==(*it) && cost < cmin) cmin = cost; } if (nctr->getDefCost() < cmin && nbtuples < nctr->getDomainSizeProduct()) cmin = nctr->getDefCost(); // assert(cmin < Top); Double mean = to_double(cmin + cu) / 2.; Double extc = to_double(cu) - mean; if(abs(extc) >= 1) { Cost costi = (Cost) extc; if(nctr->getDefCost() < Top) { nctr->firstlex(); while( nctr->nextlex(tuple,cost) ) { if (toValue(tuple[tindex] - CHAR_FIRST)==(*it)) { if(cost + costi < Top) nctr->setTuple(tuple, cost + costi); else nctr->setTuple(tuple, Top); } } nctr->setDefCost(Top); } else { nctr->first(); while( nctr->next(tuple,cost) ) { if (toValue(tuple[tindex] - CHAR_FIRST)==(*it)) { if(cost + costi < Top) nctr->addtoTuple(tuple, costi); else nctr->setTuple(tuple, Top); } } } if(mean > to_double(cu)) project(*it, -costi); else extend(*it, costi); change = true; } } } ++itc; if(itc != getConstrs()->end()) ctr = (*itc).constr; else ctr = NULL; } return change; }
int main(int argc, char *argv[]) { if (argc >= 7 && argc <= 13){ int max_nb_lines = 120; int xdrop_treshold = 0; char* reverse_comp_att = NULL; int i; for (i=7; i<argc; i+=2){ if (strcmp(argv[i],"-r") == 0) reverse_comp_att = argv[i+1]; else if (strcmp(argv[i],"-x") == 0) xdrop_treshold = atoi(argv[i+1]); else if (strcmp(argv[i],"-l") == 0) max_nb_lines = atoi(argv[i+1]); } // Initialisation du regex const char *str_regex = "^[acgtumrwsykvhdbnACGTUMRWSYKVHDBN]+"; int err; regex_t preg; err = regcomp (&preg, str_regex, REG_NOSUB | REG_EXTENDED); // Initialisation outil pour connaitre la mémoire utilisée char buffer2 [255] = "smem -ntk"; // Initialisation outil pour connaitre le temps utilisé temps_exec temps; temps.debut = times(&temps.sdebut); // On parse le fichier XGMML Pvoid_t net = parse(argv[1], argv[3], argv[4], reverse_comp_att); printf("Parsing XGMML file done \n\n"); // Affichage mémoire utilisée /*printf("Memory used by the system after parsing graph \n\n"); system(buffer2); printf("\n\n"); fflush(stdout);*/ // On parse le fichier FASTA list* list_queries = parseFastaFile(argv[2], max_nb_lines); printf("Parsing FASTA file done \n\n"); fflush(stdout); // On indexe le graphe Pvoid_t index = indexGraph(&net, atoi(argv[5]), atoi(argv[6]), reverse_comp_att); printf("Indexing graph done \n\n"); // Affichage mémoire utilisée /*printf("Memory used by the system after indexing graph \n\n"); system(buffer2); printf("\n\n");*/ // Affichage temps d'execution printf("Time after indexing graph : \n"); temps.fin = times(&temps.sfin); temp(&temps); fflush(stdout); int nb_queries = 0; int found = 0; int not_found = 0; cell* elem_list_queries = list_queries->first; while (elem_list_queries){ // Si pas d'erreur if (err == 0) { int match; // On exécute l'expression régulière match = regexec (&preg, (char*)elem_list_queries->val, 0, NULL, 0); // Si il y a correspondance if (match == 0){ // On lance les extensions int lAlign = NULL; if (reverse_comp_att == NULL) lAlign = extend((char*)elem_list_queries->val, &index, atoi(argv[5]), atoi(argv[6]), xdrop_treshold, nb_queries); else lAlign = extendR((char*)elem_list_queries->val, &index, atoi(argv[5]), atoi(argv[6]), xdrop_treshold, nb_queries); // Analyse et affichage des résultats (lAlign == 0) ? not_found++ : found++; } else{ not_found++; printf("Invalid sequence : %s \n\n", (char*)elem_list_queries->val); exit(0); } } else printf("An error occured with the regex \n\n"); elem_list_queries = elem_list_queries->prox; nb_queries++; } printf("Number of queries found : %d \n", found); printf("Number of queries not found : %d \n\n", not_found); // Affichage mémoire utilisée /*printf("Memory used by the system after extending queries \n\n"); system(buffer2); printf("\n\n");*/ // Affichage temps d'execution printf("Time after aligning graph : \n"); temps.fin = times(&temps.sfin); temp(&temps); fflush(stdout); Word_t* PValue; Word_t Bytes; uint8_t keyIndex[MAXLINE]; uint8_t keyNetwork[MAXLINE]; keyIndex[0] = keyNetwork[0] = '\0'; JSLF(PValue, index, keyIndex); while (PValue != NULL) { list_free_NodeUint16((list_NodeUint16*)*PValue); JSLN(PValue, index, keyIndex); } JSLFA(Bytes, index); JSLF(PValue, net, keyNetwork); if (reverse_comp_att == NULL){ while (PValue != NULL) { freeNode((Node*)*PValue); JSLN(PValue, net, keyNetwork); } } else { while (PValue != NULL) { freeNodeR((NodeR*)*PValue); JSLN(PValue, net, keyNetwork); } } JSLFA(Bytes, net); list_of_generic_free(list_queries); // On libère l'espace alloué à notre expression régulière regfree (&preg); return 0; } else if (argc == 2){ if (strcmp(argv[1], "-h") == 0){ printf("BlastGraph <name_file_graph.xgmml> <name_query_file.fasta> <node_attribute> <edge_attribute> <seed_size> <overlap_size> [-options]\n\n"); printf("<node_attribute> : the name of the attribute in the XGMML file (in the <node> marker) that contains the sequence of each node\n"); printf("<edge_attribute> : the name of the attribute in the XGMML file (in the <node> marker) that contains the two letters indicating if the sequences of the source node and target node have to be read in forward (F) or reverse-complement (R)\n"); printf("<seed_size> is the seed size used to anchor query sequences on the graph\n"); printf("<overlap_size> is the size of the overlaps between the sequences source and target nodes\n\n"); printf("[-options] : \n"); printf("-r reverse_complement_attribute : take into account the reverse-complement identified by reverse_complement_attribute in the graph. By default, compute the reverse-complement of each sequence in each node identified by node_attribute.\n"); printf("-x value : use this value as treshold for the X-DROP heuristic. 0 by default.\n"); printf("-l value : use this value as the maximum number of characters per line in the query file. 120 by default.\n"); return 0; } else{ fprintf (stderr, "Bad number of parameters \n"); exit (EXIT_FAILURE); } } else { fprintf (stderr, "Bad number of parameters \n"); exit (EXIT_FAILURE); } }
/* EXPORTED */ void VG_(sigframe_create)( ThreadId tid, Addr sp_top_of_frame, const vki_siginfo_t *siginfo, void *handler, UInt flags, const vki_sigset_t *mask, void *restorer ) { struct vg_sig_private *priv; Addr sp; ThreadState *tst; Int sigNo = siginfo->si_signo; Addr faultaddr; /* Stack must be 16-byte aligned */ sp_top_of_frame &= ~0xf; if (flags & VKI_SA_SIGINFO) { sp = sp_top_of_frame - sizeof(struct rt_sigframe); } else { sp = sp_top_of_frame - sizeof(struct nonrt_sigframe); } tst = VG_(get_ThreadState)(tid); if (!extend(tst, sp, sp_top_of_frame - sp)) return; vg_assert(VG_IS_16_ALIGNED(sp)); /* Set up the stack chain pointer */ VG_TRACK( pre_mem_write, Vg_CoreSignal, tid, "signal handler frame", sp, sizeof(UWord) ); *(Addr *)sp = tst->arch.vex.guest_GPR1; VG_TRACK( post_mem_write, Vg_CoreSignal, tid, sp, sizeof(UWord) ); faultaddr = (Addr)siginfo->_sifields._sigfault._addr; if (sigNo == VKI_SIGILL && siginfo->si_code > 0) faultaddr = tst->arch.vex.guest_CIA; if (flags & VKI_SA_SIGINFO) { struct rt_sigframe *frame = (struct rt_sigframe *) sp; struct vki_ucontext *ucp = &frame->ucontext; VG_TRACK( pre_mem_write, Vg_CoreSignal, tid, "signal frame siginfo", (Addr)&frame->siginfo, sizeof(frame->siginfo) ); VG_(memcpy)(&frame->siginfo, siginfo, sizeof(*siginfo)); VG_TRACK( post_mem_write, Vg_CoreSignal, tid, (Addr)&frame->siginfo, sizeof(frame->siginfo) ); VG_TRACK( pre_mem_write, Vg_CoreSignal, tid, "signal frame ucontext", (Addr)ucp, offsetof(struct vki_ucontext, uc_pad) ); ucp->uc_flags = 0; ucp->uc_link = 0; ucp->uc_stack = tst->altstack; VG_TRACK( post_mem_write, Vg_CoreSignal, tid, (Addr)ucp, offsetof(struct vki_ucontext, uc_pad) ); VG_TRACK( pre_mem_write, Vg_CoreSignal, tid, "signal frame ucontext", (Addr)&ucp->uc_regs, sizeof(ucp->uc_regs) + sizeof(ucp->uc_sigmask) ); ucp->uc_regs = &ucp->uc_mcontext; ucp->uc_sigmask = tst->sig_mask; VG_TRACK( post_mem_write, Vg_CoreSignal, tid, (Addr)&ucp->uc_regs, sizeof(ucp->uc_regs) + sizeof(ucp->uc_sigmask) ); stack_mcontext(&ucp->uc_mcontext, tst, __NR_rt_sigreturn, faultaddr); priv = &frame->priv; SET_SIGNAL_GPR(tid, 4, (Addr) &frame->siginfo); SET_SIGNAL_GPR(tid, 5, (Addr) ucp); /* the kernel sets this, though it doesn't seem to be in the ABI */ SET_SIGNAL_GPR(tid, 6, (Addr) &frame->siginfo); } else {