added some api functions

Tue, 18 Mar 2014 13:59:02 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Tue, 18 Mar 2014 13:59:02 +0100
changeset 42
6518b035a9df
parent 41
1c598ee0d3d9
child 43
03076907b58a

added some api functions

libidav/resource.c file | annotate | diff | comparison | revisions
libidav/webdav.h file | annotate | diff | comparison | revisions
--- a/libidav/resource.c	Tue Mar 18 11:48:22 2014 +0100
+++ b/libidav/resource.c	Tue Mar 18 13:59:02 2014 +0100
@@ -50,6 +50,13 @@
     return res;
 }
 
+DavResource* dav_resource_new_child(DavSession *sn, DavResource *parent, char *name) {
+    char *path = util_concat_path(parent->path, name);
+    DavResource *res = dav_resource_new(sn, path);
+    free(path);
+    return res;
+}
+
 
 DavResource* dav_resource_new_href(DavSession *sn, char *href) {  
     DavResource *res = ucx_mempool_calloc(sn->mp, 1, sizeof(DavResource));
@@ -395,8 +402,13 @@
 }
 
 DavResource* dav_create_child(DavResource *parent, char *name) {
-    // TODO
-    return NULL;
+    DavResource *res = dav_resource_new_child(parent->session, parent, name);
+    if(dav_create(res)) {
+        // TODO: free resource
+        return NULL;
+    } else {
+        return res;
+    }
 }
 
 int dav_delete(DavResource *res) {
--- a/libidav/webdav.h	Tue Mar 18 11:48:22 2014 +0100
+++ b/libidav/webdav.h	Tue Mar 18 13:59:02 2014 +0100
@@ -181,6 +181,7 @@
 /* ------------------------ resource functions ------------------------ */
 
 DavResource* dav_resource_new(DavSession *sn, char *path);
+DavResource* dav_resource_new_child(DavSession *sn, DavResource *parent, char *name);
 DavResource* dav_resource_new_href(DavSession *sn, char *href);
 
 DavResource* dav_create_child(DavResource *parent, char *name);

mercurial