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