83 default_backend.opt_delete = NULL; |
83 default_backend.opt_delete = NULL; |
84 default_backend.settings = WS_WEBDAV_PROPFIND_USE_VFS; |
84 default_backend.settings = WS_WEBDAV_PROPFIND_USE_VFS; |
85 default_backend.instance = NULL; |
85 default_backend.instance = NULL; |
86 } |
86 } |
87 |
87 |
88 int webdav_register_backend(const char *name, webdav_create_func webdavCreate) { |
88 int webdav_register_backend(const char *name, webdav_init_func webdavInit, webdav_create_func webdavCreate) { |
89 return ucx_map_cstr_put(webdav_type_map, name, webdavCreate); |
89 WebdavType *webdavType = malloc(sizeof(WebdavType)); |
90 } |
90 webdavType->init = webdavInit; |
91 |
91 webdavType->create = webdavCreate; |
92 |
92 return ucx_map_cstr_put(webdav_type_map, name, webdavType); |
93 WebdavBackend* webdav_create(Session *sn, Request *rq, const char *dav_class, pblock *pb) { |
93 } |
94 webdav_create_func createDav = ucx_map_cstr_get(webdav_type_map, dav_class); |
94 |
95 if(!createDav) { |
95 WebdavType* webdav_get_type(scstr_t dav_class) { |
|
96 return ucx_map_sstr_get(webdav_type_map, dav_class); |
|
97 } |
|
98 |
|
99 void* webdav_init_backend(ServerConfiguration *cfg, pool_handle_t *pool, WebdavType *dav_class, WSConfigNode *config, int *error) { |
|
100 *error = 0; |
|
101 if(dav_class->init) { |
|
102 void *initData = dav_class->init(cfg, pool, config); |
|
103 if(!initData) { |
|
104 *error = 1; |
|
105 } |
|
106 return initData; |
|
107 } else { |
|
108 return NULL; |
|
109 } |
|
110 } |
|
111 |
|
112 WebdavBackend* webdav_create(Session *sn, Request *rq, const char *dav_class, pblock *pb, void *initData) { |
|
113 WebdavType *webdavType = ucx_map_cstr_get(webdav_type_map, dav_class); |
|
114 if(!webdavType) { |
96 log_ereport(LOG_MISCONFIG, "webdav_create: unkown dav type %s", dav_class); |
115 log_ereport(LOG_MISCONFIG, "webdav_create: unkown dav type %s", dav_class); |
97 return NULL; |
116 return NULL; |
98 } |
117 } |
99 |
118 |
100 return createDav(sn, rq, pb); |
119 return webdavType->create(sn, rq, pb, initData); |
101 } |
120 } |
102 |
121 |
103 static WSBool webdav_is_initialized = FALSE; |
122 static WSBool webdav_is_initialized = FALSE; |
104 |
123 |
105 int webdav_init(pblock *pb, Session *sn, Request *rq) { |
124 int webdav_init(pblock *pb, Session *sn, Request *rq) { |