198 ucx_list_free(list); |
198 ucx_list_free(list); |
199 return reqbuf; |
199 return reqbuf; |
200 } |
200 } |
201 |
201 |
202 static int reset_properties(DavSession *sn, DavResult *result, DavResource *res, UcxList *fields) { |
202 static int reset_properties(DavSession *sn, DavResult *result, DavResource *res, UcxList *fields) { |
203 //return 0; |
|
204 UcxMap *new_properties = ucx_map_new_a(sn->mp->allocator, 32); |
203 UcxMap *new_properties = ucx_map_new_a(sn->mp->allocator, 32); |
205 DavResourceData *data = (DavResourceData*)res->data; |
204 DavResourceData *data = (DavResourceData*)res->data; |
206 |
205 |
207 // add basic properties |
206 // add basic properties |
208 char *value; |
207 char *value; |
286 ucx_map_remove(data->properties, ct_key); |
285 ucx_map_remove(data->properties, ct_key); |
287 ucx_map_remove(data->properties, rt_key); |
286 ucx_map_remove(data->properties, rt_key); |
288 ucx_map_remove(data->properties, cn_key); |
287 ucx_map_remove(data->properties, cn_key); |
289 ucx_map_remove(data->properties, ck_key); |
288 ucx_map_remove(data->properties, ck_key); |
290 |
289 |
291 //resource_free_properties(sn, data->properties); |
290 resource_free_properties(sn, data->properties); |
292 data->properties = new_properties; |
291 data->properties = new_properties; |
293 //printf("(%s) new properties: ", res->name, data->properties); |
|
294 |
292 |
295 free(cl_key.data); |
293 free(cl_key.data); |
296 free(cd_key.data); |
294 free(cd_key.data); |
297 free(lm_key.data); |
295 free(lm_key.data); |
298 free(ct_key.data); |
296 free(ct_key.data); |
382 stack = ucx_list_prepend(stack, r); |
380 stack = ucx_list_prepend(stack, r); |
383 |
381 |
384 // reuseable response buffer |
382 // reuseable response buffer |
385 UcxBuffer *rpbuf = ucx_buffer_new(NULL, 4096, UCX_BUFFER_AUTOEXTEND); |
383 UcxBuffer *rpbuf = ucx_buffer_new(NULL, 4096, UCX_BUFFER_AUTOEXTEND); |
386 |
384 |
|
385 result.result = selroot; |
|
386 result.status = 0; |
|
387 |
387 // do a propfind request for each resource on the stack |
388 // do a propfind request for each resource on the stack |
388 while(stack) { |
389 while(stack) { |
389 DavQLRes *sr = stack->data; // get first element from the stack |
390 DavQLRes *sr = stack->data; // get first element from the stack |
390 stack = ucx_list_remove(stack, stack); // remove first element |
391 stack = ucx_list_remove(stack, stack); // remove first element |
391 DavResource *root = sr->resource; |
392 DavResource *root = sr->resource; |
392 |
393 |
393 util_set_url(sn, dav_resource_get_href(sr->resource)); |
394 util_set_url(sn, dav_resource_get_href(sr->resource)); |
394 CURLcode ret = do_propfind_request(sn->handle, rqbuf, rpbuf); |
395 CURLcode ret = do_propfind_request(sn->handle, rqbuf, rpbuf); |
395 int http_status = 0; |
396 int http_status = 0; |
396 curl_easy_getinfo (sn->handle, CURLINFO_RESPONSE_CODE, &http_status); |
397 curl_easy_getinfo (sn->handle, CURLINFO_RESPONSE_CODE, &http_status); |
|
398 //printf("rpbuf: %s %s\n%.*s\n\n", sr->resource->path, sr->resource->href, rpbuf->pos, rpbuf->space); |
397 |
399 |
398 if(ret == CURLE_OK && http_status == 207) { |
400 if(ret == CURLE_OK && http_status == 207) { |
399 // propfind request successful, now parse the response |
401 // propfind request successful, now parse the response |
400 char *url = "http://url/"; |
402 char *url = "http://url/"; |
401 PropfindParser *parser = create_propfind_parser(rpbuf, url); |
403 PropfindParser *parser = create_propfind_parser(rpbuf, url); |
|
404 // TODO: test if parser is null |
402 ResponseTag response; |
405 ResponseTag response; |
403 int r; |
406 int r; |
404 while((r = get_propfind_response(parser, &response)) != 0) { |
407 while((r = get_propfind_response(parser, &response)) != 0) { |
405 if(r == -1) { |
408 if(r == -1) { |
406 // error |
409 // error |
471 } |
474 } |
472 } |
475 } |
473 |
476 |
474 } else { |
477 } else { |
475 dav_session_set_error(sn, ret, http_status); |
478 dav_session_set_error(sn, ret, http_status); |
|
479 result.result = NULL; |
476 result.status = -1; |
480 result.status = -1; |
477 dav_resource_free_all(selroot); |
481 dav_resource_free_all(selroot); |
478 break; |
482 break; |
479 } |
483 } |
480 |
484 |
481 // reset response buffer |
485 // reset response buffer |
482 ucx_buffer_seek(rpbuf, SEEK_SET, 0); |
486 ucx_buffer_seek(rpbuf, SEEK_SET, 0); |
483 } |
487 } |
484 |
488 |
485 ucx_mempool_destroy(mp); |
489 ucx_mempool_destroy(mp); |
486 |
|
487 result.result = selroot; |
|
488 result.status = 0; |
|
489 return result; |
490 return result; |
490 } |
491 } |
491 |
492 |
492 static int count_func_args(DavQLExpression *expr) { |
493 static int count_func_args(DavQLExpression *expr) { |
493 int count = 0; |
494 int count = 0; |