Tue, 19 Mar 2013 17:38:32 +0100
webdav uses the vfs api
13 | 1 | /* |
2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. | |
3 | * | |
44
3da1f7b6847f
added some error messages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
30
diff
changeset
|
4 | * Copyright 2013 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 | #ifndef WEBDAV_H | |
30 | #define WEBDAV_H | |
31 | ||
14
b8bf95b39952
New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
13
diff
changeset
|
32 | #include "../public/nsapi.h" |
13 | 33 | |
34 | #include <sys/file.h> | |
35 | #include <sys/stat.h> | |
36 | ||
30
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
37 | #include <inttypes.h> |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
38 | |
15
cff9c4101dd7
Replaced old utils with ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
39 | #include "../ucx/map.h" |
14
b8bf95b39952
New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
13
diff
changeset
|
40 | #include "../ucx/dlist.h" |
b8bf95b39952
New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
13
diff
changeset
|
41 | #include "../util/strbuf.h" |
13 | 42 | |
43 | #ifdef __cplusplus | |
44 | extern "C" { | |
45 | #endif | |
46 | ||
26
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
47 | #define DAV_FOREACH(elem, list) \ |
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
48 | for (UcxDlist *elem = list ; elem != NULL ; elem = elem->next) |
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
49 | |
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
50 | typedef struct PropfindResponse PropfindResponse; |
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
51 | typedef struct DAVPropertyBackend DAVPropertyBackend; |
13 | 52 | |
26
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
53 | typedef struct PropfindRequest PropfindRequest; |
29
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
54 | typedef struct ProppatchRequest ProppatchRequest; |
26
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
55 | typedef struct DavProperty DavProperty; |
30
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
56 | |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
57 | typedef struct Propstat Propstat; |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
58 | |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
59 | typedef struct XmlNs XmlNs; |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
60 | typedef struct XmlNsMap XmlNsMap; |
29
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
61 | |
30
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
62 | typedef struct XmlData XmlData; |
29
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
63 | typedef struct XmlElement XmlElement; |
13 | 64 | |
30
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
65 | typedef uint8_t xmlch_t; |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
66 | |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
67 | |
13 | 68 | struct PropfindRequest { |
69 | Session *sn; | |
70 | Request *rq; | |
71 | ||
26
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
72 | UcxDlist *properties; /* DavProperty list, requested props */ |
13 | 73 | int8_t allprop; |
74 | int8_t propname; | |
26
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
75 | |
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
76 | int8_t prop; |
13 | 77 | UcxDlist *notFoundProps; |
78 | UcxDlist *forbiddenProps; | |
79 | DAVPropertyBackend *propertyBackend; | |
80 | ||
81 | char *path; | |
82 | char *uri; | |
83 | ||
84 | sbuf_t *out; | |
85 | }; | |
86 | ||
29
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
87 | struct ProppatchRequest { |
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
88 | Session *sn; |
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
89 | Request *rq; |
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
90 | |
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
91 | UcxDlist *setProps; /* XmlElement list, set props */ |
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
92 | UcxDlist *removeProps; /* DavProperty list, remove props */ |
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
93 | |
30
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
94 | Propstat *propstat; |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
95 | XmlNsMap *nsmap; |
29
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
96 | |
30
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
97 | DAVPropertyBackend *backend; |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
98 | |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
99 | |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
100 | sbuf_t *out; |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
101 | }; |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
102 | |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
103 | struct Propstat { |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
104 | UcxDlist *okprop; /* properties with status 200 OK */ |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
105 | UcxMap *map; /* all other properties */ |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
106 | pool_handle_t *pool; |
29
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
107 | }; |
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
108 | |
13 | 109 | struct DavProperty { |
110 | char *xmlns; | |
111 | char *name; | |
112 | }; | |
113 | ||
30
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
114 | struct XmlData { |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
115 | XmlNsMap *nsmap; |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
116 | XmlElement *elm; |
29
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
117 | }; |
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
118 | |
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
119 | struct XmlElement { |
30
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
120 | XmlNs *xmlns; |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
121 | sstr_t name; |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
122 | void *content; /* xmlch* or UcxDlist* */ |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
123 | size_t ctlen; /* content string length. If 0, content is a UcxDlist */ |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
124 | }; |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
125 | |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
126 | struct XmlNs { |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
127 | char *xmlns; |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
128 | char *prefix; |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
129 | int nslen; |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
130 | int prelen; |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
131 | }; |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
132 | |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
133 | struct XmlNsMap { |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
134 | UcxMap *map; |
48
37a512d7b8f6
fixed some memory leaks
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
135 | pool_handle_t *pool; |
29
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
136 | }; |
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
137 | |
26
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
138 | /* |
30
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
139 | * dav_propfind_f |
26
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
140 | * |
30
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
141 | * Gets all requested properties for a WebDAV resource(file). This function |
26
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
142 | * should add properties with dav_propfind_add_str_prop or |
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
143 | * dav_prop_add_xml_prop. Unavailable properties should be added with |
30
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
144 | * dav_propfind_add_prop_error |
26
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
145 | * |
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
146 | * |
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
147 | * arg0: property backend |
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
148 | * arg1: current PropfindRequest object |
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
149 | * arg2: the webdav resource path |
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
150 | */ |
30
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
151 | typedef void(*dav_propfind_f)(DAVPropertyBackend*,PropfindRequest*,char*); |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
152 | |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
153 | /* |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
154 | * dav_proppatch_f |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
155 | * |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
156 | * Sets properties for a WebDAV resource. It should add all properties to the |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
157 | * propstat object (member of the ProppatchRequest). |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
158 | * |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
159 | * arg0: WebDAV backend |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
160 | * arg1: current ProppatchRequest object |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
161 | */ |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
162 | typedef void(*dav_proppatch_f)(DAVPropertyBackend*,ProppatchRequest*); |
13 | 163 | |
164 | struct DAVPropertyBackend { | |
30
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
165 | dav_propfind_f propfind; |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
166 | dav_proppatch_f proppatch; |
13 | 167 | }; |
168 | ||
169 | int webdav_service(pblock *pb, Session *sn, Request *rq); | |
27
05b7576dca2b
added put method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
26
diff
changeset
|
170 | int webdav_put(pblock *pb, Session *sn, Request *rq); |
30
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
171 | int webdav_delete(pblock *pb, Session *sn, Request *rq); |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
172 | int webdav_mkcol(pblock *pb, Session *sn, Request *rq); |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
173 | int webdav_copy(pblock *pb, Session *sn, Request *rq); |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
174 | int webdav_move(pblock *pb, Session *sn, Request *rq); |
26
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
175 | int webdav_propfind(pblock *pb, Session *sn, Request *rq); |
29
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
176 | int webdav_proppatch(pblock *pb, Session *sn, Request *rq); |
13 | 177 | |
26
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
178 | void dav_resource_response(PropfindRequest *rq, sstr_t path, sstr_t uri); |
13 | 179 | |
26
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
180 | /* |
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
181 | * dav_propfind_add_str_prop |
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
182 | * |
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
183 | * Adds a string property to the current WebDAV resource response |
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
184 | */ |
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
185 | void dav_propfind_add_str_prop( |
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
186 | PropfindRequest *rq, |
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
187 | DavProperty* prop, |
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
188 | char *str, |
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
189 | size_t len); |
13 | 190 | |
26
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
191 | //void dav_propfind_add_xml_prop(); |
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
192 | |
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
193 | /* |
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
194 | * dav_propfind_add_prop_error |
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
195 | * |
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
196 | * Adds a unavailable property to the response |
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
197 | * |
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
198 | * rq: propfind request object |
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
199 | * prop: unavailable property |
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
200 | * error: HTTP status code |
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
201 | */ |
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
202 | void dav_propfind_add_prop_error( |
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
203 | PropfindRequest *rq, |
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
204 | DavProperty *prop, |
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
205 | int error); |
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
206 | |
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
207 | |
13 | 208 | |
209 | DAVPropertyBackend* create_property_backend(); | |
30
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
210 | void dav_rq_propfind(DAVPropertyBackend *b, PropfindRequest *rq, char *path); |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
211 | void dav_rq_proppatch(DAVPropertyBackend *b, ProppatchRequest *rq); |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
212 | |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
213 | /*---------------------------------- utils ----------------------------------*/ |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
214 | |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
215 | /* |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
216 | * XmlNsMap |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
217 | * |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
218 | * a map containing xml namespaces |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
219 | * |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
220 | * key: namespace uri |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
221 | * value: XmlNs object, containing namespace uri and the prefix |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
222 | */ |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
223 | |
48
37a512d7b8f6
fixed some memory leaks
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
224 | XmlNsMap* xmlnsmap_create(pool_handle_t *pool); |
30
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
225 | |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
226 | void xmlnsmap_free(XmlNsMap *map); |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
227 | |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
228 | /* |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
229 | * Puts a namespace in the map. If the namespace is already in the map, the |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
230 | * available XmlNs object is returned |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
231 | */ |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
232 | XmlNs* xmlnsmap_put(XmlNsMap *map, char *ns); |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
233 | |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
234 | /* |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
235 | * Gets a namespace from the map. Returns NULL if the namespace is not in the |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
236 | * map |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
237 | */ |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
238 | XmlNs* xmlnsmap_get(XmlNsMap *map, char *ns); |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
239 | |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
240 | |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
241 | |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
242 | /* |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
243 | * XmlElement |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
244 | * |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
245 | * representing a xml element |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
246 | */ |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
247 | |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
248 | /* |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
249 | * adds a xml element to a parent element |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
250 | */ |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
251 | void xmlelm_add_child(XmlElement *parent, XmlElement *child); |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
252 | |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
253 | /* |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
254 | * writes an xml element to an output buffer |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
255 | * if wv is true, it writes the complete value of the element |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
256 | */ |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
257 | void xmlelm_write(XmlElement *elm, sbuf_t *out, int wv); |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
258 | |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
259 | |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
260 | /* |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
261 | * PropstatMap |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
262 | * |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
263 | * A map containing multiple propstat objects |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
264 | * |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
265 | * key: status code: int |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
266 | * value: prop list: UcxDlist* (list of XmlElement*) |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
267 | */ |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
268 | |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
269 | |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
270 | /* |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
271 | * creates a new Propstat |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
272 | */ |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
273 | Propstat* propstat_create(pool_handle_t *pool); |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
274 | |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
275 | |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
276 | /* |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
277 | * adds a property to the propstat map |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
278 | * |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
279 | * propstat: propstat object |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
280 | * status: http status code |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
281 | * prop: WebDAV property |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
282 | */ |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
283 | void propstat_add(Propstat *propstat, int status, XmlElement *prop); |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
284 | |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
285 | /* |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
286 | * writes the propstat object to an output buffer |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
287 | * if wv is true, it writes the values of the 'OK' properties |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
288 | * |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
289 | * propstat: propstat object |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
290 | * out: output buffer |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
291 | * wv: property output mode |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
292 | */ |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
293 | void propstat_write(Propstat *propstat, sbuf_t *out, int wv); |
13 | 294 | |
295 | #ifdef __cplusplus | |
296 | } | |
297 | #endif | |
298 | ||
299 | #endif /* WEBDAV_H */ | |
300 |