version 1.1, 2012/02/21 23:37:57
|
version 1.1.1.3, 2014/06/15 19:53:29
|
Line 130 static int copy = 0;
|
Line 130 static int copy = 0;
|
#endif /* LIBXML_TREE_ENABLED */ |
#endif /* LIBXML_TREE_ENABLED */ |
static int recovery = 0; |
static int recovery = 0; |
static int noent = 0; |
static int noent = 0; |
|
static int noenc = 0; |
static int noblanks = 0; |
static int noblanks = 0; |
static int noout = 0; |
static int noout = 0; |
static int nowrap = 0; |
static int nowrap = 0; |
Line 167 static int nodefdtd = 0;
|
Line 168 static int nodefdtd = 0;
|
#endif |
#endif |
#ifdef LIBXML_PUSH_ENABLED |
#ifdef LIBXML_PUSH_ENABLED |
static int push = 0; |
static int push = 0; |
|
static int pushsize = 4096; |
#endif /* LIBXML_PUSH_ENABLED */ |
#endif /* LIBXML_PUSH_ENABLED */ |
#ifdef HAVE_SYS_MMAN_H | #ifdef HAVE_MMAP |
static int memory = 0; |
static int memory = 0; |
#endif |
#endif |
static int testIO = 0; |
static int testIO = 0; |
Line 208 static xmlStreamCtxtPtr patstream = NULL;
|
Line 210 static xmlStreamCtxtPtr patstream = NULL;
|
#ifdef LIBXML_XPATH_ENABLED |
#ifdef LIBXML_XPATH_ENABLED |
static const char *xpathquery = NULL; |
static const char *xpathquery = NULL; |
#endif |
#endif |
static int options = XML_PARSE_COMPACT; | static int options = XML_PARSE_COMPACT | XML_PARSE_BIG_LINES; |
static int sax = 0; |
static int sax = 0; |
static int oldxml10 = 0; |
static int oldxml10 = 0; |
|
|
Line 519 endTimer(char *format, ...)
|
Line 521 endTimer(char *format, ...)
|
* We cannot do anything because we don't have a timing function |
* We cannot do anything because we don't have a timing function |
*/ |
*/ |
#ifdef HAVE_STDARG_H |
#ifdef HAVE_STDARG_H |
|
va_list ap; |
va_start(ap, format); |
va_start(ap, format); |
vfprintf(stderr, format, ap); |
vfprintf(stderr, format, ap); |
va_end(ap); |
va_end(ap); |
fprintf(stderr, " was not timed\n", msec); | fprintf(stderr, " was not timed\n"); |
#else |
#else |
/* We don't have gettimeofday, time or stdarg.h, what crazy world is |
/* We don't have gettimeofday, time or stdarg.h, what crazy world is |
* this ?! |
* this ?! |
Line 1667 testSAX(const char *filename) {
|
Line 1670 testSAX(const char *filename) {
|
(xmlSchemaValidityErrorFunc) fprintf, |
(xmlSchemaValidityErrorFunc) fprintf, |
(xmlSchemaValidityWarningFunc) fprintf, |
(xmlSchemaValidityWarningFunc) fprintf, |
stderr); |
stderr); |
|
xmlSchemaValidateSetFilename(vctxt, filename); |
|
|
ret = xmlSchemaValidateStream(vctxt, buf, 0, handler, |
ret = xmlSchemaValidateStream(vctxt, buf, 0, handler, |
(void *)user_data); |
(void *)user_data); |
Line 1821 static void processNode(xmlTextReaderPtr reader) {
|
Line 1825 static void processNode(xmlTextReaderPtr reader) {
|
static void streamFile(char *filename) { |
static void streamFile(char *filename) { |
xmlTextReaderPtr reader; |
xmlTextReaderPtr reader; |
int ret; |
int ret; |
#ifdef HAVE_SYS_MMAN_H | #ifdef HAVE_MMAP |
int fd = -1; |
int fd = -1; |
struct stat info; |
struct stat info; |
const char *base = NULL; |
const char *base = NULL; |
Line 1871 static void streamFile(char *filename) {
|
Line 1875 static void streamFile(char *filename) {
|
xmlTextReaderSetParserProp(reader, XML_PARSER_VALIDATE, 1); |
xmlTextReaderSetParserProp(reader, XML_PARSER_VALIDATE, 1); |
else |
else |
#endif /* LIBXML_VALID_ENABLED */ |
#endif /* LIBXML_VALID_ENABLED */ |
xmlTextReaderSetParserProp(reader, XML_PARSER_LOADDTD, 1); | if (loaddtd) |
| xmlTextReaderSetParserProp(reader, XML_PARSER_LOADDTD, 1); |
#ifdef LIBXML_SCHEMAS_ENABLED |
#ifdef LIBXML_SCHEMAS_ENABLED |
if (relaxng != NULL) { |
if (relaxng != NULL) { |
if ((timing) && (!repeat)) { |
if ((timing) && (!repeat)) { |
Line 1972 static void streamFile(char *filename) {
|
Line 1977 static void streamFile(char *filename) {
|
patstream = NULL; |
patstream = NULL; |
} |
} |
#endif |
#endif |
#ifdef HAVE_SYS_MMAN_H | #ifdef HAVE_MMAP |
if (memory) { |
if (memory) { |
xmlFreeParserInputBuffer(input); |
xmlFreeParserInputBuffer(input); |
munmap((char *) base, info.st_size); |
munmap((char *) base, info.st_size); |
Line 2072 static void doXPathDump(xmlXPathObjectPtr cur) {
|
Line 2077 static void doXPathDump(xmlXPathObjectPtr cur) {
|
#ifdef LIBXML_OUTPUT_ENABLED |
#ifdef LIBXML_OUTPUT_ENABLED |
xmlSaveCtxtPtr ctxt; |
xmlSaveCtxtPtr ctxt; |
|
|
if (cur->nodesetval->nodeNr <= 0) { | if ((cur->nodesetval == NULL) || (cur->nodesetval->nodeNr <= 0)) { |
fprintf(stderr, "XPath set is empty\n"); |
fprintf(stderr, "XPath set is empty\n"); |
progresult = XMLLINT_ERR_XPATH; |
progresult = XMLLINT_ERR_XPATH; |
break; |
break; |
Line 2137 static void doXPathQuery(xmlDocPtr doc, const char *qu
|
Line 2142 static void doXPathQuery(xmlDocPtr doc, const char *qu
|
progresult = XMLLINT_ERR_MEM; |
progresult = XMLLINT_ERR_MEM; |
return; |
return; |
} |
} |
ctxt->node = xmlDocGetRootElement(doc); | ctxt->node = (xmlNodePtr) doc; |
res = xmlXPathEval(BAD_CAST query, ctxt); |
res = xmlXPathEval(BAD_CAST query, ctxt); |
xmlXPathFreeContext(ctxt); |
xmlXPathFreeContext(ctxt); |
|
|
Line 2189 static void parseAndPrintFile(char *filename, xmlParse
|
Line 2194 static void parseAndPrintFile(char *filename, xmlParse
|
f = fopen(filename, "r"); |
f = fopen(filename, "r"); |
#endif |
#endif |
if (f != NULL) { |
if (f != NULL) { |
int res, size = 3; | int res; |
char chars[4096]; |
char chars[4096]; |
htmlParserCtxtPtr ctxt; |
htmlParserCtxtPtr ctxt; |
|
|
/* if (repeat) */ |
|
size = 4096; |
|
res = fread(chars, 1, 4, f); |
res = fread(chars, 1, 4, f); |
if (res > 0) { |
if (res > 0) { |
ctxt = htmlCreatePushParserCtxt(NULL, NULL, |
ctxt = htmlCreatePushParserCtxt(NULL, NULL, |
chars, res, filename, XML_CHAR_ENCODING_NONE); |
chars, res, filename, XML_CHAR_ENCODING_NONE); |
while ((res = fread(chars, 1, size, f)) > 0) { | while ((res = fread(chars, 1, pushsize, f)) > 0) { |
htmlParseChunk(ctxt, chars, res, 0); |
htmlParseChunk(ctxt, chars, res, 0); |
} |
} |
htmlParseChunk(ctxt, chars, 0, 1); |
htmlParseChunk(ctxt, chars, 0, 1); |
Line 2210 static void parseAndPrintFile(char *filename, xmlParse
|
Line 2213 static void parseAndPrintFile(char *filename, xmlParse
|
} |
} |
} |
} |
#endif /* LIBXML_PUSH_ENABLED */ |
#endif /* LIBXML_PUSH_ENABLED */ |
#ifdef HAVE_SYS_MMAN_H | #ifdef HAVE_MMAP |
else if ((html) && (memory)) { |
else if ((html) && (memory)) { |
int fd; |
int fd; |
struct stat info; |
struct stat info; |
Line 2325 static void parseAndPrintFile(char *filename, xmlParse
|
Line 2328 static void parseAndPrintFile(char *filename, xmlParse
|
if (rectxt == NULL) |
if (rectxt == NULL) |
xmlFreeParserCtxt(ctxt); |
xmlFreeParserCtxt(ctxt); |
} |
} |
#ifdef HAVE_SYS_MMAN_H | #ifdef HAVE_MMAP |
} else if (memory) { |
} else if (memory) { |
int fd; |
int fd; |
struct stat info; |
struct stat info; |
Line 2550 static void parseAndPrintFile(char *filename, xmlParse
|
Line 2553 static void parseAndPrintFile(char *filename, xmlParse
|
|
|
size = xmlC14NDocDumpMemory(doc, NULL, XML_C14N_1_0, NULL, 1, &result); |
size = xmlC14NDocDumpMemory(doc, NULL, XML_C14N_1_0, NULL, 1, &result); |
if (size >= 0) { |
if (size >= 0) { |
write(1, result, size); | if (write(1, result, size) == -1) { |
| fprintf(stderr, "Can't write data\n"); |
| } |
xmlFree(result); |
xmlFree(result); |
} else { |
} else { |
fprintf(stderr, "Failed to canonicalize\n"); |
fprintf(stderr, "Failed to canonicalize\n"); |
Line 2562 static void parseAndPrintFile(char *filename, xmlParse
|
Line 2567 static void parseAndPrintFile(char *filename, xmlParse
|
|
|
size = xmlC14NDocDumpMemory(doc, NULL, XML_C14N_1_1, NULL, 1, &result); |
size = xmlC14NDocDumpMemory(doc, NULL, XML_C14N_1_1, NULL, 1, &result); |
if (size >= 0) { |
if (size >= 0) { |
write(1, result, size); | if (write(1, result, size) == -1) { |
| fprintf(stderr, "Can't write data\n"); |
| } |
xmlFree(result); |
xmlFree(result); |
} else { |
} else { |
fprintf(stderr, "Failed to canonicalize\n"); |
fprintf(stderr, "Failed to canonicalize\n"); |
Line 2575 static void parseAndPrintFile(char *filename, xmlParse
|
Line 2582 static void parseAndPrintFile(char *filename, xmlParse
|
|
|
size = xmlC14NDocDumpMemory(doc, NULL, XML_C14N_EXCLUSIVE_1_0, NULL, 1, &result); |
size = xmlC14NDocDumpMemory(doc, NULL, XML_C14N_EXCLUSIVE_1_0, NULL, 1, &result); |
if (size >= 0) { |
if (size >= 0) { |
write(1, result, size); | if (write(1, result, size) == -1) { |
| fprintf(stderr, "Can't write data\n"); |
| } |
xmlFree(result); |
xmlFree(result); |
} else { |
} else { |
fprintf(stderr, "Failed to canonicalize\n"); |
fprintf(stderr, "Failed to canonicalize\n"); |
Line 2583 static void parseAndPrintFile(char *filename, xmlParse
|
Line 2592 static void parseAndPrintFile(char *filename, xmlParse
|
} |
} |
} else |
} else |
#endif |
#endif |
#ifdef HAVE_SYS_MMAN_H | #ifdef HAVE_MMAP |
if (memory) { |
if (memory) { |
xmlChar *result; |
xmlChar *result; |
int len; |
int len; |
Line 2604 static void parseAndPrintFile(char *filename, xmlParse
|
Line 2613 static void parseAndPrintFile(char *filename, xmlParse
|
fprintf(stderr, "Failed to save\n"); |
fprintf(stderr, "Failed to save\n"); |
progresult = XMLLINT_ERR_OUT; |
progresult = XMLLINT_ERR_OUT; |
} else { |
} else { |
write(1, result, len); | if (write(1, result, len) == -1) { |
| fprintf(stderr, "Can't write data\n"); |
| } |
xmlFree(result); |
xmlFree(result); |
} |
} |
|
|
} else |
} else |
#endif /* HAVE_SYS_MMAN_H */ | #endif /* HAVE_MMAP */ |
if (compress) { |
if (compress) { |
xmlSaveFile(output ? output : "-", doc); |
xmlSaveFile(output ? output : "-", doc); |
} else if (oldout) { |
} else if (oldout) { |
Line 2949 static void showVersion(const char *name) {
|
Line 2960 static void showVersion(const char *name) {
|
if (xmlHasFeature(XML_WITH_DEBUG_MEM)) fprintf(stderr, "MemDebug "); |
if (xmlHasFeature(XML_WITH_DEBUG_MEM)) fprintf(stderr, "MemDebug "); |
if (xmlHasFeature(XML_WITH_DEBUG_RUN)) fprintf(stderr, "RunDebug "); |
if (xmlHasFeature(XML_WITH_DEBUG_RUN)) fprintf(stderr, "RunDebug "); |
if (xmlHasFeature(XML_WITH_ZLIB)) fprintf(stderr, "Zlib "); |
if (xmlHasFeature(XML_WITH_ZLIB)) fprintf(stderr, "Zlib "); |
|
if (xmlHasFeature(XML_WITH_LZMA)) fprintf(stderr, "Lzma "); |
fprintf(stderr, "\n"); |
fprintf(stderr, "\n"); |
} |
} |
|
|
Line 2975 static void usage(const char *name) {
|
Line 2987 static void usage(const char *name) {
|
printf("\t--recover : output what was parsable on broken XML documents\n"); |
printf("\t--recover : output what was parsable on broken XML documents\n"); |
printf("\t--huge : remove any internal arbitrary parser limits\n"); |
printf("\t--huge : remove any internal arbitrary parser limits\n"); |
printf("\t--noent : substitute entity references by their value\n"); |
printf("\t--noent : substitute entity references by their value\n"); |
|
printf("\t--noenc : ignore any encoding specified inside the document\n"); |
printf("\t--noout : don't output the result tree\n"); |
printf("\t--noout : don't output the result tree\n"); |
printf("\t--path 'paths': provide a set of paths for resources\n"); |
printf("\t--path 'paths': provide a set of paths for resources\n"); |
printf("\t--load-trace : print trace of all external entites loaded\n"); |
printf("\t--load-trace : print trace of all external entites loaded\n"); |
Line 3004 static void usage(const char *name) {
|
Line 3017 static void usage(const char *name) {
|
#endif |
#endif |
#ifdef LIBXML_PUSH_ENABLED |
#ifdef LIBXML_PUSH_ENABLED |
printf("\t--push : use the push mode of the parser\n"); |
printf("\t--push : use the push mode of the parser\n"); |
|
printf("\t--pushsmall : use the push mode of the parser using tiny increments\n"); |
#endif /* LIBXML_PUSH_ENABLED */ |
#endif /* LIBXML_PUSH_ENABLED */ |
#ifdef HAVE_SYS_MMAN_H | #ifdef HAVE_MMAP |
printf("\t--memory : parse from memory\n"); |
printf("\t--memory : parse from memory\n"); |
#endif |
#endif |
printf("\t--maxmem nbbytes : limits memory allocation to nbbytes bytes\n"); |
printf("\t--maxmem nbbytes : limits memory allocation to nbbytes bytes\n"); |
Line 3063 static void usage(const char *name) {
|
Line 3077 static void usage(const char *name) {
|
printf("\t--sax: do not build a tree but work just at the SAX level\n"); |
printf("\t--sax: do not build a tree but work just at the SAX level\n"); |
printf("\t--oldxml10: use XML-1.0 parsing rules before the 5th edition\n"); |
printf("\t--oldxml10: use XML-1.0 parsing rules before the 5th edition\n"); |
#ifdef LIBXML_XPATH_ENABLED |
#ifdef LIBXML_XPATH_ENABLED |
printf("\t--xpath expr: evaluate the XPath expression, inply --noout\n"); | printf("\t--xpath expr: evaluate the XPath expression, imply --noout\n"); |
#endif |
#endif |
|
|
printf("\nLibxml project home page: http://xmlsoft.org/\n"); |
printf("\nLibxml project home page: http://xmlsoft.org/\n"); |
Line 3129 main(int argc, char **argv) {
|
Line 3143 main(int argc, char **argv) {
|
(!strcmp(argv[i], "--noent"))) { |
(!strcmp(argv[i], "--noent"))) { |
noent++; |
noent++; |
options |= XML_PARSE_NOENT; |
options |= XML_PARSE_NOENT; |
|
} else if ((!strcmp(argv[i], "-noenc")) || |
|
(!strcmp(argv[i], "--noenc"))) { |
|
noenc++; |
|
options |= XML_PARSE_IGNORE_ENC; |
} else if ((!strcmp(argv[i], "-nsclean")) || |
} else if ((!strcmp(argv[i], "-nsclean")) || |
(!strcmp(argv[i], "--nsclean"))) { |
(!strcmp(argv[i], "--nsclean"))) { |
options |= XML_PARSE_NSCLEAN; |
options |= XML_PARSE_NSCLEAN; |
Line 3230 main(int argc, char **argv) {
|
Line 3248 main(int argc, char **argv) {
|
else if ((!strcmp(argv[i], "-push")) || |
else if ((!strcmp(argv[i], "-push")) || |
(!strcmp(argv[i], "--push"))) |
(!strcmp(argv[i], "--push"))) |
push++; |
push++; |
|
else if ((!strcmp(argv[i], "-pushsmall")) || |
|
(!strcmp(argv[i], "--pushsmall"))) { |
|
push++; |
|
pushsize = 10; |
|
} |
#endif /* LIBXML_PUSH_ENABLED */ |
#endif /* LIBXML_PUSH_ENABLED */ |
#ifdef HAVE_SYS_MMAN_H | #ifdef HAVE_MMAP |
else if ((!strcmp(argv[i], "-memory")) || |
else if ((!strcmp(argv[i], "-memory")) || |
(!strcmp(argv[i], "--memory"))) |
(!strcmp(argv[i], "--memory"))) |
memory++; |
memory++; |
Line 3323 main(int argc, char **argv) {
|
Line 3346 main(int argc, char **argv) {
|
} |
} |
else if ((!strcmp(argv[i], "-noblanks")) || |
else if ((!strcmp(argv[i], "-noblanks")) || |
(!strcmp(argv[i], "--noblanks"))) { |
(!strcmp(argv[i], "--noblanks"))) { |
noblanks++; | noblanks++; |
xmlKeepBlanksDefault(0); | xmlKeepBlanksDefault(0); |
| options |= XML_PARSE_NOBLANKS; |
} |
} |
else if ((!strcmp(argv[i], "-maxmem")) || |
else if ((!strcmp(argv[i], "-maxmem")) || |
(!strcmp(argv[i], "--maxmem"))) { |
(!strcmp(argv[i], "--maxmem"))) { |
Line 3349 main(int argc, char **argv) {
|
Line 3373 main(int argc, char **argv) {
|
i++; |
i++; |
#ifdef LIBXML_OUTPUT_ENABLED |
#ifdef LIBXML_OUTPUT_ENABLED |
format = atoi(argv[i]); |
format = atoi(argv[i]); |
#endif /* LIBXML_OUTPUT_ENABLED */ |
|
if (format == 1) { |
if (format == 1) { |
noblanks++; |
noblanks++; |
xmlKeepBlanksDefault(0); |
xmlKeepBlanksDefault(0); |
} |
} |
|
#endif /* LIBXML_OUTPUT_ENABLED */ |
} |
} |
#ifdef LIBXML_READER_ENABLED |
#ifdef LIBXML_READER_ENABLED |
else if ((!strcmp(argv[i], "-stream")) || |
else if ((!strcmp(argv[i], "-stream")) || |