src/server/webdav/requestparser.c

branch
webdav
changeset 373
f78a585e1a2f
parent 239
d5031c30022c
child 415
d938228c382e
equal deleted inserted replaced
372:1d2538a1ba8f 373:f78a585e1a2f
33 #include <ucx/string.h> 33 #include <ucx/string.h>
34 #include <ucx/utils.h> 34 #include <ucx/utils.h>
35 #include <ucx/map.h> 35 #include <ucx/map.h>
36 36
37 #include "requestparser.h" 37 #include "requestparser.h"
38 #include "webdav.h"
38 39
39 #define xstreq(a, b) !strcmp((const char*)a, (const char*)b) 40 #define xstreq(a, b) !strcmp((const char*)a, (const char*)b)
40 41
41 void proplist_free(pool_handle_t *pool, WebdavPList *list) { 42 void proplist_free(pool_handle_t *pool, WebdavPList *list) {
42 while(list) { 43 while(list) {
55 memset(prop, 0, sizeof(WebdavProperty)); 56 memset(prop, 0, sizeof(WebdavProperty));
56 prop->lang = NULL; 57 prop->lang = NULL;
57 prop->name = (char*)name; 58 prop->name = (char*)name;
58 prop->namespace = ns; 59 prop->namespace = ns;
59 return prop; 60 return prop;
60 }
61
62 static UcxKey propkey(const char *ns, const char *name) {
63 UcxKey key;
64 sstr_t data = ucx_sprintf("%s\n%s", name, ns);
65 key.data = data.ptr;
66 key.len = data.length;
67 key.hash = ucx_hash(data.ptr, data.length);
68 return key;
69 } 61 }
70 62
71 static int parse_prop( 63 static int parse_prop(
72 Session *sn, 64 Session *sn,
73 xmlNode *node, 65 xmlNode *node,
86 78
87 const char* ns = (const char*)pnode->ns->href; 79 const char* ns = (const char*)pnode->ns->href;
88 const char* name = (const char*)pnode->name; 80 const char* name = (const char*)pnode->name;
89 81
90 // check for prop duplicates 82 // check for prop duplicates
91 UcxKey k = propkey((const char*)ns, (const char*)name); 83 UcxKey k = webdav_property_key((const char*)ns, (const char*)name);
92 if(!k.data) { 84 if(!k.data) {
93 *error = proppatch ? PROPPATCH_PARSER_OOM : PROPFIND_PARSER_OOM; 85 *error = proppatch ? PROPPATCH_PARSER_OOM : PROPFIND_PARSER_OOM;
94 return 1; 86 return 1;
95 } 87 }
96 void *c = ucx_map_get(propmap, k); 88 void *c = ucx_map_get(propmap, k);
117 } 109 }
118 } else if(proppatch) { 110 } else if(proppatch) {
119 *error = PROPPATCH_PARSER_DUPLICATE; 111 *error = PROPPATCH_PARSER_DUPLICATE;
120 } 112 }
121 113
122 free(k.data); 114 free((void*)k.data);
123 if(*error) { 115 if(*error) {
124 return 1; 116 return 1;
125 } 117 }
126 } 118 }
127 return 0; 119 return 0;

mercurial