libidav/utils.c

branch
dav-2
changeset 891
4d58cbcc9efa
parent 886
da79af4baec8
--- a/libidav/utils.c	Sun Dec 07 20:16:59 2025 +0100
+++ b/libidav/utils.c	Fri Dec 19 17:53:18 2025 +0100
@@ -521,7 +521,7 @@
 char* util_path_normalize(const char *path) {
     size_t len = strlen(path);
     CxBuffer buf;
-    cxBufferInit(&buf, NULL, len+1, cxDefaultAllocator, CX_BUFFER_FREE_CONTENTS|CX_BUFFER_AUTO_EXTEND);
+    cxBufferInit(&buf, cxDefaultAllocator, NULL, len+1, CX_BUFFER_FREE_CONTENTS|CX_BUFFER_AUTO_EXTEND);
     
     if(path[0] == '/') {
         cxBufferPut(&buf, '/');
@@ -541,7 +541,7 @@
             
             if(seg_len > 0) {
                 cxstring seg = cx_strn(seg_ptr, seg_len);
-                if(!cx_strcmp(seg, CX_STR(".."))) {
+                if(!cx_strcmp(seg, cx_str(".."))) {
                     for(int j=buf.pos;j>=0;j--) {
                         char t = j < buf.pos ? buf.space[j] : 0;
                         if(IS_PATH_SEPARATOR(t) || j == 0) {
@@ -552,7 +552,7 @@
                             break;
                         }
                     }
-                } else if(!cx_strcmp(seg, CX_STR("."))) {
+                } else if(!cx_strcmp(seg, cx_str("."))) {
                     // ignore
                 } else {
                     if(add_separator) {
@@ -615,13 +615,13 @@
             }
         }
         
-        cxBufferInit(&out, NULL, dircount*3+path_len-last_dir, cxDefaultAllocator, CX_BUFFER_FREE_CONTENTS|CX_BUFFER_AUTO_EXTEND);
+        cxBufferInit(&out, cxDefaultAllocator, NULL, dircount*3+path_len-last_dir, CX_BUFFER_FREE_CONTENTS|CX_BUFFER_AUTO_EXTEND);
         
         for(size_t i=0;i<dircount;i++) {
             cxBufferPutString(&out, "../");
         }
     } else {
-        cxBufferInit(&out, NULL, path_len - last_dir, cxDefaultAllocator, CX_BUFFER_FREE_CONTENTS|CX_BUFFER_AUTO_EXTEND);
+        cxBufferInit(&out, cxDefaultAllocator, NULL, path_len - last_dir, CX_BUFFER_FREE_CONTENTS|CX_BUFFER_AUTO_EXTEND);
     }
     
     cxBufferPutString(&out, abspath + last_dir + 1);
@@ -719,7 +719,7 @@
     if(p) {
         path = cx_str((char*)p);
     } else {
-        path = CX_STR("");
+        path = cx_str("");
     }
     
     return util_concat_path_s(base, path).ptr;
@@ -727,7 +727,7 @@
 
 cxmutstr util_concat_path_s(cxstring base, cxstring path) {
     if(!path.ptr) {
-        path = CX_STR("");
+        path = cx_str("");
     }
     
     int add_separator = 0;
@@ -743,7 +743,7 @@
     
     cxmutstr url;
     if(add_separator) {
-        url = cx_strcat(3, base, CX_STR("/"), path);
+        url = cx_strcat(3, base, cx_str("/"), path);
     } else {
         url = cx_strcat(2, base, path);
     }
@@ -753,7 +753,7 @@
 
 cxmutstr util_concat_path_ext(cxstring base, cxstring path, char separator) {
     if(!path.ptr) {
-        path = CX_STR("");
+        path = cx_str("");
     }
 
     int add_separator = 0;
@@ -809,7 +809,7 @@
     }
     
     CxBuffer url;
-    cxBufferInit(&url, NULL, 256, cxDefaultAllocator, CX_BUFFER_FREE_CONTENTS|CX_BUFFER_AUTO_EXTEND);
+    cxBufferInit(&url, cxDefaultAllocator, NULL, 256, CX_BUFFER_FREE_CONTENTS|CX_BUFFER_AUTO_EXTEND);
     
     // add base url
     cxBufferWrite(sn->base_url, 1, strlen(sn->base_url), &url);
@@ -818,7 +818,7 @@
     
     cxstring p = cx_strn(path, pathlen);
     
-    CxStrtokCtx tkctx = cx_strtok(p, CX_STR("/"), INT_MAX);
+    CxStrtokCtx tkctx = cx_strtok(p, cx_str("/"), INT_MAX);
     cxstring node;
     while(cx_strtok_next(&tkctx, &node)) {
         if(node.length > 0) {
@@ -1155,7 +1155,7 @@
     unsigned char *str = malloc(25);
     str[24] = '\0';
     
-    cxstring t = CX_STR(
+    cxstring t = cx_str(
             "01234567890"
             "abcdefghijklmnopqrstuvwxyz"
             "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
@@ -1224,7 +1224,7 @@
 
 cxmutstr util_readline(FILE *stream) {
     CxBuffer buf;
-    cxBufferInit(&buf, NULL, 128, cxDefaultAllocator, CX_BUFFER_FREE_CONTENTS|CX_BUFFER_AUTO_EXTEND);
+    cxBufferInit(&buf, cxDefaultAllocator, NULL, 128, CX_BUFFER_FREE_CONTENTS|CX_BUFFER_AUTO_EXTEND);
     
     int c;
     while((c = fgetc(stream)) != EOF) {
@@ -1260,7 +1260,7 @@
     
     // read password input
     CxBuffer buf;
-    cxBufferInit(&buf, NULL, 128, cxDefaultAllocator, CX_BUFFER_FREE_CONTENTS|CX_BUFFER_AUTO_EXTEND);
+    cxBufferInit(&buf, cxDefaultAllocator, NULL, 128, CX_BUFFER_FREE_CONTENTS|CX_BUFFER_AUTO_EXTEND);
     int c = 0;
     while((c = getpasswordchar()) != EOF) {
         if(c == '\n' || c == '\r') {
@@ -1335,7 +1335,7 @@
 char* util_hexstr(const unsigned char *data, size_t len) {
     size_t buflen = 2*len + 4;
     CxBuffer buf;
-    cxBufferInit(&buf, NULL, buflen + 1, cxDefaultAllocator, CX_BUFFER_FREE_CONTENTS|CX_BUFFER_AUTO_EXTEND);
+    cxBufferInit(&buf, cxDefaultAllocator, NULL, buflen + 1, CX_BUFFER_FREE_CONTENTS|CX_BUFFER_AUTO_EXTEND);
     for(int i=0;i<len;i++) {
         cx_bprintf(&buf, "%02x", data[i]);
     }

mercurial