- speedup of IS_CHAR like macros, significant overall improvement
- More interfaces for new I/O functions: xmlNewIOInputStream,
xmlParserInputBufferCreateIO, xmlCreateIOParserCtxt
- added I/O test to xmllint
Daniel
diff --git a/xmllint.c b/xmllint.c
index aa58625..24c17f7 100644
--- a/xmllint.c
+++ b/xmllint.c
@@ -67,6 +67,7 @@
static int htmlout = 0;
static int push = 0;
static int noblanks = 0;
+static int testIO = 0;
extern int xmlDoValidityCheckingDefaultValue;
extern int xmlGetWarningsDefaultValue;
@@ -338,6 +339,19 @@
/************************************************************************
* *
+ * I/O Interfaces *
+ * *
+ ************************************************************************/
+
+int myRead(FILE *f, char * buffer, int len) {
+ return(fread(buffer, 1, len, f));
+}
+void myClose(FILE *f) {
+ fclose(f);
+}
+
+/************************************************************************
+ * *
* Test processing *
* *
************************************************************************/
@@ -375,6 +389,28 @@
xmlFreeParserCtxt(ctxt);
}
}
+ } else if (testIO) {
+ int ret;
+ FILE *f;
+
+ f = fopen(filename, "r");
+ if (f != NULL) {
+ xmlParserCtxtPtr ctxt;
+
+ ctxt = xmlCreateIOParserCtxt(NULL, NULL,
+ (xmlInputReadCallback) myRead,
+ (xmlInputCloseCallback) myClose,
+ f, XML_CHAR_ENCODING_NONE);
+ xmlParseDocument(ctxt);
+
+ ret = ctxt->wellFormed;
+ doc = ctxt->myDoc;
+ xmlFreeParserCtxt(ctxt);
+ if (!ret) {
+ xmlFreeDoc(doc);
+ doc = NULL;
+ }
+ }
} else if (recovery) {
doc = xmlRecoverFile(filename);
} else if (htmlout) {
@@ -545,6 +581,9 @@
else if ((!strcmp(argv[i], "-push")) ||
(!strcmp(argv[i], "--push")))
push++;
+ else if ((!strcmp(argv[i], "-testIO")) ||
+ (!strcmp(argv[i], "--testIO")))
+ testIO++;
else if ((!strcmp(argv[i], "-compress")) ||
(!strcmp(argv[i], "--compress"))) {
compress++;
@@ -612,6 +651,7 @@
printf("\t--push : use the push mode of the parser\n");
printf("\t--nowarning : do not emit warnings from parser/validator\n");
printf("\t--noblanks : drop (ignorable?) blanks spaces\n");
+ printf("\t--testIO : test user I/O support\n");
}
xmlCleanupParser();
xmlMemoryDump();