Sat, 29 Dec 2012 18:08:23 +0100
added ldap authentication
13 | 1 | /* |
2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. | |
3 | * | |
4 | * Copyright 2011 Olaf Wintermann. All rights reserved. | |
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; |
29
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
135 | }; |
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
136 | |
26
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
137 | /* |
30
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
138 | * dav_propfind_f |
26
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
139 | * |
30
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
140 | * 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
|
141 | * should add properties with dav_propfind_add_str_prop or |
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
142 | * 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
|
143 | * dav_propfind_add_prop_error |
26
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
144 | * |
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 | * arg0: property backend |
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
147 | * arg1: current PropfindRequest object |
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
148 | * arg2: the webdav resource path |
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
149 | */ |
30
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
150 | 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
|
151 | |
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 | * dav_proppatch_f |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
154 | * |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
155 | * 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
|
156 | * propstat object (member of the ProppatchRequest). |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
157 | * |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
158 | * arg0: WebDAV backend |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
159 | * arg1: current ProppatchRequest object |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
160 | */ |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
161 | typedef void(*dav_proppatch_f)(DAVPropertyBackend*,ProppatchRequest*); |
13 | 162 | |
163 | struct DAVPropertyBackend { | |
30
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
164 | dav_propfind_f propfind; |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
165 | dav_proppatch_f proppatch; |
13 | 166 | }; |
167 | ||
168 | int webdav_service(pblock *pb, Session *sn, Request *rq); | |
27
05b7576dca2b
added put method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
26
diff
changeset
|
169 | 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
|
170 | 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
|
171 | 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
|
172 | 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
|
173 | int webdav_move(pblock *pb, Session *sn, Request *rq); |
26
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
174 | int webdav_propfind(pblock *pb, Session *sn, Request *rq); |
29
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
175 | int webdav_proppatch(pblock *pb, Session *sn, Request *rq); |
13 | 176 | |
26
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
177 | void dav_resource_response(PropfindRequest *rq, sstr_t path, sstr_t uri); |
13 | 178 | |
26
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
179 | /* |
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
180 | * dav_propfind_add_str_prop |
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
181 | * |
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
182 | * Adds a string property to the current WebDAV resource response |
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
183 | */ |
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
184 | void dav_propfind_add_str_prop( |
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
185 | PropfindRequest *rq, |
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
186 | DavProperty* prop, |
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
187 | char *str, |
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
188 | size_t len); |
13 | 189 | |
26
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
190 | //void dav_propfind_add_xml_prop(); |
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
191 | |
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 | * dav_propfind_add_prop_error |
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
194 | * |
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
195 | * Adds a unavailable property to the response |
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
196 | * |
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
197 | * rq: propfind request object |
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
198 | * prop: unavailable property |
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
199 | * error: HTTP status code |
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
200 | */ |
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
201 | void dav_propfind_add_prop_error( |
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
202 | PropfindRequest *rq, |
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
203 | DavProperty *prop, |
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
204 | int error); |
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
205 | |
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
206 | |
13 | 207 | |
208 | DAVPropertyBackend* create_property_backend(); | |
30
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
209 | 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
|
210 | 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
|
211 | |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
212 | /*---------------------------------- utils ----------------------------------*/ |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
213 | |
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 | * XmlNsMap |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
216 | * |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
217 | * a map containing xml namespaces |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
218 | * |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
219 | * key: namespace uri |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
220 | * 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
|
221 | */ |
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 | XmlNsMap* xmlnsmap_create(); |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
224 | |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
225 | void xmlnsmap_free(XmlNsMap *map); |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
226 | |
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 | * 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
|
229 | * available XmlNs object is returned |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
230 | */ |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
231 | XmlNs* xmlnsmap_put(XmlNsMap *map, char *ns); |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
232 | |
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 | * 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
|
235 | * map |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
236 | */ |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
237 | XmlNs* xmlnsmap_get(XmlNsMap *map, char *ns); |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
238 | |
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 | * XmlElement |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
243 | * |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
244 | * representing a xml element |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
245 | */ |
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 | * 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
|
249 | */ |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
250 | 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
|
251 | |
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 | * 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
|
254 | * 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
|
255 | */ |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
256 | 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
|
257 | |
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 | * PropstatMap |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
261 | * |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
262 | * A map containing multiple propstat objects |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
263 | * |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
264 | * key: status code: int |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
265 | * value: prop list: UcxDlist* (list of XmlElement*) |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
266 | */ |
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 | * creates a new Propstat |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
271 | */ |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
272 | Propstat* propstat_create(pool_handle_t *pool); |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
273 | |
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 | * adds a property to the propstat map |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
277 | * |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
278 | * propstat: propstat object |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
279 | * status: http status code |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
280 | * prop: WebDAV property |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
281 | */ |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
282 | 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
|
283 | |
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 | * 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
|
286 | * 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
|
287 | * |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
288 | * propstat: propstat object |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
289 | * out: output buffer |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
290 | * wv: property output mode |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
291 | */ |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
292 | void propstat_write(Propstat *propstat, sbuf_t *out, int wv); |
13 | 293 | |
294 | #ifdef __cplusplus | |
295 | } | |
296 | #endif | |
297 | ||
298 | #endif /* WEBDAV_H */ | |
299 |