libidav/webdav.h

changeset 331
9ca1e4706acc
parent 317
7eea57f6d847
child 338
c7f3fe4abdb2
equal deleted inserted replaced
330:54819e984a19 331:9ca1e4706acc
51 51
52 typedef struct DavContext DavContext; 52 typedef struct DavContext DavContext;
53 typedef struct DavProxy DavProxy; 53 typedef struct DavProxy DavProxy;
54 typedef struct DavSession DavSession; 54 typedef struct DavSession DavSession;
55 typedef struct DavResource DavResource; 55 typedef struct DavResource DavResource;
56 typedef struct DavResult DavResult; 56 typedef struct DavResult DavResult;
57 typedef struct DavNamespace DavNamespace; 57 typedef struct DavNamespace DavNamespace;
58 typedef struct DavProperty DavProperty; 58 typedef struct DavProperty DavProperty;
59 typedef struct DavPropName DavPropName; 59 typedef struct DavPropName DavPropName;
60 typedef struct DavKey DavKey; 60 typedef struct DavKey DavKey;
61 typedef struct DavXmlNode DavXmlNode;
61 62
62 typedef size_t(*dav_read_func)(void*, size_t, size_t, void*); 63 typedef size_t(*dav_read_func)(void*, size_t, size_t, void*);
63 typedef size_t(*dav_write_func)(const void*, size_t, size_t, void*); 64 typedef size_t(*dav_write_func)(const void*, size_t, size_t, void*);
64 65
65 enum DavError { 66 enum DavError {
85 DAV_NET_AUTH_REQUIRED 86 DAV_NET_AUTH_REQUIRED
86 }; 87 };
87 88
88 typedef enum DavError DavError; 89 typedef enum DavError DavError;
89 90
91 enum DavXmlNodeType {
92 DAV_XML_NONE = 0,
93 DAV_XML_ELEMENT,
94 DAV_XML_TEXT
95 };
96
97 typedef enum DavXmlNodeType DavXmlNodeType;
98
90 #define DAV_SESSION_ENCRYPT_CONTENT 0x0001 99 #define DAV_SESSION_ENCRYPT_CONTENT 0x0001
91 #define DAV_SESSION_ENCRYPT_NAME 0x0002 100 #define DAV_SESSION_ENCRYPT_NAME 0x0002
92 #define DAV_SESSION_DECRYPT_CONTENT 0x0004 101 #define DAV_SESSION_DECRYPT_CONTENT 0x0004
93 #define DAV_SESSION_DECRYPT_NAME 0x0008 102 #define DAV_SESSION_DECRYPT_NAME 0x0008
94 103
149 }; 158 };
150 159
151 struct DavProperty { 160 struct DavProperty {
152 DavNamespace *ns; 161 DavNamespace *ns;
153 char *name; 162 char *name;
154 char *value; 163 DavXmlNode *value;
155 }; 164 };
156 165
157 struct DavPropName { 166 struct DavPropName {
158 char *ns; 167 char *ns;
159 char *name; 168 char *name;
170 struct DavKey { 179 struct DavKey {
171 char *name; 180 char *name;
172 int type; 181 int type;
173 void *data; 182 void *data;
174 size_t length; 183 size_t length;
184 };
185
186 struct DavXmlNode {
187 DavXmlNodeType type;
188
189 char *namespace;
190 char *name;
191
192 DavXmlNode *prev;
193 DavXmlNode *next;
194 DavXmlNode *children;
195 DavXmlNode *parent;
196
197 // TODO: attributes
198
199 char *content;
200 size_t contentlength;
175 }; 201 };
176 202
177 DavContext* dav_context_new(); 203 DavContext* dav_context_new();
178 void dav_context_destroy(DavContext *ctx); 204 void dav_context_destroy(DavContext *ctx);
179 205
243 269
244 int dav_lock(DavResource *res); 270 int dav_lock(DavResource *res);
245 int dav_lock_t(DavResource *res, time_t timeout); 271 int dav_lock_t(DavResource *res, time_t timeout);
246 int dav_unlock(DavResource *res); 272 int dav_unlock(DavResource *res);
247 273
248 char* dav_get_property(DavResource *res, char *name); 274 DavXmlNode* dav_get_property(DavResource *res, char *name);
249 char* dav_get_property_ns(DavResource *res, char *ns, char *name); 275 DavXmlNode* dav_get_property_ns(DavResource *res, char *ns, char *name);
276 char* dav_get_string_property(DavResource *res, char *name);
277 char* dav_get_string_property_ns(DavResource *res, char *ns, char *name);
250 void dav_set_property(DavResource *res, char *name, char *value); 278 void dav_set_property(DavResource *res, char *name, char *value);
251 void dav_set_property_ns(DavResource *res, char *ns, char *name, char *value); 279 void dav_set_property_ns(DavResource *res, char *ns, char *name, char *value);
252 void dav_remove_property(DavResource *res, char *name); 280 void dav_remove_property(DavResource *res, char *name);
253 void dav_remove_property_ns(DavResource *res, char *ns, char *name); 281 void dav_remove_property_ns(DavResource *res, char *ns, char *name);
254 282
264 int dav_get_content(DavResource *res, void *stream, dav_write_func write_func); 292 int dav_get_content(DavResource *res, void *stream, dav_write_func write_func);
265 293
266 // private 294 // private
267 int dav_propfind(DavSession *sn, DavResource *root, UcxBuffer *rqbuf); 295 int dav_propfind(DavSession *sn, DavResource *root, UcxBuffer *rqbuf);
268 296
297 char* dav_xml_getstring(DavXmlNode *node);
298 DavXmlNode* dav_text_node(DavSession *sn, char *text);
299
269 #ifdef __cplusplus 300 #ifdef __cplusplus
270 } 301 }
271 #endif 302 #endif
272 303
273 #endif /* WEBDAV_H */ 304 #endif /* WEBDAV_H */

mercurial