int VRML1_MODEL_PARSER::readIndexedFaceSet() { char text[BUFLINE_SIZE]; // DBG( printf( " readIndexedFaceSet\n" ) ); while( GetNextTag( m_file, text, sizeof(text) ) ) { if( *text == ']' ) { continue; } if( *text == '}' ) { return 0; } if( strcmp( text, "coordIndex" ) == 0 ) { readIndexedFaceSet_coordIndex(); } else if( strcmp( text, "materialIndex" ) == 0 ) { readIndexedFaceSet_materialIndex(); } } wxLogTrace( traceVrmlV1Parser, wxT( " readIndexedFaceSet failed" ) ); return -1; }
bool VRML1_MODEL_PARSER::Load( const wxString& aFilename ) { char text[BUFLINE_SIZE]; wxLogTrace( traceVrmlV1Parser, wxT( "Loading: %s" ), GetChars( aFilename ) ); m_file = wxFopen( aFilename, wxT( "rt" ) ); if( m_file == NULL ) return false; // Switch the locale to standard C (needed to print floating point numbers) LOCALE_IO toggle; m_ModelParser->childs.clear(); while( GetNextTag( m_file, text, sizeof(text) ) ) { if( ( *text == '}' ) || ( *text == ']' ) ) { continue; } if( strcmp( text, "Separator" ) == 0 ) { m_model.reset( new S3D_MESH() ); m_ModelParser->childs.push_back( m_model ); read_separator(); } } fclose( m_file ); return true; }
EFI_STATUS FixDataMatchingTag( CHAR8* buffer, CHAR8* tag,UINT32* lenPtr) { EFI_STATUS Status; UINT32 length; UINT32 start; UINT32 stop; CHAR8* endTag; start = 0; while (1) { Status = GetNextTag(((UINT8 *)buffer) + start, &endTag, &stop,&length); if (EFI_ERROR(Status)) return Status; if ((*endTag == '/') && !AsciiStrCmp(endTag + 1, tag)) break; start += length; } buffer[start + stop] = '\0'; *lenPtr=start + length; return EFI_SUCCESS; }
int VRML1_MODEL_PARSER::readCoordinate3() { char text[BUFLINE_SIZE]; // DBG( printf( " readCoordinate3\n" ) ); while( GetNextTag( m_file, text, sizeof( text ) ) ) { if( *text == ']' ) { continue; } if( *text == '}' ) { return 0; } if( strcmp( text, "point" ) == 0 ) { readCoordinate3_point(); } } wxLogTrace( traceVrmlV1Parser, wxT( " readCoordinate3 failed" ) ); return -1; }
int VRML1_MODEL_PARSER::readMaterial() { char text[BUFLINE_SIZE]; S3D_MATERIAL* material = NULL; // DBG( printf( " readMaterial\n" ) ); wxString mat_name; material = new S3D_MATERIAL( m_Master, mat_name ); m_Master->Insert( material ); m_model->m_Materials = material; while( GetNextTag( m_file, text, sizeof(text) ) ) { if( *text == ']' ) { continue; } if( *text == '}' ) { return 0; } if( strcmp( text, "ambientColor" ) == 0 ) { readMaterial_ambientColor(); } else if( strcmp( text, "diffuseColor" ) == 0 ) { readMaterial_diffuseColor(); } else if( strcmp( text, "emissiveColor" ) == 0 ) { readMaterial_emissiveColor(); } else if( strcmp( text, "specularColor" ) == 0 ) { readMaterial_specularColor(); } else if( strcmp( text, "shininess" ) == 0 ) { readMaterial_shininess(); } else if( strcmp( text, "transparency" ) == 0 ) { readMaterial_transparency(); } } wxLogTrace( traceVrmlV1Parser, wxT( " readMaterial failed" ) ); return -1; }
static bool GetNextItemTag(streamtokenizer *st) { char htmlTag[1024]; while (GetNextTag(st, htmlTag, sizeof(htmlTag))) { if (strncasecmp(htmlTag, kItemTagPrefix, strlen(kItemTagPrefix)) == 0) { return true; } } return false; }
static long ParseNextTag(char *buffer, TagPtr *tag) { long length, pos, empty = 0; char *tagName; TagPtr refTag; length = GetNextTag(buffer, &tagName, 0, &empty); if (length == -1) return -1; #if PLIST_DEBUG gLastTag = tagName; gTagsParsed++; #endif pos = length; if (MATCHTAG(tagName, kXMLTagPList)) { length = 0; // just a header; nothing to parse // return-via-reference tag should be left alone } else if (MATCHTAG(tagName, kXMLTagDict)) { length = ParseTagList(buffer + pos, tag, kTagTypeDict, empty); } else if (!strcmp(tagName, kXMLTagKey)) { length = ParseTagKey(buffer + pos, tag); } else if (MATCHTAG(tagName, kXMLTagReference) && (refTag = TagFromRef(tagName, sizeof(kXMLTagReference)-1))) { *tag = refTag; length = 0; } else if (MATCHTAG(tagName, kXMLTagString)) { PARSESTASHINGTAG(tagName, kXMLTagString, ParseTagString); } else if (MATCHTAG(tagName, kXMLTagInteger)) { PARSESTASHINGTAG(tagName, kXMLTagInteger, ParseTagInteger); } else if (!strcmp(tagName, kXMLTagData)) { length = ParseTagData(buffer + pos, tag); } else if (!strcmp(tagName, kXMLTagDate)) { length = ParseTagDate(buffer + pos, tag); } else if (!strcmp(tagName, kXMLTagFalse)) { length = ParseTagBoolean(buffer + pos, tag, kTagTypeFalse); } else if (!strcmp(tagName, kXMLTagTrue)) { length = ParseTagBoolean(buffer + pos, tag, kTagTypeTrue); } else if (MATCHTAG(tagName, kXMLTagArray)) { length = ParseTagList(buffer + pos, tag, kTagTypeArray, empty); } else { // it wasn't parsed so we consumed no additional characters length = 0; if (tagName[0] == '/') // was it an end tag (indicated w/*tag = 0) *tag = 0; else { //printf("ignored plist tag: %s (*tag: %x)\n", tagName, *tag); *tag = (TagPtr)-1; // we're *not* returning a tag } } if (length == -1) return -1; return pos + length; }
long XMLParseNextTag(char *buffer, TagPtr * tag) { char *tagName; long length = GetNextTag(buffer, &tagName, 0); if (length == -1) { return -1; } long pos = length; if (!strncmp(tagName, kXMLTagPList, 6)) { length = 0; } else if (!strcmp(tagName, kXMLTagDict)) { length = ParseTagList(buffer + pos, tag, kTagTypeDict, 0); } else if (!strcmp(tagName, kXMLTagDict "/")) { length = ParseTagList(buffer + pos, tag, kTagTypeDict, 1); } else if (!strcmp(tagName, kXMLTagKey)) { length = ParseTagKey(buffer + pos, tag); } else if (!strcmp(tagName, kXMLTagString)) { length = ParseTagString(buffer + pos, tag); } else if (!strcmp(tagName, kXMLTagInteger)) { length = ParseTagInteger(buffer + pos, tag); } else if (!strcmp(tagName, kXMLTagData)) { length = ParseTagData(buffer + pos, tag); } else if (!strcmp(tagName, kXMLTagDate)) { length = ParseTagDate(buffer + pos, tag); } else if (!strcmp(tagName, kXMLTagFalse)) { length = ParseTagBoolean(buffer + pos, tag, kTagTypeFalse); } else if (!strcmp(tagName, kXMLTagTrue)) { length = ParseTagBoolean(buffer + pos, tag, kTagTypeTrue); } else if (!strcmp(tagName, kXMLTagArray)) { length = ParseTagList(buffer + pos, tag, kTagTypeArray, 0); } else if (!strcmp(tagName, kXMLTagArray "/")) { length = ParseTagList(buffer + pos, tag, kTagTypeArray, 1); } else { *tag = 0; length = 0; } if (length == -1) { return -1; } return pos + length; }
int VRML1_MODEL_PARSER::read_separator() { char text[BUFLINE_SIZE]; // DBG( printf( "Separator\n" ) ); while( GetNextTag( m_file, text, sizeof(text) ) ) { if( strcmp( text, "Material" ) == 0 ) { readMaterial(); } else if( strcmp( text, "Coordinate3" ) == 0 ) { readCoordinate3(); } else if( strcmp( text, "IndexedFaceSet" ) == 0 ) { readIndexedFaceSet(); } else if( strcmp( text, "Separator" ) == 0 ) { S3D_MESH_PTR parent( m_model.get() ); S3D_MESH_PTR new_mesh_model( new S3D_MESH() ); m_model->childs.push_back( new_mesh_model ); m_model.reset( new_mesh_model.get() ); // recursive read_separator(); m_model.reset( parent.get() ); } else if( ( *text != '}' ) ) { // DBG( printf( "read_NotImplemented %s\n", text ) ); Read_NotImplemented( m_file, '}' ); } else break; } return 0; }
static long FixDataMatchingTag(char *buffer, char *tag) { long length, start, stop; char *endTag; start = 0; while (1) { length = GetNextTag(buffer + start, &endTag, &stop, NULL); if (length == -1) return -1; if ((*endTag == '/') && !strcmp(endTag + 1, tag)) break; start += length; } buffer[start + stop] = '\0'; return start + length; }
static void ProcessSingleNewsItem(streamtokenizer *st, hashset *stopWords, hashset *prevSeenArticles, hashset *wordCounts) { char htmlTag[1024]; char articleTitle[1024]; char articleDescription[1024]; char articleURL[1024]; articleTitle[0] = articleDescription[0] = articleURL[0] = '\0'; while (GetNextTag(st, htmlTag, sizeof(htmlTag)) && (strcasecmp(htmlTag, kItemEndTag) != 0)) { if (strncasecmp(htmlTag, kTitleTagPrefix, strlen(kTitleTagPrefix)) == 0) ExtractElement(st, htmlTag, articleTitle, sizeof(articleTitle)); if (strncasecmp(htmlTag, kDescriptionTagPrefix, strlen(kDescriptionTagPrefix)) == 0) ExtractElement(st, htmlTag, articleDescription, sizeof(articleDescription)); if (strncasecmp(htmlTag, kLinkTagPrefix, strlen(kLinkTagPrefix)) == 0) ExtractElement(st, htmlTag, articleURL, sizeof(articleURL)); } if (strncmp(articleURL, "", sizeof(articleURL)) == 0) return; // punt, since it's not going to take us anywhere if (isNewArticle(prevSeenArticles, articleTitle, articleURL)) { ParseArticle(articleTitle, articleDescription, articleURL, stopWords, wordCounts); } else { printf("Skipping previously seen article: \"%s\"\n\tfrom \"%s\"\n", articleTitle, articleURL); } }
static void ProcessSingleNewsItem(streamtokenizer *st, hashset *stopWords, hashset * wordHash, hashset *articlesSeen) { char htmlTag[1024]; char articleTitle[1024]; char articleDescription[1024]; char articleURL[1024]; articleTitle[0] = articleDescription[0] = articleURL[0] = '\0'; while (GetNextTag(st, htmlTag, sizeof(htmlTag)) && (strcasecmp(htmlTag, kItemEndTag) != 0)) { if (strncasecmp(htmlTag, kTitleTagPrefix, strlen(kTitleTagPrefix)) == 0) ExtractElement(st, htmlTag, articleTitle, sizeof(articleTitle)); if (strncasecmp(htmlTag, kDescriptionTagPrefix,strlen(kDescriptionTagPrefix)) == 0) ExtractElement(st, htmlTag, articleDescription, sizeof(articleDescription)); if (strncasecmp(htmlTag, kLinkTagPrefix, strlen(kLinkTagPrefix)) == 0) ExtractElement(st, htmlTag, articleURL, sizeof(articleURL)); } if (strncmp(articleURL, "", sizeof(articleURL)) == 0) return; // punt, since it's not going to take us anywhere ParseArticle(articleTitle,articleDescription,articleURL,stopWords,wordHash,articlesSeen); }
static void ProcessSingleNewsItem(streamtokenizer *st, rssData *allData) { char htmlTag[1024]; char articleTitle[1024]; char articleDescription[1024]; char articleURL[1024]; articleTitle[0] = articleDescription[0] = articleURL[0] = '\0'; int count = 0; while (GetNextTag(st, htmlTag, sizeof(htmlTag)) && (strcasecmp(htmlTag, kItemEndTag) != 0)) { if (strncasecmp(htmlTag, kTitleTagPrefix, strlen(kTitleTagPrefix)) == 0) ExtractElement(st, htmlTag, articleTitle, sizeof(articleTitle)); if (strncasecmp(htmlTag, kDescriptionTagPrefix, strlen(kDescriptionTagPrefix)) == 0) ExtractElement(st, htmlTag, articleDescription, sizeof(articleDescription)); if (strncasecmp(htmlTag, kLinkTagPrefix, strlen(kLinkTagPrefix)) == 0) ExtractElement(st, htmlTag, articleURL, sizeof(articleURL)); count++; if (count == 5 ) break; } if (strncmp(articleURL, "", sizeof(articleURL)) == 0) return; // punt, since it's not going to take us anywhere ParseArticle(articleURL, articleTitle, allData); }
//========================================================================== // ParseNextTag // TODO: cleanup long XMLParseNextTag( char * buffer, TagPtr * tag ) { long length, pos; char * tagName; length = GetNextTag(buffer, &tagName, 0); if (length == -1) return -1; pos = length; /* Check most common cases first, make them fast */ /***** key ****/ if (!strcmp(tagName, kXMLTagKey)) { length = ParseTagKey(buffer + pos, tag); } /***** string ****/ else if (!strncmp(tagName, kXMLTagString, kXMLTagStringLen)) { if (!tagName[kXMLTagStringLen]) /* <string> */ { length = ParseTagString(buffer + pos, tag); } else if (' ' == tagName[kXMLTagStringLen]) /* <string ...> */ { // TODO: save tag if if found if(!strncmp(tagName + kXMLTagStringLen + 1, (kXMLStringID "\""), kXMLStringIDLen + 1)) /* <string ID="...> */ { // ID= int id = 0; /* find end of ID string */ int cnt = kXMLTagStringLen + 1 + kXMLStringIDLen + 2; while ((tagName[cnt] != '\0') && (tagName[cnt] != '"')) cnt++; tagName[cnt] = 0; char* val = tagName + kXMLTagStringLen + 1 + kXMLStringIDLen + 1; while(*val) { if ((*val >= '0' && *val <= '9')) // 0 - 9 { id = (id * 10) + (*val++ - '0'); } else { printf("ParseStringID error (0x%x)\n", *val); getchar(); return -1; } } length = ParseTagString(buffer + pos, tag); SaveRefString(buffer + pos, id); } else if(!strncmp(tagName + kXMLTagStringLen + 1, kXMLStringIDRef, kXMLStringIDRefLen)) /* <string IDREF= ...> */ { // IDREF= int id = 0; int cnt = strlen(kXMLTagString " " kXMLStringIDRef "\"") + 1; while ((tagName[cnt] != '\0') && (tagName[cnt] != '"')) cnt++; tagName[cnt] = 0; char* val = tagName + strlen(kXMLTagString " " kXMLStringIDRef "\""); while(*val) { if ((*val >= '0' && *val <= '9')) // 0 - 9 { id = (id * 10) + (*val++ - '0'); } else { printf("ParseStringIDREF error (0x%x)\n", *val); getchar(); return -1; } } char* str = GetRefString(id); TagPtr tmpTag = NewTag(); tmpTag->type = kTagTypeString; tmpTag->string = str; tmpTag->tag = 0; tmpTag->tagNext = 0; tmpTag->offset = buffer_start ? buffer - buffer_start + pos : 0; *tag = tmpTag; length = 0; //printf("Located IDREF, id = %d, string = %s\n", id, str); } } else /* unrecognized <string...> */ { *tag = 0; length = 0; } } /***** integer ****/ else if (!strncmp(tagName, kXMLTagInteger, kXMLTagIntegerLen)) { if (!tagName[kXMLTagIntegerLen]) /* <integer> */ { length = ParseTagInteger(buffer + pos, tag); } else if (' ' == tagName[kXMLTagIntegerLen]) /* <integer ...> */ { if(!strncmp(tagName + kXMLTagIntegerLen + 1, kXMLStringID, kXMLStringIDLen)) /* <integer ID=...> */ { // ID= int id = 0; int cnt = strlen(kXMLTagInteger " " kXMLStringID "\"") + 1; while ((tagName[cnt] != '\0') && (tagName[cnt] != '"')) cnt++; tagName[cnt] = 0; char* val = tagName + strlen(kXMLTagInteger " " kXMLStringID "\""); while(*val) { if ((*val >= '0' && *val <= '9')) // 0 - 9 { id = (id * 10) + (*val++ - '0'); } else { printf("ParseIntegerID error (0x%x)\n", *val); getchar(); return -1; } } length = ParseTagInteger(buffer + pos, tag); SaveRefString((*tag)->string, id); } else if(!strncmp(tagName + kXMLTagIntegerLen + 1, kXMLStringIDRef, kXMLStringIDRefLen)) /* <integer IDREF=...> */ { // IDREF= int id = 0; int cnt = strlen(kXMLTagInteger " " kXMLStringIDRef "\"") + 1; while ((tagName[cnt] != '\0') && (tagName[cnt] != '"')) cnt++; tagName[cnt] = 0; char* val = tagName + strlen(kXMLTagInteger " " kXMLStringIDRef "\""); while(*val) { if ((*val >= '0' && *val <= '9')) // 0 - 9 { id = (id * 10) + (*val++ - '0'); } else { printf("ParseStringIDREF error (0x%x)\n", *val); getchar(); return -1; } } int integer = (int)GetRefString(id); TagPtr tmpTag = NewTag(); tmpTag->type = kTagTypeInteger; tmpTag->string = (char*) integer; tmpTag->tag = 0; tmpTag->tagNext = 0; tmpTag->offset = buffer_start ? buffer - buffer_start + pos : 0; *tag = tmpTag; length = 0; //printf("Located IDREF, id = %d, string = %s\n", id, str); } else /* presume <integer ...>...</integer> */ { length = ParseTagInteger(buffer + pos, tag); } } else /* unrecognized <integer...> */ { *tag = 0; length = 0; } } /***** false ****/ else if (!strcmp(tagName, kXMLTagFalse)) { length = ParseTagBoolean(buffer + pos, tag, kTagTypeFalse); } /***** true ****/ else if (!strcmp(tagName, kXMLTagTrue)) { length = ParseTagBoolean(buffer + pos, tag, kTagTypeTrue); } /***** plist ****/ else if (!strncmp(tagName, kXMLTagPList, kXMLTagPListLen)) { length = 0; } /***** dict ****/ else if (!strncmp(tagName, kXMLTagDict, kXMLTagDictLen)) { if (!strncmp(tagName, kXMLTagDict, kXMLTagDictLen) && tagName[strlen(tagName)-1] == '/') /* <dict.../> */ { length = ParseTagList(buffer + pos, tag, kTagTypeDict, 1); } else if (!tagName[kXMLTagDictLen] || ' ' == tagName[kXMLTagDictLen]) /* <dict> or<dict ...> */ { length = ParseTagList(buffer + pos, tag, kTagTypeDict, 0); } else /* unrecognized <dict...> */ { *tag = 0; length = 0; } } /***** data ****/ else if ((!strncmp(tagName, kXMLTagData, kXMLTagDataLen)) && (!tagName[kXMLTagDataLen] /* <data> */ || ' ' == tagName[kXMLTagDataLen])) /* <data ...> */ { length = ParseTagData(buffer + pos, tag); } /***** date ****/ else if ((!strncmp(tagName, kXMLTagDate, kXMLTagDateLen)) && (!tagName[kXMLTagDateLen] /* <date> */ || ' ' == tagName[kXMLTagDateLen])) /* <date ...> */ { length = ParseTagDate(buffer + pos, tag); } /***** array ****/ else if (!strncmp(tagName, kXMLTagArray, kXMLTagArrayLen)) { /* <array...> */ char c = tagName[kXMLTagArrayLen]; if ('/' == c) /* <array/> */ { length = ParseTagList(buffer + pos, tag, kTagTypeArray, 1); } else if ('\0' == c || ' ' == c) /* <array> or <array ...> */ { length = ParseTagList(buffer + pos, tag, kTagTypeArray, 0); } else /* unrecognized <array...> */ { *tag = 0; length = 0; } } /***** unknown ****/ else { *tag = 0; length = 0; } if (length == -1) return -1; return pos + length; }
//========================================================================== // ParseNextTag // TODO: cleanup long XMLParseNextTag( char * buffer, TagPtr * tag ) { long length, pos; char * tagName; length = GetNextTag(buffer, &tagName, 0); if (length == -1) return -1; pos = length; if (!strncmp(tagName, kXMLTagPList, 6)) { length = 0; } /***** dict ****/ else if (!strcmp(tagName, kXMLTagDict)) { length = ParseTagList(buffer + pos, tag, kTagTypeDict, 0); } else if (!strncmp(tagName, kXMLTagDict, strlen(kXMLTagDict)) && tagName[strlen(tagName)-1] == '/') { length = ParseTagList(buffer + pos, tag, kTagTypeDict, 1); } else if (!strncmp(tagName, kXMLTagDict " ", strlen(kXMLTagDict " "))) { length = ParseTagList(buffer + pos, tag, kTagTypeDict, 0); } /***** key ****/ else if (!strcmp(tagName, kXMLTagKey)) { length = ParseTagKey(buffer + pos, tag); } /***** string ****/ else if (!strcmp(tagName, kXMLTagString)) { length = ParseTagString(buffer + pos, tag); } else if (!strncmp(tagName, kXMLTagString " ", strlen(kXMLTagString " "))) { // TODO: save tag if if found if(!strncmp(tagName + strlen(kXMLTagString " "), kXMLStringID, strlen(kXMLStringID))) { // ID= int id = 0; int cnt = strlen(kXMLTagString " " kXMLStringID "\"") + 1; while ((tagName[cnt] != '\0') && (tagName[cnt] != '"')) cnt++; tagName[cnt] = 0; char* val = tagName + strlen(kXMLTagString " " kXMLStringID "\""); while(*val) { if ((*val >= '0' && *val <= '9')) // 0 - 9 { id = (id * 10) + (*val++ - '0'); } else { printf("ParseStringID error (0x%x)\n", *val); getchar(); return -1; } } length = ParseTagString(buffer + pos, tag); SaveRefString(buffer + pos, id); } else if(!strncmp(tagName + strlen(kXMLTagString " "), kXMLStringIDRef, strlen(kXMLStringIDRef))) { // IDREF= int id = 0; int cnt = strlen(kXMLTagString " " kXMLStringIDRef "\"") + 1; while ((tagName[cnt] != '\0') && (tagName[cnt] != '"')) cnt++; tagName[cnt] = 0; char* val = tagName + strlen(kXMLTagString " " kXMLStringIDRef "\""); while(*val) { if ((*val >= '0' && *val <= '9')) // 0 - 9 { id = (id * 10) + (*val++ - '0'); } else { printf("ParseStringIDREF error (0x%x)\n", *val); getchar(); return -1; } } char* str = GetRefString(id); TagPtr tmpTag = NewTag(); tmpTag->type = kTagTypeString; tmpTag->string = str; tmpTag->tag = 0; tmpTag->tagNext = 0; tmpTag->offset = buffer_start ? buffer - buffer_start + pos : 0; *tag = tmpTag; length = 0; //printf("Located IDREF, id = %d, string = %s\n", id, str); } } /***** integer ****/ else if (!strcmp(tagName, kXMLTagInteger)) { length = ParseTagInteger(buffer + pos, tag); } else if (!strncmp(tagName, kXMLTagInteger " ", strlen(kXMLTagInteger " "))) { if(!strncmp(tagName + strlen(kXMLTagInteger " "), kXMLStringID, strlen(kXMLStringID))) { // ID= int id = 0; int cnt = strlen(kXMLTagInteger " " kXMLStringID "\"") + 1; while ((tagName[cnt] != '\0') && (tagName[cnt] != '"')) cnt++; tagName[cnt] = 0; char* val = tagName + strlen(kXMLTagInteger " " kXMLStringID "\""); while(*val) { if ((*val >= '0' && *val <= '9')) // 0 - 9 { id = (id * 10) + (*val++ - '0'); } else { printf("ParseIntegerID error (0x%x)\n", *val); getchar(); return -1; } } length = ParseTagInteger(buffer + pos, tag); SaveRefString((*tag)->string, id); } else if(!strncmp(tagName + strlen(kXMLTagInteger " "), kXMLStringIDRef, strlen(kXMLStringIDRef))) { // IDREF= int id = 0; int cnt = strlen(kXMLTagInteger " " kXMLStringIDRef "\"") + 1; while ((tagName[cnt] != '\0') && (tagName[cnt] != '"')) cnt++; tagName[cnt] = 0; char* val = tagName + strlen(kXMLTagInteger " " kXMLStringIDRef "\""); while(*val) { if ((*val >= '0' && *val <= '9')) // 0 - 9 { id = (id * 10) + (*val++ - '0'); } else { printf("ParseStringIDREF error (0x%x)\n", *val); getchar(); return -1; } } int integer = (int)GetRefString(id); TagPtr tmpTag = NewTag(); tmpTag->type = kTagTypeInteger; tmpTag->string = (char*) integer; tmpTag->tag = 0; tmpTag->tagNext = 0; tmpTag->offset = buffer_start ? buffer - buffer_start + pos : 0; *tag = tmpTag; length = 0; //printf("Located IDREF, id = %d, string = %s\n", id, str); } else { length = ParseTagInteger(buffer + pos, tag); } } /***** data ****/ else if (!strcmp(tagName, kXMLTagData)) { length = ParseTagData(buffer + pos, tag); } else if (!strncmp(tagName, kXMLTagData " ", strlen(kXMLTagData " "))) { length = ParseTagData(buffer + pos, tag); } else if (!strcmp(tagName, kXMLTagDate)) { length = ParseTagDate(buffer + pos, tag); } /***** date ****/ else if (!strncmp(tagName, kXMLTagDate " ", strlen(kXMLTagDate " "))) { length = ParseTagDate(buffer + pos, tag); } /***** false ****/ else if (!strcmp(tagName, kXMLTagFalse)) { length = ParseTagBoolean(buffer + pos, tag, kTagTypeFalse); } /***** true ****/ else if (!strcmp(tagName, kXMLTagTrue)) { length = ParseTagBoolean(buffer + pos, tag, kTagTypeTrue); } /***** array ****/ else if (!strcmp(tagName, kXMLTagArray)) { length = ParseTagList(buffer + pos, tag, kTagTypeArray, 0); } else if (!strncmp(tagName, kXMLTagArray " ", strlen(kXMLTagArray " "))) { length = ParseTagList(buffer + pos, tag, kTagTypeArray, 0); } else if (!strcmp(tagName, kXMLTagArray "/")) { length = ParseTagList(buffer + pos, tag, kTagTypeArray, 1); } /***** unknown ****/ else { *tag = 0; length = 0; } if (length == -1) return -1; return pos + length; }
EFI_STATUS XMLParseNextTag(CHAR8* buffer, TagPtr * tag, UINT32* lenPtr) { EFI_STATUS Status; UINT32 length=0; UINT32 pos=0; CHAR8* tagName=NULL; *lenPtr=0; Status = GetNextTag((UINT8*)buffer, &tagName, 0, &length); if (EFI_ERROR(Status)) return Status; pos = length; if (!AsciiStrnCmp(tagName, kXMLTagPList, 6)) { length=0; Status=EFI_SUCCESS; } /***** dict ****/ else if (!AsciiStrCmp(tagName, kXMLTagDict)) { Status = ParseTagList(buffer + pos, tag, kTagTypeDict, 0, &length); } else if (!AsciiStrCmp(tagName, kXMLTagDict "/")) { Status = ParseTagList(buffer + pos, tag, kTagTypeDict, 1, &length); } else if (!AsciiStrCmp(tagName, kXMLTagDict " ")) { Status = ParseTagList(buffer + pos, tag, kTagTypeDict, 0, &length); } /***** key ****/ else if (!AsciiStrCmp(tagName, kXMLTagKey)) { Status = ParseTagKey(buffer + pos, tag,&length); } /***** string ****/ else if (!AsciiStrCmp(tagName, kXMLTagString)) { Status = ParseTagString(buffer + pos, tag, &length); } /***** integer ****/ else if (!AsciiStrCmp(tagName, kXMLTagInteger)) { Status = ParseTagInteger(buffer + pos, tag, &length); } else if (!AsciiStrCmp(tagName, kXMLTagInteger " ")) { Status = ParseTagInteger(buffer + pos, tag, &length); } /***** data ****/ else if (!AsciiStrCmp(tagName, kXMLTagData)) { Status = ParseTagData(buffer + pos, tag,&length); } else if (!AsciiStrCmp(tagName, kXMLTagData " ")) { Status = ParseTagData(buffer + pos, tag, &length); } /***** date ****/ else if (!AsciiStrCmp(tagName, kXMLTagDate)) { Status = ParseTagDate(buffer + pos, tag, &length); } /***** FALSE ****/ else if (!AsciiStrCmp(tagName, kXMLTagFalse)) { Status = ParseTagBoolean(buffer + pos, tag, kTagTypeFalse, &length); } /***** TRUE ****/ else if (!AsciiStrCmp(tagName, kXMLTagTrue)) { Status = ParseTagBoolean(buffer + pos, tag, kTagTypeTrue, &length); } /***** array ****/ else if (!AsciiStrCmp(tagName, kXMLTagArray)) { Status = ParseTagList(buffer + pos, tag, kTagTypeArray, 0, &length); } else if (!AsciiStrCmp(tagName, kXMLTagArray " ")) { Status = ParseTagList(buffer + pos, tag, kTagTypeArray, 0, &length); } else if (!AsciiStrCmp(tagName, kXMLTagArray "/")) { Status = ParseTagList(buffer + pos, tag, kTagTypeArray, 1, &length); } /***** unknown ****/ else { *tag = NULL; length = 0; } if (EFI_ERROR(Status)) return EFI_UNSUPPORTED; *lenPtr=pos + length; return EFI_SUCCESS; }