38 |
38 |
39 #include <ucx/utils.h> |
39 #include <ucx/utils.h> |
40 |
40 |
41 #define xstreq(a,b) xmlStrEqual(BAD_CAST a, BAD_CAST b) |
41 #define xstreq(a,b) xmlStrEqual(BAD_CAST a, BAD_CAST b) |
42 |
42 |
|
43 |
|
44 int dav_buffer_seek(UcxBuffer *b, curl_off_t offset, int origin) { |
|
45 return ucx_buffer_seek(b, offset, origin) == 0 ? 0:CURL_SEEKFUNC_CANTSEEK; |
|
46 } |
|
47 |
43 /* ----------------------------- PROPFIND ----------------------------- */ |
48 /* ----------------------------- PROPFIND ----------------------------- */ |
44 |
49 |
45 CURLcode do_propfind_request( |
50 CURLcode do_propfind_request( |
46 DavSession *sn, |
51 DavSession *sn, |
47 UcxBuffer *request, |
52 UcxBuffer *request, |
58 struct curl_slist *headers = NULL; |
63 struct curl_slist *headers = NULL; |
59 CURLcode ret = 0; |
64 CURLcode ret = 0; |
60 |
65 |
61 curl_easy_setopt(handle, CURLOPT_UPLOAD, 1); |
66 curl_easy_setopt(handle, CURLOPT_UPLOAD, 1); |
62 curl_easy_setopt(handle, CURLOPT_READFUNCTION, ucx_buffer_read); |
67 curl_easy_setopt(handle, CURLOPT_READFUNCTION, ucx_buffer_read); |
|
68 curl_easy_setopt(handle, CURLOPT_SEEKFUNCTION, dav_buffer_seek); |
63 curl_easy_setopt(handle, CURLOPT_READDATA, request); |
69 curl_easy_setopt(handle, CURLOPT_READDATA, request); |
64 curl_easy_setopt(handle, CURLOPT_INFILESIZE, request->size); |
70 curl_easy_setopt(handle, CURLOPT_INFILESIZE, request->size); |
65 |
71 |
66 curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, ucx_buffer_write); |
72 curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, ucx_buffer_write); |
67 curl_easy_setopt(handle, CURLOPT_WRITEDATA, response); |
73 curl_easy_setopt(handle, CURLOPT_WRITEDATA, response); |
729 } |
735 } |
730 curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers); |
736 curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers); |
731 |
737 |
732 curl_easy_setopt(handle, CURLOPT_UPLOAD, 1); |
738 curl_easy_setopt(handle, CURLOPT_UPLOAD, 1); |
733 curl_easy_setopt(handle, CURLOPT_READFUNCTION, ucx_buffer_read); |
739 curl_easy_setopt(handle, CURLOPT_READFUNCTION, ucx_buffer_read); |
|
740 curl_easy_setopt(handle, CURLOPT_SEEKFUNCTION, dav_buffer_seek); |
734 curl_easy_setopt(handle, CURLOPT_READDATA, request); |
741 curl_easy_setopt(handle, CURLOPT_READDATA, request); |
735 curl_easy_setopt(handle, CURLOPT_INFILESIZE, request->size); |
742 curl_easy_setopt(handle, CURLOPT_INFILESIZE, request->size); |
736 |
743 |
737 curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, ucx_buffer_write); |
744 curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, ucx_buffer_write); |
738 curl_easy_setopt(handle, CURLOPT_WRITEDATA, response); |
745 curl_easy_setopt(handle, CURLOPT_WRITEDATA, response); |
917 static size_t dummy_write(void *buf, size_t s, size_t n, void *data) { |
924 static size_t dummy_write(void *buf, size_t s, size_t n, void *data) { |
918 //fwrite(buf, s, n, stdout); |
925 //fwrite(buf, s, n, stdout); |
919 return s*n; |
926 return s*n; |
920 } |
927 } |
921 |
928 |
922 CURLcode do_put_request(DavSession *sn, char *lock, DavBool create, void *data, dav_read_func read_func, size_t length) { |
929 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) { |
923 CURL *handle = sn->handle; |
930 CURL *handle = sn->handle; |
924 curl_easy_setopt(handle, CURLOPT_CUSTOMREQUEST, NULL); |
931 curl_easy_setopt(handle, CURLOPT_CUSTOMREQUEST, NULL); |
925 curl_easy_setopt(handle, CURLOPT_UPLOAD, 1L); |
932 curl_easy_setopt(handle, CURLOPT_UPLOAD, 1L); |
926 |
933 |
927 // clear headers |
934 // clear headers |
957 } else { |
964 } else { |
958 curl_easy_setopt(handle, CURLOPT_INFILESIZE_LARGE, (curl_off_t)length); |
965 curl_easy_setopt(handle, CURLOPT_INFILESIZE_LARGE, (curl_off_t)length); |
959 } |
966 } |
960 |
967 |
961 curl_easy_setopt(handle, CURLOPT_READFUNCTION, read_func); |
968 curl_easy_setopt(handle, CURLOPT_READFUNCTION, read_func); |
|
969 curl_easy_setopt(handle, CURLOPT_SEEKFUNCTION, seek_func); |
962 curl_easy_setopt(handle, CURLOPT_READDATA, data); |
970 curl_easy_setopt(handle, CURLOPT_READDATA, data); |
963 |
971 |
964 curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, dummy_write); |
972 curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, dummy_write); |
965 curl_easy_setopt(handle, CURLOPT_WRITEDATA, NULL); |
973 curl_easy_setopt(handle, CURLOPT_WRITEDATA, NULL); |
966 |
974 |
1186 } |
1194 } |
1187 curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers); |
1195 curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers); |
1188 |
1196 |
1189 curl_easy_setopt(handle, CURLOPT_UPLOAD, 1); |
1197 curl_easy_setopt(handle, CURLOPT_UPLOAD, 1); |
1190 curl_easy_setopt(handle, CURLOPT_READFUNCTION, ucx_buffer_read); |
1198 curl_easy_setopt(handle, CURLOPT_READFUNCTION, ucx_buffer_read); |
|
1199 curl_easy_setopt(handle, CURLOPT_SEEKFUNCTION, dav_buffer_seek); |
1191 curl_easy_setopt(handle, CURLOPT_READDATA, request); |
1200 curl_easy_setopt(handle, CURLOPT_READDATA, request); |
1192 curl_easy_setopt(handle, CURLOPT_INFILESIZE, request->size); |
1201 curl_easy_setopt(handle, CURLOPT_INFILESIZE, request->size); |
1193 |
1202 |
1194 curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, ucx_buffer_write); |
1203 curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, ucx_buffer_write); |
1195 curl_easy_setopt(handle, CURLOPT_WRITEDATA, response); |
1204 curl_easy_setopt(handle, CURLOPT_WRITEDATA, response); |
1254 CURL *handle = sn->handle; |
1263 CURL *handle = sn->handle; |
1255 curl_easy_setopt(handle, CURLOPT_CUSTOMREQUEST, "REPORT"); |
1264 curl_easy_setopt(handle, CURLOPT_CUSTOMREQUEST, "REPORT"); |
1256 |
1265 |
1257 curl_easy_setopt(handle, CURLOPT_UPLOAD, 1); |
1266 curl_easy_setopt(handle, CURLOPT_UPLOAD, 1); |
1258 curl_easy_setopt(handle, CURLOPT_READFUNCTION, ucx_buffer_read); |
1267 curl_easy_setopt(handle, CURLOPT_READFUNCTION, ucx_buffer_read); |
|
1268 curl_easy_setopt(handle, CURLOPT_SEEKFUNCTION, dav_buffer_seek); |
1259 curl_easy_setopt(handle, CURLOPT_READDATA, request); |
1269 curl_easy_setopt(handle, CURLOPT_READDATA, request); |
1260 curl_easy_setopt(handle, CURLOPT_INFILESIZE, request->size); |
1270 curl_easy_setopt(handle, CURLOPT_INFILESIZE, request->size); |
1261 |
1271 |
1262 curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, ucx_buffer_write); |
1272 curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, ucx_buffer_write); |
1263 curl_easy_setopt(handle, CURLOPT_WRITEDATA, response); |
1273 curl_easy_setopt(handle, CURLOPT_WRITEDATA, response); |