UNIXworkcode

1 /* 2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 * 4 * Copyright 2023 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 30 #ifndef WS_WEBDAV_XATTRBACKEND_H 31 #define WS_WEBDAV_XATTRBACKEND_H 32 33 #include "../public/webdav.h" 34 35 #include <cx/map.h> 36 #include <cx/string.h> 37 38 #ifdef __cplusplus 39 extern "C" { 40 #endif 41 42 typedef struct WebdavXAttrRepository { 43 char *xattr_name; 44 } WebdavXAttrRepository; 45 46 typedef struct WebdavXAttrBackend { 47 WebdavXAttrRepository *repo; 48 } WebdavXAttrBackend; 49 50 typedef struct XAttrPropfind { 51 const char *base_href; 52 const char *base_path; 53 } XAttrPropfind; 54 55 typedef struct XAttrProppatch { 56 CxMap *properties; 57 } XAttrProppatch; 58 59 60 int webdav_init_xattr_backend(void); 61 62 63 void* webdav_xattr_init(ServerConfiguration *cfg, pool_handle_t *pool, WSConfigNode *config); 64 65 WebdavBackend* webdav_xattr_create(Session *sn, Request *rq, pblock *pb, void *initData); 66 67 68 69 /* webdav backend implementation */ 70 int webdav_xattr_propfind_init( 71 WebdavPropfindRequest *rq, 72 const char *path, 73 const char *href, 74 WebdavPList **outplist); 75 int webdav_xattr_propfind_do( 76 WebdavPropfindRequest *request, 77 WebdavResponse *response, 78 VFS_DIR parent, 79 WebdavResource *resource, 80 struct stat *s); 81 int webdav_xattr_propfind_finish(WebdavPropfindRequest *rq); 82 int webdav_xattr_proppatch_do( 83 WebdavProppatchRequest *request, 84 WebdavResource *response, 85 VFSFile *file, 86 WebdavPList **setInOut, 87 WebdavPList **removeInOut); 88 int webdav_xattr_proppatch_finish( 89 WebdavProppatchRequest *request, 90 WebdavResource *response, 91 VFSFile *file, 92 WSBool commit); 93 94 int webdav_xattr_propfind_get_requested_properties( 95 WebdavPropfindRequest *request, 96 WebdavResource *resource, 97 CxAllocator *a, 98 CxMap *pmap); 99 100 int webdav_xattr_propfind_allprop( 101 WebdavPropfindRequest *request, 102 WebdavResource *resource, 103 CxAllocator *a, 104 CxMap *pmap); 105 106 /* properties xattr data */ 107 108 int webdav_xattr_put_prop(CxMap *pmap, WebdavProperty *prop); 109 110 CxMap* webdav_xattr_parse_data(CxAllocator *a, const char *data, size_t len, const char *path); 111 112 cxmutstr webdav_xattr_serialze_map(CxAllocator *a, CxMap *pmap); 113 114 115 #ifdef __cplusplus 116 } 117 #endif 118 119 #endif /* WS_WEBDAV_XATTRBACKEND_H */ 120 121