235 CURLcode ret = do_propfind_request(handle, rqbuf, rpbuf); |
235 CURLcode ret = do_propfind_request(handle, rqbuf, rpbuf); |
236 int status = 0; |
236 int status = 0; |
237 curl_easy_getinfo (handle, CURLINFO_RESPONSE_CODE, &status); |
237 curl_easy_getinfo (handle, CURLINFO_RESPONSE_CODE, &status); |
238 if(ret == CURLE_OK && status == 207) { |
238 if(ret == CURLE_OK && status == 207) { |
239 //printf("response\n%s\n", rpbuf->space); |
239 //printf("response\n%s\n", rpbuf->space); |
240 resource = parse_propfind_response(sn, NULL, rpbuf); |
240 resource = parse_propfind_response(sn, NULL, rpbuf, NULL, 0); |
241 sn->error = DAV_OK; |
241 sn->error = DAV_OK; |
242 } else { |
242 } else { |
243 session_set_error(sn, ret, status); |
243 session_set_error(sn, ret, status); |
244 } |
244 } |
245 return resource; |
245 return resource; |
246 } |
246 } |
247 |
247 |
248 DavResource* dav_propfind(DavSession *sn, DavResource *root, UcxBuffer *rqbuf, char *path) { |
248 DavResource* dav_propfind(DavSession *sn, DavResource *root, UcxBuffer *rqbuf, char *path, DavQOp *cond, size_t len) { |
249 char *url = util_concat_path(sn->base_url, path); |
249 char *url = util_concat_path(sn->base_url, path); |
250 CURL *handle = sn->handle; |
250 CURL *handle = sn->handle; |
251 curl_easy_setopt(handle, CURLOPT_URL, url); |
251 curl_easy_setopt(handle, CURLOPT_URL, url); |
252 free(url); |
252 free(url); |
253 |
253 |
256 CURLcode ret = do_propfind_request(handle, rqbuf, rpbuf); |
256 CURLcode ret = do_propfind_request(handle, rqbuf, rpbuf); |
257 int status = 0; |
257 int status = 0; |
258 curl_easy_getinfo (handle, CURLINFO_RESPONSE_CODE, &status); |
258 curl_easy_getinfo (handle, CURLINFO_RESPONSE_CODE, &status); |
259 if(ret == CURLE_OK && status == 207) { |
259 if(ret == CURLE_OK && status == 207) { |
260 //printf("response\n%s\n", rpbuf->space); |
260 //printf("response\n%s\n", rpbuf->space); |
261 resource = parse_propfind_response(sn, resource, rpbuf); |
261 resource = parse_propfind_response(sn, resource, rpbuf, cond, len); |
262 sn->error = DAV_OK; |
262 sn->error = DAV_OK; |
263 } else { |
263 } else { |
264 session_set_error(sn, ret, status); |
264 session_set_error(sn, ret, status); |
265 resource = NULL; |
265 resource = NULL; |
266 } |
266 } |
298 } |
298 } |
299 |
299 |
300 //fwrite(rqbuf->space, 1, rqbuf->size, stdout); |
300 //fwrite(rqbuf->space, 1, rqbuf->size, stdout); |
301 //printf("\n"); |
301 //printf("\n"); |
302 |
302 |
303 DavResource *resource = dav_propfind(sn, NULL, rqbuf, path); |
303 DavResource *resource = dav_propfind(sn, NULL, rqbuf, path, query->condition, query->condlen); |
304 free(path); |
304 free(path); |
305 int error = 0; |
305 int error = 0; |
306 if(resource && depth == -1) { |
306 if(resource && depth == -1) { |
307 UcxList *stack = NULL; // stack with davResource* elements |
307 UcxList *stack = NULL; // stack with davResource* elements |
308 stack = propfind_stack_push(stack, resource->children); |
308 stack = propfind_stack_push(stack, resource->children); |
309 while(stack) { |
309 while(stack) { |
310 DavResource *sr = stack->data; // get first element from the stack |
310 DavResource *sr = stack->data; // get first element from the stack |
311 stack = ucx_list_remove(stack, stack); // remove first element |
311 stack = ucx_list_remove(stack, stack); // remove first element |
312 // do propfind request for sr |
312 // do propfind request for sr |
313 sr = dav_propfind(sn, sr, rqbuf, sr->path); |
313 sr = dav_propfind(sn, sr, rqbuf, sr->path, query->condition, query->condlen); |
314 if(!sr) { |
314 if(!sr) { |
315 error = 1; |
315 error = 1; |
316 printf("subrequest failed\n"); |
316 printf("subrequest failed\n"); |
317 break; |
317 break; |
318 } |
318 } |
505 xmlNode *xml_root = xmlDocGetRootElement(doc); |
505 xmlNode *xml_root = xmlDocGetRootElement(doc); |
506 xmlNode *node = xml_root->children; |
506 xmlNode *node = xml_root->children; |
507 while(node) { |
507 while(node) { |
508 if(node->type == XML_ELEMENT_NODE) { |
508 if(node->type == XML_ELEMENT_NODE) { |
509 if(xstreq(node->name, "response")) { |
509 if(xstreq(node->name, "response")) { |
510 parse_response_tag(res, node); |
510 parse_response_tag(res, node, NULL, 0); |
511 } |
511 } |
512 } |
512 } |
513 node = node->next; |
513 node = node->next; |
514 } |
514 } |
515 |
515 |
796 xmlNode *xml_root = xmlDocGetRootElement(doc); |
796 xmlNode *xml_root = xmlDocGetRootElement(doc); |
797 xmlNode *node = xml_root->children; |
797 xmlNode *node = xml_root->children; |
798 while(node) { |
798 while(node) { |
799 if(node->type == XML_ELEMENT_NODE) { |
799 if(node->type == XML_ELEMENT_NODE) { |
800 if(xstreq(node->name, "response")) { |
800 if(xstreq(node->name, "response")) { |
801 parse_response_tag(res, node); |
801 parse_response_tag(res, node, NULL, 0); |
802 } |
802 } |
803 } |
803 } |
804 node = node->next; |
804 node = node->next; |
805 } |
805 } |
806 |
806 |