diff options
author | Darren Salt <linux@youmustbejoking.demon.co.uk> | 2008-04-09 18:28:49 +0100 |
---|---|---|
committer | Darren Salt <linux@youmustbejoking.demon.co.uk> | 2008-04-09 18:28:49 +0100 |
commit | 39939c95eff90545285a9a8f761d9fa6e9349358 (patch) | |
tree | b8ea1fa3f2ddf1627eeecbd889f47226b01a45d8 /src/xine-utils/xmlparser.c | |
parent | 19357940a57c565ebe319729bd08d6e4800aff5d (diff) | |
parent | 628c4cbd9d023e74a7c6805d7ec0f163f2c172d1 (diff) | |
download | xine-lib-39939c95eff90545285a9a8f761d9fa6e9349358.tar.gz xine-lib-39939c95eff90545285a9a8f761d9fa6e9349358.tar.bz2 |
Merge from 1.2 main.
Diffstat (limited to 'src/xine-utils/xmlparser.c')
-rw-r--r-- | src/xine-utils/xmlparser.c | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/src/xine-utils/xmlparser.c b/src/xine-utils/xmlparser.c index 8ef828105..0c3d12f59 100644 --- a/src/xine-utils/xmlparser.c +++ b/src/xine-utils/xmlparser.c @@ -837,3 +837,73 @@ void xml_parser_dump_tree (const xml_node_t *node) { node = node->next; } while (node); } + +#ifdef XINE_XML_PARSER_TEST +#include <sys/mman.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> + +void *xine_xmalloc (size_t size) +{ + return malloc (size); +} + +int main (int argc, char **argv) +{ + int i, ret = 0; + for (i = 1; argv[i]; ++i) + { + xml_node_t *tree; + int fd; + void *buf; + struct stat st; + + if (stat (argv[i], &st)) + { + perror (argv[i]); + ret = 1; + continue; + } + if (!S_ISREG (st.st_mode)) + { + printf ("%s: not a file\n", argv[i]); + ret = 1; + continue; + } + fd = open (argv[i], O_RDONLY); + if (!fd) + { + perror (argv[i]); + ret = 1; + continue; + } + buf = mmap (NULL, st.st_size, PROT_READ, MAP_SHARED, fd, 0); + if (!buf) + { + perror (argv[i]); + if (close (fd)) + perror (argv[i]); + ret = 1; + continue; + } + + xml_parser_init (buf, st.st_size, 0); + if (!xml_parser_build_tree (&tree)) + { + puts (argv[i]); + xml_parser_dump_tree (tree); + xml_parser_free_tree (tree); + } + else + printf ("%s: parser failure\n", argv[i]); + + if (close (fd)) + { + perror (argv[i]); + ret = 1; + } + } + return ret; +} +#endif |