64 curl_slist_free_all(headers); |
64 curl_slist_free_all(headers); |
65 return ret; |
65 return ret; |
66 } |
66 } |
67 |
67 |
68 UcxBuffer* create_allprop_propfind_request() { |
68 UcxBuffer* create_allprop_propfind_request() { |
69 UcxBuffer *buf = ucx_buffer_new(NULL, 512, 0); |
69 UcxBuffer *buf = ucx_buffer_new(NULL, 512, UCX_BUFFER_AUTOFREE); |
70 sstr_t s; |
70 sstr_t s; |
71 |
71 |
72 s = S("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"); |
72 s = S("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"); |
73 ucx_buffer_write(s.ptr, 1, s.length, buf); |
73 ucx_buffer_write(s.ptr, 1, s.length, buf); |
74 |
74 |
80 |
80 |
81 return buf; |
81 return buf; |
82 } |
82 } |
83 |
83 |
84 UcxBuffer* create_propfind_request(DavSession *sn, UcxList *properties) { |
84 UcxBuffer* create_propfind_request(DavSession *sn, UcxList *properties) { |
85 UcxBuffer *buf = ucx_buffer_new(NULL, 512, 0); |
85 UcxBuffer *buf = ucx_buffer_new(NULL, 512, UCX_BUFFER_AUTOEXTEND); |
86 sstr_t s; |
86 sstr_t s; |
87 |
87 |
88 int add_crypto_name = 1; |
88 int add_crypto_name = 1; |
89 int add_crypto_key = 1; |
89 int add_crypto_key = 1; |
90 char *crypto_ns = "idav"; |
90 char *crypto_ns = "idav"; |
190 ucx_map_free(namespaces); |
190 ucx_map_free(namespaces); |
191 return buf; |
191 return buf; |
192 } |
192 } |
193 |
193 |
194 UcxBuffer* create_basic_propfind_request() { |
194 UcxBuffer* create_basic_propfind_request() { |
195 UcxBuffer *buf = ucx_buffer_new(NULL, 512, 0); |
195 UcxBuffer *buf = ucx_buffer_new(NULL, 512, UCX_BUFFER_AUTOEXTEND); |
196 sstr_t s; |
196 sstr_t s; |
197 |
197 |
198 s = S("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"); |
198 s = S("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"); |
199 ucx_buffer_write(s.ptr, 1, s.length, buf); |
199 ucx_buffer_write(s.ptr, 1, s.length, buf); |
200 |
200 |
252 } |
252 } |
253 free(parser); |
253 free(parser); |
254 return NULL; |
254 return NULL; |
255 } |
255 } |
256 |
256 |
|
257 void destroy_propfind_parser(PropfindParser *parser) { |
|
258 if(parser->document) { |
|
259 xmlFreeDoc(parser->document); |
|
260 } |
|
261 free(parser); |
|
262 } |
|
263 |
257 int get_propfind_response(PropfindParser *parser, ResponseTag *result) { |
264 int get_propfind_response(PropfindParser *parser, ResponseTag *result) { |
258 if(parser->current == NULL) { |
265 if(parser->current == NULL) { |
259 return 0; |
266 return 0; |
260 } |
267 } |
261 |
268 |
262 char *href = NULL; |
269 char *href = NULL; |
263 int iscollection = 0; |
270 int iscollection = 0; |
264 UcxList *properties = NULL; // xmlNode list |
271 UcxList *properties = NULL; // xmlNode list |
265 char *crypto_name = NULL; // name set by crypto-name property |
272 char *crypto_name = NULL; // name set by crypto-name property |
266 char *crypto_key = NULL; |
273 char *crypto_key = NULL; |
|
274 |
|
275 result->properties = NULL; |
267 |
276 |
268 xmlNode *node = parser->current->children; |
277 xmlNode *node = parser->current->children; |
269 while(node) { |
278 while(node) { |
270 if(node->type == XML_ELEMENT_NODE) { |
279 if(node->type == XML_ELEMENT_NODE) { |
271 if(xstreq(node->name, "href")) { |
280 if(xstreq(node->name, "href")) { |
348 next = next->next; |
357 next = next->next; |
349 } |
358 } |
350 parser->current = next; |
359 parser->current = next; |
351 |
360 |
352 return 1; |
361 return 1; |
|
362 } |
|
363 |
|
364 void cleanup_response(ResponseTag *result) { |
|
365 if(result) { |
|
366 ucx_list_free(result->properties); |
|
367 } |
353 } |
368 } |
354 |
369 |
355 int hrefeq(DavSession *sn, char *href1, char *href2) { |
370 int hrefeq(DavSession *sn, char *href1, char *href2) { |
356 sstr_t href_s = sstr(util_url_decode(sn, href1)); |
371 sstr_t href_s = sstr(util_url_decode(sn, href1)); |
357 sstr_t href_r = sstr(util_url_decode(sn, href2)); |
372 sstr_t href_r = sstr(util_url_decode(sn, href2)); |
662 curl_slist_free_all(headers); |
677 curl_slist_free_all(headers); |
663 return ret; |
678 return ret; |
664 } |
679 } |
665 |
680 |
666 UcxBuffer* create_proppatch_request(DavResourceData *data) { |
681 UcxBuffer* create_proppatch_request(DavResourceData *data) { |
667 UcxBuffer *buf = ucx_buffer_new(NULL, 512, 0); |
682 UcxBuffer *buf = ucx_buffer_new(NULL, 512, UCX_BUFFER_AUTOEXTEND); |
668 sstr_t s; |
683 sstr_t s; |
669 |
684 |
670 UcxMap *namespaces = ucx_map_new(8); |
685 UcxMap *namespaces = ucx_map_new(8); |
671 char prefix[8]; |
686 char prefix[8]; |
672 int pfxnum = 0; |
687 int pfxnum = 0; |
769 |
784 |
770 return buf; |
785 return buf; |
771 } |
786 } |
772 |
787 |
773 UcxBuffer* create_crypto_proppatch_request(DavSession *sn, DavKey *key, char *name) { |
788 UcxBuffer* create_crypto_proppatch_request(DavSession *sn, DavKey *key, char *name) { |
774 UcxBuffer *buf = ucx_buffer_new(NULL, 512, 0); |
789 UcxBuffer *buf = ucx_buffer_new(NULL, 512, UCX_BUFFER_AUTOEXTEND); |
775 sstr_t s; |
790 sstr_t s; |
776 |
791 |
777 s = S("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"); |
792 s = S("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"); |
778 ucx_buffer_write(s.ptr, 1, s.length, buf); |
793 ucx_buffer_write(s.ptr, 1, s.length, buf); |
779 |
794 |