libidav/davqlexec.c

changeset 137
01cb9aabff05
parent 136
59058927b885
child 139
c6424aebcf5e
--- a/libidav/davqlexec.c	Thu Jul 09 15:00:16 2015 +0200
+++ b/libidav/davqlexec.c	Thu Jul 09 17:15:35 2015 +0200
@@ -200,7 +200,6 @@
 }
 
 static int reset_properties(DavSession *sn, DavResult *result, DavResource *res, UcxList *fields) {
-    //return 0;
     UcxMap *new_properties = ucx_map_new_a(sn->mp->allocator, 32);
     DavResourceData *data = (DavResourceData*)res->data;
     
@@ -288,9 +287,8 @@
     ucx_map_remove(data->properties, cn_key);
     ucx_map_remove(data->properties, ck_key);
     
-    //resource_free_properties(sn, data->properties);
+    resource_free_properties(sn, data->properties);
     data->properties = new_properties;
-    //printf("(%s) new properties: ", res->name, data->properties);
     
     free(cl_key.data);
     free(cd_key.data);
@@ -384,6 +382,9 @@
     // reuseable response buffer
     UcxBuffer *rpbuf = ucx_buffer_new(NULL, 4096, UCX_BUFFER_AUTOEXTEND);
     
+    result.result = selroot;
+    result.status = 0;
+    
     // do a propfind request for each resource on the stack
     while(stack) {
         DavQLRes *sr = stack->data; // get first element from the stack
@@ -394,11 +395,13 @@
         CURLcode ret = do_propfind_request(sn->handle, rqbuf, rpbuf);
         int http_status = 0;
         curl_easy_getinfo (sn->handle, CURLINFO_RESPONSE_CODE, &http_status);
+        //printf("rpbuf: %s %s\n%.*s\n\n", sr->resource->path, sr->resource->href, rpbuf->pos, rpbuf->space);
         
         if(ret == CURLE_OK && http_status == 207) {
             // propfind request successful, now parse the response
             char *url = "http://url/";
             PropfindParser *parser = create_propfind_parser(rpbuf, url);
+            // TODO: test if parser is null
             ResponseTag response;
             int r;
             while((r = get_propfind_response(parser, &response)) != 0) {
@@ -473,6 +476,7 @@
             
         } else  {
             dav_session_set_error(sn, ret, http_status);
+            result.result = NULL;
             result.status = -1;
             dav_resource_free_all(selroot);
             break;
@@ -483,9 +487,6 @@
     }
     
     ucx_mempool_destroy(mp);
-    
-    result.result = selroot;
-    result.status = 0;
     return result;
 }
 

mercurial