| 283 |
283 |
| 284 if(!xmlText) { |
284 if(!xmlText) { |
| 285 return NULL; |
285 return NULL; |
| 286 } |
286 } |
| 287 |
287 |
| 288 CxBuffer *buf = cxBufferCreate(NULL, textLen, cxDefaultAllocator, CX_BUFFER_AUTO_EXTEND|CX_BUFFER_FREE_CONTENTS); |
288 CxBuffer *buf = cxBufferCreate(cxDefaultAllocator, NULL, textLen, CX_BUFFER_AUTO_EXTEND|CX_BUFFER_FREE_CONTENTS); |
| 289 cxBufferWrite(xmlText, 1, textLen, buf); |
289 cxBufferWrite(xmlText, 1, textLen, buf); |
| 290 xmlFree(xmlText); |
290 xmlFree(xmlText); |
| 291 return buf; |
291 return buf; |
| 292 } |
292 } |
| 293 |
293 |
| 938 DavCfgRepository* dav_config_url2repo_s(DavConfig *config, cxstring url, cxmutstr *path) { |
938 DavCfgRepository* dav_config_url2repo_s(DavConfig *config, cxstring url, cxmutstr *path) { |
| 939 path->ptr = NULL; |
939 path->ptr = NULL; |
| 940 path->length = 0; |
940 path->length = 0; |
| 941 |
941 |
| 942 int s; |
942 int s; |
| 943 if(cx_strprefix(url, CX_STR("http://"))) { |
943 if(cx_strprefix(url, cx_str("http://"))) { |
| 944 s = 7; |
944 s = 7; |
| 945 } else if(cx_strprefix(url, CX_STR("https://"))) { |
945 } else if(cx_strprefix(url, cx_str("https://"))) { |
| 946 s = 8; |
946 s = 8; |
| 947 } else { |
947 } else { |
| 948 s = 1; |
948 s = 1; |
| 949 } |
949 } |
| 950 |
950 |
| 961 *path = cx_strdup(p); |
961 *path = cx_strdup(p); |
| 962 } else { |
962 } else { |
| 963 // TODO: who is responsible for freeing this repository? |
963 // TODO: who is responsible for freeing this repository? |
| 964 // how can the callee know, if he has to call free()? |
964 // how can the callee know, if he has to call free()? |
| 965 repo = dav_repository_new(config); |
965 repo = dav_repository_new(config); |
| 966 repo->name.value = cx_strdup_a(config->mp->allocator, CX_STR("")); |
966 repo->name.value = cx_strdup_a(config->mp->allocator, cx_str("")); |
| 967 if(url.ptr[url.length-1] == '/') { |
967 if(url.ptr[url.length-1] == '/') { |
| 968 repo->url.value = cx_strdup_a(config->mp->allocator, url); |
968 repo->url.value = cx_strdup_a(config->mp->allocator, url); |
| 969 *path = cx_strdup(CX_STR("/")); |
969 *path = cx_strdup(cx_str("/")); |
| 970 } else if (cx_strchr(url, '/').length > 0) { |
970 } else if (cx_strchr(url, '/').length > 0) { |
| 971 // TODO: fix the following workaround after |
971 // TODO: fix the following workaround after |
| 972 // fixing the inconsistent behavior of util_url_*() |
972 // fixing the inconsistent behavior of util_url_*() |
| 973 cxstring repo_url = util_url_base_s(url); |
973 cxstring repo_url = util_url_base_s(url); |
| 974 repo->url.value = cx_strdup_a(config->mp->allocator, repo_url); |
974 repo->url.value = cx_strdup_a(config->mp->allocator, repo_url); |
| 975 *path = cx_strdup(util_url_path_s(url)); |
975 *path = cx_strdup(util_url_path_s(url)); |
| 976 } else { |
976 } else { |
| 977 repo->url.value = cx_strdup(url); |
977 repo->url.value = cx_strdup(url); |
| 978 *path = cx_strdup(CX_STR("/")); |
978 *path = cx_strdup(cx_str("/")); |
| 979 } |
979 } |
| 980 } |
980 } |
| 981 |
981 |
| 982 return repo; |
982 return repo; |
| 983 } |
983 } |