The W3C system administrators
\n\ \n\ \n\ "; /************************************************************************ * * * Debug * * * ************************************************************************/ void parseAndPrintFile(char *filename) { htmlDocPtr doc, tmp; /* * build an HTML tree from a string; */ doc = htmlParseFile(filename, NULL); /* * test intermediate copy if needed. */ if (copy) { tmp = doc; doc = xmlCopyDoc(doc, 1); xmlFreeDoc(tmp); } /* * print it. */ if (!debug) htmlDocDump(stdout, doc); else xmlDebugDumpDocument(stdout, doc); /* * free it. */ xmlFreeDoc(doc); } void parseAndPrintBuffer(CHAR *buf) { htmlDocPtr doc, tmp; /* * build an HTML tree from a string; */ doc = htmlParseDoc(buf, NULL); /* * test intermediate copy if needed. */ if (copy) { tmp = doc; doc = xmlCopyDoc(doc, 1); xmlFreeDoc(tmp); } /* * print it. */ if (!debug) htmlDocDump(stdout, doc); else xmlDebugDumpDocument(stdout, doc); /* * free it. */ xmlFreeDoc(doc); } int main(int argc, char **argv) { int i; int files = 0; for (i = 1; i < argc ; i++) { if ((!strcmp(argv[i], "-debug")) || (!strcmp(argv[i], "--debug"))) debug++; else if ((!strcmp(argv[i], "-copy")) || (!strcmp(argv[i], "--copy"))) copy++; } for (i = 1; i < argc ; i++) { if (argv[i][0] != '-') { parseAndPrintFile(argv[i]); files ++; } } if (files == 0) { printf("Usage : %s [--debug] [--copy] HTMLfiles ...\n", argv[0]); printf("\tParse the HTML files and output the result of the parsing\n"); printf("\t--debug : dump a debug tree of the in-memory document\n"); printf("\t--copy : used to test the internal copy implementation\n"); } return(0); }