libidav/webdav.h

changeset 331
9ca1e4706acc
parent 317
7eea57f6d847
child 338
c7f3fe4abdb2
--- a/libidav/webdav.h	Thu Oct 12 20:37:46 2017 +0200
+++ b/libidav/webdav.h	Sun Oct 22 12:58:07 2017 +0200
@@ -53,11 +53,12 @@
 typedef struct DavProxy      DavProxy;
 typedef struct DavSession    DavSession;
 typedef struct DavResource   DavResource;
-typedef struct DavResult   DavResult;
+typedef struct DavResult     DavResult;
 typedef struct DavNamespace  DavNamespace;
 typedef struct DavProperty   DavProperty;
 typedef struct DavPropName   DavPropName;
 typedef struct DavKey        DavKey;
+typedef struct DavXmlNode    DavXmlNode;
 
 typedef size_t(*dav_read_func)(void*, size_t, size_t, void*);
 typedef size_t(*dav_write_func)(const void*, size_t, size_t, void*);
@@ -87,6 +88,14 @@
 
 typedef enum DavError DavError;
 
+enum DavXmlNodeType {
+    DAV_XML_NONE = 0,
+    DAV_XML_ELEMENT,
+    DAV_XML_TEXT
+};
+
+typedef enum DavXmlNodeType DavXmlNodeType;
+
 #define DAV_SESSION_ENCRYPT_CONTENT     0x0001
 #define DAV_SESSION_ENCRYPT_NAME        0x0002
 #define DAV_SESSION_DECRYPT_CONTENT     0x0004
@@ -151,7 +160,7 @@
 struct DavProperty {
     DavNamespace *ns;
     char         *name;
-    char         *value;
+    DavXmlNode   *value;
 };
 
 struct DavPropName {
@@ -174,6 +183,23 @@
     size_t  length;
 };
 
+struct DavXmlNode {
+    DavXmlNodeType type;
+    
+    char           *namespace;
+    char           *name;
+    
+    DavXmlNode     *prev;
+    DavXmlNode     *next;
+    DavXmlNode     *children;
+    DavXmlNode     *parent;
+    
+    // TODO: attributes
+    
+    char           *content;
+    size_t         contentlength;
+};
+
 DavContext* dav_context_new();
 void dav_context_destroy(DavContext *ctx);
 
@@ -245,8 +271,10 @@
 int dav_lock_t(DavResource *res, time_t timeout);
 int dav_unlock(DavResource *res);
 
-char* dav_get_property(DavResource *res, char *name);
-char* dav_get_property_ns(DavResource *res, char *ns, char *name);
+DavXmlNode* dav_get_property(DavResource *res, char *name);
+DavXmlNode* dav_get_property_ns(DavResource *res, char *ns, char *name);
+char* dav_get_string_property(DavResource *res, char *name);
+char* dav_get_string_property_ns(DavResource *res, char *ns, char *name);
 void dav_set_property(DavResource *res, char *name, char *value);
 void dav_set_property_ns(DavResource *res, char *ns, char *name, char *value);
 void dav_remove_property(DavResource *res, char *name);
@@ -266,6 +294,9 @@
 // private
 int dav_propfind(DavSession *sn, DavResource *root, UcxBuffer *rqbuf);
 
+char* dav_xml_getstring(DavXmlNode *node);
+DavXmlNode* dav_text_node(DavSession *sn, char *text);
+
 #ifdef	__cplusplus
 }
 #endif

mercurial