2 * testURI.c : a small tester program for XML input.
4 * See Copyright for the status of this software.
15 #include <libxml/xmlmemory.h>
16 #include <libxml/uri.h>
17 #include <libxml/globals.h>
19 static const char *base = NULL;
20 static int escape = 0;
22 static void handleURI(const char *str) {
25 xmlChar *res = NULL, *parsed = NULL;
30 ret = xmlParseURIReference(uri, str);
32 printf("%s : error %d\n", str, ret);
34 xmlNormalizeURIPath(uri->path);
36 parsed = xmlSaveUri(uri);
37 res = xmlURIEscape(parsed);
38 printf("%s\n", (char *) res);
41 xmlPrintURI(stdout, uri);
46 res = xmlBuildURI((xmlChar *)str, (xmlChar *) base);
48 printf("%s\n", (char *) res);
51 printf("::ERROR::\n");
60 int main(int argc, char **argv) {
63 if ((argc > arg) && (argv[arg] != NULL) &&
64 ((!strcmp(argv[arg], "-base")) || (!strcmp(argv[arg], "--base")))) {
70 if ((argc > arg) && (argv[arg] != NULL) &&
71 ((!strcmp(argv[arg], "-escape")) || (!strcmp(argv[arg], "--escape")))) {
75 if (argv[arg] == NULL) {
80 * read one line in string buffer.
82 if (fgets (&str[0], sizeof (str) - 1, stdin) == NULL)
86 * remove the ending spaces
90 ((str[i - 1] == '\n') || (str[i - 1] == '\r') ||
91 (str[i - 1] == ' ') || (str[i - 1] == '\t'))) {
98 while (argv[arg] != NULL) {