| 151 cxBufferWrite(s.ptr, 1, s.length, buf); |
151 cxBufferWrite(s.ptr, 1, s.length, buf); |
| 152 |
152 |
| 153 return buf; |
153 return buf; |
| 154 } |
154 } |
| 155 |
155 |
| 156 CxBuffer* create_propfind_request(DavSession *sn, CxList *properties, char *rootelm, DavBool nocrypt) { |
156 CxBuffer* create_propfind_request(DavSession *sn, CxList *properties, const char *rootelm, DavBool nocrypt) { |
| 157 CxBuffer *buf = cxBufferCreate(cxDefaultAllocator, NULL, 512, CX_BUFFER_FREE_CONTENTS|CX_BUFFER_AUTO_EXTEND); |
157 CxBuffer *buf = cxBufferCreate(cxDefaultAllocator, NULL, 512, CX_BUFFER_FREE_CONTENTS|CX_BUFFER_AUTO_EXTEND); |
| 158 cxstring s; |
158 cxstring s; |
| 159 |
159 |
| 160 int add_crypto_name = 1; |
160 int add_crypto_name = 1; |
| 161 int add_crypto_key = 1; |
161 int add_crypto_key = 1; |
| 275 cxBufferPutString(buf, "</D:propfind>\n"); |
275 cxBufferPutString(buf, "</D:propfind>\n"); |
| 276 |
276 |
| 277 return buf; |
277 return buf; |
| 278 } |
278 } |
| 279 |
279 |
| 280 PropfindParser* create_propfind_parser(CxBuffer *response, char *url) { |
280 PropfindParser* create_propfind_parser(CxBuffer *response, const char *url) { |
| 281 PropfindParser *parser = malloc(sizeof(PropfindParser)); |
281 PropfindParser *parser = malloc(sizeof(PropfindParser)); |
| 282 if(!parser) { |
282 if(!parser) { |
| 283 return NULL; |
283 return NULL; |
| 284 } |
284 } |
| 285 parser->document = xmlReadMemory(response->space, response->pos, url, NULL, 0); |
285 parser->document = xmlReadMemory(response->space, response->pos, url, NULL, 0); |
| 470 xmlFreeDoc(doc); |
470 xmlFreeDoc(doc); |
| 471 |
471 |
| 472 return root; |
472 return root; |
| 473 } |
473 } |
| 474 |
474 |
| 475 DavResource* response2resource(DavSession *sn, ResponseTag *response, char *parent_path) { |
475 DavResource* response2resource(DavSession *sn, ResponseTag *response, const char *parent_path) { |
| 476 // create resource |
476 // create resource |
| 477 char *name = NULL; |
477 char *name = NULL; |
| 478 DavKey *key = NULL; |
478 DavKey *key = NULL; |
| 479 if(DAV_DECRYPT_NAME(sn) && response->crypto_name && (key = dav_context_get_key(sn->context, response->crypto_key))) { |
479 if(DAV_DECRYPT_NAME(sn) && response->crypto_name && (key = dav_context_get_key(sn->context, response->crypto_key))) { |
| 480 if(!response->crypto_key) { |
480 if(!response->crypto_key) { |
| 749 |
749 |
| 750 /* ----------------------------- PROPPATCH ----------------------------- */ |
750 /* ----------------------------- PROPPATCH ----------------------------- */ |
| 751 |
751 |
| 752 CURLcode do_proppatch_request( |
752 CURLcode do_proppatch_request( |
| 753 DavSession *sn, |
753 DavSession *sn, |
| 754 char *lock, |
754 const char *lock, |
| 755 CxBuffer *request, |
755 CxBuffer *request, |
| 756 CxBuffer *response) |
756 CxBuffer *response) |
| 757 { |
757 { |
| 758 CURL *handle = sn->handle; |
758 CURL *handle = sn->handle; |
| 759 curl_easy_setopt(handle, CURLOPT_CUSTOMREQUEST, "PROPPATCH"); |
759 curl_easy_setopt(handle, CURLOPT_CUSTOMREQUEST, "PROPPATCH"); |
| 927 static size_t dummy_write(void *buf, size_t s, size_t n, void *data) { |
927 static size_t dummy_write(void *buf, size_t s, size_t n, void *data) { |
| 928 //fwrite(buf, s, n, stdout); |
928 //fwrite(buf, s, n, stdout); |
| 929 return s*n; |
929 return s*n; |
| 930 } |
930 } |
| 931 |
931 |
| 932 CURLcode do_put_request(DavSession *sn, char *lock, DavBool create, void *data, dav_read_func read_func, dav_seek_func seek_func, size_t length) { |
932 CURLcode do_put_request(DavSession *sn, const char *lock, DavBool create, void *data, dav_read_func read_func, dav_seek_func seek_func, size_t length) { |
| 933 CURL *handle = sn->handle; |
933 CURL *handle = sn->handle; |
| 934 curl_easy_setopt(handle, CURLOPT_CUSTOMREQUEST, NULL); |
934 curl_easy_setopt(handle, CURLOPT_CUSTOMREQUEST, NULL); |
| 935 curl_easy_setopt(handle, CURLOPT_UPLOAD, 1L); |
935 curl_easy_setopt(handle, CURLOPT_UPLOAD, 1L); |
| 936 |
936 |
| 937 // clear headers |
937 // clear headers |
| 983 } |
983 } |
| 984 |
984 |
| 985 return ret; |
985 return ret; |
| 986 } |
986 } |
| 987 |
987 |
| 988 CURLcode do_delete_request(DavSession *sn, char *lock, CxBuffer *response) { |
988 CURLcode do_delete_request(DavSession *sn, const char *lock, CxBuffer *response) { |
| 989 CURL *handle = sn->handle; |
989 CURL *handle = sn->handle; |
| 990 struct curl_slist *headers = NULL; |
990 struct curl_slist *headers = NULL; |
| 991 if(lock) { |
991 if(lock) { |
| 992 char *url = NULL; |
992 char *url = NULL; |
| 993 curl_easy_getinfo(handle, CURLINFO_EFFECTIVE_URL, &url); |
993 curl_easy_getinfo(handle, CURLINFO_EFFECTIVE_URL, &url); |
| 1008 CURLcode ret = dav_session_curl_perform(sn, NULL); |
1008 CURLcode ret = dav_session_curl_perform(sn, NULL); |
| 1009 curl_slist_free_all(headers); |
1009 curl_slist_free_all(headers); |
| 1010 return ret; |
1010 return ret; |
| 1011 } |
1011 } |
| 1012 |
1012 |
| 1013 CURLcode do_mkcol_request(DavSession *sn, char *lock) { |
1013 CURLcode do_mkcol_request(DavSession *sn, const char *lock) { |
| 1014 CURL *handle = sn->handle; |
1014 CURL *handle = sn->handle; |
| 1015 struct curl_slist *headers = NULL; |
1015 struct curl_slist *headers = NULL; |
| 1016 if(lock) { |
1016 if(lock) { |
| 1017 char *url = NULL; |
1017 char *url = NULL; |
| 1018 curl_easy_getinfo(handle, CURLINFO_EFFECTIVE_URL, &url); |
1018 curl_easy_getinfo(handle, CURLINFO_EFFECTIVE_URL, &url); |
| 1211 } |
1211 } |
| 1212 |
1212 |
| 1213 return ret; |
1213 return ret; |
| 1214 } |
1214 } |
| 1215 |
1215 |
| 1216 CURLcode do_unlock_request(DavSession *sn, char *locktoken) { |
1216 CURLcode do_unlock_request(DavSession *sn, const char *locktoken) { |
| 1217 CURL *handle = sn->handle; |
1217 CURL *handle = sn->handle; |
| 1218 curl_easy_setopt(handle, CURLOPT_CUSTOMREQUEST, "UNLOCK"); |
1218 curl_easy_setopt(handle, CURLOPT_CUSTOMREQUEST, "UNLOCK"); |
| 1219 curl_easy_setopt(handle, CURLOPT_UPLOAD, 0L); |
1219 curl_easy_setopt(handle, CURLOPT_UPLOAD, 0L); |
| 1220 |
1220 |
| 1221 curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, dummy_write); |
1221 curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, dummy_write); |
| 1231 free(ltheader.ptr); |
1231 free(ltheader.ptr); |
| 1232 |
1232 |
| 1233 return ret; |
1233 return ret; |
| 1234 } |
1234 } |
| 1235 |
1235 |
| 1236 CURLcode do_simple_request(DavSession *sn, const char *method, char *locktoken) { |
1236 CURLcode do_simple_request(DavSession *sn, const char *method, const char *locktoken) { |
| 1237 CURL *handle = sn->handle; |
1237 CURL *handle = sn->handle; |
| 1238 curl_easy_setopt(handle, CURLOPT_CUSTOMREQUEST, method); |
1238 curl_easy_setopt(handle, CURLOPT_CUSTOMREQUEST, method); |
| 1239 curl_easy_setopt(handle, CURLOPT_UPLOAD, 0L); |
1239 curl_easy_setopt(handle, CURLOPT_UPLOAD, 0L); |
| 1240 |
1240 |
| 1241 curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, dummy_write); |
1241 curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, dummy_write); |