From e77a918a348cf23706905d87826d255bb715fd0d Mon Sep 17 00:00:00 2001 From: Daniel Veillard Date: Wed, 5 Apr 2000 19:12:29 +0000 Subject: [PATCH] added testURI.c, Daniel. --- ChangeLog | 4 +++ testURI.c | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+) create mode 100644 testURI.c diff --git a/ChangeLog b/ChangeLog index e9d762ab..b898e82f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Wed Apr 5 21:11:35 CEST 2000 Daniel Veillard + + * testURI.c: yet another forgotten commit, I should get some sleep ! + Wed Apr 5 20:36:46 CEST 2000 Daniel Veillard * xmllint.c: forgot to commit this too ? diff --git a/testURI.c b/testURI.c new file mode 100644 index 00000000..6712119c --- /dev/null +++ b/testURI.c @@ -0,0 +1,91 @@ +/* + * testURI.c : a small tester program for XML input. + * + * See Copyright for the status of this software. + * + * Daniel.Veillard@w3.org + */ + +#ifdef WIN32 +#include "win32config.h" +#else +#include "config.h" +#endif + +#include +#include +#include +#include + +#include + +int main(int argc, char **argv) { + int i, ret, arg = 1; + xmlURIPtr uri; + const char *base = NULL; + xmlChar *composite; + + if ((!strcmp(argv[arg], "-base")) || (!strcmp(argv[arg], "--base"))) { + arg++; + base = argv[arg]; + if (base != NULL) + arg++; + } + uri = xmlCreateURI(); + if (argv[arg] == NULL) { + char str[1024]; + + while (1) { + /* + * read one line in string buffer. + */ + if (fgets (&str[0], sizeof (str) - 1, stdin) == NULL) + break; + + /* + * remove the ending spaces + */ + i = strlen(str); + while ((i > 0) && + ((str[i - 1] == '\n') || (str[i - 1] == '\r') || + (str[i - 1] == ' ') || (str[i - 1] == '\t'))) { + i--; + str[i] = 0; + } + if (i <= 0) + continue; + + ret = xmlParseURIReference(uri, str); + if (ret != 0) + printf("%s : error %d\n", str, ret); + else { + xmlPrintURI(stdout, uri); + printf("\n"); + } + + } + } else { + while (argv[arg] != NULL) { + if (base == NULL) { + ret = xmlParseURIReference(uri, argv[arg]); + if (ret != 0) + printf("%s : error %d\n", argv[arg], ret); + else { + xmlPrintURI(stdout, uri); + printf("\n"); + } + } else { + composite = xmlBuildURI((xmlChar *)argv[arg], (xmlChar *) base); + if (base == NULL) { + } else { + printf("%s\n", composite); + xmlFree(composite); + } + } + arg++; + } + } + xmlFreeURI(uri); + xmlMemoryDump(); + exit(0); +}