UNIXworkcode

1 /* 2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 * 4 * Copyright 2019 Olaf Wintermann. All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions are met: 8 * 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 * POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29 #ifndef WEBDAV_H 30 #define WEBDAV_H 31 32 #include "../public/webdav.h" 33 34 #include <cx/map.h> 35 #include <cx/list.h> 36 #include <cx/buffer.h> 37 #include <cx/string.h> 38 39 #ifdef __cplusplus 40 extern "C" { 41 #endif 42 43 typedef struct WebdavType { 44 webdav_init_func init; 45 webdav_create_func create; 46 } WebdavType; 47 48 typedef struct DefaultWebdavData { 49 WebdavVFSProperties vfsproperties; 50 } DefaultWebdavData; 51 52 typedef struct WebdavPropfindRequestList WebdavPropfindRequestList; 53 struct WebdavPropfindRequestList { 54 WebdavPropfindRequest *propfind; 55 WebdavPropfindRequestList *next; 56 }; 57 58 WebdavType* webdav_get_type(cxstring dav_class); 59 60 void* webdav_init_backend(ServerConfiguration *cfg, pool_handle_t *pool, WebdavType *dav_class, WSConfigNode *config, int *error); 61 62 int webdav_init(pblock *pb, Session *sn, Request *rq); 63 64 int webdav_service(pblock *pb, Session *sn, Request *rq); 65 66 /* 67 * returns a buffer containing the request body 68 * 69 * this function sets an http response code in case of an error 70 * or missing request body 71 */ 72 int rqbody2buffer(Session *sn, Request *rq, CxBuffer *buf); 73 74 75 int webdav_options(pblock *pb, Session *sn, Request *rq); 76 77 int webdav_propfind(pblock *pb, Session *sn, Request *rq); 78 79 int webdav_propfind_init( 80 WebdavBackend *dav, 81 WebdavPropfindRequest *propfind, 82 const char *path, 83 const char *uri, 84 WebdavPropfindRequestList **out_req); 85 86 int webdav_propfind_do( 87 WebdavBackend *dav, 88 WebdavPropfindRequest *propfind, 89 WebdavResponse *response, 90 VFSContext *vfs, 91 char *path, 92 char *uri); 93 94 95 int webdav_proppatch(pblock *pb, Session *sn, Request *rq); 96 int webdav_mkcol(pblock *pb, Session *sn, Request *rq); 97 int webdav_post(pblock *pb, Session *sn, Request *rq); 98 int webdav_delete(pblock *pb, Session *sn, Request *rq); 99 int webdav_put(pblock *pb, Session *sn, Request *rq); 100 int webdav_copy(pblock *pb, Session *sn, Request *rq); 101 int webdav_move(pblock *pb, Session *sn, Request *rq); 102 int webdav_lock(pblock *pb, Session *sn, Request *rq); 103 int webdav_unlock(pblock *pb, Session *sn, Request *rq); 104 int webdav_report(pblock *pb, Session *sn, Request *rq); 105 int webdav_acl(pblock *pb, Session *sn, Request *rq); 106 int webdav_search (pblock *pb, Session *sn, Request *rq); 107 108 109 int default_propfind_init( 110 WebdavPropfindRequest *rq, 111 const char *path, 112 const char *href, 113 WebdavPList **outplist); 114 int default_propfind_do( 115 WebdavPropfindRequest *request, 116 WebdavResponse *response, 117 VFS_DIR parent, 118 WebdavResource *resource, 119 struct stat *s); 120 int default_propfind_finish(WebdavPropfindRequest *rq); 121 int default_proppatch_do( 122 WebdavProppatchRequest *request, 123 WebdavResource *response, 124 VFSFile *file, 125 WebdavPList **setInOut, 126 WebdavPList **removeInOut); 127 int default_proppatch_finish( 128 WebdavProppatchRequest *request, 129 WebdavResource *response, 130 VFSFile *file, 131 WSBool commit); 132 133 CxHashKey webdav_property_key(const char *ns, const char *name); 134 135 CxHashKey webdav_property_key_a(const CxAllocator *a, const char *ns, const char *name); 136 137 #ifdef __cplusplus 138 } 139 #endif 140 141 #endif /* WEBDAV_H */ 142 143