28 |
28 |
29 #ifndef WS_WEBDAV_H |
29 #ifndef WS_WEBDAV_H |
30 #define WS_WEBDAV_H |
30 #define WS_WEBDAV_H |
31 |
31 |
32 #include "nsapi.h" |
32 #include "nsapi.h" |
|
33 #include "vfs.h" |
33 |
34 |
34 #include <sys/file.h> |
35 #include <sys/file.h> |
35 #include <sys/stat.h> |
36 #include <sys/stat.h> |
36 #include <inttypes.h> |
37 #include <inttypes.h> |
37 |
38 |
38 #ifdef __cplusplus |
39 #ifdef __cplusplus |
39 extern "C" { |
40 extern "C" { |
40 #endif |
41 #endif |
41 |
42 |
42 |
43 typedef struct WebdavBackend WebdavBackend; |
|
44 |
|
45 typedef struct WebdavProperty WebdavProperty; |
|
46 typedef struct WebdavPList WebdavPList; |
|
47 |
|
48 typedef enum WebdavLockScope WebdavLockScope; |
|
49 typedef enum WebdavLockType WebdavLockType; |
|
50 |
|
51 typedef struct WebdavPropfindRequest WebdavPropfindRequest; |
|
52 typedef struct WebdavProppatchRequest WebdavProppatchRequest; |
|
53 typedef struct WebdavLockRequest WebdavLockRequest; |
|
54 |
|
55 typedef struct WebdavResponse WebdavResponse; |
|
56 typedef struct WebdavResource WebdavResource; |
|
57 |
|
58 typedef struct WebdavVFSProperties WebdavVFSProperties; |
|
59 |
|
60 typedef struct _xmlNs WSNamespace; |
|
61 typedef struct _xmlNode WSXmlNode; |
|
62 |
|
63 #define WS_NODE_ELEMENT 1 |
|
64 #define WS_NODE_TEXT 3 |
|
65 #define WS_NODE_CDATA 4 |
|
66 #define WS_NODE_ENTITY_REF 5 |
|
67 |
|
68 /* propfind settings */ |
|
69 |
|
70 /* |
|
71 * Don't use the vfs to stat files or read the directory children |
|
72 */ |
|
73 #define WS_PROPFIND_NO_VFS 0x01 |
|
74 |
|
75 struct WebdavProperty { |
|
76 WSNamespace *namespace; |
|
77 |
|
78 const char *name; |
|
79 |
|
80 char *lang; |
|
81 |
|
82 WSXmlNode *value; |
|
83 }; |
|
84 |
|
85 struct WebdavPList { |
|
86 WebdavProperty *property; |
|
87 WebdavPList *prev; |
|
88 WebdavPList *next; |
|
89 }; |
|
90 |
|
91 enum WebdavLockScope { |
|
92 WEBDAV_LOCK_EXCLUSIVE = 0, |
|
93 WEBDAV_LOCK_SHARED, |
|
94 WEBDAV_LOCK_SCOPE_UNKNOWN |
|
95 }; |
|
96 |
|
97 enum WebdavLockType { |
|
98 WEBDAV_LOCK_WRITE = 0, |
|
99 WEBDAV_LOCK_TYPE_UNKNOWN |
|
100 }; |
|
101 |
|
102 struct WebdavPropfindRequest { |
|
103 Session *sn; |
|
104 Request *rq; |
|
105 |
|
106 void *doc; |
|
107 |
|
108 /* |
|
109 * list of requested properties |
|
110 */ |
|
111 WebdavPList *properties; |
|
112 |
|
113 /* |
|
114 * number of properties |
|
115 */ |
|
116 size_t propcount; |
|
117 |
|
118 WSBool allprop; |
|
119 WSBool propname; |
|
120 |
|
121 int depth; |
|
122 |
|
123 /* |
|
124 * custom userdata for the backend |
|
125 */ |
|
126 void *userdata; |
|
127 }; |
|
128 |
|
129 struct WebdavProppatchRequest { |
|
130 Session *sn; |
|
131 Request *rq; |
|
132 |
|
133 void *doc; |
|
134 |
|
135 WebdavPList *set; |
|
136 size_t setcount; |
|
137 |
|
138 WebdavPList *remove; |
|
139 size_t removecount; |
|
140 }; |
|
141 |
|
142 struct WebdavLockRequest { |
|
143 Session *sn; |
|
144 Request *rq; |
|
145 |
|
146 void *doc; |
|
147 |
|
148 WebdavLockScope scope; |
|
149 WebdavLockType type; |
|
150 |
|
151 WSXmlNode *owner; |
|
152 }; |
|
153 |
|
154 struct WebdavVFSProperties { |
|
155 uint32_t getcontentlength:1; |
|
156 uint32_t getlastmodified:1; |
|
157 uint32_t getresourcetype:1; |
|
158 uint32_t getetag:1; |
|
159 uint32_t creationdate:1; |
|
160 }; |
|
161 |
|
162 struct WebdavResponse { |
|
163 WebdavResource* (*addresource)(WebdavResponse*, const char*); |
|
164 }; |
|
165 |
|
166 struct WebdavResource { |
|
167 char *href; |
|
168 |
|
169 /* |
|
170 * int addprop(WebdavResource *res, WebdavProperty *property, int status); |
|
171 * |
|
172 * Adds a property to the resource |
|
173 */ |
|
174 int (*addproperty)(WebdavResource*, WebdavProperty*, int); |
|
175 }; |
|
176 |
|
177 struct WebdavBackend { |
|
178 /* |
|
179 * int propfind_init( |
|
180 * WebdavPropfindRequest *rq, |
|
181 * const char *path, |
|
182 * WebdavPList **outplist); |
|
183 * |
|
184 * Initializes a propfind request. This is called once for each propfind |
|
185 * request and should initialize everything needed for generating the |
|
186 * multistatus response. |
|
187 * |
|
188 * Optionally, the function can store a pointer to a list of all properties, |
|
189 * which will be processed by this backend, in the outplist argument. |
|
190 */ |
|
191 int (*propfind_init)(WebdavPropfindRequest *, const char *, WebdavPList **); |
|
192 |
|
193 /* |
|
194 * int propfind_do( |
|
195 * WebdavPropfindRequest *rq, |
|
196 * WebdavResponse *response, |
|
197 * VFS_DIR parent, |
|
198 * const char *path, |
|
199 * struct stat *s); |
|
200 * |
|
201 * This function is called for the requsted resource and for all children |
|
202 * if WS_PROPFIND_NO_VFS_CHILDREN is not set. |
|
203 */ |
|
204 int (*propfind_do)( |
|
205 WebdavPropfindRequest *, |
|
206 WebdavResponse *, |
|
207 VFS_DIR, |
|
208 const char *, |
|
209 struct stat *); |
|
210 |
|
211 /* |
|
212 * int propfind_finish(WebdavPropfindRequest *rq); |
|
213 * |
|
214 * Finishes a propfind request. |
|
215 */ |
|
216 int (*propfind_finish)(WebdavPropfindRequest *); |
|
217 |
|
218 /* |
|
219 * See the WS_PROPFIND_ macros for informations about the settings |
|
220 */ |
|
221 uint32_t settings; |
|
222 }; |
|
223 |
|
224 int webdav_getdepth(Request *rq); |
|
225 |
|
226 WSNamespace* webdav_dav_namespace(void); |
|
227 WebdavProperty* webdav_dav_property( |
|
228 pool_handle_t *pool, |
|
229 const char *name); |
|
230 |
|
231 int webdav_property_set_value( |
|
232 WebdavProperty *p, |
|
233 pool_handle_t *pool, |
|
234 char *value); |
|
235 |
|
236 WebdavVFSProperties webdav_vfs_properties( |
|
237 WebdavPropfindRequest *rq, |
|
238 WSBool removefromlist, |
|
239 uint32_t flags); |
|
240 |
|
241 int webdav_add_vfs_properties( |
|
242 WebdavResource *res, |
|
243 pool_handle_t *pool, |
|
244 WebdavVFSProperties properties, |
|
245 struct stat *s); |
43 |
246 |
44 #ifdef __cplusplus |
247 #ifdef __cplusplus |
45 } |
248 } |
46 #endif |
249 #endif |
47 |
250 |