28 |
28 |
29 #ifndef WEBDAV_H |
29 #ifndef WEBDAV_H |
30 #define WEBDAV_H |
30 #define WEBDAV_H |
31 |
31 |
32 #include <inttypes.h> |
32 #include <inttypes.h> |
33 #include <ucx/map.h> |
33 #include <cx/map.h> |
34 #include <ucx/mempool.h> |
34 #include <cx/mempool.h> |
35 #include <ucx/list.h> |
35 #include <cx/linked_list.h> |
36 #include <ucx/buffer.h> |
36 #include <cx/string.h> |
|
37 #include <cx/buffer.h> |
37 #include <curl/curl.h> |
38 #include <curl/curl.h> |
38 #include <libxml/tree.h> |
39 #include <libxml/tree.h> |
39 |
40 |
40 #ifdef __cplusplus |
41 #ifdef __cplusplus |
41 extern "C" { |
42 extern "C" { |
163 void(*put_progress)(DavResource *res, int64_t total, int64_t now, void *userdata); |
164 void(*put_progress)(DavResource *res, int64_t total, int64_t now, void *userdata); |
164 void *progress_userdata; |
165 void *progress_userdata; |
165 }; |
166 }; |
166 |
167 |
167 struct DavContext { |
168 struct DavContext { |
168 UcxMap *namespaces; |
169 CxMap *namespaces; |
169 UcxMap *namespaceinfo; |
170 CxMap *namespaceinfo; |
170 UcxMap *keys; |
171 CxMap *keys; |
171 UcxList *sessions; |
172 CxList *sessions; |
172 DavProxy *http_proxy; |
173 DavProxy *http_proxy; |
173 DavProxy *https_proxy; |
174 DavProxy *https_proxy; |
174 }; |
175 }; |
175 |
176 |
176 struct DavProxy { |
177 struct DavProxy { |
236 |
237 |
237 DavContext* dav_context_new(void); |
238 DavContext* dav_context_new(void); |
238 void dav_context_destroy(DavContext *ctx); |
239 void dav_context_destroy(DavContext *ctx); |
239 |
240 |
240 void dav_context_add_key(DavContext *context, DavKey *key); |
241 void dav_context_add_key(DavContext *context, DavKey *key); |
241 DavKey* dav_context_get_key(DavContext *context, char *name); |
242 DavKey* dav_context_get_key(DavContext *context, const char *name); |
242 |
243 |
243 int dav_add_namespace(DavContext *context, const char *prefix, const char *ns); |
244 int dav_add_namespace(DavContext *context, const char *prefix, const char *ns); |
244 DavNamespace* dav_get_namespace(DavContext *context, const char *prefix); |
245 DavNamespace* dav_get_namespace(DavContext *context, const char *prefix); |
|
246 DavNamespace* dav_get_namespace_s(DavContext *context, cxstring prefix); |
245 |
247 |
246 int dav_enable_namespace_encryption(DavContext *context, const char *ns, DavBool encrypt); |
248 int dav_enable_namespace_encryption(DavContext *context, const char *ns, DavBool encrypt); |
247 int dav_namespace_is_encrypted(DavContext *context, const char *ns); |
249 int dav_namespace_is_encrypted(DavContext *context, const char *ns); |
248 |
250 |
249 DavSession* dav_session_new(DavContext *context, char *base_url); |
251 DavSession* dav_session_new(DavContext *context, char *base_url); |
266 void* dav_session_realloc(DavSession *sn, void *ptr, size_t size); |
268 void* dav_session_realloc(DavSession *sn, void *ptr, size_t size); |
267 void dav_session_free(DavSession *sn, void *ptr); |
269 void dav_session_free(DavSession *sn, void *ptr); |
268 char* dav_session_strdup(DavSession *sn, const char *str); |
270 char* dav_session_strdup(DavSession *sn, const char *str); |
269 |
271 |
270 void dav_set_effective_href(DavSession *sn, DavResource *resource); |
272 void dav_set_effective_href(DavSession *sn, DavResource *resource); |
271 DavResource* dav_get(DavSession *sn, char *path, char *properties); |
273 DavResource* dav_get(DavSession *sn, char *path, const char *properties); |
272 |
274 |
273 UcxList* parse_properties_string(DavContext *context, sstr_t str); |
275 CxList* parse_properties_string(DavContext *context, cxstring str); |
274 |
276 |
275 DavResource* dav_query(DavSession *sn, char *query, ...); |
277 DavResource* dav_query(DavSession *sn, char *query, ...); |
276 |
278 |
277 sstr_t dav_property_key(const char *ns, const char *name); |
279 cxmutstr dav_property_key(const char *ns, const char *name); |
278 void dav_get_property_namespace_str( |
280 void dav_get_property_namespace_str( |
279 DavContext *ctx, |
281 DavContext *ctx, |
280 char *prefixed_name, |
282 char *prefixed_name, |
281 char **ns, |
283 char **ns, |
282 char **name); |
284 char **name); |
285 char *prefixed_name, |
287 char *prefixed_name, |
286 char **name); |
288 char **name); |
287 |
289 |
288 /* ------------------------ resource functions ------------------------ */ |
290 /* ------------------------ resource functions ------------------------ */ |
289 |
291 |
290 DavResource* dav_resource_new(DavSession *sn, char *path); |
292 DavResource* dav_resource_new(DavSession *sn, const char *path); |
291 DavResource* dav_resource_new_child(DavSession *sn, DavResource *parent, char *name); |
293 DavResource* dav_resource_new_child(DavSession *sn, DavResource *parent, const char *name); |
292 DavResource* dav_resource_new_href(DavSession *sn, char *href); |
294 DavResource* dav_resource_new_href(DavSession *sn, const char *href); |
293 |
295 |
294 void dav_resource_free(DavResource *res); |
296 void dav_resource_free(DavResource *res); |
295 void dav_resource_free_all(DavResource *res); |
297 void dav_resource_free_all(DavResource *res); |
296 |
298 |
297 char* dav_resource_get_href(DavResource *resource); |
299 char* dav_resource_get_href(DavResource *resource); |
345 DavOutputStream* dav_outputstream_open(DavResource *res); |
347 DavOutputStream* dav_outputstream_open(DavResource *res); |
346 size_t dav_write(const void *buf, size_t size, size_t nitems, DavOutputStream *out); |
348 size_t dav_write(const void *buf, size_t size, size_t nitems, DavOutputStream *out); |
347 int dav_outputstream_close(DavOutputStream *out); |
349 int dav_outputstream_close(DavOutputStream *out); |
348 |
350 |
349 // private |
351 // private |
350 int dav_propfind(DavSession *sn, DavResource *root, UcxBuffer *rqbuf); |
352 int dav_propfind(DavSession *sn, DavResource *root, CxBuffer *rqbuf); |
351 |
353 |
352 |
354 |
353 /* --------------------------- DeltaV ---------------------------- */ |
355 /* --------------------------- DeltaV ---------------------------- */ |
354 |
356 |
355 int dav_versioncontrol(DavResource *res); |
357 int dav_versioncontrol(DavResource *res); |