--- a/libidav/versioning.c Sun Apr 16 14:12:24 2023 +0200 +++ b/libidav/versioning.c Fri Apr 21 21:25:32 2023 +0200 @@ -74,32 +74,34 @@ DavSession *sn = res->session; util_set_url(sn, dav_resource_get_href(res)); - UcxList *proplist = NULL; + CxList *proplist = NULL; if(properties) { - proplist = parse_properties_string(sn->context, sstr(properties)); + proplist = parse_properties_string(sn->context, cx_str(properties)); + + // check if the list already contains a D:version-name property + int add_vname = 1; + CxIterator i = cxListIterator(proplist); + cx_foreach(DavProperty *, p, i) { + if(!strcmp(p->ns->name, "DAV:") && !strcmp(p->name, "version-name")) { + add_vname = 0; + break; + } + } + if(add_vname) { + // we need at least the D:version-name prop + DavProperty p; + p.ns = dav_get_namespace(sn->context, "D"); + p.name = strdup("version-name"); + p.value = NULL; + cxListInsert(proplist, 0, &p); + } } - // check if the list already contains a D:version-name property - int add_vname = 1; - UCX_FOREACH(elm, proplist) { - DavProperty *p = elm->data; - if(!strcmp(p->ns->name, "DAV:") && !strcmp(p->name, "version-name")) { - add_vname = 0; - break; - } - } - if(add_vname) { - // we need at least the D:version-name prop - DavProperty *p = malloc(sizeof(DavProperty)); - p->ns = dav_get_namespace(sn->context, "D"); - p->name = strdup("version-name"); - p->value = NULL; - proplist = ucx_list_prepend(proplist, p); - } + // create a version-tree request, which is almost the same as propfind - UcxBuffer *rqbuf = create_propfind_request(sn, proplist, "version-tree", 1); - UcxBuffer *rpbuf = ucx_buffer_new(NULL, 4096, UCX_BUFFER_AUTOEXTEND); + CxBuffer *rqbuf = create_propfind_request(sn, proplist, "version-tree", 1); + CxBuffer *rpbuf = cxBufferCreate(NULL, 4096, cxDefaultAllocator, CX_BUFFER_FREE_CONTENTS|CX_BUFFER_AUTO_EXTEND); // do the request CURLcode ret = do_report_request(sn, rqbuf, rpbuf); @@ -151,14 +153,14 @@ } // cleanup - while(proplist) { - DavProperty *p = proplist->data; - free(p->name); - free(p); - UcxList *next = proplist->next; - free(proplist); - proplist = next; + if(proplist) { + CxIterator i = cxListIterator(proplist); + cx_foreach(DavProperty*, p, i) { + free(p->name); + } + cxListDestroy(proplist); } + if(error && versions) { DavResource *cur = versions; while(cur) {