src/server/webdav/webdav.c

branch
webdav
changeset 301
2bc514931612
parent 300
0e3f275b2492
child 302
dfbd3a535eac
equal deleted inserted replaced
300:0e3f275b2492 301:2bc514931612
46 #include "../daemon/session.h" 46 #include "../daemon/session.h"
47 #include "../daemon/http.h" 47 #include "../daemon/http.h"
48 #include "../daemon/protocol.h" 48 #include "../daemon/protocol.h"
49 #include "../daemon/vfs.h" 49 #include "../daemon/vfs.h"
50 50
51 /*
52 * http method fptr mapping
53 * key: http method name (string)
54 * value: SAF fptr
55 */
51 static UcxMap *method_handler_map; 56 static UcxMap *method_handler_map;
57
58 /*
59 * webdav backend types
60 * key: backend name (string)
61 * value: WebdavBackend*
62 */
63 static UcxMap *webdav_type_map;
52 64
53 static WebdavBackend default_backend; 65 static WebdavBackend default_backend;
54 66
55 static WSNamespace dav_namespace; 67 static WSNamespace dav_namespace;
56 68
71 default_backend.opt_delete = NULL; 83 default_backend.opt_delete = NULL;
72 default_backend.settings = WS_WEBDAV_PROPFIND_USE_VFS; 84 default_backend.settings = WS_WEBDAV_PROPFIND_USE_VFS;
73 default_backend.instance = NULL; 85 default_backend.instance = NULL;
74 } 86 }
75 87
88 int webdav_register_backend(const char *name, webdav_create_func webdavCreate) {
89 return ucx_map_cstr_put(webdav_type_map, name, webdavCreate);
90 }
91
76 int webdav_init(pblock *pb, Session *sn, Request *rq) { 92 int webdav_init(pblock *pb, Session *sn, Request *rq) {
93 webdav_type_map = ucx_map_new(8);
94 if(!webdav_type_map) {
95 return REQ_ABORTED;
96 }
97
98 method_handler_map = ucx_map_new(64);
99 if(!method_handler_map) {
100 return REQ_ABORTED;
101 }
102
77 init_default_backend(); 103 init_default_backend();
78 104 ucx_map_cstr_put(webdav_type_map, "default", &default_backend);
79 method_handler_map = ucx_map_new(64);
80 105
81 ucx_map_cstr_put(method_handler_map, "OPTIONS", webdav_options); 106 ucx_map_cstr_put(method_handler_map, "OPTIONS", webdav_options);
82 ucx_map_cstr_put(method_handler_map, "PROPFIND", webdav_propfind); 107 ucx_map_cstr_put(method_handler_map, "PROPFIND", webdav_propfind);
83 ucx_map_cstr_put(method_handler_map, "PROPPATCH", webdav_proppatch); 108 ucx_map_cstr_put(method_handler_map, "PROPPATCH", webdav_proppatch);
84 ucx_map_cstr_put(method_handler_map, "MKCOL", webdav_mkcol); 109 ucx_map_cstr_put(method_handler_map, "MKCOL", webdav_mkcol);

mercurial