237 resource->path); |
237 resource->path); |
238 } |
238 } |
239 return resource->href; |
239 return resource->href; |
240 } |
240 } |
241 |
241 |
242 void resource_add_property(DavResource *res, char *ns, char *name, xmlNode *val) { |
242 void resource_add_property(DavResource *res, const char *ns, const char *name, xmlNode *val) { |
243 if(!val) { |
243 if(!val) { |
244 return; |
244 return; |
245 } |
245 } |
246 |
246 |
247 UcxKey key = dav_property_key(ns, name); |
247 sstr_t key = dav_property_key(ns, name); |
248 DavXmlNode *v = dav_convert_xml(res->session, val); |
248 DavXmlNode *v = dav_convert_xml(res->session, val); |
249 ucx_map_put(((DavResourceData*)res->data)->properties, key, v); |
249 ucx_map_sstr_put(((DavResourceData*)res->data)->properties, key, v); |
250 free(key.data); |
250 free(key.ptr); |
251 } |
251 } |
252 |
252 |
253 void resource_add_string_property(DavResource *res, char *ns, char *name, char *val) { |
253 void resource_add_string_property(DavResource *res, char *ns, char *name, char *val) { |
254 if(!val) { |
254 if(!val) { |
255 return; |
255 return; |
256 } |
256 } |
257 |
257 |
258 UcxKey key = dav_property_key(ns, name); |
258 sstr_t key = dav_property_key(ns, name); |
259 DavXmlNode *v = dav_text_node(res->session, val); |
259 DavXmlNode *v = dav_text_node(res->session, val); |
260 ucx_map_put(((DavResourceData*)res->data)->properties, key, v); |
260 ucx_map_sstr_put(((DavResourceData*)res->data)->properties, key, v); |
261 free(key.data); |
261 free(key.ptr); |
262 } |
262 } |
263 |
263 |
264 DavXmlNode* resource_get_property(DavResource *res, char *ns, char *name) { |
264 DavXmlNode* resource_get_property(DavResource *res, const char *ns, const char *name) { |
265 UcxKey key = dav_property_key(ns, name); |
265 sstr_t keystr = dav_property_key(ns, name); |
|
266 UcxKey key = ucx_key(keystr.ptr, keystr.length); |
266 DavXmlNode *property = resource_get_property_k(res, key); |
267 DavXmlNode *property = resource_get_property_k(res, key); |
267 free(key.data); |
268 free(keystr.ptr); |
268 return property; |
269 return property; |
269 } |
270 } |
270 |
271 |
271 DavXmlNode* resource_get_property_k(DavResource *res, UcxKey key) { |
272 DavXmlNode* resource_get_property_k(DavResource *res, UcxKey key) { |
272 DavResourceData *data = (DavResourceData*)res->data; |
273 DavResourceData *data = (DavResourceData*)res->data; |
273 return ucx_map_get(data->properties, key); |
274 return ucx_map_get(data->properties, key); |
274 } |
275 } |
275 |
276 |
276 UcxKey dav_property_key(char *ns, char *name) { |
277 sstr_t dav_property_key(const char *ns, const char *name) { |
277 return dav_property_key_a(ucx_default_allocator(), ns, name); |
278 return dav_property_key_a(ucx_default_allocator(), ns, name); |
278 } |
279 } |
279 |
280 |
280 UcxKey dav_property_key_a(UcxAllocator *a, char *ns, char *name) { |
281 sstr_t dav_property_key_a(UcxAllocator *a, const char *ns, const char *name) { |
281 sstr_t ns_str = sstr(ns); |
282 scstr_t ns_str = scstr(ns); |
282 sstr_t name_str = sstr(name); |
283 scstr_t name_str = scstr(name); |
283 |
284 |
284 sstr_t key; |
285 return sstrcat_a(a, 4, ns_str, S("\0"), name_str, S("\0")); |
285 key = sstrcat_a(a, 4, ns_str, S("\0"), name_str, S("\0")); |
|
286 |
|
287 return ucx_key(key.ptr, key.length); |
|
288 } |
286 } |
289 |
287 |
290 |
288 |
291 |
289 |
292 |
290 |