void FastXmlDocument::getXMLAsLines(string path, vector<FastXmlLine*> *lines) { char *data = readTextFile(path); char *head = data; head = nextTag(head); bool foundData = false; while(head<end) { head = nextData(head, foundData); if(foundData) lines->push_back(new FastXmlLine(tagBuffer)); head = nextTag(head); lines->push_back(new FastXmlLine(tagBuffer)); } delete [] data; }
//-------------------------------------------------------------- void GrafPlayerApp::resetPlayer( int next) { if(tags.size() <= 0 ) return; myTagPlayer.reset(); nextTag(next); drawer.setup( &tags[currentTagID], tags[currentTagID].distMax ); particleDrawer.reset(); waitTimer = waitTime; rotationY = 0; tagPosVel.set(0,0,0); prevStroke = 0; if(bRotating) bRotating = true; archPDropTime = 0; }
void readComment(FILE *f, char *comment, int len) { char tag[32] = {0}; do nextTag(f, tag, 32); while (tag[0] && strcmp(tag, "en") != 0 && strcmp(tag, "/comments") != 0); if (strcmp(tag, "en") == 0) readValue(f, comment, len); }
// ctors and dtor Timer::Timer(): BaseObject(false), usertag_(InvalidTag), tag_(InvalidTag), type_(OneShotTimer), seconds_(0), microseconds_(0), userseconds_(0), usermicroseconds_(0) { tag_ = nextTag(); setOk(false); }
Timer::Timer(Seconds s, MicroSeconds us, Tag t, Type y): BaseObject(true), usertag_(t), tag_(InvalidTag), type_(y), seconds_(s+us/1000000), microseconds_(us%1000000), userseconds_(0), usermicroseconds_(0) { userseconds_ = seconds_; usermicroseconds_ = microseconds_; tag_ = nextTag(); setOk(true); }
// ---------------------------------------------------------------------------- string CFeatTableEdit::xNextFeatId() // ---------------------------------------------------------------------------- { const int WIDTH = 6; const string padding = string(WIDTH, '0'); string suffix = NStr::NumericToString(mNextFeatId++); if (suffix.size() < WIDTH) { suffix = padding.substr(0, WIDTH-suffix.size()) + suffix; } string nextTag("auto"); return nextTag + suffix; }
Timer::Timer(const timeval &tv, Tag t, Type y): BaseObject(true), usertag_(t), tag_(InvalidTag), type_(y), seconds_(tv.tv_sec+tv.tv_usec/1000000), microseconds_(tv.tv_usec%1000000), userseconds_(0), usermicroseconds_(0) { userseconds_ = seconds_; usermicroseconds_ = microseconds_; tag_ = nextTag(); setOk(true); }
int sfccLex(parseUnion * lvalp, ParserControl * parm) { int i, rc; char *next; for (;;) { next = nextTag(parm->xmb); if (next == NULL) { return 0; } // fprintf(stderr,"--- token: %.32s\n",next); //usefull for debugging if (parm->xmb->eTagFound) { parm->xmb->eTagFound = 0; return parm->xmb->etag; } if (*next == '/') { for (i = 0; i < TAGS_NITEMS; i++) { if (nextEquals(next + 1, tags[i].tag, tags[i].tagLen) == 1) { skipTag(parm->xmb); return tags[i].etag; } } } else { if (strncmp(parm->xmb->cur, "<!--", 4) == 0) { parm->xmb->cur = strstr(parm->xmb->cur, "-->") + 3; continue; } for (i = 0; i < TAGS_NITEMS; i++) { if (nextEquals(next, tags[i].tag, tags[i].tagLen) == 1) { // printf("+++ %d\n",i); rc=tags[i].process(lvalp, parm); return rc; } } } break; } return 0; }
void xs_x509_decodeSubjectKeyId(xsMachine *the) { UInt32 sz = xsToInteger(xsGet(xsArg(0), xsID("length"))); unsigned char *p = xsGetHostData(xsArg(0)), *endp = p + sz, *endTBS, *endEXT, *extnID, *spki, *spk; int l, extnIDLen, spkLen; static UInt8 id_ce_ski[] = {2 * 40 + 5, 29, 14}; /* [2, 5, 29, 14] */ #define getTag() (p < endp ? (int)*p++ : -1) #define getBerLen() _getBerLen(&p, endp) #define nextTag() (getTag(), l = getBerLen(), p += l) if (getTag() != 0x30) return; if ((l = getBerLen()) < 0) return; if (p + l > endp) return; /* TBSCertficate */ if (getTag() != 0x30) return; if ((l = getBerLen()) < 0) return; if ((endTBS = p + l) > endp) return; if (*p & 0x80) { /* EXPLICT Version */ p++; nextTag(); } nextTag(); /* serialNumber */ nextTag(); /* signature */ nextTag(); /* issuer */ nextTag(); /* validity */ nextTag(); /* subject */ spki = p; /* subjectPublicKeyInfo */ nextTag(); /* OPTIONAL */ while (p < endTBS) { int tag = getTag(); if ((l = getBerLen()) < 0) return; switch (tag & 0x1f) { case 1: /* issuerUniqueID */ case 2: /* subjectUniqueID */ p += l; continue; /* goto the next tag */ case 3: /* extensions */ break; /* fall thru */ default: return; } /* must be a SEQUENCE of [1..MAX] */ if (getTag() != 0x30) return; if ((l = getBerLen()) < 0) return; endEXT = p + l; while (p < endEXT) { /* must be a SEQUENCE of {extnID, critical, extnValue} */ if (getTag() != 0x30) return; if ((l = getBerLen()) < 0) return; /* extnID: OBJECT ID */ if (getTag() != 0x06) return; if ((extnIDLen = getBerLen()) < 0) return; extnID = p; p += extnIDLen; /* critical: BOOLEAN */ if (*p == 0x01) nextTag(); /* extnValue: OCTET STRING */ if (getTag() != 0x04) return; if ((l = getBerLen()) < 0) return; if (extnIDLen == sizeof(id_ce_ski) && FskMemCompare(extnID, id_ce_ski, extnIDLen) == 0) { /* SKI: OCTET STRING */ if (getTag() != 0x04) return; l = getBerLen(); xsResult = xsNew1(xsGlobal, xsID("Chunk"), xsInteger(l)); FskMemCopy(xsGetHostData(xsResult), p, l); return; } p += l; } } { /* * Couldn't find Subject Key Identifier. Make up the ID from the Subject Public Key */ struct sha1 sha1; p = spki; if (getTag() != 0x30) return; /* should be a SEQUENCE */ l = getBerLen(); /* skip AlgorithmIdentifier */ nextTag(); if (getTag() != 0x03) return; /* should be a BIT STRING */ spkLen = getBerLen(); spk = p; xsResult = xsNew1(xsGlobal, xsID("Chunk"), xsInteger(SHA1_DGSTSIZE)); sha1_create(&sha1); sha1_update(&sha1, spk, spkLen); sha1_fin(&sha1, xsGetHostData(xsResult)); } }
// // p a r s e // // Take a look at the state machine of parse() to understand // what is going on here. // // TODO: It seems to be useful that this function throws an exception // if something goes wrong. XmlTagObject *XmlParser::parse() { // Increment recursion depth ++m_recursionDepth; // currentTagObject is the tag object we want to create // in this invocation of parse() XmlTagObject *currentTagObject = 0; // Now we are in the start state of the state machine for( ; ; ) { XmlToken token = m_pScanner->getNextToken(); // Expect "<", otherwise failure if (token != openingBracket) { reportError("XmlParser::parse", __LINE__, "Opening Bracket expected!", getInputFileLineCounter()); } // Let's look what comes after "<" token = m_pScanner->getNextToken(); // Read "?", i.e. we have the XML header line <? ... ?> if (token == questionMark) { // Skip until we reach the matching question mark if (!m_pScanner->skipUntil('?')) { reportError("XmlParser::parse", __LINE__, "Could not found the matching '?'", getInputFileLineCounter()); } // Consume ">", otherwise failure token = m_pScanner->getNextToken(); if (token != closingBracket) { reportError("XmlParser::parse", __LINE__, "Closing Bracket expected!", getInputFileLineCounter()); } // Go to start state of the state machine continue; } // end of Read "?" // Read "!", i.e. we have a XML comment <!-- bla --> if (token == exclamationMark) { // A preambel comment <!lala > which could be also nested if ((m_pScanner->getNextToken() != minus) || (m_pScanner->getNextToken() != minus)) { if (!m_pScanner->skipUntilMatchingClosingBracket()) { reportError("XmlParser::parse", __LINE__, "Could not find closing comment bracket!", getInputFileLineCounter()); } continue; } // Find end of comment bool endOfCommentFound = false; while (!endOfCommentFound) { // Skip until we find a - (and skip over it) if (!m_pScanner->skipUntil('-', true)) { reportError("XmlParser::parse", __LINE__, "Closing --> of comment not found!", getInputFileLineCounter()); } // The next characters must be -> (note that one minus is already consumed) if ((m_pScanner->getNextToken() == minus) && (m_pScanner->getNextToken() == closingBracket)) { endOfCommentFound = true; } } // while // Go to start state of the state machine continue; } // end of Read "!" // We have found an identifier, i.e. a tag name if (token == identifier) { // Get hash element of token string HashedString *tagName = hashString(m_pScanner->getCurrentTokenString()); // Create new tag object currentTagObject = new XmlTagObject(tagName); if (currentTagObject == 0) { OGDF_THROW(InsufficientMemoryException); } //push (opening) tagName to stack m_tagObserver.push(tagName->key()); // set depth of current tag object currentTagObject->setDepth(m_recursionDepth); // set line of the tag object in the parsed xml document currentTagObject->setLine(getInputFileLineCounter()); // Next token token = m_pScanner->getNextToken(); // Again we found an identifier, so it must be an attribute if (token == identifier) { // Read list of attributes do { // Save the attribute name HashedString *attributeName = hashString(m_pScanner->getCurrentTokenString()); // Consume "=", otherwise failure token = m_pScanner->getNextToken(); if (token != equalSign) { reportError("XmlParser::parse", __LINE__, "Equal Sign expected!", getInputFileLineCounter()); } // Read value token = m_pScanner->getNextToken(); if ((token != quotedValue) && (token != identifier) && (token != attributeValue)) { reportError("XmlParser::parse", __LINE__, "No valid attribute value!", getInputFileLineCounter()); } // Create a new XmlAttributeObject XmlAttributeObject *currentAttributeObject = new XmlAttributeObject(attributeName, hashString(m_pScanner->getCurrentTokenString())); if (currentAttributeObject == 0) { OGDF_THROW(InsufficientMemoryException); } // Append attribute to attribute list of the current tag object appendAttributeObject(currentTagObject, currentAttributeObject); // Get next token token = m_pScanner->getNextToken(); } while (token == identifier); } // Found an identifier of an attribute // Read "/", i.e. the tag is ended immeadiately, e.g. // <A ... /> without a closing tag </A> if (token == slash) { // Consume ">", otherwise failure token = m_pScanner->getNextToken(); if (token != closingBracket) { reportError("XmlParser::parse", __LINE__, "Closing Bracket expected!", getInputFileLineCounter()); } // The tag is closed and ended so we return string s = m_tagObserver.pop(); --m_recursionDepth; return currentTagObject; } // end of Read "/" // Read ">", i.e. the tag is closed and we // expect some content if (token == closingBracket) { // We read something different from "<", so we have to // deal with a tag value now, i.e. a string inbetween the // opening and the closing tag, e.g. <A ...> lalala </A> if (m_pScanner->testNextToken() != openingBracket) { // Read the characters until "<" is reached and put them into // currentTagObject m_pScanner->readStringUntil('<'); currentTagObject->m_pTagValue = hashString(m_pScanner->getCurrentTokenString()); // We expect a closing tag now, i.e. </id> token = m_pScanner->getNextToken(); if (token != openingBracket) { reportError("XmlParser::parse", __LINE__, "Opening Bracket expected!", getInputFileLineCounter()); } token = m_pScanner->getNextToken(); if (token != slash) { reportError("XmlParser::parse", __LINE__, "Slash expected!", getInputFileLineCounter()); } token = m_pScanner->getNextToken(); if (token != identifier) { reportError("XmlParser::parse", __LINE__, "Identifier expected!", getInputFileLineCounter()); } // next token is the closing tag string nextTag(m_pScanner->getCurrentTokenString()); // pop corresponding tag from stack string s = m_tagObserver.pop(); // compare the two tags if (s != nextTag) { // the closing tag doesn't correspond to the opening tag: reportError("XmlParser::parse", __LINE__, "wrong closing tag!", getInputFileLineCounter()); } token = m_pScanner->getNextToken(); if (token != closingBracket) { reportError("XmlParser::parse", __LINE__, "Closing Bracket expected!", getInputFileLineCounter()); } // The tag is closed so we return --m_recursionDepth; return currentTagObject; } // end of read something different from "<" // Found "<", so a (series of) new tag begins and we have to perform // recursive invocation of parse() // // There are two exceptions: // - a slash follows afer <, i.e. we have a closing tag // - an exclamation mark follows after <, i.e. we have a comment while (m_pScanner->testNextToken() == openingBracket) { // Leave the while loop if a closing tag occurs if (m_pScanner->testNextNextToken() == slash) { break; } // Ignore comments if (m_pScanner->testNextNextToken() == exclamationMark) { // Comment must start with <!-- if ((m_pScanner->getNextToken() != openingBracket) || (m_pScanner->getNextToken() != exclamationMark) || (m_pScanner->getNextToken() != minus) || (m_pScanner->getNextToken() != minus)) { reportError("XmlParser::parse", __LINE__, "Comment must start with <!--", getInputFileLineCounter()); } // Find end of comment bool endOfCommentFound = false; while (!endOfCommentFound) { // Skip until we find a - (and skip over it) if (!m_pScanner->skipUntil('-', true)) { reportError("XmlParser::parse", __LINE__, "Closing --> of comment not found!", getInputFileLineCounter()); } // The next characters must be -> (note that one minus is already consumed) if ((m_pScanner->getNextToken() == minus) && (m_pScanner->getNextToken() == closingBracket)) { endOfCommentFound = true; } } // while // Proceed with outer while loop continue; } // Ignore comments // The new tag object is a son of the current tag object XmlTagObject *sonTagObject = parse(); appendSonTagObject(currentTagObject, sonTagObject); } // while // Now we have found all tags. // We expect a closing tag now, i.e. </id> token = m_pScanner->getNextToken(); if (token != openingBracket) { reportError("XmlParser::parse", __LINE__, "Opening Bracket expected!", getInputFileLineCounter()); } token = m_pScanner->getNextToken(); if (token != slash) { reportError("XmlParser::parse", __LINE__, "Slash expected!", getInputFileLineCounter()); } token = m_pScanner->getNextToken(); if (token != identifier) { reportError("XmlParser::parse", __LINE__, "Identifier expected!", getInputFileLineCounter()); } // next token is the closing tag string nextTag(m_pScanner->getCurrentTokenString()); // pop corresponding tag from stack string s = m_tagObserver.pop(); // compare the two tags if (s != nextTag) { // the closing tag doesn't correspond to the opening tag: reportError("XmlParser::parse", __LINE__, "wrong closing tag!", getInputFileLineCounter()); } token = m_pScanner->getNextToken(); if (token != closingBracket) { reportError("XmlParser::parse", __LINE__, "Closing Bracket expected!", getInputFileLineCounter()); } --m_recursionDepth; // check if Document contains code after the last closing bracket if (m_recursionDepth == 0) { token = m_pScanner->getNextToken(); if (token != endOfFile) { reportError("XmlParser::parse", __LINE__, "Document contains code after the last closing bracket!", getInputFileLineCounter()); } } return currentTagObject; } // end of Read ">" OGDF_ASSERT(false) //continue; } // end of found identifier OGDF_ASSERT(false) } // end of while (true)
int parseMaticFile(const char *driver, FILE *output) { FILE *drFile; char name[32] = {0}, make[64] = {0}, model[64] = {0}, tag[32] = {0}, recomm[64] = {0}, comment[4096] = {0}, comment2[4096] = {0}, pnpmake[64] = {0}, pnpmodel[64] = {0}; char id[128]; char path[256], *c; drFile = fopen(driver, "r"); if (drFile == NULL) return 0; strncpy(path, driver, 255); path[ 255 ] = '\0'; if ((c = strstr(path, "/driver/")) != NULL) *c = 0; c = comment; while (!feof(drFile)) { tag[0] = 0; nextTag(drFile, tag, 32); if (tag[0]) { if (strcmp(tag, "name") == 0) readValue(drFile, name, 32); else if (strcmp(tag, "comments") == 0) readComment(drFile, c, 4096); else if (strcmp(tag, "printers") == 0) c = comment2; else if (strcmp(tag, "printer") == 0) { id[0] = 0; comment2[0] = 0; } else if (strcmp(tag, "id") == 0) readValue(drFile, id, 128); else if (strcmp(tag, "/printer") == 0 && id[0]) { fprintf(output, "FILE=foomatic/%s/%s\n", id+8, name); make[0] = 0; model[0] = 0; recomm[0] = 0; pnpmake[0] = 0; pnpmodel[0] = 0; getMaticPrinterInfos(path, id, make, model, recomm, NULL, pnpmake, pnpmodel); fprintf(output, "MANUFACTURER=%s\n", make); fprintf(output, "MODELNAME=%s\n", model); fprintf(output, "MODEL=%s\n", model); fprintf(output, "DESCRIPTION=%s %s (Foomatic + %s)\n", make, model, name); if (recomm[0] && strcmp(name, recomm) == 0) fprintf(output, "RECOMMANDED=yes\n"); if (comment[0] || comment2[0]) { fprintf(output, "DRIVERCOMMENT="); if (comment2[0]) { fprintf(output, "<h3>Printer note</h3>%s", comment2); } if (comment[0]) fprintf(output, "<h3>General driver note</h3>%s", comment); fprintf(output, "\n"); } if ( pnpmake[0] ) fprintf( output, "PNPMANUFACTURER=%s\n", pnpmake ); if ( pnpmodel[0] ) fprintf( output, "PNPMODEL=%s\n", pnpmodel ); fprintf(output, "\n"); } else if (strcmp(tag, "/printers") == 0) break; } } fclose(drFile); return 1; }
int getMaticPrinterInfos(const char *base, const char *id, char *make, char *model, char *recomm, char *comment, char *pnpmake, char *pnpmodel) { char filePath[256]; FILE *xmlFile; char tag[32] = {0}; int n = 0; int in_autodetect = 0; snprintf(filePath, 256, "%s/%s.xml", base, id); if ( access( filePath, F_OK ) != 0 ) { /* file doesn't seem to exists, see if Foomatic ID translation file can help */ const char *c; char ID1[ 256 ], ID2[ 256 ]; int found = 0; /* Locate the actual ID part in the given "id" argument whose format is "printer/<ID>" */ c = id; while ( *c && *c != '/' ) c++; c++; /* Translation file is usually /usr/share/foomatic/db/oldprinterids */ snprintf( filePath, 256, "%s/../oldprinterids", base ); if ( ( xmlFile = fopen( filePath, "r" ) ) == NULL ) return 0; /* Look for possible translated ID */ while ( !feof( xmlFile ) ) { if ( fscanf( xmlFile, "%256s %256s", ID1, ID2 ) == 2 ) { if ( strcmp( c, ID1 ) == 0 ) { snprintf( filePath, 256, "%s/printer/%s.xml", base, ID2 ); found = 1; break; } } else break; } fclose( xmlFile ); if ( !found ) return 0; } xmlFile = fopen(filePath, "r"); if (xmlFile == NULL) return 0; while (!feof(xmlFile) && n < 6) { tag[0] = 0; nextTag(xmlFile, tag, 32); if (tag[0]) { char *c; if ( strcmp( tag, "autodetect" ) == 0 ) { in_autodetect = 1; continue; } else if ( strcmp( tag, "/autodetect" ) == 0 ) { in_autodetect = 0; continue; } else if (!make[0] && strcmp(tag, "make") == 0) c = make; else if (strcmp(tag, "model") == 0) { if ( in_autodetect && !pnpmodel[ 0 ] ) c = pnpmodel; else if ( !in_autodetect && !model[ 0 ] ) c = model; else continue; } else if ( !pnpmake[0] && in_autodetect && strcmp( tag, "manufacturer" ) == 0 ) c = pnpmake; else if (!recomm[0] && strcmp(tag, "driver") == 0) c = recomm; else if (comment && !comment[0] && strcmp(tag, "comments") == 0) { readComment(xmlFile, comment, 4096); n++; continue; } else continue; n++; readValue(xmlFile, c, 64); } } fclose(xmlFile); return 1; }
void CC3Light::initWithName( const std::string& aName, GLuint ltIndx ) { return initWithTag( nextTag(), aName, ltIndx ); }
int sfccLex(parseUnion * lvalp, ParserControl * parm) { int i, rc; char *next; char *nextSection ; for (;;) { if(parm->econ) { if(parm->econ->asynRCntl.escanInfo.getnew == 1 ){ nextSection = getNextSection(parm->econ) ; if(nextSection != NULL) { parm->xmb->base = nextSection ; parm->xmb->cur = nextSection ; parm->xmb->last = nextSection + (parm->econ->asynRCntl.escanInfo.sectlen) ; } else { printf(" sfccLex --- section is NULL !!!!!!!!!!!!!!!!! \n") ; } } } next = nextTag(parm->xmb); if (next == NULL) { return 0; } // fprintf(stderr,"--- token: %.32s\n",next); //usefull for debugging if (parm->xmb->eTagFound) { parm->xmb->eTagFound = 0; return parm->xmb->etag; } if (*next == '/') { for (i = 0; i < TAGS_NITEMS; i++) { if (nextEquals(next + 1, tags[i].tag, tags[i].tagLen) == 1) { skipTag(parm->xmb); return tags[i].etag; } } } else { if (strncmp(parm->xmb->cur, "<!--", 4) == 0) { parm->xmb->cur = strstr(parm->xmb->cur, "-->") + 3; continue; } else if (strncmp(parm->xmb->cur, "<EC>", 4) == 0) { parm->econ->asynRCntl.escanInfo.getnew = 1 ; parm->econ->asynRCntl.escanInfo.parsestate = PARSTATE_STARTED ; continue; } for (i = 0; i < TAGS_NITEMS; i++) { if (nextEquals(next, tags[i].tag, tags[i].tagLen) == 1) { // printf("+++ %d\n",i); rc=tags[i].process(lvalp, parm); return rc; } } } break; } return 0; }
/*from fos to FossilInt fos*/ TypeFossilIntFeature *fosToFossilInt(TypeTree *tree) { TypeFossilIntFeature *fos; int n; char *s; fos = newFossilIntFeature(tree->sizeBuf); fos->sizeNode = tree->size; if(tree->comment != NULL) { for(n=0; n<tree->root; n++) { if(tree->comment[n] != NULL) { TypeTimeInterval ti; ti.inf = sqrt(-1); ti.sup = sqrt(-1); s = tree->comment[n]; while(s!=NULL && s[0]!='\0') { char *tag, *val; s = nextTag(s, &tag, &val); //fprintf(stderr, "tag %s\t val %s\n", tag, val); if(tag != NULL && strcmp(tag, "FOS")==0 && val != NULL) { if(fos->sizeFossil>=fos->sizeBufNode) { fos->sizeBufFossil += INC_FOSSIL_ITEM; fos->fossilIntList = (TypeFossilIntList*) realloc((void*) fos->fossilIntList, fos->sizeBufFossil*sizeof(TypeFossilIntList)); } fos->fossilIntList[fos->sizeFossil].fossilInt = toFossilInt(val); fos->fossilIntList[fos->sizeFossil].prec = fos->fossilInt[n]; fos->fossilInt[n] = fos->sizeFossil++; } if(tag != NULL && strcmp(tag, TAG_STATUS)==0 && val != NULL) { int st = atoi(val); switch(st) { case 1: fos->status[n] = contempNodeStatus; break; case 2: fos->status[n] = extinctNodeStatus; break; case 3: fos->status[n] = unknownNodeStatus; break; default: fos->status[n] = noneNodeStatus; } } if(tag != NULL && strcmp(tag, TAG_TIME)==0 && val != NULL) ti = toFossilInt(val); } if(fos->status[n] == unknownNodeStatus) { if(!isnan(ti.inf)) { if(fos->sizeTime>=fos->sizeBufTime) { fos->sizeBufTime += INC_BUF_TIME_TABLE; fos->endTimeTable = (TypeTimeInterval*) realloc ((void*)fos->endTimeTable,fos->sizeBufTime*sizeof(TypeTimeInterval)); } fos->endTimeTable[fos->sizeTime] = ti; fos->endTime[n] = fos->sizeTime++; } else { if(tree->node[n].child == NOSUCH) fos->status[n] = contempNodeStatus; else fos->status[n] = noneNodeStatus; } } } } if(tree->comment[tree->root] != NULL) { TypeTimeInterval ti; ti.inf = sqrt(-1); ti.sup = sqrt(-1); s = tree->comment[tree->root]; while(s!=NULL && s[0]!='\0') { char *tag, *val; s = nextTag(s, &tag, &val); // fprintf(stderr, "tag %s\t val %s\n", tag, val); if(tag != NULL && strcmp(tag, TAG_FOSSIL)==0 && val != NULL) { if(fos->sizeFossil>=fos->sizeBufFossil) { fos->sizeBufFossil += INC_FOSSIL_ITEM; fos->fossilIntList = (TypeFossilIntList*) realloc((void*) fos->fossilIntList, fos->sizeBufFossil*sizeof(TypeFossilIntList)); } fos->fossilIntList[fos->sizeFossil].fossilInt = toFossilInt(val); fos->fossilIntList[fos->sizeFossil].prec = fos->fossilInt[tree->root]; fos->fossilInt[tree->root] = fos->sizeFossil++; } if(tag != NULL && strcmp(tag, TAG_ORIGIN)==0 && val != NULL) tree->minTimeInt = toFossilInt(val); if(tag != NULL && strcmp(tag, TAG_END)==0 && val != NULL) tree->maxTimeInt = toFossilInt(val); if(tag != NULL && strcmp(tag, TAG_STATUS)==0 && val != NULL) { int st = atoi(val); switch(st) { case 1: fos->status[tree->root] = contempNodeStatus; break; case 2: fos->status[tree->root] = extinctNodeStatus; break; case 3: fos->status[tree->root] = unknownNodeStatus; break; default: fos->status[tree->root] = noneNodeStatus; } } if(tag != NULL && strcmp(tag, TAG_TIME)==0 && val != NULL) ti = toFossilInt(val); } if(fos->status[tree->root] == unknownNodeStatus) { if(!isnan(ti.inf)) { if(fos->sizeTime>=fos->sizeBufTime) { fos->sizeBufTime += INC_BUF_TIME_TABLE; fos->endTimeTable = (TypeTimeInterval*) realloc ((void*)fos->endTimeTable,fos->sizeBufTime*sizeof(TypeTimeInterval)); } fos->endTimeTable[fos->sizeTime] = ti; fos->endTime[tree->root] = fos->sizeTime++; } else { if(tree->node[tree->root].child == NOSUCH) fos->status[tree->root] = contempNodeStatus; else fos->status[tree->root] = noneNodeStatus; } } } for(n=tree->root+1; n<tree->size; n++) { if(tree->comment[n] != NULL) { TypeTimeInterval ti; ti.inf = sqrt(-1); ti.sup = sqrt(-1); s = tree->comment[n]; while(s[0]!='\0') { char *tag, *val; s = nextTag(s, &tag, &val); fprintf(stderr, "tag %s\t val %s\n", tag, val); if(tag != NULL && strcmp(tag, "FOS")==0 && val != NULL) { if(fos->sizeFossil>=fos->sizeBufFossil) { fos->sizeBufFossil += INC_FOSSIL_ITEM; fos->fossilIntList = (TypeFossilIntList*) realloc((void*) fos->fossilIntList, fos->sizeBufFossil*sizeof(TypeFossilIntList)); } fos->fossilIntList[fos->sizeFossil].fossilInt = toFossilInt(val); fos->fossilIntList[fos->sizeFossil].prec = fos->fossilInt[n]; fos->fossilInt[n] = fos->sizeFossil++; } if(tag != NULL && strcmp(tag, TAG_STATUS)==0 && val != NULL) { int st = atoi(val); switch(st) { case 1: fos->status[n] = contempNodeStatus; break; case 2: fos->status[n] = extinctNodeStatus; break; case 3: fos->status[n] = unknownNodeStatus; break; default: fos->status[n] = noneNodeStatus; } } if(tag != NULL && strcmp(tag, TAG_TIME)==0 && val != NULL) ti = toFossilInt(val); } if(fos->status[n] == unknownNodeStatus) { if(!isnan(ti.inf)) { if(fos->sizeTime>=fos->sizeBufTime) { fos->sizeBufTime += INC_BUF_TIME_TABLE; fos->endTimeTable = (TypeTimeInterval*) realloc ((void*)fos->endTimeTable,fos->sizeBufTime*sizeof(TypeTimeInterval)); } fos->endTimeTable[fos->sizeTime] = ti; fos->endTime[n] = fos->sizeTime++; } else { if(tree->node[n].child == NOSUCH) fos->status[n] = contempNodeStatus; else fos->status[n] = noneNodeStatus; } } } } } fixStatus(tree, fos); return fos; }