libidav/resource.c

changeset 298
755b8198b071
parent 280
6d8784bee427
child 315
7db4dbf4e6f9
--- a/libidav/resource.c	Tue Sep 05 16:03:48 2017 +0200
+++ b/libidav/resource.c	Tue Sep 05 17:25:09 2017 +0200
@@ -569,6 +569,31 @@
     return ret;
 }
 
+int dav_load_prop(DavResource *res, DavPropName *properties, size_t numprop) {
+    UcxMempool *mp = ucx_mempool_new(64);
+    
+    UcxList *proplist = NULL;
+    for(size_t i=0;i<numprop;i++) {
+        DavProperty *p = ucx_mempool_malloc(mp, sizeof(DavProperty));
+        p->name = properties[i].name;
+        p->ns = ucx_mempool_malloc(mp, sizeof(DavNamespace));
+        p->ns->name = properties[i].ns;
+        if(!strcmp(properties[i].ns, "DAV:")) {
+            p->ns->prefix = "D";
+        } else {
+            p->ns->prefix = ucx_asprintf(mp->allocator, "x%d", i).ptr;
+        }
+        p->value = NULL;
+        proplist = ucx_list_append_a(mp->allocator, proplist, p);
+    }
+    
+    UcxBuffer *rqbuf = create_propfind_request(res->session, proplist);
+    int ret = dav_propfind(res->session, res, rqbuf);
+    ucx_buffer_free(rqbuf);
+    ucx_mempool_destroy(mp);
+    return ret;
+}
+
 int dav_store(DavResource *res) {
     DavSession *sn = res->session;
     DavResourceData *data = res->data;

mercurial