fixed horrible bugs, davql hopefully just works now (without order by yet)

Thu, 09 Jul 2015 17:15:35 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Thu, 09 Jul 2015 17:15:35 +0200
changeset 137
01cb9aabff05
parent 136
59058927b885
child 138
6a3248e22d58

fixed horrible bugs, davql hopefully just works now (without order by yet)

libidav/davqlexec.c file | annotate | diff | comparison | revisions
libidav/methods.c file | annotate | diff | comparison | revisions
--- 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;
 }
 
--- a/libidav/methods.c	Thu Jul 09 15:00:16 2015 +0200
+++ b/libidav/methods.c	Thu Jul 09 17:15:35 2015 +0200
@@ -229,7 +229,7 @@
     if(!parser) {
         return NULL;
     }
-    parser->document = xmlReadMemory(response->space, response->size, url, NULL, 0);
+    parser->document = xmlReadMemory(response->space, response->pos, url, NULL, 0);
     parser->current = NULL;
     if(parser->document) {
         xmlNode *xml_root = xmlDocGetRootElement(parser->document);
@@ -432,7 +432,7 @@
         curl_free(uname);
     }
 
-    char *href = dav_session_strdup(sn, href);
+    char *href = dav_session_strdup(sn, response->href);
     DavResource *res = NULL;
     if(parent_path) {
         res = dav_resource_new_full(sn, parent_path, name, href);

mercurial