30 |
30 |
31 #include "../daemon/log.h" |
31 #include "../daemon/log.h" |
32 #include "../daemon/request.h" |
32 #include "../daemon/request.h" |
33 #include "../util/pblock.h" |
33 #include "../util/pblock.h" |
34 #include "../util/util.h" |
34 #include "../util/util.h" |
|
35 #include "../public/webdav.h" |
35 |
36 |
36 #include "../public/vfs.h" |
37 #include "../public/vfs.h" |
37 |
38 |
38 static int nametrans_set_vfs(pblock *pb, Session *sn, Request *rq) { |
39 static int nametrans_set_vfs(pblock *pb, Session *sn, Request *rq) { |
39 char *vfsclass = pblock_findkeyval(pb_key_vfsclass, pb); |
40 char *vfsclass = pblock_findkeyval(pb_key_vfsclass, pb); |
42 VFS *vfs = vfs_create(sn, rq, vfsclass, pb); |
43 VFS *vfs = vfs_create(sn, rq, vfsclass, pb); |
43 if(!vfs) { |
44 if(!vfs) { |
44 return 1; |
45 return 1; |
45 } |
46 } |
46 rq->vfs = vfs; |
47 rq->vfs = vfs; |
|
48 return 0; |
|
49 } |
|
50 |
|
51 static int nametrans_set_dav(pblock *pb, Session *sn, Request *rq) { |
|
52 char *davclass = pblock_findkeyval(pb_key_davclass, pb); |
|
53 if(!davclass) return 0; |
|
54 |
|
55 WebdavBackend *dav = webdav_create(sn, rq, davclass, pb); |
|
56 |
|
57 rq->davCollection = dav; |
47 return 0; |
58 return 0; |
48 } |
59 } |
49 |
60 |
50 /* |
61 /* |
51 * assign_name |
62 * assign_name |
128 * |
139 * |
129 * pblock parameter: |
140 * pblock parameter: |
130 * from prefix |
141 * from prefix |
131 * dir file system directory |
142 * dir file system directory |
132 * name (optional) object name |
143 * name (optional) object name |
|
144 * vfsclass (optional) vfs name |
|
145 * davclass (optional) dav backend |
133 * |
146 * |
134 */ |
147 */ |
135 int pfx2dir(pblock *pb, Session *sn, Request *rq) { |
148 int pfx2dir(pblock *pb, Session *sn, Request *rq) { |
136 char *from = pblock_findkeyval(pb_key_from, pb); |
149 char *from = pblock_findkeyval(pb_key_from, pb); |
137 char *dir = pblock_findkeyval(pb_key_dir, pb); |
150 char *dir = pblock_findkeyval(pb_key_dir, pb); |
171 uri++; |
184 uri++; |
172 } |
185 } |
173 |
186 |
174 if(nametrans_set_vfs(pb, sn, rq)) { |
187 if(nametrans_set_vfs(pb, sn, rq)) { |
175 log_ereport(LOG_FAILURE, "pfx2dir: cannot create VFS: from=%s dir=%s name=%s", from, dir, name); |
188 log_ereport(LOG_FAILURE, "pfx2dir: cannot create VFS: from=%s dir=%s name=%s", from, dir, name); |
|
189 return REQ_ABORTED; |
|
190 } |
|
191 if(nametrans_set_dav(pb, sn, rq)) { |
|
192 log_ereport(LOG_FAILURE, "pfx2dir: cannot create Webdav Backend: from=%s dir=%s name=%s", from, dir, name); |
176 return REQ_ABORTED; |
193 return REQ_ABORTED; |
177 } |
194 } |
178 |
195 |
179 request_set_path(sstr(dir), sstr(uri), rq->vars); |
196 request_set_path(sstr(dir), sstr(uri), rq->vars); |
180 |
197 |