static int getid(void) { if(nmtoken(cc)) { int i=0; do { value[i++]=cc; if(i==len_v) value=(char*)m_stretch(value,len_v=2*i,i,sizeof(char)); getcc(); } while(nmtoken(cc)); value[i]='\0'; return 1; } else return 0; }
signed xmlscan (NODE * node) { NODE * section = node; NODE * element; NODE * attribute; NODE * value; char prefix = (char)(0); char suffix = (char)(0); char * string = node->text; unsigned lineno = 1; if (!section) { error (1, EFAULT, "section is null"); } if (!string) { error (1, EFAULT, "string is null"); } while (*string) { if (*string == '<') { prefix = '<'; suffix = '>'; string = discard (string, &lineno); if ((*string == '/') || (*string == '?') || (*string == '!')) { prefix = *string; string = discard (string, &lineno); } element = xmlnode (section); element->line = lineno; element->type = NODE_ELEM; element->text = string; if (isalpha (*string)) { string = nmtoken (string); } else if (*string == '-') { string = comment (string, &lineno); } else if (*string == '[') { string = context (string, ']', &lineno); } else { string = collect (string); } string = advance (string, &lineno); while ((*string) && (*string != '<') && (*string != '/') && (*string != '?') && (*string != '>')) { attribute = xmlnode (element); attribute->line = lineno; attribute->type = NODE_ATTR; attribute->text = string; if (isalpha (*string)) { string = nmtoken (string); } else if (*string == '-') { string = comment (string, &lineno); } else if (*string == '[') { string = context (string, ']', &lineno); } else if ((*string == '\"') || (*string == '\'')) { string = content (string, *string, &lineno); attribute->text++; } else { string = collect (string); } string = advance (string, &lineno); if (*string == '=') { string = discard (string, &lineno); value = xmlnode (attribute); value->line = lineno; value->type = NODE_VALU; value->text = string; if ((*string == '\"') || (*string == '\'')) { string = content (string, *string, &lineno); value->text++; } else { string = collect (string); } string = advance (string, &lineno); } } if ((*string == '/') || (*string == '?')) { suffix = *string; string = discard (string, &lineno); } } else if (*string == '>') { string = discard (string, &lineno); if (prefix == '!') { element->type = NODE_SGML; } else if (prefix == '?') { element->type = NODE_INST; } else if (suffix == '?') { } else if (prefix == '/') { element->type = NODE_ETAG; if (element->below) { error (1, 0, "Element </%s> on line %d has attributes or content.", element->text, element->line); } if (strcmp (section->text, element->text)) { error (1, 0, "Element <%s> on line %d teminated by </%s> on line %d", section->text, section->line, element->text, element->line); } if (section->above) { section = section->above; } } else if (suffix == '/') { } else { section = element; } } else { signed space = 0; char * output = string; NODE * segment = xmlnode (section); segment->line = lineno; segment->type = NODE_DATA; segment->text = string; while (*string) { if (*string == '<') { break; } if (isspace (*string)) { string = advance (string, &lineno); space++; continue; } if (space) { *output++ = ' '; space--; } *output++ = *string++; } if (output < string) { *output = (char)(0); } } } return (0); }