1 /* |
1 /* |
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
3 * |
3 * |
4 * Copyright 2018 Olaf Wintermann. All rights reserved. |
4 * Copyright 2019 Olaf Wintermann. All rights reserved. |
5 * |
5 * |
6 * Redistribution and use in source and binary forms, with or without |
6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions are met: |
7 * modification, are permitted provided that the following conditions are met: |
8 * |
8 * |
9 * 1. Redistributions of source code must retain the above copyright |
9 * 1. Redistributions of source code must retain the above copyright |
42 |
42 |
43 typedef struct WebdavBackend WebdavBackend; |
43 typedef struct WebdavBackend WebdavBackend; |
44 |
44 |
45 typedef struct WebdavProperty WebdavProperty; |
45 typedef struct WebdavProperty WebdavProperty; |
46 typedef struct WebdavPList WebdavPList; |
46 typedef struct WebdavPList WebdavPList; |
|
47 typedef struct WebdavNSList WebdavNSList; |
47 |
48 |
48 typedef enum WebdavLockScope WebdavLockScope; |
49 typedef enum WebdavLockScope WebdavLockScope; |
49 typedef enum WebdavLockType WebdavLockType; |
50 typedef enum WebdavLockType WebdavLockType; |
|
51 |
|
52 typedef enum WebdavValueType WebdavValueType; |
50 |
53 |
51 typedef struct WebdavPropfindRequest WebdavPropfindRequest; |
54 typedef struct WebdavPropfindRequest WebdavPropfindRequest; |
52 typedef struct WebdavProppatchRequest WebdavProppatchRequest; |
55 typedef struct WebdavProppatchRequest WebdavProppatchRequest; |
53 typedef struct WebdavLockRequest WebdavLockRequest; |
56 typedef struct WebdavLockRequest WebdavLockRequest; |
54 |
57 |
55 typedef struct WebdavResponse WebdavResponse; |
58 typedef struct WebdavResponse WebdavResponse; |
56 typedef struct WebdavResource WebdavResource; |
59 typedef struct WebdavResource WebdavResource; |
57 |
60 |
58 typedef struct WebdavVFSProperties WebdavVFSProperties; |
61 typedef struct WebdavVFSProperties WebdavVFSProperties; |
|
62 |
|
63 typedef struct WSXmlData WSXmlData; |
|
64 typedef struct WSText WSText; |
59 |
65 |
60 typedef struct _xmlNs WSNamespace; |
66 typedef struct _xmlNs WSNamespace; |
61 typedef struct _xmlNode WSXmlNode; |
67 typedef struct _xmlNode WSXmlNode; |
62 |
68 |
63 #define WS_NODE_ELEMENT 1 |
69 #define WS_NODE_ELEMENT 1 |
70 /* |
76 /* |
71 * Don't use the vfs to stat files or read the directory children |
77 * Don't use the vfs to stat files or read the directory children |
72 */ |
78 */ |
73 #define WS_PROPFIND_NO_VFS 0x01 |
79 #define WS_PROPFIND_NO_VFS 0x01 |
74 |
80 |
|
81 |
|
82 enum WebdavValueType { |
|
83 WS_VALUE_NO_TYPE = 0, |
|
84 WS_VALUE_XML_NODE, |
|
85 WS_VALUE_XML_DATA, |
|
86 WS_VALUE_TEXT |
|
87 }; |
|
88 |
|
89 struct WSText { |
|
90 char *str; |
|
91 size_t length; |
|
92 }; |
|
93 |
75 struct WebdavProperty { |
94 struct WebdavProperty { |
76 WSNamespace *namespace; |
95 WSNamespace *namespace; |
77 |
96 |
78 const char *name; |
97 const char *name; |
79 |
98 |
80 char *lang; |
99 char *lang; |
81 |
100 |
82 WSXmlNode *value; |
101 union { |
|
102 WSXmlNode *node; |
|
103 WSXmlData *data; |
|
104 WSText text; |
|
105 } value; |
|
106 WebdavValueType vtype; |
|
107 }; |
|
108 |
|
109 struct WSXmlData { |
|
110 WebdavNSList *namespaces; |
|
111 char *data; |
|
112 size_t length; |
83 }; |
113 }; |
84 |
114 |
85 struct WebdavPList { |
115 struct WebdavPList { |
86 WebdavProperty *property; |
116 WebdavProperty *property; |
87 WebdavPList *prev; |
117 WebdavPList *prev; |
88 WebdavPList *next; |
118 WebdavPList *next; |
|
119 }; |
|
120 |
|
121 struct WebdavNSList { |
|
122 WSNamespace *namespace; |
|
123 WebdavNSList *prev; |
|
124 WebdavNSList *next; |
89 }; |
125 }; |
90 |
126 |
91 enum WebdavLockScope { |
127 enum WebdavLockScope { |
92 WEBDAV_LOCK_EXCLUSIVE = 0, |
128 WEBDAV_LOCK_EXCLUSIVE = 0, |
93 WEBDAV_LOCK_SHARED, |
129 WEBDAV_LOCK_SHARED, |
183 * |
219 * |
184 * Initializes a propfind request. This is called once for each propfind |
220 * Initializes a propfind request. This is called once for each propfind |
185 * request and should initialize everything needed for generating the |
221 * request and should initialize everything needed for generating the |
186 * multistatus response. |
222 * multistatus response. |
187 * |
223 * |
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 */ |
224 */ |
191 int (*propfind_init)(WebdavPropfindRequest *, const char *, WebdavPList **); |
225 int (*propfind_init)(WebdavPropfindRequest *, const char *, WebdavPList **); |
192 |
226 |
193 /* |
227 /* |
194 * int propfind_do( |
228 * int propfind_do( |
217 |
251 |
218 /* |
252 /* |
219 * See the WS_PROPFIND_ macros for informations about the settings |
253 * See the WS_PROPFIND_ macros for informations about the settings |
220 */ |
254 */ |
221 uint32_t settings; |
255 uint32_t settings; |
222 }; |
256 |
223 |
257 |
|
258 /* |
|
259 * next Backend |
|
260 */ |
|
261 WebdavBackend *next; |
|
262 }; |
|
263 |
|
264 /* |
|
265 * gets the requested depth |
|
266 * |
|
267 * in case of infinity, -1 is returned |
|
268 * if no depth is specified, 0 is returned |
|
269 */ |
224 int webdav_getdepth(Request *rq); |
270 int webdav_getdepth(Request *rq); |
|
271 |
|
272 WebdavPList* webdav_plist_clone(pool_handle_t *pool, WebdavPList *list); |
|
273 |
|
274 size_t webdav_plist_count(WebdavPList *list); |
225 |
275 |
226 WSNamespace* webdav_dav_namespace(void); |
276 WSNamespace* webdav_dav_namespace(void); |
227 WebdavProperty* webdav_dav_property( |
277 WebdavProperty* webdav_dav_property( |
228 pool_handle_t *pool, |
278 pool_handle_t *pool, |
229 const char *name); |
279 const char *name); |