src/server/webdav/operation.h

changeset 385
a1f4cb076d2f
parent 252
5653a9626cc0
child 415
d938228c382e
equal deleted inserted replaced
210:21274e5950af 385:a1f4cb076d2f
1 /*
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3 *
4 * Copyright 2019 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 OPERATION_H
30 #define OPERATION_H
31
32 #include "../public/webdav.h"
33 #include <ucx/list.h>
34 #include <ucx/map.h>
35
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39
40 typedef int(*response_close_func)(WebdavOperation *, WebdavResource *);
41
42 typedef struct WebdavVFSOperation WebdavVFSOperation;
43
44 typedef struct WebdavCopy WebdavCopy;
45 typedef struct CopyResource CopyResource;
46
47 struct WebdavOperation {
48 WebdavBackend *dav;
49 Request *rq;
50 Session *sn;
51
52 WebdavProppatchRequest *proppatch; /* proppatch request or NULL */
53 WebdavPList *reqprops; /* requested properties */
54 UcxList *requests; /* backend specific request objects */
55
56 WebdavResponse *response;
57
58 response_close_func response_close;
59
60 VFS_DIR parent; /* current directory */
61 struct stat *stat; /* current stat object */
62 };
63
64 struct WebdavVFSOperation {
65 WebdavBackend *dav;
66 Request *rq;
67 Session *sn;
68
69 VFSContext *vfs;
70
71 char *path;
72 struct stat *stat;
73 int stat_errno;
74 };
75
76 struct WebdavCopy {
77 WebdavResponse response;
78 Session *sn;
79 Request *rq;
80 CopyResource *current;
81
82 char *src_href;
83 char *src_path;
84 char *dst_href;
85 char *dst_path;
86 };
87
88 struct CopyResource {
89 WebdavResource resource;
90 UcxMap *properties;
91 };
92
93 enum WebdavVFSOpType {
94 WEBDAV_VFS_MKDIR = 0,
95 WEBDAV_VFS_DELETE
96 };
97
98 typedef enum WebdavVFSOpType WebdavVFSOpType;
99
100 typedef int(*vfs_op_func)(WebdavVFSRequest *, WSBool *);
101 typedef int(*vfs_op_finish_func)(WebdavVFSRequest *, WSBool);
102
103 typedef int(*vfs_op_child_func)(
104 VFSContext *,
105 const char *, /* href */
106 const char *, /* path */
107 VFSDir *, /* parent dir */
108 struct stat *, /* child stat */
109 void *); /* user data */
110
111 /*
112 * counts the number of backends
113 */
114 size_t webdav_num_backends(WebdavBackend *dav);
115
116 WebdavOperation* webdav_create_propfind_operation(
117 Session *sn,
118 Request *rq,
119 WebdavBackend *dav,
120 WebdavPList *reqprops,
121 UcxList *requests,
122 WebdavResponse *response);
123
124 int webdav_op_propfind_begin(
125 WebdavOperation *op,
126 const char *href,
127 VFS_DIR parent,
128 struct stat *s);
129
130 int webdav_op_propfind_children(
131 WebdavOperation *op,
132 VFSContext *vfs,
133 const char *href,
134 const char *path);
135
136 int webdav_op_propfiond_close_resource(
137 WebdavOperation *op,
138 WebdavResource *resource);
139
140 int webdav_op_propfind_finish(WebdavOperation *op);
141
142 WebdavOperation* webdav_create_proppatch_operation(
143 Session *sn,
144 Request *rq,
145 WebdavBackend *dav,
146 WebdavProppatchRequest *proppatch,
147 WebdavResponse *response);
148
149 int webdav_op_proppatch(
150 WebdavOperation *op,
151 const char *href,
152 const char *path);
153
154 int webdav_op_proppatch_close_resource(
155 WebdavOperation *op,
156 WebdavResource *resource);
157
158
159 WebdavVFSOperation* webdav_vfs_op(
160 Session *sn,
161 Request *rq,
162 WebdavBackend *dav,
163 WSBool precondition);
164
165 WebdavVFSOperation webdav_vfs_sub_op(
166 WebdavVFSOperation *op,
167 char *path,
168 struct stat *s);
169
170 int webdav_op_iterate_children(
171 VFSContext *vfs,
172 int depth,
173 const char *href,
174 const char *path,
175 vfs_op_child_func func,
176 void *userdata);
177
178 int webdav_vfs_stat(WebdavVFSOperation *op);
179
180 int webdav_vfs_op_do(WebdavVFSOperation *op, WebdavVFSOpType type);
181
182 int webdav_vfs_unlink(WebdavVFSOperation *op);
183
184
185 WebdavCopy* webdav_copy_create(
186 Session *sn,
187 Request *rq,
188 VFSContext *vfs,
189 char *from_href,
190 char *from_path,
191 char *to_href,
192 char *to_path);
193
194 #ifdef __cplusplus
195 }
196 #endif
197
198 #endif /* OPERATION_H */
199

mercurial