src/server/webdav/webdav.c

changeset 91
fac51f87def0
parent 88
73b3485e96f1
child 94
6b15a094d996
equal deleted inserted replaced
90:279f343bbf6c 91:fac51f87def0
29 #include <stdio.h> 29 #include <stdio.h>
30 #include <stdlib.h> 30 #include <stdlib.h>
31 #include <string.h> 31 #include <string.h>
32 32
33 #include "webdav.h" 33 #include "webdav.h"
34 #include "../ucx/string.h" 34 #include <ucx/list.h>
35 #include <ucx/string.h>
35 #include "../util/pool.h" 36 #include "../util/pool.h"
36 #include "../util/pblock.h" 37 #include "../util/pblock.h"
37 #include "../util/date.h" 38 #include "../util/date.h"
38 #include "../util/util.h" 39 #include "../util/util.h"
39 40
539 PropfindRequest *davrq, 540 PropfindRequest *davrq,
540 DavProperty *prop, 541 DavProperty *prop,
541 int error) 542 int error)
542 { 543 {
543 // TODO: different errors 544 // TODO: different errors
544 davrq->notFoundProps = ucx_dlist_append(davrq->notFoundProps, prop); 545 davrq->notFoundProps = ucx_list_append(davrq->notFoundProps, prop);
545 } 546 }
546 547
547 548
548 549
549 550
710 711
711 /* XmlElement */ 712 /* XmlElement */
712 713
713 void xmlelm_add_child(XmlElement *parent, XmlElement *child) { 714 void xmlelm_add_child(XmlElement *parent, XmlElement *child) {
714 if(parent->ctlen == 0) { 715 if(parent->ctlen == 0) {
715 parent->content = ucx_dlist_append(parent->content, child); 716 parent->content = ucx_list_append(parent->content, child);
716 } 717 }
717 } 718 }
718 719
719 void xmlelm_write(XmlElement *elm, Buffer *out, int wv) { 720 void xmlelm_write(XmlElement *elm, Buffer *out, int wv) {
720 sbuf_append(out, sstrn("<", 1)); 721 sbuf_append(out, sstrn("<", 1));
726 if(elm->ctlen == 0) { 727 if(elm->ctlen == 0) {
727 if(elm->content == NULL) { 728 if(elm->content == NULL) {
728 sbuf_append(out, sstrn(" />", 3)); 729 sbuf_append(out, sstrn(" />", 3));
729 } else { 730 } else {
730 sbuf_append(out, sstrn(">", 1)); 731 sbuf_append(out, sstrn(">", 1));
731 DAV_FOREACH(pr, (UcxDlist*)elm->content) { 732 DAV_FOREACH(pr, (UcxList*)elm->content) {
732 xmlelm_write((XmlElement*)pr->data, out, 1); 733 xmlelm_write((XmlElement*)pr->data, out, 1);
733 } 734 }
734 sbuf_append(out, sstrn("</", 2)); 735 sbuf_append(out, sstrn("</", 2));
735 sbuf_append(out, sstrn(elm->xmlns->prefix, elm->xmlns->prelen)); 736 sbuf_append(out, sstrn(elm->xmlns->prefix, elm->xmlns->prelen));
736 sbuf_append(out, sstrn(":", 1)); 737 sbuf_append(out, sstrn(":", 1));
762 return propstat; 763 return propstat;
763 } 764 }
764 765
765 void propstat_add(Propstat *propstat, int status, XmlElement *prop) { 766 void propstat_add(Propstat *propstat, int status, XmlElement *prop) {
766 if(status == 200) { 767 if(status == 200) {
767 propstat->okprop = ucx_dlist_append(propstat->okprop, prop); 768 propstat->okprop = ucx_list_append(propstat->okprop, prop);
768 } else { 769 } else {
769 UcxKey key; 770 UcxKey key;
770 key.data = &status; 771 key.data = &status;
771 key.len = sizeof(int); 772 key.len = sizeof(int);
772 773
773 UcxDlist *list = ucx_map_get(propstat->map, key); 774 UcxList *list = ucx_map_get(propstat->map, key);
774 list = ucx_dlist_append(list, prop); 775 list = ucx_list_append(list, prop);
775 776
776 ucx_map_put(propstat->map, key, list); 777 ucx_map_put(propstat->map, key, list);
777 } 778 }
778 } 779 }
779 780
788 sbuf_puts(out, "\n</D:prop>\n<D:status>HTTP/1.1 200 OK</D:status>\n"); 789 sbuf_puts(out, "\n</D:prop>\n<D:status>HTTP/1.1 200 OK</D:status>\n");
789 sbuf_puts(out, "</D:propstat>\n"); 790 sbuf_puts(out, "</D:propstat>\n");
790 } 791 }
791 792
792 UcxMapIterator iter = ucx_map_iterator(propstat->map); 793 UcxMapIterator iter = ucx_map_iterator(propstat->map);
793 UcxDlist *proplist; 794 UcxList *proplist;
794 UCX_MAP_FOREACH(key, proplist, iter) { 795 UCX_MAP_FOREACH(key, proplist, iter) {
795 if(proplist) { 796 if(proplist) {
796 sbuf_puts(out, "<D:propstat>\n<D:prop>\n"); 797 sbuf_puts(out, "<D:propstat>\n<D:prop>\n");
797 798
798 DAV_FOREACH(prop, proplist) { 799 DAV_FOREACH(prop, proplist) {

mercurial