42 #include "versioning.h" |
42 #include "versioning.h" |
43 #include "multistatus.h" |
43 #include "multistatus.h" |
44 #include "requestparser.h" |
44 #include "requestparser.h" |
45 #include "operation.h" |
45 #include "operation.h" |
46 |
46 |
|
47 #include "xattrbackend.h" |
|
48 |
47 #include "../util/pblock.h" |
49 #include "../util/pblock.h" |
48 #include "../util/util.h" |
50 #include "../util/util.h" |
49 #include "../daemon/session.h" |
51 #include "../daemon/session.h" |
50 #include "../daemon/http.h" |
52 #include "../daemon/http.h" |
51 #include "../daemon/protocol.h" |
53 #include "../daemon/protocol.h" |
73 static WebdavProperty dav_resourcetype_collection; |
75 static WebdavProperty dav_resourcetype_collection; |
74 static WSXmlData dav_resourcetype_collection_value; |
76 static WSXmlData dav_resourcetype_collection_value; |
75 |
77 |
76 #define WEBDAV_RESOURCE_TYPE_COLLECTION "<D:collection/>" |
78 #define WEBDAV_RESOURCE_TYPE_COLLECTION "<D:collection/>" |
77 |
79 |
78 static void init_default_backend(void) { |
80 |
|
81 static WebdavBackend* default_backend_create(Session *sn, Request *rq, pblock *pb, void *initData) { |
|
82 WebdavBackend *dav = pool_malloc(sn->pool, sizeof(WebdavBackend)); |
|
83 if(!dav) { |
|
84 return NULL; |
|
85 } |
|
86 |
|
87 *dav = default_backend; |
|
88 return dav; |
|
89 } |
|
90 |
|
91 static int init_default_backend(void) { |
79 memset(&default_backend, 0, sizeof(WebdavBackend)); |
92 memset(&default_backend, 0, sizeof(WebdavBackend)); |
80 default_backend.propfind_init = default_propfind_init; |
93 default_backend.propfind_init = default_propfind_init; |
81 default_backend.propfind_do = default_propfind_do; |
94 default_backend.propfind_do = default_propfind_do; |
82 default_backend.propfind_finish = default_propfind_finish; |
95 default_backend.propfind_finish = default_propfind_finish; |
83 default_backend.proppatch_do = default_proppatch_do; |
96 default_backend.proppatch_do = default_proppatch_do; |
84 default_backend.proppatch_finish = default_proppatch_finish; |
97 default_backend.proppatch_finish = default_proppatch_finish; |
85 default_backend.opt_mkcol = NULL; |
98 default_backend.opt_mkcol = NULL; |
86 default_backend.opt_delete = NULL; |
99 default_backend.opt_delete = NULL; |
87 default_backend.settings = WS_WEBDAV_PROPFIND_USE_VFS; |
100 default_backend.settings = WS_WEBDAV_PROPFIND_USE_VFS; |
88 default_backend.instance = NULL; |
101 default_backend.instance = NULL; |
89 } |
102 |
|
103 return webdav_register_backend("default", NULL, default_backend_create); |
|
104 } |
|
105 |
90 |
106 |
91 int webdav_register_backend(const char *name, webdav_init_func webdavInit, webdav_create_func webdavCreate) { |
107 int webdav_register_backend(const char *name, webdav_init_func webdavInit, webdav_create_func webdavCreate) { |
92 WebdavType *webdavType = malloc(sizeof(WebdavType)); |
108 WebdavType *webdavType = malloc(sizeof(WebdavType)); |
93 webdavType->init = webdavInit; |
109 webdavType->init = webdavInit; |
94 webdavType->create = webdavCreate; |
110 webdavType->create = webdavCreate; |
138 method_handler_map = cxHashMapCreate(cxDefaultAllocator, 64); |
154 method_handler_map = cxHashMapCreate(cxDefaultAllocator, 64); |
139 if(!method_handler_map) { |
155 if(!method_handler_map) { |
140 return REQ_ABORTED; |
156 return REQ_ABORTED; |
141 } |
157 } |
142 |
158 |
143 init_default_backend(); |
159 if(init_default_backend()) { |
144 cxMapPut(webdav_type_map, cx_hash_key_str("default"), &default_backend); |
160 return REQ_ABORTED; |
|
161 } |
|
162 |
|
163 if(webdav_init_xattr_backend()) { |
|
164 return REQ_ABORTED; |
|
165 } |
145 |
166 |
146 cxMapPut(method_handler_map, cx_hash_key_str("OPTIONS"), webdav_options); |
167 cxMapPut(method_handler_map, cx_hash_key_str("OPTIONS"), webdav_options); |
147 cxMapPut(method_handler_map, cx_hash_key_str("PROPFIND"), webdav_propfind); |
168 cxMapPut(method_handler_map, cx_hash_key_str("PROPFIND"), webdav_propfind); |
148 cxMapPut(method_handler_map, cx_hash_key_str("PROPPATCH"), webdav_proppatch); |
169 cxMapPut(method_handler_map, cx_hash_key_str("PROPPATCH"), webdav_proppatch); |
149 cxMapPut(method_handler_map, cx_hash_key_str("MKCOL"), webdav_mkcol); |
170 cxMapPut(method_handler_map, cx_hash_key_str("MKCOL"), webdav_mkcol); |