src/server/webdav/webdav.c

branch
webdav
changeset 227
3c23855f7b46
parent 222
5f05e56cb8e2
child 230
ca50e1ebdc4d
equal deleted inserted replaced
226:49adcbd7d473 227:3c23855f7b46
458 } 458 }
459 } 459 }
460 return depth; 460 return depth;
461 } 461 }
462 462
463 int webdav_plist_add(
464 pool_handle_t *pool,
465 WebdavPList **begin,
466 WebdavPList **end,
467 WebdavProperty *prop)
468 {
469 WebdavPList *elm = pool_malloc(pool, sizeof(WebdavPList));
470 if(!elm) {
471 return 1;
472 }
473 elm->prev = *end;
474 elm->next = NULL;
475 elm->property = prop;
476
477 if(!*begin) {
478 *begin = elm;
479 *end = elm;
480 return 0;
481 }
482
483 (*end)->next = elm;
484 *end = elm;
485
486 return 0;
487 }
488
463 WebdavPList* webdav_plist_clone(pool_handle_t *pool, WebdavPList *list) { 489 WebdavPList* webdav_plist_clone(pool_handle_t *pool, WebdavPList *list) {
464 WebdavPList *new_list = NULL; // start of the new list 490 WebdavPList *new_list = NULL; // start of the new list
465 WebdavPList *new_list_end = NULL; // end of the new list 491 WebdavPList *new_list_end = NULL; // end of the new list
466 492
467 WebdavPList *elm = list; 493 WebdavPList *elm = list;
568 node->content = (xmlChar*)value; 594 node->content = (xmlChar*)value;
569 node->type = XML_TEXT_NODE; 595 node->type = XML_TEXT_NODE;
570 596
571 p->value.node = node; 597 p->value.node = node;
572 p->vtype = WS_VALUE_XML_NODE; 598 p->vtype = WS_VALUE_XML_NODE;
573 return 0;
574 }
575
576 int webdav_property_add_nsdef(
577 WebdavProperty *property,
578 pool_handle_t *pool,
579 const char *prefix,
580 const char *nsuri)
581 {
582 // because we're using a memory pool, we don't free in case stuff in
583 // case of an error (OOM) - stuff will be freed by destroyinig the pool
584
585 WebdavNSList *new_def = pool_malloc(pool, sizeof(WebdavNSList));
586 if(!new_def) {
587 return 1;
588 }
589 WSNamespace *new_ns = pool_malloc(pool, sizeof(WSNamespace));
590 if(!new_ns) {
591 return 1;
592 }
593 ZERO(new_ns, sizeof(WSNamespace));
594
595 new_ns->prefix = (xmlChar*)pool_strdup(pool, prefix);
596 new_ns->href = (xmlChar*)pool_strdup(pool, nsuri);
597 if(!new_ns->prefix || !new_ns->href) {
598 return 1;
599 }
600
601 new_def->namespace = new_ns;
602 new_def->prev = NULL;
603 new_def->next = NULL;
604
605 if(property->nsdef) {
606 property->nsdef->prev = new_def;
607 new_def->next = property->nsdef;
608 }
609 property->nsdef = new_def;
610
611 return 0; 599 return 0;
612 } 600 }
613 601
614 WebdavVFSProperties webdav_vfs_properties( 602 WebdavVFSProperties webdav_vfs_properties(
615 WebdavPropfindRequest *rq, 603 WebdavPropfindRequest *rq,

mercurial