diff -r 5da2cf15eb44 -r b6f2462ee055 dav/main.c --- a/dav/main.c Mon Dec 18 16:24:32 2017 +0100 +++ b/dav/main.c Mon Jan 01 19:53:36 2018 +0100 @@ -41,6 +41,7 @@ #include #include #include +#include #include "config.h" #include "error.h" #include "assistant.h" @@ -61,6 +62,7 @@ //define DO_THE_TEST #include #include +#include "tags.h" void test() { } @@ -1488,9 +1490,9 @@ char *value = a->argc > 2 ? a->argv[2] : stdin2str(); if(namespace) { - dav_set_property_ns(res, namespace, property, value); + dav_set_string_property_ns(res, namespace, property, value); } else { - dav_set_property(res, property, value); + dav_set_string_property(res, property, value); } int ret = 0; @@ -1789,44 +1791,6 @@ return space; } -static void printnode(FILE *out, UcxMap *nsmap, DavXmlNode *node) { - while(node) { - if(node->type == DAV_XML_ELEMENT) { - char *prefix = ucx_map_cstr_get(nsmap, node->namespace); - char *freethis = NULL; - char *tagend = node->children ? ">" : " />"; - if(!prefix) { - sstr_t newpre = ucx_sprintf("x%d", (int)nsmap->count); - ucx_map_cstr_put(nsmap, node->namespace, newpre.ptr); - freethis = newpre.ptr; - prefix = newpre.ptr; - fprintf( - out, - "<%s:%s xmlns:%s=\"%s\"%s", - prefix, - node->name, - prefix, - node->namespace, - tagend); - } else { - fprintf(out, "<%s:%s%s", prefix, node->name, tagend); - } - - if(node->children) { - printnode(out, nsmap, node->children); - fprintf(out, "", prefix, node->name); - } - if(freethis) { - free(freethis); - } - } else if(node->type == DAV_XML_TEXT) { - fwrite(node->content, 1, node->contentlength, out); - } - - node = node->next; - } -} - void printxmldoc(FILE *out, char *root, char *rootns, DavXmlNode *content) { UcxMap *nsmap = ucx_map_new(16); @@ -1834,9 +1798,14 @@ fprintf(out, "%s", "\n"); fprintf(out, "", root, rootns); - printnode(out, nsmap, content); + dav_print_node(out, (write_func)fwrite, nsmap, content); fprintf(out, "\n", root); + + // cleanup namespace map + ucx_map_cstr_remove(nsmap, rootns); + ucx_map_free_content(nsmap, free); + ucx_map_free(nsmap); }