62 static void init_default_backend(void) { |
62 static void init_default_backend(void) { |
63 memset(&default_backend, 0, sizeof(WebdavBackend)); |
63 memset(&default_backend, 0, sizeof(WebdavBackend)); |
64 default_backend.propfind_init = default_propfind_init; |
64 default_backend.propfind_init = default_propfind_init; |
65 default_backend.propfind_do = default_propfind_do; |
65 default_backend.propfind_do = default_propfind_do; |
66 default_backend.propfind_finish = default_propfind_finish; |
66 default_backend.propfind_finish = default_propfind_finish; |
|
67 default_backend.proppatch_do = NULL; |
|
68 default_backend.proppatch_finish = NULL; |
|
69 default_backend.settings = WS_WEBDAV_PROPFIND_USE_VFS; |
67 } |
70 } |
68 |
71 |
69 int webdav_init(pblock *pb, Session *sn, Request *rq) { |
72 int webdav_init(pblock *pb, Session *sn, Request *rq) { |
70 init_default_backend(); |
73 init_default_backend(); |
71 |
74 |
240 struct stat *statptr = NULL; |
243 struct stat *statptr = NULL; |
241 |
244 |
242 VFSContext *vfs = NULL; |
245 VFSContext *vfs = NULL; |
243 if(usevfs) { |
246 if(usevfs) { |
244 vfs = vfs_request_context(sn, rq); |
247 vfs = vfs_request_context(sn, rq); |
|
248 if(!vfs) { |
|
249 return REQ_ABORTED; |
|
250 } |
245 |
251 |
246 if(vfs_stat(vfs, path, &s)) { |
252 if(vfs_stat(vfs, path, &s)) { |
247 protocol_status(sn, rq, util_errno2status(vfs->vfs_errno), NULL); |
253 protocol_status(sn, rq, util_errno2status(vfs->vfs_errno), NULL); |
248 return REQ_ABORTED; |
254 return REQ_ABORTED; |
249 } |
255 } |
489 |
495 |
490 return 0; |
496 return 0; |
491 } |
497 } |
492 |
498 |
493 WebdavPList* webdav_plist_clone(pool_handle_t *pool, WebdavPList *list) { |
499 WebdavPList* webdav_plist_clone(pool_handle_t *pool, WebdavPList *list) { |
|
500 return webdav_plist_clone_s(pool, list, NULL); |
|
501 } |
|
502 |
|
503 WebdavPList* webdav_plist_clone_s( |
|
504 pool_handle_t *pool, |
|
505 WebdavPList *list, |
|
506 size_t *newlen) |
|
507 { |
494 WebdavPList *new_list = NULL; // start of the new list |
508 WebdavPList *new_list = NULL; // start of the new list |
495 WebdavPList *new_list_end = NULL; // end of the new list |
509 WebdavPList *new_list_end = NULL; // end of the new list |
|
510 |
|
511 size_t len = 0; |
496 |
512 |
497 WebdavPList *elm = list; |
513 WebdavPList *elm = list; |
498 while(elm) { |
514 while(elm) { |
499 // copy list item |
515 // copy list item |
500 WebdavPList *new_elm = pool_malloc(pool, sizeof(WebdavPList)); |
516 WebdavPList *new_elm = pool_malloc(pool, sizeof(WebdavPList)); |
501 if(!new_elm) { |
517 if(!new_elm) { |
|
518 if(newlen) *newlen = 0; |
502 return NULL; |
519 return NULL; |
503 } |
520 } |
504 new_elm->property = elm->property; // new list contains original ptr |
521 new_elm->property = elm->property; // new list contains original ptr |
505 new_elm->prev = new_list_end; |
522 new_elm->prev = new_list_end; |
506 new_elm->next = NULL; |
523 new_elm->next = NULL; |