src/server/webdav/xattrbackend.c

changeset 579
e10457d74fe1
parent 490
d218607f5a7e
equal deleted inserted replaced
578:eb48f716b31c 579:e10457d74fe1
238 WebdavPropfindRequest *request, 238 WebdavPropfindRequest *request,
239 WebdavResource *resource, 239 WebdavResource *resource,
240 CxAllocator *a, 240 CxAllocator *a,
241 CxMap *pmap) 241 CxMap *pmap)
242 { 242 {
243 CxIterator i = cxMapIteratorValues(pmap); 243 CxMapIterator i = cxMapIteratorValues(pmap);
244 cx_foreach(WebdavProperty*, prop, i) { 244 cx_foreach(WebdavProperty*, prop, i) {
245 if(request->propname) { 245 if(request->propname) {
246 prop->vtype = WS_VALUE_NO_TYPE; 246 prop->vtype = WS_VALUE_NO_TYPE;
247 } 247 }
248 if(resource->addproperty(resource, prop, 200)) { 248 if(resource->addproperty(resource, prop, 200)) {
320 CxHashKey key = webdav_property_key_a( 320 CxHashKey key = webdav_property_key_a(
321 a, 321 a,
322 (const char*)prop->namespace->href, 322 (const char*)prop->namespace->href,
323 (const char*)prop->name); 323 (const char*)prop->name);
324 if(!key.data) { 324 if(!key.data) {
325 cxMapDestroy(pmap); 325 cxMapFree(pmap);
326 return 1; 326 return 1;
327 } 327 }
328 void *rmprop = cxMapRemoveAndGet(pmap, key); 328 void *rmprop = NULL;
329 cxMapRemoveAndGet(pmap, key, &rmprop);
329 cxFree(a, (void*)key.data); 330 cxFree(a, (void*)key.data);
330 331
331 // TODO: free rmprop 332 // TODO: free rmprop
332 333
333 if(rmprop) { 334 if(rmprop) {
343 log_ereport(LOG_WARN, "webdav_xattr_proppatch_do: property %s has missing namespace infos", prop->name); 344 log_ereport(LOG_WARN, "webdav_xattr_proppatch_do: property %s has missing namespace infos", prop->name);
344 continue; 345 continue;
345 } 346 }
346 347
347 if(webdav_xattr_put_prop(pmap, prop)) { 348 if(webdav_xattr_put_prop(pmap, prop)) {
348 cxMapDestroy(pmap); 349 cxMapFree(pmap);
349 return 1; 350 return 1;
350 } 351 }
351 352
352 webdav_plist_iterator_remove_current(&i); 353 webdav_plist_iterator_remove_current(&i);
353 } 354 }
504 return 0; 505 return 0;
505 } 506 }
506 507
507 int webdav_xattr_put_prop(CxMap *pmap, WebdavProperty *prop) { 508 int webdav_xattr_put_prop(CxMap *pmap, WebdavProperty *prop) {
508 CxHashKey key = webdav_property_key_a( 509 CxHashKey key = webdav_property_key_a(
509 pmap->allocator, 510 pmap->collection.allocator,
510 (const char*)prop->namespace->href, 511 (const char*)prop->namespace->href,
511 (const char*)prop->name); 512 (const char*)prop->name);
512 if(!key.data) { 513 if(!key.data) {
513 return 1; 514 return 1;
514 } 515 }
515 int ret = cxMapPut(pmap, key, prop); 516 int ret = cxMapPut(pmap, key, prop);
516 cxFree(pmap->allocator, (void*)key.data); 517 cxFree(pmap->collection.allocator, (void*)key.data);
517 return ret; 518 return ret;
518 } 519 }
519 520
520 CxMap* webdav_xattr_parse_data(CxAllocator *a, const char *data, size_t len, const char *path) { 521 CxMap* webdav_xattr_parse_data(CxAllocator *a, const char *data, size_t len, const char *path) {
521 CxMap *pmap = cxHashMapCreate(a, CX_STORE_POINTERS, 32); 522 CxMap *pmap = cxHashMapCreate(a, CX_STORE_POINTERS, 32);
696 } 697 }
697 } 698 }
698 699
699 if(error) { 700 if(error) {
700 // TODO: free pmap content 701 // TODO: free pmap content
701 cxMapDestroy(pmap); 702 cxMapFree(pmap);
702 pmap = NULL; 703 pmap = NULL;
703 } 704 }
704 705
705 return pmap; 706 return pmap;
706 } 707 }
711 CxBuffer buf; 712 CxBuffer buf;
712 if(cxBufferInit(&buf, NULL, 8192, a, CX_BUFFER_AUTO_EXTEND)) { 713 if(cxBufferInit(&buf, NULL, 8192, a, CX_BUFFER_AUTO_EXTEND)) {
713 return (cxmutstr){NULL,0}; 714 return (cxmutstr){NULL,0};
714 } 715 }
715 716
716 CxIterator i = cxMapIteratorValues(pmap); 717 CxMapIterator i = cxMapIteratorValues(pmap);
717 cx_foreach(WebdavProperty*, prop, i) { 718 cx_foreach(WebdavProperty*, prop, i) {
718 WSXmlData *property_value = NULL; 719 WSXmlData *property_value = NULL;
719 if(prop->vtype == WS_VALUE_XML_NODE) { 720 if(prop->vtype == WS_VALUE_XML_NODE) {
720 property_value = wsxml_node2data(pool, prop->value.node); 721 property_value = wsxml_node2data(pool, prop->value.node);
721 } else if(prop->vtype == WS_VALUE_XML_DATA) { 722 } else if(prop->vtype == WS_VALUE_XML_DATA) {

mercurial