src/server/webdav/webdav.c

Thu, 15 Aug 2024 22:38:03 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Thu, 15 Aug 2024 22:38:03 +0200
changeset 549
b26bec196a2e
parent 490
d218607f5a7e
permissions
-rw-r--r--

fix http_stream_parse_chunk_header: check if the chunk starts with a digit

13
1fdbf4170ef4 Added webdav code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1 /*
1fdbf4170ef4 Added webdav code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
1fdbf4170ef4 Added webdav code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
3 *
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
4 * Copyright 2019 Olaf Wintermann. All rights reserved.
13
1fdbf4170ef4 Added webdav code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
5 *
1fdbf4170ef4 Added webdav code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
6 * Redistribution and use in source and binary forms, with or without
1fdbf4170ef4 Added webdav code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
7 * modification, are permitted provided that the following conditions are met:
1fdbf4170ef4 Added webdav code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
8 *
1fdbf4170ef4 Added webdav code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
9 * 1. Redistributions of source code must retain the above copyright
1fdbf4170ef4 Added webdav code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
10 * notice, this list of conditions and the following disclaimer.
1fdbf4170ef4 Added webdav code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
11 *
1fdbf4170ef4 Added webdav code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
12 * 2. Redistributions in binary form must reproduce the above copyright
1fdbf4170ef4 Added webdav code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
13 * notice, this list of conditions and the following disclaimer in the
1fdbf4170ef4 Added webdav code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
14 * documentation and/or other materials provided with the distribution.
1fdbf4170ef4 Added webdav code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
15 *
1fdbf4170ef4 Added webdav code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
1fdbf4170ef4 Added webdav code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1fdbf4170ef4 Added webdav code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1fdbf4170ef4 Added webdav code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
1fdbf4170ef4 Added webdav code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
1fdbf4170ef4 Added webdav code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
1fdbf4170ef4 Added webdav code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
1fdbf4170ef4 Added webdav code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
1fdbf4170ef4 Added webdav code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
1fdbf4170ef4 Added webdav code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
1fdbf4170ef4 Added webdav code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
26 * POSSIBILITY OF SUCH DAMAGE.
1fdbf4170ef4 Added webdav code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
27 */
1fdbf4170ef4 Added webdav code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
28
1fdbf4170ef4 Added webdav code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
29 #include <stdio.h>
1fdbf4170ef4 Added webdav code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
30 #include <stdlib.h>
1fdbf4170ef4 Added webdav code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
31 #include <string.h>
1fdbf4170ef4 Added webdav code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
32
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
33 #include <cx/buffer.h>
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
34 #include <cx/list.h>
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
35 #include <cx/linked_list.h>
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
36 #include <cx/hash_map.h>
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
37 #include <cx/printf.h>
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
38
13
1fdbf4170ef4 Added webdav code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
39 #include "webdav.h"
1fdbf4170ef4 Added webdav code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
40
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
41 #include "search.h"
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
42 #include "versioning.h"
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
43 #include "multistatus.h"
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
44 #include "requestparser.h"
217
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
45 #include "operation.h"
26
37ff8bf54b89 Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 24
diff changeset
46
476
477cbeec7b0b fix default webdav backend initialization
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 453
diff changeset
47 #include "xattrbackend.h"
477cbeec7b0b fix default webdav backend initialization
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 453
diff changeset
48
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
49 #include "../util/pblock.h"
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
50 #include "../util/util.h"
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
51 #include "../daemon/session.h"
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
52 #include "../daemon/http.h"
235
4990147c58d0 add handler for http expect header
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 234
diff changeset
53 #include "../daemon/protocol.h"
246
155bdef7fe7e add webdav op function for iterating directories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
54 #include "../daemon/vfs.h"
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
55
301
2bc514931612 add function for registering webdav backends
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
56 /*
2bc514931612 add function for registering webdav backends
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
57 * http method fptr mapping
2bc514931612 add function for registering webdav backends
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
58 * key: http method name (string)
2bc514931612 add function for registering webdav backends
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
59 * value: SAF fptr
2bc514931612 add function for registering webdav backends
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
60 */
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
61 static CxMap *method_handler_map;
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
62
301
2bc514931612 add function for registering webdav backends
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
63 /*
2bc514931612 add function for registering webdav backends
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
64 * webdav backend types
2bc514931612 add function for registering webdav backends
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
65 * key: backend name (string)
2bc514931612 add function for registering webdav backends
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
66 * value: WebdavBackend*
2bc514931612 add function for registering webdav backends
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
67 */
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
68 static CxMap *webdav_type_map;
301
2bc514931612 add function for registering webdav backends
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
69
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
70 static WebdavBackend default_backend;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
71
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
72 static WSNamespace dav_namespace;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
73
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
74 static WebdavProperty dav_resourcetype_empty;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
75 static WebdavProperty dav_resourcetype_collection;
233
c5985d2fc19a add test for webdav_propfind() that checks if the response is valid xml
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 230
diff changeset
76 static WSXmlData dav_resourcetype_collection_value;
c5985d2fc19a add test for webdav_propfind() that checks if the response is valid xml
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 230
diff changeset
77
c5985d2fc19a add test for webdav_propfind() that checks if the response is valid xml
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 230
diff changeset
78 #define WEBDAV_RESOURCE_TYPE_COLLECTION "<D:collection/>"
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
79
476
477cbeec7b0b fix default webdav backend initialization
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 453
diff changeset
80
477cbeec7b0b fix default webdav backend initialization
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 453
diff changeset
81 static WebdavBackend* default_backend_create(Session *sn, Request *rq, pblock *pb, void *initData) {
477cbeec7b0b fix default webdav backend initialization
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 453
diff changeset
82 WebdavBackend *dav = pool_malloc(sn->pool, sizeof(WebdavBackend));
477cbeec7b0b fix default webdav backend initialization
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 453
diff changeset
83 if(!dav) {
477cbeec7b0b fix default webdav backend initialization
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 453
diff changeset
84 return NULL;
477cbeec7b0b fix default webdav backend initialization
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 453
diff changeset
85 }
477cbeec7b0b fix default webdav backend initialization
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 453
diff changeset
86
477cbeec7b0b fix default webdav backend initialization
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 453
diff changeset
87 *dav = default_backend;
477cbeec7b0b fix default webdav backend initialization
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 453
diff changeset
88 return dav;
477cbeec7b0b fix default webdav backend initialization
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 453
diff changeset
89 }
477cbeec7b0b fix default webdav backend initialization
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 453
diff changeset
90
477cbeec7b0b fix default webdav backend initialization
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 453
diff changeset
91 static int init_default_backend(void) {
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
92 memset(&default_backend, 0, sizeof(WebdavBackend));
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
93 default_backend.propfind_init = default_propfind_init;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
94 default_backend.propfind_do = default_propfind_do;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
95 default_backend.propfind_finish = default_propfind_finish;
243
1a29b1d8d9d8 add proppatch handler to default backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 242
diff changeset
96 default_backend.proppatch_do = default_proppatch_do;
1a29b1d8d9d8 add proppatch handler to default backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 242
diff changeset
97 default_backend.proppatch_finish = default_proppatch_finish;
244
e59abb210584 add minimal mkcol implementation and prepare delete
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 243
diff changeset
98 default_backend.opt_mkcol = NULL;
e59abb210584 add minimal mkcol implementation and prepare delete
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 243
diff changeset
99 default_backend.opt_delete = NULL;
241
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 240
diff changeset
100 default_backend.settings = WS_WEBDAV_PROPFIND_USE_VFS;
300
0e3f275b2492 add instance field to webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 262
diff changeset
101 default_backend.instance = NULL;
476
477cbeec7b0b fix default webdav backend initialization
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 453
diff changeset
102
477cbeec7b0b fix default webdav backend initialization
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 453
diff changeset
103 return webdav_register_backend("default", NULL, default_backend_create);
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
104 }
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
105
476
477cbeec7b0b fix default webdav backend initialization
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 453
diff changeset
106
366
47bc686fafe4 add new dav config element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 352
diff changeset
107 int webdav_register_backend(const char *name, webdav_init_func webdavInit, webdav_create_func webdavCreate) {
47bc686fafe4 add new dav config element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 352
diff changeset
108 WebdavType *webdavType = malloc(sizeof(WebdavType));
47bc686fafe4 add new dav config element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 352
diff changeset
109 webdavType->init = webdavInit;
47bc686fafe4 add new dav config element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 352
diff changeset
110 webdavType->create = webdavCreate;
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
111 return cxMapPut(webdav_type_map, cx_hash_key_str(name), webdavType);
366
47bc686fafe4 add new dav config element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 352
diff changeset
112 }
47bc686fafe4 add new dav config element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 352
diff changeset
113
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
114 WebdavType* webdav_get_type(cxstring dav_class) {
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
115 return cxMapGet(webdav_type_map, cx_hash_key_bytes((unsigned const char *)dav_class.ptr, dav_class.length));
301
2bc514931612 add function for registering webdav backends
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
116 }
2bc514931612 add function for registering webdav backends
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
117
366
47bc686fafe4 add new dav config element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 352
diff changeset
118 void* webdav_init_backend(ServerConfiguration *cfg, pool_handle_t *pool, WebdavType *dav_class, WSConfigNode *config, int *error) {
47bc686fafe4 add new dav config element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 352
diff changeset
119 *error = 0;
47bc686fafe4 add new dav config element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 352
diff changeset
120 if(dav_class->init) {
47bc686fafe4 add new dav config element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 352
diff changeset
121 void *initData = dav_class->init(cfg, pool, config);
47bc686fafe4 add new dav config element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 352
diff changeset
122 if(!initData) {
47bc686fafe4 add new dav config element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 352
diff changeset
123 *error = 1;
47bc686fafe4 add new dav config element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 352
diff changeset
124 }
47bc686fafe4 add new dav config element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 352
diff changeset
125 return initData;
47bc686fafe4 add new dav config element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 352
diff changeset
126 } else {
47bc686fafe4 add new dav config element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 352
diff changeset
127 return NULL;
47bc686fafe4 add new dav config element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 352
diff changeset
128 }
47bc686fafe4 add new dav config element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 352
diff changeset
129 }
325
2d14055c3543 add davclass parameter to pfx2dir for setting the webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 322
diff changeset
130
366
47bc686fafe4 add new dav config element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 352
diff changeset
131 WebdavBackend* webdav_create(Session *sn, Request *rq, const char *dav_class, pblock *pb, void *initData) {
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
132 WebdavType *webdavType = cxMapGet(webdav_type_map, cx_hash_key_str(dav_class));
366
47bc686fafe4 add new dav config element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 352
diff changeset
133 if(!webdavType) {
325
2d14055c3543 add davclass parameter to pfx2dir for setting the webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 322
diff changeset
134 log_ereport(LOG_MISCONFIG, "webdav_create: unkown dav type %s", dav_class);
2d14055c3543 add davclass parameter to pfx2dir for setting the webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 322
diff changeset
135 return NULL;
2d14055c3543 add davclass parameter to pfx2dir for setting the webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 322
diff changeset
136 }
2d14055c3543 add davclass parameter to pfx2dir for setting the webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 322
diff changeset
137
366
47bc686fafe4 add new dav config element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 352
diff changeset
138 return webdavType->create(sn, rq, pb, initData);
325
2d14055c3543 add davclass parameter to pfx2dir for setting the webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 322
diff changeset
139 }
2d14055c3543 add davclass parameter to pfx2dir for setting the webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 322
diff changeset
140
306
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 302
diff changeset
141 static WSBool webdav_is_initialized = FALSE;
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 302
diff changeset
142
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
143 int webdav_init(pblock *pb, Session *sn, Request *rq) {
306
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 302
diff changeset
144 if(webdav_is_initialized) {
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 302
diff changeset
145 return REQ_NOACTION;
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 302
diff changeset
146 }
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 302
diff changeset
147 webdav_is_initialized = TRUE;
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 302
diff changeset
148
490
d218607f5a7e update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 489
diff changeset
149 webdav_type_map = cxHashMapCreate(cxDefaultAllocator, CX_STORE_POINTERS, 8);
301
2bc514931612 add function for registering webdav backends
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
150 if(!webdav_type_map) {
2bc514931612 add function for registering webdav backends
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
151 return REQ_ABORTED;
2bc514931612 add function for registering webdav backends
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
152 }
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
153
490
d218607f5a7e update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 489
diff changeset
154 method_handler_map = cxHashMapCreate(cxDefaultAllocator, CX_STORE_POINTERS, 64);
301
2bc514931612 add function for registering webdav backends
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
155 if(!method_handler_map) {
2bc514931612 add function for registering webdav backends
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
156 return REQ_ABORTED;
2bc514931612 add function for registering webdav backends
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
157 }
2bc514931612 add function for registering webdav backends
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
158
476
477cbeec7b0b fix default webdav backend initialization
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 453
diff changeset
159 if(init_default_backend()) {
477cbeec7b0b fix default webdav backend initialization
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 453
diff changeset
160 return REQ_ABORTED;
477cbeec7b0b fix default webdav backend initialization
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 453
diff changeset
161 }
477cbeec7b0b fix default webdav backend initialization
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 453
diff changeset
162
477cbeec7b0b fix default webdav backend initialization
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 453
diff changeset
163 if(webdav_init_xattr_backend()) {
477cbeec7b0b fix default webdav backend initialization
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 453
diff changeset
164 return REQ_ABORTED;
477cbeec7b0b fix default webdav backend initialization
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 453
diff changeset
165 }
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
166
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
167 cxMapPut(method_handler_map, cx_hash_key_str("OPTIONS"), webdav_options);
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
168 cxMapPut(method_handler_map, cx_hash_key_str("PROPFIND"), webdav_propfind);
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
169 cxMapPut(method_handler_map, cx_hash_key_str("PROPPATCH"), webdav_proppatch);
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
170 cxMapPut(method_handler_map, cx_hash_key_str("MKCOL"), webdav_mkcol);
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
171 cxMapPut(method_handler_map, cx_hash_key_str("POST"), webdav_post);
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
172 cxMapPut(method_handler_map, cx_hash_key_str("DELETE"), webdav_delete);
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
173 cxMapPut(method_handler_map, cx_hash_key_str("PUT"), webdav_put);
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
174 cxMapPut(method_handler_map, cx_hash_key_str("COPY"), webdav_copy);
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
175 cxMapPut(method_handler_map, cx_hash_key_str("MOVE"), webdav_move);
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
176 cxMapPut(method_handler_map, cx_hash_key_str("LOCK"), webdav_lock);
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
177 cxMapPut(method_handler_map, cx_hash_key_str("UNLOCK"), webdav_unlock);
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
178 cxMapPut(method_handler_map, cx_hash_key_str("REPORT"), webdav_report);
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
179 cxMapPut(method_handler_map, cx_hash_key_str("ACL"), webdav_acl);
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
180
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
181 cxMapPut(method_handler_map, cx_hash_key_str("SEARCH"), webdav_search);
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
182
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
183 cxMapPut(method_handler_map, cx_hash_key_str("VERSION-CONTROL"), webdav_version_control);
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
184 cxMapPut(method_handler_map, cx_hash_key_str("CHECKOUT"), webdav_checkout);
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
185 cxMapPut(method_handler_map, cx_hash_key_str("CHECKIN"), webdav_checkin);
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
186 cxMapPut(method_handler_map, cx_hash_key_str("UNCHECKOUT"), webdav_uncheckout);
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
187 cxMapPut(method_handler_map, cx_hash_key_str("MKWORKSPACE"), webdav_mkworkspace);
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
188 cxMapPut(method_handler_map, cx_hash_key_str("UPDATE"), webdav_update);
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
189 cxMapPut(method_handler_map, cx_hash_key_str("LABEL"), webdav_label);
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
190 cxMapPut(method_handler_map, cx_hash_key_str("MERGE"), webdav_merge);
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
191
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
192 dav_namespace.href = (xmlChar*)"DAV:";
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
193 dav_namespace.prefix = (xmlChar*)"D";
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
194
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
195 dav_resourcetype_empty.namespace = &dav_namespace;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
196 dav_resourcetype_empty.name = "resourcetype";
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
197
381
7d55d60e1fe2 fix resourcetype initialization
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 376
diff changeset
198 dav_resourcetype_collection_value.data = WEBDAV_RESOURCE_TYPE_COLLECTION;
7d55d60e1fe2 fix resourcetype initialization
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 376
diff changeset
199 dav_resourcetype_collection_value.length = sizeof(WEBDAV_RESOURCE_TYPE_COLLECTION)-1;
7d55d60e1fe2 fix resourcetype initialization
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 376
diff changeset
200
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
201 dav_resourcetype_collection.namespace = &dav_namespace;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
202 dav_resourcetype_collection.name = "resourcetype";
376
61d481d3c2e4 Add support for extended properties in pg propfind
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
203 dav_resourcetype_collection.value.data = dav_resourcetype_collection_value;
233
c5985d2fc19a add test for webdav_propfind() that checks if the response is valid xml
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 230
diff changeset
204 dav_resourcetype_collection.vtype = WS_VALUE_XML_DATA;
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
205
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
206 return REQ_PROCEED;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
207 }
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
208
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
209
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
210 int webdav_service(pblock *pb, Session *sn, Request *rq) {
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
211 if(!method_handler_map) {
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
212 log_ereport(LOG_FAILURE, "WebDAV module not initialized");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
213 protocol_status(sn, rq, 500, NULL);
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
214 return REQ_ABORTED;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
215 }
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
216 char *method = pblock_findkeyval(pb_key_method, rq->reqpb);
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
217
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
218 FuncPtr saf = (FuncPtr)cxMapGet(method_handler_map, cx_hash_key_str(method));
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
219 if(!saf) {
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
220 return REQ_NOACTION;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
221 }
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
222
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
223 return saf(pb, sn, rq);
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
224 }
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
225
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
226 int rqbody2buffer(Session *sn, Request *rq, CxBuffer *buf) {
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
227 if(!sn->inbuf) {
212
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
228 //request body required, set http response code
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
229 protocol_status(sn, rq, 400, NULL);
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
230 return 1;
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
231 }
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
232
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
233 CxAllocator *a = pool_allocator(sn->pool);
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
234 if(cxBufferInit(buf, NULL, sn->inbuf->maxsize, a, CX_BUFFER_AUTO_EXTEND|CX_BUFFER_FREE_CONTENTS)) {
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
235 protocol_status(sn, rq, 500, NULL);
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
236 return 1;
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
237 }
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
238
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
239 char in[2048];
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
240 int r;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
241 while((r = netbuf_getbytes(sn->inbuf, in, 2048)) > 0) {
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
242 if(cxBufferWrite(in, 1, r, buf) != r) {
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
243 protocol_status(sn, rq, 500, NULL);
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
244 cxBufferDestroy(buf);
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
245 return 1;
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
246 }
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
247 }
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
248
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
249 return 0;
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
250 }
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
251
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
252 int webdav_options(pblock *pb, Session *sn, Request *rq) {
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
253 return REQ_ABORTED;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
254 }
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
255
414
99a34860c105 improve propfind error handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 412
diff changeset
256 static const char* propfind_error2str(int error) {
99a34860c105 improve propfind error handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 412
diff changeset
257 switch(error) {
99a34860c105 improve propfind error handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 412
diff changeset
258 case PROPFIND_PARSER_OK: return "ok";
99a34860c105 improve propfind error handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 412
diff changeset
259 case PROPFIND_PARSER_NO_PROPFIND: return "invalid xml root element";
99a34860c105 improve propfind error handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 412
diff changeset
260 case PROPFIND_PARSER_NO_PROPERTIES: return "no properties specified";
99a34860c105 improve propfind error handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 412
diff changeset
261 case PROPFIND_PARSER_INVALID_REQUEST: return "invalid propfind request";
99a34860c105 improve propfind error handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 412
diff changeset
262 case PROPFIND_PARSER_OOM: return "OOM";
99a34860c105 improve propfind error handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 412
diff changeset
263 case PROPFIND_PARSER_ERROR: return "error";
99a34860c105 improve propfind error handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 412
diff changeset
264 }
99a34860c105 improve propfind error handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 412
diff changeset
265 return "";
99a34860c105 improve propfind error handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 412
diff changeset
266 }
99a34860c105 improve propfind error handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 412
diff changeset
267
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
268 int webdav_propfind(pblock *pb, Session *sn, Request *rq) {
235
4990147c58d0 add handler for http expect header
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 234
diff changeset
269 char *expect = pblock_findkeyval(pb_key_expect, rq->headers);
4990147c58d0 add handler for http expect header
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 234
diff changeset
270 if(expect) {
4990147c58d0 add handler for http expect header
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 234
diff changeset
271 if(!strcasecmp(expect, "100-continue")) {
4990147c58d0 add handler for http expect header
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 234
diff changeset
272 if(http_send_continue(sn)) {
4990147c58d0 add handler for http expect header
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 234
diff changeset
273 return REQ_ABORTED;
4990147c58d0 add handler for http expect header
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 234
diff changeset
274 }
4990147c58d0 add handler for http expect header
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 234
diff changeset
275 }
4990147c58d0 add handler for http expect header
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 234
diff changeset
276 }
4990147c58d0 add handler for http expect header
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 234
diff changeset
277
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
278 CxBuffer reqbody;
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
279 if(rqbody2buffer(sn, rq, &reqbody)) {
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
280 return REQ_ABORTED;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
281 }
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
282
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
283 int error = 0;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
284 WebdavPropfindRequest *propfind = propfind_parse(
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
285 sn,
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
286 rq,
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
287 reqbody.space,
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
288 reqbody.size,
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
289 &error);
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
290 cxBufferDestroy(&reqbody);
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
291 if(!propfind) {
414
99a34860c105 improve propfind error handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 412
diff changeset
292 log_ereport(LOG_FAILURE, "webdav-propfind: %s", propfind_error2str(error));
99a34860c105 improve propfind error handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 412
diff changeset
293 return REQ_ABORTED;
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
294 }
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
295
217
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
296 WebdavBackend *dav = rq->davCollection ?
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
297 rq->davCollection : &default_backend;
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
298
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
299
221
ff5826fc6a6c add href parameter to webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 220
diff changeset
300 // requested uri and path
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
301 char *path = pblock_findkeyval(pb_key_path, rq->vars);
221
ff5826fc6a6c add href parameter to webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 220
diff changeset
302 char *uri = pblock_findkeyval(pb_key_uri, rq->reqpb);
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
303
217
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
304 // The multistatus response object contains responses for all
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
305 // requested resources. At the end the Multistatus object will be
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
306 // serialized to xml
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
307 Multistatus *ms = multistatus_response(sn, rq);
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
308 if(!ms) {
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
309 return REQ_ABORTED;
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
310 }
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
311
252
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
312 int ret = webdav_propfind_do(dav, propfind, (WebdavResponse*)ms, NULL, path, uri);
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
313
222
5f05e56cb8e2 create namespace definition lists when properties are added to a multistatus response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
314 // if propfind was successful, send the result to the client
414
99a34860c105 improve propfind error handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 412
diff changeset
315 if(ret == REQ_PROCEED) {
99a34860c105 improve propfind error handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 412
diff changeset
316 if(multistatus_send(ms, sn->csd)) {
99a34860c105 improve propfind error handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 412
diff changeset
317 ret = REQ_ABORTED;
99a34860c105 improve propfind error handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 412
diff changeset
318 }
487
f2b0e48aa483 webdav_propfind logs less errors for http 4xx errors
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 481
diff changeset
319 } else if(rq->status_num < 400 || rq->status_num >= 500) {
414
99a34860c105 improve propfind error handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 412
diff changeset
320 log_ereport(LOG_FAILURE, "webdav-propfind: operation failed");
233
c5985d2fc19a add test for webdav_propfind() that checks if the response is valid xml
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 230
diff changeset
321 }
c5985d2fc19a add test for webdav_propfind() that checks if the response is valid xml
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 230
diff changeset
322
252
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
323 // cleanup
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
324 if(propfind->doc) {
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
325 xmlFreeDoc(propfind->doc);
222
5f05e56cb8e2 create namespace definition lists when properties are added to a multistatus response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
326 }
5f05e56cb8e2 create namespace definition lists when properties are added to a multistatus response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
327
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
328 return ret;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
329 }
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
330
212
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
331 /*
213
4a6be4f10d5f move backend initialization to new function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
332 * Initializes Backend Chain
4a6be4f10d5f move backend initialization to new function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
333 *
4a6be4f10d5f move backend initialization to new function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
334 * Calls propfind_init of each Backend and generates a list of custom
4a6be4f10d5f move backend initialization to new function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
335 * WebdavPropfindRequest objects for each backend
4a6be4f10d5f move backend initialization to new function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
336 */
4a6be4f10d5f move backend initialization to new function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
337 int webdav_propfind_init(
4a6be4f10d5f move backend initialization to new function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
338 WebdavBackend *dav,
4a6be4f10d5f move backend initialization to new function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
339 WebdavPropfindRequest *propfind,
4a6be4f10d5f move backend initialization to new function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
340 const char *path,
307
8787cb5ebab3 fix href in pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 306
diff changeset
341 const char *uri,
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
342 WebdavPropfindRequestList **out_req)
213
4a6be4f10d5f move backend initialization to new function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
343 {
4a6be4f10d5f move backend initialization to new function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
344 pool_handle_t *pool = propfind->sn->pool;
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
345 CxAllocator *a = pool_allocator(pool);
213
4a6be4f10d5f move backend initialization to new function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
346
4a6be4f10d5f move backend initialization to new function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
347 // list of individual WebdavPropfindRequest objects for each Backend
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
348 WebdavPropfindRequestList *requestObjectsBegin = NULL;
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
349 WebdavPropfindRequestList *requestObjectsEnd = NULL;
213
4a6be4f10d5f move backend initialization to new function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
350
4a6be4f10d5f move backend initialization to new function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
351 // new properties after init, start with clone of original plist
4a6be4f10d5f move backend initialization to new function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
352 WebdavPList *newProp = webdav_plist_clone(pool, propfind->properties);
4a6be4f10d5f move backend initialization to new function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
353 size_t newPropCount = propfind->propcount;
4a6be4f10d5f move backend initialization to new function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
354
4a6be4f10d5f move backend initialization to new function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
355 // Call propfind_init for each Backend
4a6be4f10d5f move backend initialization to new function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
356 // propfind_init can return a new property list, which
4a6be4f10d5f move backend initialization to new function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
357 // will be passed to the next backend
4a6be4f10d5f move backend initialization to new function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
358
4a6be4f10d5f move backend initialization to new function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
359 WebdavBackend *davList = dav;
4a6be4f10d5f move backend initialization to new function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
360 while(davList) {
4a6be4f10d5f move backend initialization to new function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
361 // create WebdavPropfindRequest copy
4a6be4f10d5f move backend initialization to new function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
362 WebdavPropfindRequest *pReq = pool_malloc(
4a6be4f10d5f move backend initialization to new function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
363 pool,
4a6be4f10d5f move backend initialization to new function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
364 sizeof(WebdavPropfindRequest));
220
2915b6c11aec add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
365 memcpy(pReq, propfind, sizeof(WebdavPropfindRequest));
213
4a6be4f10d5f move backend initialization to new function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
366 // use new plist after previous init (or orig. plist in the first run)
4a6be4f10d5f move backend initialization to new function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
367 pReq->properties = newProp;
4a6be4f10d5f move backend initialization to new function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
368 pReq->propcount = newPropCount;
306
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 302
diff changeset
369 pReq->dav = davList;
213
4a6be4f10d5f move backend initialization to new function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
370
4a6be4f10d5f move backend initialization to new function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
371 // add new WebdavPropfindRequest object to list for later use
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
372 WebdavPropfindRequestList *reqListElm = pool_malloc(pool, sizeof(WebdavPropfindRequestList));
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
373 if(!reqListElm) {
213
4a6be4f10d5f move backend initialization to new function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
374 return REQ_ABORTED; // OOM
4a6be4f10d5f move backend initialization to new function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
375 }
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
376 reqListElm->propfind = pReq;
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
377 reqListElm->next = NULL;
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
378 cx_linked_list_add(
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
379 (void**)&requestObjectsBegin,
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
380 (void**)&requestObjectsEnd,
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
381 -1,
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
382 offsetof(WebdavPropfindRequestList, next),
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
383 reqListElm);
213
4a6be4f10d5f move backend initialization to new function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
384
4a6be4f10d5f move backend initialization to new function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
385 // create plist copy as out-plist for init
4a6be4f10d5f move backend initialization to new function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
386 newProp = webdav_plist_clone(pool, newProp);
4a6be4f10d5f move backend initialization to new function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
387
4a6be4f10d5f move backend initialization to new function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
388 // run init: this can generate a new properties list (newProp)
4a6be4f10d5f move backend initialization to new function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
389 // which will be passed to the next backend
307
8787cb5ebab3 fix href in pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 306
diff changeset
390 if(davList->propfind_init(pReq, path, uri, &newProp)) {
213
4a6be4f10d5f move backend initialization to new function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
391 return REQ_ABORTED;
4a6be4f10d5f move backend initialization to new function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
392 }
4a6be4f10d5f move backend initialization to new function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
393
216
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
394 newPropCount = webdav_plist_size(newProp);
213
4a6be4f10d5f move backend initialization to new function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
395
4a6be4f10d5f move backend initialization to new function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
396 davList = davList->next;
4a6be4f10d5f move backend initialization to new function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
397 }
4a6be4f10d5f move backend initialization to new function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
398
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
399 *out_req = requestObjectsBegin;
213
4a6be4f10d5f move backend initialization to new function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
400 return REQ_PROCEED;
4a6be4f10d5f move backend initialization to new function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
401 }
4a6be4f10d5f move backend initialization to new function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
402
252
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
403 int webdav_propfind_do(
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
404 WebdavBackend *dav,
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
405 WebdavPropfindRequest *propfind,
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
406 WebdavResponse *response,
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
407 VFSContext *vfs,
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
408 char *path,
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
409 char *uri)
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
410 {
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
411 Session *sn = propfind->sn;
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
412 Request *rq = propfind->rq;
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
413
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
414 // VFS settings are only taken from the first backend
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
415 uint32_t settings = dav->settings;
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
416
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
417 // list of individual WebdavPropfindRequest objects for each Backend
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
418 WebdavPropfindRequestList *requestObjects = NULL;
252
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
419
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
420 // Initialize all Webdav Backends
307
8787cb5ebab3 fix href in pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 306
diff changeset
421 if(webdav_propfind_init(dav, propfind, path, uri, &requestObjects)) {
252
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
422 return REQ_ABORTED;
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
423 }
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
424
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
425 WebdavOperation *op = webdav_create_propfind_operation(
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
426 sn,
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
427 rq,
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
428 dav,
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
429 propfind->properties,
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
430 requestObjects,
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
431 response);
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
432
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
433 // some Backends can list all children by themselves, but some
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
434 // require the VFS for this
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
435 WSBool usevfs = (settings & WS_WEBDAV_PROPFIND_USE_VFS)
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
436 == WS_WEBDAV_PROPFIND_USE_VFS;
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
437 struct stat s;
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
438 struct stat *statptr = NULL;
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
439
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
440 if(usevfs && !vfs) {
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
441 vfs = vfs_request_context(sn, rq);
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
442 if(!vfs) {
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
443 return REQ_ABORTED;
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
444 }
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
445
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
446 if(vfs_stat(vfs, path, &s)) {
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
447 protocol_status(sn, rq, util_errno2status(vfs->vfs_errno), NULL);
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
448 return REQ_ABORTED;
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
449 }
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
450 statptr = &s;
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
451 if(!S_ISDIR(s.st_mode)) {
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
452 // the file is not a directory, therefore we don't need the VFS
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
453 usevfs = FALSE;
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
454 }
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
455 }
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
456 if(propfind->depth == 0) {
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
457 usevfs = FALSE;
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
458 }
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
459
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
460 int ret = REQ_PROCEED;
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
461
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
462 // create WebdavResource object for requested resource
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
463 if(!webdav_op_propfind_begin(op, uri, NULL, statptr)) {
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
464 // propfind for the requested resource was successful
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
465
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
466 // usevfsdir is TRUE if
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
467 // the webdav backend has not disabled vfs usage
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
468 // the file is a directory
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
469 // depth is not 0
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
470 // in this case we need to execute propfind_do for all children
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
471 if(usevfs) {
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
472 if(webdav_op_propfind_children(op, vfs, uri, path)) {
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
473 ret = REQ_ABORTED;
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
474 }
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
475 }
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
476 }
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
477
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
478 // finish the propfind request
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
479 // this function should cleanup all resources, therefore we execute it
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
480 // even if a previous function failed
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
481 if(webdav_op_propfind_finish(op)) {
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
482 // TODO: log error
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
483 ret = REQ_ABORTED;
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
484 }
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
485
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
486 return ret;
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
487 }
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
488
213
4a6be4f10d5f move backend initialization to new function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
489
412
a4e2ce073c0f improve error handling in webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 396
diff changeset
490 static const char* proppatch_error2str(int error) {
a4e2ce073c0f improve error handling in webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 396
diff changeset
491 switch(error) {
a4e2ce073c0f improve error handling in webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 396
diff changeset
492 case PROPPATCH_PARSER_OK: return "ok";
a4e2ce073c0f improve error handling in webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 396
diff changeset
493 case PROPPATCH_PARSER_NO_PROPERTYUPDATE: return "no property update";
a4e2ce073c0f improve error handling in webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 396
diff changeset
494 case PROPPATCH_PARSER_NO_PROPERTIES: return "no properties";
a4e2ce073c0f improve error handling in webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 396
diff changeset
495 case PROPPATCH_PARSER_INVALID_REQUEST: return "invalid proppatch request";
a4e2ce073c0f improve error handling in webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 396
diff changeset
496 case PROPPATCH_PARSER_DUPLICATE: return "proppatch property duplicate";
a4e2ce073c0f improve error handling in webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 396
diff changeset
497 case PROPPATCH_PARSER_OOM: return "OOM";
a4e2ce073c0f improve error handling in webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 396
diff changeset
498 case PROPPATCH_PARSER_ERROR: return "proppatch parser error";
a4e2ce073c0f improve error handling in webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 396
diff changeset
499 }
a4e2ce073c0f improve error handling in webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 396
diff changeset
500 return "error";
a4e2ce073c0f improve error handling in webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 396
diff changeset
501 }
a4e2ce073c0f improve error handling in webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 396
diff changeset
502
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
503 int webdav_proppatch(pblock *pb, Session *sn, Request *rq) {
242
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
504 char *expect = pblock_findkeyval(pb_key_expect, rq->headers);
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
505 if(expect) {
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
506 if(!strcasecmp(expect, "100-continue")) {
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
507 if(http_send_continue(sn)) {
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
508 return REQ_ABORTED;
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
509 }
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
510 }
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
511 }
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
512
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
513 CxBuffer reqbody;
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
514 if(rqbody2buffer(sn, rq, &reqbody)) {
412
a4e2ce073c0f improve error handling in webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 396
diff changeset
515 // most likely OOM
242
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
516 return REQ_ABORTED;
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
517 }
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
518
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
519 int error = 0;
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
520 WebdavProppatchRequest *proppatch = proppatch_parse(
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
521 sn,
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
522 rq,
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
523 reqbody.space,
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
524 reqbody.size,
242
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
525 &error);
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
526 cxBufferDestroy(&reqbody);
242
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
527 if(!proppatch) {
412
a4e2ce073c0f improve error handling in webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 396
diff changeset
528 log_ereport(LOG_FAILURE, "webdav-proppatch: %s", proppatch_error2str(error));
a4e2ce073c0f improve error handling in webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 396
diff changeset
529 return REQ_ABORTED;
242
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
530 }
251
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
531
242
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
532 WebdavBackend *dav = rq->davCollection ?
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
533 rq->davCollection : &default_backend;
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
534
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
535 // requested uri and path
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
536 char *path = pblock_findkeyval(pb_key_path, rq->vars);
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
537 char *uri = pblock_findkeyval(pb_key_uri, rq->reqpb);
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
538
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
539 // The multistatus response object contains responses for all
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
540 // requested resources. At the end the Multistatus object will be
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
541 // serialized to xml
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
542 Multistatus *ms = multistatus_response(sn, rq);
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
543 if(!ms) {
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
544 return REQ_ABORTED;
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
545 }
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
546 ms->proppatch = TRUE;
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
547
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
548 // WebdavResponse is the public interface used by Backends
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
549 // for adding resources to the response
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
550 WebdavResponse *response = (WebdavResponse*)ms;
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
551
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
552 WebdavOperation *op = webdav_create_proppatch_operation(
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
553 sn,
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
554 rq,
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
555 dav,
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
556 proppatch,
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
557 response);
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
558
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
559 int ret = REQ_PROCEED;
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
560
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
561 // Execute proppatch
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
562 if(webdav_op_proppatch(op, uri, path)) {
412
a4e2ce073c0f improve error handling in webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 396
diff changeset
563 log_ereport(LOG_FAILURE, "webdav-proppatch: proppatch operation failed");
242
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
564 ret = REQ_ABORTED;
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
565 }
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
566
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
567 // send response
412
a4e2ce073c0f improve error handling in webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 396
diff changeset
568 if(ret == REQ_PROCEED) {
a4e2ce073c0f improve error handling in webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 396
diff changeset
569 if(multistatus_send(ms, sn->csd)) {
a4e2ce073c0f improve error handling in webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 396
diff changeset
570 log_ereport(LOG_FAILURE, "webdav-proppatch: multistatus_send failed");
a4e2ce073c0f improve error handling in webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 396
diff changeset
571 }
242
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
572 } else {
412
a4e2ce073c0f improve error handling in webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 396
diff changeset
573 protocol_status(sn, rq, 500, NULL);
242
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
574 }
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
575
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
576 // cleanup
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
577 xmlFreeDoc(proppatch->doc);
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
578
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
579 return ret;
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
580 }
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
581
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
582 int webdav_mkcol(pblock *pb, Session *sn, Request *rq) {
245
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
583 WebdavVFSOperation *op = webdav_vfs_op(sn, rq, rq->davCollection, TRUE);
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
584 if(!op) {
244
e59abb210584 add minimal mkcol implementation and prepare delete
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 243
diff changeset
585 return REQ_ABORTED;
e59abb210584 add minimal mkcol implementation and prepare delete
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 243
diff changeset
586 }
e59abb210584 add minimal mkcol implementation and prepare delete
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 243
diff changeset
587
344
70a9b945206a fix webdav_mkcol response and add error handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 340
diff changeset
588 int ret = REQ_ABORTED;
70a9b945206a fix webdav_mkcol response and add error handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 340
diff changeset
589 if(!webdav_vfs_op_do(op, WEBDAV_VFS_MKDIR)) {
70a9b945206a fix webdav_mkcol response and add error handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 340
diff changeset
590 pblock_nvinsert("content-length", "0", rq->srvhdrs);
70a9b945206a fix webdav_mkcol response and add error handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 340
diff changeset
591 protocol_status(sn, rq, 201, NULL);
70a9b945206a fix webdav_mkcol response and add error handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 340
diff changeset
592 protocol_start_response(sn, rq);
70a9b945206a fix webdav_mkcol response and add error handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 340
diff changeset
593 ret = REQ_PROCEED;
396
77d81f2bb9f7 add initial ipv6 support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 395
diff changeset
594 } else if(rq->status_num <= 0) {
77d81f2bb9f7 add initial ipv6 support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 395
diff changeset
595 int status_code = 500;
77d81f2bb9f7 add initial ipv6 support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 395
diff changeset
596 if(op->vfs->vfs_errno == EEXIST) {
77d81f2bb9f7 add initial ipv6 support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 395
diff changeset
597 // 405 (Method Not Allowed) - MKCOL can only be executed on an unmapped URL.
77d81f2bb9f7 add initial ipv6 support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 395
diff changeset
598 status_code = 405;
77d81f2bb9f7 add initial ipv6 support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 395
diff changeset
599 } else if(op->vfs->vfs_errno == ENOENT) {
77d81f2bb9f7 add initial ipv6 support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 395
diff changeset
600 // 409 (Conflict) - A collection cannot be made at the Request-URI until
77d81f2bb9f7 add initial ipv6 support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 395
diff changeset
601 // one or more intermediate collections have been created. The server
77d81f2bb9f7 add initial ipv6 support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 395
diff changeset
602 // MUST NOT create those intermediate collections automatically.
77d81f2bb9f7 add initial ipv6 support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 395
diff changeset
603 status_code = 409;
77d81f2bb9f7 add initial ipv6 support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 395
diff changeset
604 } else {
77d81f2bb9f7 add initial ipv6 support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 395
diff changeset
605 log_ereport(LOG_VERBOSE, "webdav_mkcol: errno: %d", op->vfs->vfs_errno);
344
70a9b945206a fix webdav_mkcol response and add error handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 340
diff changeset
606 }
396
77d81f2bb9f7 add initial ipv6 support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 395
diff changeset
607 protocol_status(sn, rq, status_code, NULL);
344
70a9b945206a fix webdav_mkcol response and add error handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 340
diff changeset
608 }
244
e59abb210584 add minimal mkcol implementation and prepare delete
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 243
diff changeset
609
e59abb210584 add minimal mkcol implementation and prepare delete
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 243
diff changeset
610 return ret;
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
611 }
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
612
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
613 int webdav_post(pblock *pb, Session *sn, Request *rq) {
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
614 return REQ_ABORTED;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
615 }
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
616
247
1df803e06076 implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 246
diff changeset
617 typedef struct DeleteFile {
1df803e06076 implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 246
diff changeset
618 char *path;
1df803e06076 implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 246
diff changeset
619 struct stat s;
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
620 struct DeleteFile *prev;
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
621 struct DeleteFile *next;
247
1df803e06076 implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 246
diff changeset
622 } DeleteFile;
1df803e06076 implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 246
diff changeset
623
1df803e06076 implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 246
diff changeset
624 typedef struct DeleteLists {
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
625 CxAllocator *a;
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
626 DeleteFile *dirs_begin;
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
627 DeleteFile *dirs_end;
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
628 DeleteFile *files_begin;
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
629 DeleteFile *files_end;
247
1df803e06076 implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 246
diff changeset
630 } DeleteOp;
1df803e06076 implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 246
diff changeset
631
1df803e06076 implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 246
diff changeset
632 static int deletelist_add(
1df803e06076 implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 246
diff changeset
633 VFSContext *vfs,
1df803e06076 implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 246
diff changeset
634 const char *href,
1df803e06076 implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 246
diff changeset
635 const char *path,
1df803e06076 implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 246
diff changeset
636 VFSDir *parent,
1df803e06076 implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 246
diff changeset
637 struct stat *s,
1df803e06076 implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 246
diff changeset
638 void *userdata)
1df803e06076 implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 246
diff changeset
639 {
1df803e06076 implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 246
diff changeset
640 DeleteOp *op = userdata;
1df803e06076 implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 246
diff changeset
641
1df803e06076 implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 246
diff changeset
642 // create object for this file
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
643 DeleteFile *file = cxMalloc(op->a, sizeof(DeleteFile));
247
1df803e06076 implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 246
diff changeset
644 if(!file) {
1df803e06076 implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 246
diff changeset
645 return 1;
1df803e06076 implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 246
diff changeset
646 }
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
647 file->path = cx_strdup_a(op->a, cx_str((char*)path)).ptr;
247
1df803e06076 implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 246
diff changeset
648 if(!file->path) {
1df803e06076 implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 246
diff changeset
649 return 1;
1df803e06076 implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 246
diff changeset
650 }
1df803e06076 implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 246
diff changeset
651 file->s = *s;
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
652 file->next = NULL;
247
1df803e06076 implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 246
diff changeset
653
1df803e06076 implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 246
diff changeset
654 // determine which list to use
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
655 DeleteFile **begin;
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
656 DeleteFile **end;
247
1df803e06076 implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 246
diff changeset
657 if(S_ISDIR(s->st_mode)) {
1df803e06076 implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 246
diff changeset
658 begin = &op->dirs_begin;
1df803e06076 implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 246
diff changeset
659 end = &op->dirs_end;
1df803e06076 implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 246
diff changeset
660 } else {
1df803e06076 implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 246
diff changeset
661 begin = &op->files_begin;
1df803e06076 implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 246
diff changeset
662 end = &op->files_end;
1df803e06076 implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 246
diff changeset
663 }
1df803e06076 implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 246
diff changeset
664
1df803e06076 implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 246
diff changeset
665 // add file to list
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
666 cx_linked_list_add(
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
667 (void**)begin, (void**)end,
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
668 offsetof(DeleteFile, prev), offsetof(DeleteFile, next),
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
669 file);
247
1df803e06076 implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 246
diff changeset
670
1df803e06076 implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 246
diff changeset
671 return 0;
1df803e06076 implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 246
diff changeset
672 }
1df803e06076 implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 246
diff changeset
673
246
155bdef7fe7e add webdav op function for iterating directories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
674 static int webdav_delete_collection(WebdavVFSOperation *op)
244
e59abb210584 add minimal mkcol implementation and prepare delete
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 243
diff changeset
675 {
247
1df803e06076 implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 246
diff changeset
676 DeleteOp del;
1df803e06076 implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 246
diff changeset
677 ZERO(&del, sizeof(DeleteOp));
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
678 del.a = pool_allocator(op->sn->pool);
247
1df803e06076 implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 246
diff changeset
679
1df803e06076 implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 246
diff changeset
680 // get a list of all files
1df803e06076 implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 246
diff changeset
681 if(webdav_op_iterate_children(op->vfs, -1, NULL, op->path,
1df803e06076 implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 246
diff changeset
682 deletelist_add, &del))
1df803e06076 implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 246
diff changeset
683 {
1df803e06076 implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 246
diff changeset
684 return 1;
1df803e06076 implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 246
diff changeset
685 }
1df803e06076 implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 246
diff changeset
686
249
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 247
diff changeset
687 // add root to list of dir list
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 247
diff changeset
688 DeleteFile root;
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 247
diff changeset
689 root.path = op->path;
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 247
diff changeset
690 root.s = *op->stat;
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
691 root.prev = NULL;
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
692 root.next = del.dirs_begin;
249
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 247
diff changeset
693
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 247
diff changeset
694 if(del.dirs_begin) {
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
695 del.dirs_begin->prev = &root;
249
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 247
diff changeset
696 } else {
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
697 del.dirs_end = &root;
249
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 247
diff changeset
698 }
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
699 del.dirs_begin = &root;
249
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 247
diff changeset
700
247
1df803e06076 implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 246
diff changeset
701 // delete files first
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
702 for(DeleteFile *file=del.files_begin;file;file=file->next) {
247
1df803e06076 implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 246
diff changeset
703 WebdavVFSOperation sub = webdav_vfs_sub_op(op, file->path, &file->s);
1df803e06076 implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 246
diff changeset
704 if(webdav_vfs_op_do(&sub, WEBDAV_VFS_DELETE)) {
1df803e06076 implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 246
diff changeset
705 return 1;
1df803e06076 implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 246
diff changeset
706 }
1df803e06076 implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 246
diff changeset
707 }
1df803e06076 implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 246
diff changeset
708
1df803e06076 implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 246
diff changeset
709 // delete directories, reverse order
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
710 for(DeleteFile *file=del.dirs_end;file;file=file->prev) {
247
1df803e06076 implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 246
diff changeset
711 WebdavVFSOperation sub = webdav_vfs_sub_op(op, file->path, &file->s);
1df803e06076 implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 246
diff changeset
712 if(webdav_vfs_op_do(&sub, WEBDAV_VFS_DELETE)) {
1df803e06076 implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 246
diff changeset
713 return 1;
1df803e06076 implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 246
diff changeset
714 }
1df803e06076 implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 246
diff changeset
715 }
1df803e06076 implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 246
diff changeset
716
1df803e06076 implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 246
diff changeset
717 return 0;
244
e59abb210584 add minimal mkcol implementation and prepare delete
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 243
diff changeset
718 }
e59abb210584 add minimal mkcol implementation and prepare delete
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 243
diff changeset
719
245
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
720 int webdav_delete(pblock *pb, Session *sn, Request *rq) {
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
721 WebdavVFSOperation *op = webdav_vfs_op(sn, rq, rq->davCollection, TRUE);
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
722 if(!op) {
244
e59abb210584 add minimal mkcol implementation and prepare delete
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 243
diff changeset
723 return REQ_ABORTED;
e59abb210584 add minimal mkcol implementation and prepare delete
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 243
diff changeset
724 }
e59abb210584 add minimal mkcol implementation and prepare delete
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 243
diff changeset
725
246
155bdef7fe7e add webdav op function for iterating directories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
726 // stat to find out if the resource is a collection
155bdef7fe7e add webdav op function for iterating directories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
727 struct stat s;
155bdef7fe7e add webdav op function for iterating directories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
728 if(vfs_stat(op->vfs, op->path, &s)) {
155bdef7fe7e add webdav op function for iterating directories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
729 sys_set_error_status(op->vfs);
155bdef7fe7e add webdav op function for iterating directories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
730 return REQ_ABORTED;
155bdef7fe7e add webdav op function for iterating directories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
731 }
249
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 247
diff changeset
732 op->stat = &s;
246
155bdef7fe7e add webdav op function for iterating directories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
733
155bdef7fe7e add webdav op function for iterating directories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
734 int ret;
155bdef7fe7e add webdav op function for iterating directories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
735 if(S_ISDIR(s.st_mode)) {
155bdef7fe7e add webdav op function for iterating directories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
736 ret = webdav_delete_collection(op);
155bdef7fe7e add webdav op function for iterating directories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
737 } else {
155bdef7fe7e add webdav op function for iterating directories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
738 ret = webdav_vfs_op_do(op, WEBDAV_VFS_DELETE);
155bdef7fe7e add webdav op function for iterating directories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
739 }
244
e59abb210584 add minimal mkcol implementation and prepare delete
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 243
diff changeset
740
327
24e740ed90b3 move http response code from webdav_vfs_op_do to webdav_delete
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 325
diff changeset
741 // send response
24e740ed90b3 move http response code from webdav_vfs_op_do to webdav_delete
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 325
diff changeset
742 if(ret == REQ_PROCEED) {
329
d2b2124801f4 add content-length header to webdav_delete and webdav_put
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 328
diff changeset
743 pblock_nvinsert("content-length", "0", rq->srvhdrs);
328
1c08aa0c060e send response in webdav_put
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 327
diff changeset
744 protocol_status(sn, rq, 204, NULL);
1c08aa0c060e send response in webdav_put
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 327
diff changeset
745 protocol_start_response(sn, rq);
327
24e740ed90b3 move http response code from webdav_vfs_op_do to webdav_delete
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 325
diff changeset
746 } else {
352
d0a7ef49db0f fix webdav_delete response in case of errors
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 344
diff changeset
747 protocol_status(sn, rq, 500, NULL);
327
24e740ed90b3 move http response code from webdav_vfs_op_do to webdav_delete
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 325
diff changeset
748 }
24e740ed90b3 move http response code from webdav_vfs_op_do to webdav_delete
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 325
diff changeset
749
244
e59abb210584 add minimal mkcol implementation and prepare delete
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 243
diff changeset
750 return ret;
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
751 }
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
752
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
753 int webdav_put(pblock *pb, Session *sn, Request *rq) {
251
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
754 char *path = pblock_findkeyval(pb_key_path, rq->vars);
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
755
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
756 VFSContext *vfs = vfs_request_context(sn, rq);
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
757 if(!vfs) {
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
758 protocol_status(sn, rq, PROTOCOL_SERVER_ERROR, NULL);
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
759 return REQ_ABORTED;
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
760 }
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
761
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
762 struct stat s;
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
763 int create_file = 0;
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
764 if(vfs_stat(vfs, path, &s)) {
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
765 if(vfs->vfs_errno == ENOENT) {
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
766 create_file = O_CREAT;
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
767 } else {
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
768 protocol_status(sn, rq, util_errno2status(vfs->vfs_errno), NULL);
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
769 return REQ_ABORTED;
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
770 }
322
f26bd6e17594 fix uninitialized memory access in directory check
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 318
diff changeset
771 } else if(S_ISDIR(s.st_mode)) {
251
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
772 // PUT on collections is not allowed
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
773 protocol_status(sn, rq, PROTOCOL_METHOD_NOT_ALLOWED, NULL);
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
774 return REQ_ABORTED;
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
775 }
489
921f83a8943f fix PUT could potentially return a wrong status code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 487
diff changeset
776 vfs->error_response_set = FALSE; // reset error
251
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
777
340
03c052d9a097 add O_TRUNC to oflags in webdav_put
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 331
diff changeset
778 SYS_FILE fd = vfs_open(vfs, path, O_WRONLY | O_TRUNC | create_file);
251
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
779 if(!fd) {
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
780 // if it fails, vfs_open sets http status code
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
781 return REQ_ABORTED;
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
782 }
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
783
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
784 // TODO: check permissions, lock, ...
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
785
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
786 // all checks done
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
787
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
788 char *expect = pblock_findkeyval(pb_key_expect, rq->headers);
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
789 if(expect) {
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
790 if(!strcasecmp(expect, "100-continue")) {
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
791 if(http_send_continue(sn)) {
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
792 return REQ_ABORTED;
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
793 }
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
794 }
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
795 }
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
796
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
797 char in[4096];
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
798 int r;
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
799 while((r = netbuf_getbytes(sn->inbuf, in, 2048)) > 0) {
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
800 int w = 0;
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
801 while(w < r) {
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
802 w += system_fwrite(fd, in, r);
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
803 }
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
804 }
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
805
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
806 system_fclose(fd);
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
807
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
808 int status = create_file ? PROTOCOL_CREATED : PROTOCOL_NO_CONTENT;
329
d2b2124801f4 add content-length header to webdav_delete and webdav_put
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 328
diff changeset
809 pblock_nvinsert("content-length", "0", rq->srvhdrs);
251
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
810 protocol_status(sn, rq, status, NULL);
328
1c08aa0c060e send response in webdav_put
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 327
diff changeset
811 protocol_start_response(sn, rq);
251
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
812
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
813 return REQ_PROCEED;
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
814 }
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
815
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
816 int webdav_copy(pblock *pb, Session *sn, Request *rq) {
252
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
817 char *path = pblock_findkeyval(pb_key_path, rq->vars);
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
818 char *uri = pblock_findkeyval(pb_key_uri, rq->reqpb);
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
819
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
820 char *destination = pblock_findval("destination", rq->headers);
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
821 if(!destination) {
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
822 protocol_status(sn, rq, PROTOCOL_BAD_REQUEST, NULL);
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
823 return REQ_ABORTED;
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
824 }
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
825
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
826 VFSContext *vfs = vfs_request_context(sn, rq);
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
827 if(!vfs) {
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
828 protocol_status(sn, rq, PROTOCOL_SERVER_ERROR, NULL);
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
829 return REQ_ABORTED;
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
830 }
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
831
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
832 struct stat src_s;
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
833 if(vfs_stat(vfs, path, &src_s)) {
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
834 protocol_status(sn, rq, util_errno2status(vfs->vfs_errno), NULL);
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
835 return REQ_ABORTED;
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
836 }
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
837
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
838 // TODO: if src is a directory, make sure the uri has a trailing path separator
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
839
5653a9626cc0 prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
840
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
841 return REQ_ABORTED;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
842 }
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
843
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
844 int webdav_move(pblock *pb, Session *sn, Request *rq) {
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
845 return REQ_ABORTED;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
846 }
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
847
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
848 int webdav_lock(pblock *pb, Session *sn, Request *rq) {
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
849 return REQ_ABORTED;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
850 }
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
851
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
852 int webdav_unlock(pblock *pb, Session *sn, Request *rq) {
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
853 return REQ_ABORTED;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
854 }
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
855
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
856 int webdav_report(pblock *pb, Session *sn, Request *rq) {
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
857 return REQ_ABORTED;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
858 }
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
859
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
860 int webdav_acl(pblock *pb, Session *sn, Request *rq) {
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
861 return REQ_ABORTED;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
862 }
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
863
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
864
244
e59abb210584 add minimal mkcol implementation and prepare delete
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 243
diff changeset
865
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
866 /* ------------------------ default webdav backend ------------------------ */
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
867
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
868 int default_propfind_init(
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
869 WebdavPropfindRequest *rq,
212
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
870 const char* path,
307
8787cb5ebab3 fix href in pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 306
diff changeset
871 const char *href,
212
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
872 WebdavPList **outplist)
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
873 {
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
874 DefaultWebdavData *data = pool_malloc(
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
875 rq->sn->pool,
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
876 sizeof(DefaultWebdavData));
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
877 if(!data) {
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
878 return 1;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
879 }
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
880 rq->userdata = data;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
881
331
ab26980faad6 implement allprop in default and postgresql webdav backends
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 329
diff changeset
882 data->vfsproperties = webdav_vfs_properties(outplist, TRUE, rq->allprop, 0);
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
883
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
884 return 0;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
885 }
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
886
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
887 int default_propfind_do(
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
888 WebdavPropfindRequest *request,
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
889 WebdavResponse *response,
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
890 VFS_DIR parent,
217
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
891 WebdavResource *resource,
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
892 struct stat *s)
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
893 {
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
894 DefaultWebdavData *data = request->userdata;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
895
478
4dccc47c282e prevent crash in default_propfind_do triggered by bad webdav config
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 476
diff changeset
896 if(!s) {
4dccc47c282e prevent crash in default_propfind_do triggered by bad webdav config
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 476
diff changeset
897 // stat is required for the default vfs
4dccc47c282e prevent crash in default_propfind_do triggered by bad webdav config
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 476
diff changeset
898 // if s is null, the dav backend config is not right
4dccc47c282e prevent crash in default_propfind_do triggered by bad webdav config
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 476
diff changeset
899 // (multiple backends configured and the primary backend doesn't
4dccc47c282e prevent crash in default_propfind_do triggered by bad webdav config
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 476
diff changeset
900 // use the VFS)
4dccc47c282e prevent crash in default_propfind_do triggered by bad webdav config
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 476
diff changeset
901 return 1;
4dccc47c282e prevent crash in default_propfind_do triggered by bad webdav config
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 476
diff changeset
902 }
4dccc47c282e prevent crash in default_propfind_do triggered by bad webdav config
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 476
diff changeset
903
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
904 // add all requested vfs properties like getcontentlength ...
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
905 if(webdav_add_vfs_properties(
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
906 resource,
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
907 request->sn->pool,
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
908 data->vfsproperties,
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
909 s))
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
910 {
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
911 return 1;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
912 }
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
913
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
914 return 0;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
915 }
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
916
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
917 int default_propfind_finish(WebdavPropfindRequest *rq) {
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
918 return 0;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
919 }
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
920
243
1a29b1d8d9d8 add proppatch handler to default backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 242
diff changeset
921 int default_proppatch_do(
1a29b1d8d9d8 add proppatch handler to default backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 242
diff changeset
922 WebdavProppatchRequest *request,
1a29b1d8d9d8 add proppatch handler to default backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 242
diff changeset
923 WebdavResource *response,
1a29b1d8d9d8 add proppatch handler to default backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 242
diff changeset
924 VFSFile *file,
1a29b1d8d9d8 add proppatch handler to default backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 242
diff changeset
925 WebdavPList **setInOut,
1a29b1d8d9d8 add proppatch handler to default backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 242
diff changeset
926 WebdavPList **removeInOut)
1a29b1d8d9d8 add proppatch handler to default backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 242
diff changeset
927 {
1a29b1d8d9d8 add proppatch handler to default backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 242
diff changeset
928 return 0;
1a29b1d8d9d8 add proppatch handler to default backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 242
diff changeset
929 }
1a29b1d8d9d8 add proppatch handler to default backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 242
diff changeset
930
1a29b1d8d9d8 add proppatch handler to default backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 242
diff changeset
931 int default_proppatch_finish(
1a29b1d8d9d8 add proppatch handler to default backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 242
diff changeset
932 WebdavProppatchRequest *request,
1a29b1d8d9d8 add proppatch handler to default backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 242
diff changeset
933 WebdavResource *response,
1a29b1d8d9d8 add proppatch handler to default backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 242
diff changeset
934 VFSFile *file,
1a29b1d8d9d8 add proppatch handler to default backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 242
diff changeset
935 WSBool commit)
1a29b1d8d9d8 add proppatch handler to default backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 242
diff changeset
936 {
1a29b1d8d9d8 add proppatch handler to default backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 242
diff changeset
937 return 0;
1a29b1d8d9d8 add proppatch handler to default backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 242
diff changeset
938 }
1a29b1d8d9d8 add proppatch handler to default backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 242
diff changeset
939
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
940
373
f78a585e1a2f add parser for extended postgresql webdav config
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 366
diff changeset
941
f78a585e1a2f add parser for extended postgresql webdav config
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 366
diff changeset
942 /* ------------------------------ Utils ------------------------------ */
f78a585e1a2f add parser for extended postgresql webdav config
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 366
diff changeset
943
490
d218607f5a7e update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 489
diff changeset
944 CxHashKey webdav_property_key_a(const CxAllocator *a, const char *ns, const char *name) {
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
945 CxHashKey key;
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 414
diff changeset
946 cxmutstr data = cx_asprintf("%s\n%s", name, ns);
481
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 478
diff changeset
947 if(data.ptr) {
490
d218607f5a7e update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 489
diff changeset
948 key.data = data.ptr;
481
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 478
diff changeset
949 key.len = data.length;
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 478
diff changeset
950 cx_hash_murmur(&key);
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 478
diff changeset
951 } else {
490
d218607f5a7e update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 489
diff changeset
952 key.data = NULL;
481
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 478
diff changeset
953 key.len = 0;
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 478
diff changeset
954 key.hash = 0;
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 478
diff changeset
955 }
373
f78a585e1a2f add parser for extended postgresql webdav config
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 366
diff changeset
956 return key;
f78a585e1a2f add parser for extended postgresql webdav config
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 366
diff changeset
957 }
f78a585e1a2f add parser for extended postgresql webdav config
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 366
diff changeset
958
481
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 478
diff changeset
959 CxHashKey webdav_property_key(const char *ns, const char *name) {
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 478
diff changeset
960 return webdav_property_key_a(cxDefaultAllocator, ns, name);
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 478
diff changeset
961 }
373
f78a585e1a2f add parser for extended postgresql webdav config
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 366
diff changeset
962
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
963 /* ------------------------------ public API ------------------------------ */
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
964
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
965 int webdav_getdepth(Request *rq) {
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
966 char *depth_str = pblock_findkeyval(pb_key_depth, rq->headers);
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
967 int depth = 0;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
968 if(depth_str) {
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
969 size_t dlen = strlen(depth_str);
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
970 if(!memcmp(depth_str, "infinity", dlen)) {
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
971 depth = -1;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
972 } else if(dlen == 1 && depth_str[0] == '1') {
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
973 depth = 1;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
974 }
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
975 }
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
976 return depth;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
977 }
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
978
227
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 222
diff changeset
979 int webdav_plist_add(
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 222
diff changeset
980 pool_handle_t *pool,
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 222
diff changeset
981 WebdavPList **begin,
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 222
diff changeset
982 WebdavPList **end,
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 222
diff changeset
983 WebdavProperty *prop)
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 222
diff changeset
984 {
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 222
diff changeset
985 WebdavPList *elm = pool_malloc(pool, sizeof(WebdavPList));
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 222
diff changeset
986 if(!elm) {
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 222
diff changeset
987 return 1;
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 222
diff changeset
988 }
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 222
diff changeset
989 elm->prev = *end;
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 222
diff changeset
990 elm->next = NULL;
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 222
diff changeset
991 elm->property = prop;
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 222
diff changeset
992
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 222
diff changeset
993 if(!*begin) {
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 222
diff changeset
994 *begin = elm;
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 222
diff changeset
995 *end = elm;
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 222
diff changeset
996 return 0;
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 222
diff changeset
997 }
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 222
diff changeset
998
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 222
diff changeset
999 (*end)->next = elm;
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 222
diff changeset
1000 *end = elm;
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 222
diff changeset
1001
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 222
diff changeset
1002 return 0;
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 222
diff changeset
1003 }
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 222
diff changeset
1004
212
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
1005 WebdavPList* webdav_plist_clone(pool_handle_t *pool, WebdavPList *list) {
241
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 240
diff changeset
1006 return webdav_plist_clone_s(pool, list, NULL);
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 240
diff changeset
1007 }
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 240
diff changeset
1008
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 240
diff changeset
1009 WebdavPList* webdav_plist_clone_s(
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 240
diff changeset
1010 pool_handle_t *pool,
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 240
diff changeset
1011 WebdavPList *list,
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 240
diff changeset
1012 size_t *newlen)
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 240
diff changeset
1013 {
212
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
1014 WebdavPList *new_list = NULL; // start of the new list
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
1015 WebdavPList *new_list_end = NULL; // end of the new list
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
1016
241
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 240
diff changeset
1017 size_t len = 0;
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 240
diff changeset
1018
212
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
1019 WebdavPList *elm = list;
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
1020 while(elm) {
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
1021 // copy list item
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
1022 WebdavPList *new_elm = pool_malloc(pool, sizeof(WebdavPList));
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
1023 if(!new_elm) {
241
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 240
diff changeset
1024 if(newlen) *newlen = 0;
212
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
1025 return NULL;
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
1026 }
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
1027 new_elm->property = elm->property; // new list contains original ptr
216
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
1028 new_elm->prev = new_list_end;
212
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
1029 new_elm->next = NULL;
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
1030
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
1031 if(new_list_end) {
216
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
1032 new_list_end->next = new_elm;
212
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
1033 } else {
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
1034 new_list = new_elm;
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
1035 }
216
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
1036 new_list_end = new_elm;
212
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
1037
241
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 240
diff changeset
1038 len++;
212
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
1039 elm = elm->next;
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
1040 }
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
1041
241
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 240
diff changeset
1042 if(newlen) *newlen = len;
212
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
1043 return new_list;
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
1044 }
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
1045
216
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
1046 size_t webdav_plist_size(WebdavPList *list) {
212
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
1047 size_t count = 0;
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
1048 WebdavPList *elm = list;
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
1049 while(elm) {
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
1050 count++;
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
1051 elm = elm->next;
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
1052 }
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
1053 return count;
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
1054 }
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
1055
215
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
1056 WebdavPListIterator webdav_plist_iterator(WebdavPList **list) {
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
1057 WebdavPListIterator i;
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
1058 i.list = list;
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
1059 i.cur = NULL;
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
1060 i.next = *list;
216
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
1061 i.index = 0;
215
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
1062 return i;
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
1063 }
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
1064
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
1065 int webdav_plist_iterator_next(WebdavPListIterator *i, WebdavPList **cur) {
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
1066 if(i->cur) {
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
1067 i->index++;
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
1068 }
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
1069
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
1070 i->cur = i->next;
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
1071 i->next = i->cur ? i->cur->next : NULL;
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
1072 *cur = i->cur;
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
1073
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
1074 return i->cur != NULL;
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
1075 }
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
1076
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
1077 void webdav_plist_iterator_remove_current(WebdavPListIterator *i) {
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
1078 WebdavPList *cur = i->cur;
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
1079 if(cur->prev) {
216
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
1080 cur->prev->next = cur->next;
215
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
1081 if(cur->next) {
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
1082 cur->next->prev = cur->prev;
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
1083 }
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
1084 } else {
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
1085 *i->list = cur->next;
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
1086 if(cur->next) {
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
1087 cur->next->prev = NULL;
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
1088 }
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
1089 }
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
1090 }
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
1091
230
ca50e1ebdc4d readd namespace handling to msresponse_addproperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
1092 int webdav_nslist_add(
ca50e1ebdc4d readd namespace handling to msresponse_addproperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
1093 pool_handle_t *pool,
ca50e1ebdc4d readd namespace handling to msresponse_addproperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
1094 WebdavNSList **begin,
ca50e1ebdc4d readd namespace handling to msresponse_addproperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
1095 WebdavNSList **end,
ca50e1ebdc4d readd namespace handling to msresponse_addproperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
1096 WSNamespace *ns)
ca50e1ebdc4d readd namespace handling to msresponse_addproperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
1097 {
ca50e1ebdc4d readd namespace handling to msresponse_addproperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
1098 // same as webdav_plist_add but with different type
ca50e1ebdc4d readd namespace handling to msresponse_addproperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
1099 WebdavNSList *elm = pool_malloc(pool, sizeof(WebdavNSList));
ca50e1ebdc4d readd namespace handling to msresponse_addproperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
1100 if(!elm) {
ca50e1ebdc4d readd namespace handling to msresponse_addproperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
1101 return 1;
ca50e1ebdc4d readd namespace handling to msresponse_addproperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
1102 }
ca50e1ebdc4d readd namespace handling to msresponse_addproperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
1103 elm->prev = *end;
ca50e1ebdc4d readd namespace handling to msresponse_addproperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
1104 elm->next = NULL;
ca50e1ebdc4d readd namespace handling to msresponse_addproperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
1105 elm->namespace = ns;
ca50e1ebdc4d readd namespace handling to msresponse_addproperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
1106
ca50e1ebdc4d readd namespace handling to msresponse_addproperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
1107 if(!*begin) {
ca50e1ebdc4d readd namespace handling to msresponse_addproperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
1108 *begin = elm;
ca50e1ebdc4d readd namespace handling to msresponse_addproperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
1109 *end = elm;
ca50e1ebdc4d readd namespace handling to msresponse_addproperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
1110 return 0;
ca50e1ebdc4d readd namespace handling to msresponse_addproperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
1111 }
ca50e1ebdc4d readd namespace handling to msresponse_addproperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
1112
ca50e1ebdc4d readd namespace handling to msresponse_addproperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
1113 (*end)->next = elm;
ca50e1ebdc4d readd namespace handling to msresponse_addproperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
1114 *end = elm;
ca50e1ebdc4d readd namespace handling to msresponse_addproperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
1115
ca50e1ebdc4d readd namespace handling to msresponse_addproperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
1116 return 0;
ca50e1ebdc4d readd namespace handling to msresponse_addproperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
1117 }
ca50e1ebdc4d readd namespace handling to msresponse_addproperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
1118
215
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
1119
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1120 WSNamespace* webdav_dav_namespace(void) {
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1121 return &dav_namespace;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1122 }
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1123
306
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 302
diff changeset
1124 WebdavProperty* webdav_resourcetype_collection(void) {
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 302
diff changeset
1125 return &dav_resourcetype_collection;
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 302
diff changeset
1126 }
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 302
diff changeset
1127
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 302
diff changeset
1128 WebdavProperty* webdav_resourcetype_empty(void) {
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 302
diff changeset
1129 return &dav_resourcetype_empty;
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 302
diff changeset
1130 }
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 302
diff changeset
1131
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1132 WebdavProperty* webdav_dav_property(
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1133 pool_handle_t *pool,
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1134 const char *name)
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1135 {
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1136 WebdavProperty *property = pool_malloc(pool, sizeof(WebdavProperty));
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1137 if(!property) {
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1138 return NULL;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1139 }
212
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
1140 memset(property, 0, sizeof(WebdavProperty));
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1141
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1142 property->namespace = &dav_namespace;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1143 property->name = name;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1144 return property;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1145 }
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1146
309
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1147 int webdav_resource_add_dav_stringproperty(
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1148 WebdavResource *res,
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1149 pool_handle_t pool,
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1150 const char *name,
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1151 const char *str,
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1152 size_t len)
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1153 {
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1154 WebdavProperty *property = webdav_dav_property(pool, name);
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1155 if(!property) {
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1156 return 1;
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1157 }
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1158
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1159 property->name = pool_strdup(pool, name);
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1160 if(!property->name) {
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1161 return 1;
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1162 }
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1163
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1164 char *value = pool_malloc(pool, len+1);
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1165 if(!value) {
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1166 return 1;
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1167 }
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1168 memcpy(value, str, len);
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1169 value[len] = '\0';
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1170 property->value.text.str = value;
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1171 property->value.text.length = len;
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1172 property->vtype = WS_VALUE_TEXT;
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1173
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1174 return res->addproperty(res, property, 200);
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1175 }
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1176
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1177 int webdav_resource_add_stringproperty(
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1178 WebdavResource *res,
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1179 pool_handle_t pool,
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1180 const char *xmlns_prefix,
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1181 const char *xmlns_href,
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1182 const char *name,
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1183 const char *str,
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1184 size_t len)
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1185 {
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1186 WebdavProperty *property = pool_malloc(pool, sizeof(WebdavProperty));
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1187 if(!property) {
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1188 return 1;
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1189 }
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1190 memset(property, 0, sizeof(WebdavProperty));
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1191
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1192 property->name = pool_strdup(pool, name);
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1193 if(!property->name) {
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1194 return 1;
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1195 }
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1196
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1197 xmlNs *ns = pool_malloc(pool, sizeof(xmlNs));
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1198 if(!ns) {
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1199 return 1;
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1200 }
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1201 memset(ns, 0, sizeof(xmlNs));
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1202 ns->prefix = (const xmlChar*)pool_strdup(pool, xmlns_prefix);
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1203 ns->href = (const xmlChar*)pool_strdup(pool, xmlns_href);
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1204 if(!ns->prefix || !ns->href) {
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1205 return 1;
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1206 }
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1207
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1208 char *value = pool_malloc(pool, len+1);
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1209 if(!value) {
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1210 return 1;
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1211 }
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1212 memcpy(value, str, len);
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1213 value[len] = '\0';
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1214 property->value.text.str = value;
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1215 property->value.text.length = len;
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1216 property->vtype = WS_VALUE_TEXT;
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1217
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1218 property->value.text.str = value;
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1219 property->value.text.length = len;
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1220 property->vtype = WS_VALUE_TEXT;
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1221
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1222 return res->addproperty(res, property, 200);
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1223 }
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1224
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1225 int webdav_property_set_value(
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1226 WebdavProperty *p,
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1227 pool_handle_t *pool,
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1228 char *value)
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1229 {
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1230 WSXmlNode *node = pool_malloc(pool, sizeof(WSXmlNode));
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1231 if(!node) {
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1232 return 1;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1233 }
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1234 ZERO(node, sizeof(WSXmlNode));
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1235
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1236 node->content = (xmlChar*)value;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1237 node->type = XML_TEXT_NODE;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1238
212
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
1239 p->value.node = node;
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
1240 p->vtype = WS_VALUE_XML_NODE;
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1241 return 0;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1242 }
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1243
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1244 WebdavVFSProperties webdav_vfs_properties(
237
ee1680ef1ef2 handle missing properties in multistatus.c
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 236
diff changeset
1245 WebdavPList **plistInOut,
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1246 WSBool removefromlist,
331
ab26980faad6 implement allprop in default and postgresql webdav backends
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 329
diff changeset
1247 WSBool allprop,
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1248 uint32_t flags)
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1249 {
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1250 WebdavVFSProperties ret;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1251 ZERO(&ret, sizeof(WebdavVFSProperties));
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1252
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1253 WSBool etag = 1;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1254 WSBool creationdate = 1;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1255
237
ee1680ef1ef2 handle missing properties in multistatus.c
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 236
diff changeset
1256 WebdavPListIterator i = webdav_plist_iterator(plistInOut);
ee1680ef1ef2 handle missing properties in multistatus.c
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 236
diff changeset
1257 WebdavPList *cur;
ee1680ef1ef2 handle missing properties in multistatus.c
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 236
diff changeset
1258 while(webdav_plist_iterator_next(&i, &cur)) {
ee1680ef1ef2 handle missing properties in multistatus.c
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 236
diff changeset
1259 WSNamespace *ns = cur->property->namespace;
ee1680ef1ef2 handle missing properties in multistatus.c
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 236
diff changeset
1260 if(ns && !strcmp((const char*)ns->href, "DAV:")) {
ee1680ef1ef2 handle missing properties in multistatus.c
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 236
diff changeset
1261 const char *name = cur->property->name;
318
60870dbac94f add basic pg proppatch implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 309
diff changeset
1262 WSBool remove_prop = removefromlist;
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1263 if(!strcmp(name, "getlastmodified")) {
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1264 ret.getlastmodified = 1;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1265 } else if(!strcmp(name, "getcontentlength")) {
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1266 ret.getcontentlength = 1;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1267 } else if(!strcmp(name, "resourcetype")) {
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1268 ret.getresourcetype = 1;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1269 } else if(etag && !strcmp(name, "getetag")) {
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1270 ret.getetag = 1;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1271 } else if(creationdate && !strcmp(name, "creationdate")) {
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1272 ret.creationdate = 1;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1273 } else {
237
ee1680ef1ef2 handle missing properties in multistatus.c
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 236
diff changeset
1274 remove_prop = FALSE;
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1275 }
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1276
237
ee1680ef1ef2 handle missing properties in multistatus.c
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 236
diff changeset
1277 if(remove_prop) {
ee1680ef1ef2 handle missing properties in multistatus.c
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 236
diff changeset
1278 webdav_plist_iterator_remove_current(&i);
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1279 }
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1280 }
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1281 }
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1282
331
ab26980faad6 implement allprop in default and postgresql webdav backends
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 329
diff changeset
1283 if(allprop) {
ab26980faad6 implement allprop in default and postgresql webdav backends
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 329
diff changeset
1284 ret.creationdate = 1;
ab26980faad6 implement allprop in default and postgresql webdav backends
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 329
diff changeset
1285 ret.getcontentlength = 1;
ab26980faad6 implement allprop in default and postgresql webdav backends
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 329
diff changeset
1286 ret.getetag = 1;
ab26980faad6 implement allprop in default and postgresql webdav backends
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 329
diff changeset
1287 ret.getlastmodified = 1;
ab26980faad6 implement allprop in default and postgresql webdav backends
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 329
diff changeset
1288 ret.getresourcetype = 1;
ab26980faad6 implement allprop in default and postgresql webdav backends
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 329
diff changeset
1289 }
ab26980faad6 implement allprop in default and postgresql webdav backends
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 329
diff changeset
1290
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1291 return ret;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1292 }
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1293
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1294 int webdav_add_vfs_properties(
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1295 WebdavResource *res,
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1296 pool_handle_t *pool,
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1297 WebdavVFSProperties properties,
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1298 struct stat *s)
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1299 {
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1300 if(properties.getresourcetype) {
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1301 if(S_ISDIR(s->st_mode)) {
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1302 res->addproperty(res, &dav_resourcetype_collection, 200);
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1303 } else {
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1304 res->addproperty(res, &dav_resourcetype_empty, 200);
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1305 }
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1306 }
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1307 if(properties.getcontentlength) {
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1308 char *buf = pool_malloc(pool, 64);
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1309 if(!buf) {
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1310 return 1;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1311 }
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1312 uint64_t contentlength = s->st_size;
302
dfbd3a535eac fix some snprintf warnings
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 301
diff changeset
1313 snprintf(buf, 64, "%" PRIu64, contentlength);
309
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1314 if(webdav_resource_add_dav_stringproperty(res, pool, "getcontentlength", buf, strlen(buf))) {
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1315 return 1;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1316 }
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1317 }
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1318 if(properties.getlastmodified) {
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1319 char *buf = pool_malloc(pool, HTTP_DATE_LEN+1);
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1320 if(!buf) {
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1321 return 1;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1322 }
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1323 buf[HTTP_DATE_LEN] = 0;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1324
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1325 struct tm mtms;
453
4586d534f9b5 fix build on macos
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 415
diff changeset
1326 struct tm *mtm = system_gmtime(&s->st_mtime, &mtms);
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1327
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1328 if(mtm) {
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1329 strftime(buf, HTTP_DATE_LEN, HTTP_DATE_FMT, mtm);
309
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1330 if(webdav_resource_add_dav_stringproperty(res, pool, "getlastmodified", buf, strlen(buf))) {
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1331 return 1;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1332 }
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1333 } else {
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1334 return 1;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1335 }
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1336 }
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1337 if(properties.creationdate) {
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1338 // TODO
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1339 }
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1340 if(properties.getetag) {
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1341 char *buf = pool_malloc(pool, 96);
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1342 if(!buf) {
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1343 return 1;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1344 }
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1345 snprintf(buf,
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1346 96,
302
dfbd3a535eac fix some snprintf warnings
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 301
diff changeset
1347 "\"%x-%x\"",
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1348 (int)s->st_size,
453
4586d534f9b5 fix build on macos
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 415
diff changeset
1349 (int)s->st_mtime);
309
fc021bd576d4 implement pg getcontentlength property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1350 if(webdav_resource_add_dav_stringproperty(res, pool, "getetag", buf, strlen(buf))) {
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1351 return 1;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1352 }
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1353 }
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1354
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1355 return 0;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
1356 }

mercurial