summaryrefslogtreecommitdiff
path: root/testC14N.c
diff options
context:
space:
mode:
authorAleksey Sanin <aleksey@aleksey.com>2009-07-09 10:26:22 +0200
committerDaniel Veillard <veillard@redhat.com>2009-07-09 10:26:22 +0200
commit838682478cf89ddcbda294d9557c72813135fc7a (patch)
treebeb96f53231fbd3952e611b695e7f2690715e0ad /testC14N.c
parent44af232c837312900f7d5c0ad58c2d52cdc8aa8f (diff)
downloadlibxml2-838682478cf89ddcbda294d9557c72813135fc7a.tar.gz
Aleksey Sanin support for c14n 1.1
* c14n.c include/libxml/c14n.h: adds support for C14N 1.1, new flags at the API level * runtest.c Makefile.am testC14N.c xmllint.c: add support in CLI tools and test binaries * result/c14n/1-1-without-comments/* test/c14n/1-1-without-comments/*: add a new batch of tests
Diffstat (limited to 'testC14N.c')
-rw-r--r--testC14N.c28
1 files changed, 18 insertions, 10 deletions
diff --git a/testC14N.c b/testC14N.c
index 674fc71e..ba70127e 100644
--- a/testC14N.c
+++ b/testC14N.c
@@ -32,13 +32,17 @@ static void usage(const char *name) {
name);
fprintf(stderr, "where <mode> is one of following:\n");
fprintf(stderr,
- "--with-comments \t XML file canonization w comments\n");
+ "--with-comments \t XML file canonicalization v1.0 w comments \n");
fprintf(stderr,
- "--without-comments \t XML file canonization w/o comments\n");
+ "--without-comments \t XML file canonicalization v1.0 w/o comments\n");
fprintf(stderr,
- "--exc-with-comments \t Exclusive XML file canonization w comments\n");
+ "--1-1-with-comments \t XML file canonicalization v1.1 w comments\n");
fprintf(stderr,
- "--exc-without-comments\t Exclusive XML file canonization w/o comments\n");
+ "--1-1-without-comments \t XML file canonicalization v1.1 w/o comments\n");
+ fprintf(stderr,
+ "--exc-with-comments \t Exclusive XML file canonicalization v1.0 w comments\n");
+ fprintf(stderr,
+ "--exc-without-comments\t Exclusive XML file canonicalization v1.0 w/o comments\n");
}
static xmlXPathObjectPtr
@@ -49,7 +53,7 @@ static xmlChar **parse_list(xmlChar *str);
/* static void print_xpath_nodes(xmlNodeSetPtr nodes); */
static int
-test_c14n(const char* xml_filename, int with_comments, int exclusive,
+test_c14n(const char* xml_filename, int with_comments, int mode,
const char* xpath_filename, xmlChar **inclusive_namespaces) {
xmlDocPtr doc;
xmlXPathObjectPtr xpath = NULL;
@@ -96,7 +100,7 @@ test_c14n(const char* xml_filename, int with_comments, int exclusive,
/* fprintf(stderr,"File \"%s\" loaded: start canonization\n", xml_filename); */
ret = xmlC14NDocDumpMemory(doc,
(xpath) ? xpath->nodesetval : NULL,
- exclusive, inclusive_namespaces,
+ mode, inclusive_namespaces,
with_comments, &result);
if(ret >= 0) {
if(result != NULL) {
@@ -135,22 +139,26 @@ int main(int argc, char **argv) {
fprintf(stderr, "Error: wrong number of arguments.\n");
usage(argv[0]);
} else if(strcmp(argv[1], "--with-comments") == 0) {
- ret = test_c14n(argv[2], 1, 0, (argc > 3) ? argv[3] : NULL, NULL);
+ ret = test_c14n(argv[2], 1, XML_C14N_1_0, (argc > 3) ? argv[3] : NULL, NULL);
} else if(strcmp(argv[1], "--without-comments") == 0) {
- ret = test_c14n(argv[2], 0, 0, (argc > 3) ? argv[3] : NULL, NULL);
+ ret = test_c14n(argv[2], 0, XML_C14N_1_0, (argc > 3) ? argv[3] : NULL, NULL);
+ } else if(strcmp(argv[1], "--1-1-with-comments") == 0) {
+ ret = test_c14n(argv[2], 1, XML_C14N_1_1, (argc > 3) ? argv[3] : NULL, NULL);
+ } else if(strcmp(argv[1], "--1-1-without-comments") == 0) {
+ ret = test_c14n(argv[2], 0, XML_C14N_1_1, (argc > 3) ? argv[3] : NULL, NULL);
} else if(strcmp(argv[1], "--exc-with-comments") == 0) {
xmlChar **list;
/* load exclusive namespace from command line */
list = (argc > 4) ? parse_list((xmlChar *)argv[4]) : NULL;
- ret = test_c14n(argv[2], 1, 1, (argc > 3) ? argv[3] : NULL, list);
+ ret = test_c14n(argv[2], 1, XML_C14N_EXCLUSIVE_1_0, (argc > 3) ? argv[3] : NULL, list);
if(list != NULL) xmlFree(list);
} else if(strcmp(argv[1], "--exc-without-comments") == 0) {
xmlChar **list;
/* load exclusive namespace from command line */
list = (argc > 4) ? parse_list((xmlChar *)argv[4]) : NULL;
- ret = test_c14n(argv[2], 0, 1, (argc > 3) ? argv[3] : NULL, list);
+ ret = test_c14n(argv[2], 0, XML_C14N_EXCLUSIVE_1_0, (argc > 3) ? argv[3] : NULL, list);
if(list != NULL) xmlFree(list);
} else {
fprintf(stderr, "Error: bad option.\n");