davqlexec handles xml properties now (not really, but it doesn't destroy everything)

Sun, 17 Dec 2017 10:53:08 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sun, 17 Dec 2017 10:53:08 +0100
changeset 348
b79fb94f9e0a
parent 347
b6ff6be7aa91
child 349
0b4ecadaf3f9

davqlexec handles xml properties now (not really, but it doesn't destroy everything)

libidav/davqlexec.c file | annotate | diff | comparison | revisions
libidav/davqlexec.h file | annotate | diff | comparison | revisions
libidav/resource.c file | annotate | diff | comparison | revisions
--- a/libidav/davqlexec.c	Sat Dec 16 10:37:50 2017 +0100
+++ b/libidav/davqlexec.c	Sun Dec 17 10:53:08 2017 +0100
@@ -266,21 +266,36 @@
             sstr_t str;
             str.ptr = NULL;
             str.length = 0;
+            DavXmlNode *node = NULL;
             if(field_result.type == 0) {
                 str = ucx_asprintf(
                         sn->mp->allocator,
                         "%d",
                         field_result.data.integer);
-            } else {
+            } else if(field_result.type == 1) {
                 if(field_result.data.string) {
                     str = sstrdup_a(sn->mp->allocator, sstrn(
                             field_result.data.string,
                             field_result.length));
                 }
+            } else if(field_result.type == 2) {
+                // TODO:
+            } else {
+                // unknown type
+                // TODO: error
+                resource_free_properties(sn, new_properties);
+                return -1;
             }
             if(str.ptr) {
+                node = dav_session_malloc(sn, sizeof(DavXmlNode));
+                memset(node, 0, sizeof(DavXmlNode));
+                node->type = DAV_XML_TEXT;
+                node->content = str.ptr;
+                node->contentlength = str.length;
+            }
+            if(node) {
                 UcxKey key = dav_property_key(field->ns, field->name);
-                ucx_map_put(new_properties, key, str.ptr);
+                ucx_map_put(new_properties, key, node);
                 free(key.data);
             }
         } else {
--- a/libidav/davqlexec.h	Sat Dec 16 10:37:50 2017 +0100
+++ b/libidav/davqlexec.h	Sun Dec 17 10:53:08 2017 +0100
@@ -106,11 +106,12 @@
 };
 
 struct DavQLStackObj {
-    int32_t  type; // 0: int, 1: string
+    int32_t  type; // 0: int, 1: string, 2: xml
     uint32_t length;
     union DavQLStackData {
-        int64_t integer;
-        char    *string;
+        int64_t    integer;
+        char       *string;
+        DavXmlNode *node;
     } data;
 };
 
--- a/libidav/resource.c	Sat Dec 16 10:37:50 2017 +0100
+++ b/libidav/resource.c	Sun Dec 17 10:53:08 2017 +0100
@@ -121,9 +121,10 @@
 
 void resource_free_properties(DavSession *sn, UcxMap *properties) {
     UcxMapIterator i = ucx_map_iterator(properties);
-    char *property;
-    UCX_MAP_FOREACH(key, property, i) {
-        dav_session_free(sn, property);
+    DavXmlNode *node;
+    UCX_MAP_FOREACH(key, node, i) {
+        // TODO: free everything
+        dav_session_free(sn, node);
     }
     ucx_map_free(properties);
 }

mercurial