Mon, 10 Jul 2023 18:39:24 +0200
update ucx
479
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1 | /* |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
3 | * |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
4 | * Copyright 2023 Olaf Wintermann. All rights reserved. |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
5 | * |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
6 | * Redistribution and use in source and binary forms, with or without |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
7 | * modification, are permitted provided that the following conditions are met: |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
8 | * |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
9 | * 1. Redistributions of source code must retain the above copyright |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
10 | * notice, this list of conditions and the following disclaimer. |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
11 | * |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
12 | * 2. Redistributions in binary form must reproduce the above copyright |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
13 | * notice, this list of conditions and the following disclaimer in the |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
14 | * documentation and/or other materials provided with the distribution. |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
15 | * |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
26 | * POSSIBILITY OF SUCH DAMAGE. |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
27 | */ |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
28 | |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
29 | |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
30 | #include "xattrbackend.h" |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
31 | |
481
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
32 | #include "webdav.h" |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
33 | |
480 | 34 | #include "../util/util.h" |
35 | #include "../util/libxattr.h" | |
481
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
36 | #include "../util/pblock.h" |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
37 | |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
38 | #include <inttypes.h> |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
39 | |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
40 | #include <cx/hash_map.h> |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
41 | #include <cx/buffer.h> |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
42 | #include <cx/utils.h> |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
43 | #include <cx/printf.h> |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
44 | #include <libxml/tree.h> |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
45 | |
480 | 46 | |
479
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
47 | |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
48 | static WebdavBackend webdav_xattr_backend = { |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
49 | webdav_xattr_propfind_init, |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
50 | webdav_xattr_propfind_do, |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
51 | webdav_xattr_propfind_finish, |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
52 | webdav_xattr_proppatch_do, |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
53 | webdav_xattr_proppatch_finish, |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
54 | NULL, // opt_mkcol |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
55 | NULL, // opt_mkcol_finish |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
56 | NULL, // opt_delete |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
57 | NULL, // opt_delete_finish |
481
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
58 | 0, // settings |
479
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
59 | NULL, // instance |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
60 | NULL // next |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
61 | }; |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
62 | |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
63 | int webdav_init_xattr_backend(void) { |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
64 | |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
65 | |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
66 | if(webdav_register_backend("xattr", webdav_xattr_init, webdav_xattr_create)) { |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
67 | return 1; |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
68 | } |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
69 | return 0; |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
70 | } |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
71 | |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
72 | void* webdav_xattr_init(ServerConfiguration *cfg, pool_handle_t *pool, WSConfigNode *config) { |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
73 | WebdavXAttrRepository *repo = pool_malloc(pool, sizeof(WebdavXAttrRepository)); |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
74 | if(!repo) { |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
75 | return NULL; |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
76 | } |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
77 | |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
78 | // TODO: config |
480 | 79 | repo->xattr_name = "webdav_properties"; |
479
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
80 | |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
81 | return repo; |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
82 | } |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
83 | |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
84 | WebdavBackend* webdav_xattr_create(Session *sn, Request *rq, pblock *pb, void *initData) { |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
85 | WebdavBackend *dav = pool_malloc(sn->pool, sizeof(WebdavBackend)); |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
86 | if(!dav) { |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
87 | return NULL; |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
88 | } |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
89 | |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
90 | WebdavXAttrBackend *instance = pool_malloc(sn->pool, sizeof(WebdavXAttrBackend)); |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
91 | if(!instance) { |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
92 | return NULL; |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
93 | } |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
94 | instance->repo = initData; |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
95 | |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
96 | *dav = webdav_xattr_backend; |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
97 | dav->instance = instance; |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
98 | |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
99 | return dav; |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
100 | } |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
101 | |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
102 | |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
103 | |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
104 | /* -------------------- webdav backend imlementation ----------------------*/ |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
105 | |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
106 | int webdav_xattr_propfind_init( |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
107 | WebdavPropfindRequest *rq, |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
108 | const char *path, |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
109 | const char *href, |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
110 | WebdavPList **outplist) |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
111 | { |
480 | 112 | // make sure the sys vfs is used, because currently only |
113 | // native sysfs xattr is supported | |
114 | if(rq->rq->vfs) { | |
115 | log_ereport(LOG_FAILURE, "webdav-propfind: xattr backend unsupported with non-native VFS"); | |
116 | return 1; | |
117 | } | |
118 | ||
119 | XAttrPropfind *xprop = pool_malloc(rq->sn->pool, sizeof(XAttrPropfind)); | |
120 | if(!xprop) { | |
121 | return 1; | |
122 | } | |
123 | rq->userdata = xprop; | |
124 | ||
125 | xprop->base_href = href; | |
126 | xprop->base_path = path; | |
127 | ||
479
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
128 | return 0; |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
129 | } |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
130 | |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
131 | int webdav_xattr_propfind_do( |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
132 | WebdavPropfindRequest *request, |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
133 | WebdavResponse *response, |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
134 | VFS_DIR parent, |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
135 | WebdavResource *resource, |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
136 | struct stat *s) |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
137 | { |
480 | 138 | Session *sn = request->sn; |
139 | Request *rq = request->rq; | |
482
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
140 | CxAllocator *a = pool_allocator(sn->pool); |
480 | 141 | |
142 | WebdavXAttrBackend *xdav = request->dav->instance; | |
143 | WebdavXAttrRepository *repo = xdav->repo; | |
144 | XAttrPropfind *xprop = request->userdata; | |
145 | ||
482
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
146 | // get resource path |
480 | 147 | const char *path; |
148 | char *path_dp = NULL; | |
149 | if(!parent) { | |
150 | // use base path | |
151 | path = xprop->base_path; | |
152 | } else { | |
153 | size_t base_href_len = strlen(xprop->base_href); | |
154 | size_t base_path_len = strlen(xprop->base_path); | |
155 | char *res_path = resource->href + base_href_len; | |
156 | size_t res_path_len = strlen(res_path); | |
157 | ||
158 | path_dp = pool_malloc(sn->pool, base_path_len + res_path_len + 2); | |
159 | memcpy(path_dp, xprop->base_path, base_path_len); | |
160 | int s = 0; | |
161 | if(path_dp[base_path_len-1] != '/' && res_path[0] != '/') { | |
162 | path_dp[base_path_len] = '/'; | |
163 | s = 1; | |
164 | } | |
165 | memcpy(path_dp + base_path_len + s, res_path, res_path_len); | |
166 | path_dp[base_path_len + s + res_path_len] = 0; | |
167 | ||
168 | path = path_dp; | |
169 | } | |
170 | ||
171 | ssize_t xattr_data_len = 0; | |
172 | char *xattr_data = xattr_get_alloc( | |
173 | sn->pool, | |
174 | (libxattr_malloc_func)pool_malloc, | |
175 | (libxattr_free_func)pool_free, | |
176 | path, | |
177 | repo->xattr_name, | |
178 | &xattr_data_len); | |
179 | ||
482
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
180 | if(!xattr_data) { |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
181 | // no properties for this resource |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
182 | return 0; |
481
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
183 | } |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
184 | |
482
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
185 | CxMap *pmap = webdav_xattr_parse_data(a, xattr_data, xattr_data_len, path); |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
186 | pool_free(sn->pool, xattr_data); |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
187 | if(!pmap) { |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
188 | return 1; |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
189 | } |
480 | 190 | |
482
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
191 | int err; |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
192 | if(request->allprop || request->propname) { |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
193 | err = webdav_xattr_propfind_allprop(request, resource, a, pmap); |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
194 | } else { |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
195 | err = webdav_xattr_propfind_get_requested_properties(request, resource, a, pmap); |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
196 | } |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
197 | |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
198 | return err; |
479
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
199 | } |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
200 | |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
201 | int webdav_xattr_propfind_finish(WebdavPropfindRequest *rq) { |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
202 | return 0; |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
203 | } |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
204 | |
482
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
205 | // helper functions for propfind_do |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
206 | |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
207 | int webdav_xattr_propfind_get_requested_properties( |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
208 | WebdavPropfindRequest *request, |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
209 | WebdavResource *resource, |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
210 | CxAllocator *a, |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
211 | CxMap *pmap) |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
212 | { |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
213 | WebdavPListIterator i = webdav_plist_iterator(&request->properties); |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
214 | WebdavPList *cur; |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
215 | while(webdav_plist_iterator_next(&i, &cur)) { |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
216 | WebdavProperty *reqprop = cur->property; |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
217 | |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
218 | CxHashKey key = webdav_property_key_a( |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
219 | a, |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
220 | (const char*)reqprop->namespace->href, |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
221 | (const char*)reqprop->name); |
490 | 222 | if(!key.data) { |
482
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
223 | return 1; |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
224 | } |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
225 | |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
226 | WebdavProperty *prop = cxMapGet(pmap, key); |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
227 | if(prop) { |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
228 | if(resource->addproperty(resource, prop, 200)) { |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
229 | return 1; |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
230 | } |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
231 | } |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
232 | } |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
233 | |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
234 | return 0; |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
235 | } |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
236 | |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
237 | int webdav_xattr_propfind_allprop( |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
238 | WebdavPropfindRequest *request, |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
239 | WebdavResource *resource, |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
240 | CxAllocator *a, |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
241 | CxMap *pmap) |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
242 | { |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
243 | CxIterator i = cxMapIteratorValues(pmap); |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
244 | cx_foreach(WebdavProperty*, prop, i) { |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
245 | if(request->propname) { |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
246 | prop->vtype = WS_VALUE_NO_TYPE; |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
247 | } |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
248 | if(resource->addproperty(resource, prop, 200)) { |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
249 | return 1; |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
250 | } |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
251 | } |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
252 | return 0; |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
253 | } |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
254 | |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
255 | |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
256 | |
479
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
257 | int webdav_xattr_proppatch_do( |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
258 | WebdavProppatchRequest *request, |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
259 | WebdavResource *response, |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
260 | VFSFile *file, |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
261 | WebdavPList **setInOut, |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
262 | WebdavPList **removeInOut) |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
263 | { |
481
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
264 | Session *sn = request->sn; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
265 | Request *rq = request->rq; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
266 | CxAllocator *a = pool_allocator(sn->pool); |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
267 | |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
268 | WebdavXAttrBackend *xdav = request->dav->instance; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
269 | WebdavXAttrRepository *repo = xdav->repo; |
482
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
270 | |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
271 | char *path = pblock_findkeyval(pb_key_path, rq->vars); |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
272 | |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
273 | // How xattr proppatch works: |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
274 | // 1. get existing property data from the file's xattr |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
275 | // 2. do set/remove operations to the existing data |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
276 | // 3. write new property data to the xattr (webdav_xattr_proppatch_finish) |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
277 | |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
278 | // TODO: proppatch file lock (in-process userspace lock) |
481
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
279 | |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
280 | XAttrProppatch *xprop = pool_malloc(sn->pool, sizeof(XAttrProppatch)); |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
281 | if(!xprop) { |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
282 | return 1; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
283 | } |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
284 | request->userdata = xprop; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
285 | |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
286 | // get existing property data |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
287 | ssize_t xattr_data_len = 0; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
288 | char *xattr_data = xattr_get_alloc( |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
289 | sn->pool, |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
290 | (libxattr_malloc_func)pool_malloc, |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
291 | (libxattr_free_func)pool_free, |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
292 | path, |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
293 | repo->xattr_name, |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
294 | &xattr_data_len); |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
295 | |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
296 | CxMap *pmap; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
297 | if(xattr_data) { |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
298 | pmap = webdav_xattr_parse_data(a, xattr_data, xattr_data_len, path); |
482
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
299 | pool_free(sn->pool, xattr_data); |
481
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
300 | } else { |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
301 | // empty map |
490 | 302 | pmap = cxHashMapCreate(a, CX_STORE_POINTERS, request->setcount + 8); |
481
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
303 | } |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
304 | if(!pmap) { |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
305 | return 1; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
306 | } |
482
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
307 | xprop->properties = pmap; |
481
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
308 | |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
309 | // remove properties |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
310 | WebdavPListIterator i = webdav_plist_iterator(removeInOut); |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
311 | WebdavPList *cur; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
312 | while(webdav_plist_iterator_next(&i, &cur)) { |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
313 | WebdavProperty *prop = cur->property; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
314 | if(!prop->namespace || !prop->namespace->prefix) { |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
315 | // not sure if this check is required |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
316 | log_ereport(LOG_WARN, "webdav_xattr_proppatch_do: property %s has missing namespace infos", prop->name); |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
317 | continue; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
318 | } |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
319 | |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
320 | CxHashKey key = webdav_property_key_a( |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
321 | a, |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
322 | (const char*)prop->namespace->href, |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
323 | (const char*)prop->name); |
490 | 324 | if(!key.data) { |
481
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
325 | cxMapDestroy(pmap); |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
326 | return 1; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
327 | } |
490 | 328 | void *rmprop = cxMapRemoveAndGet(pmap, key); |
329 | cxFree(a, (void*)key.data); | |
481
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
330 | |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
331 | // TODO: free rmprop |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
332 | |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
333 | if(rmprop) { |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
334 | webdav_plist_iterator_remove_current(&i); |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
335 | } |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
336 | } |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
337 | |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
338 | i = webdav_plist_iterator(setInOut); |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
339 | while(webdav_plist_iterator_next(&i, &cur)) { |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
340 | WebdavProperty *prop = cur->property; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
341 | if(!prop->namespace || !prop->namespace->prefix) { |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
342 | // not sure if this check is required |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
343 | log_ereport(LOG_WARN, "webdav_xattr_proppatch_do: property %s has missing namespace infos", prop->name); |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
344 | continue; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
345 | } |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
346 | |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
347 | if(webdav_xattr_put_prop(pmap, prop)) { |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
348 | cxMapDestroy(pmap); |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
349 | return 1; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
350 | } |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
351 | |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
352 | webdav_plist_iterator_remove_current(&i); |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
353 | } |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
354 | |
482
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
355 | return 0; |
479
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
356 | } |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
357 | |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
358 | int webdav_xattr_proppatch_finish( |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
359 | WebdavProppatchRequest *request, |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
360 | WebdavResource *response, |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
361 | VFSFile *file, |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
362 | WSBool commit) |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
363 | { |
482
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
364 | Session *sn = request->sn; |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
365 | Request *rq = request->rq; |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
366 | CxAllocator *a = pool_allocator(sn->pool); |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
367 | |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
368 | WebdavXAttrBackend *xdav = request->dav->instance; |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
369 | WebdavXAttrRepository *repo = xdav->repo; |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
370 | |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
371 | XAttrProppatch *xprop = request->userdata; |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
372 | |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
373 | char *path = pblock_findkeyval(pb_key_path, rq->vars); |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
374 | |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
375 | int ret = 0; |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
376 | if(commit) { |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
377 | cxmutstr new_data = webdav_xattr_serialze_map(a, xprop->properties); |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
378 | if(new_data.ptr) { |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
379 | if(xattr_set(path, repo->xattr_name, new_data.ptr, new_data.length)) { |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
380 | ret = 1; |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
381 | } |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
382 | } else { |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
383 | ret = 1; |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
384 | } |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
385 | } |
b02da778362e
implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
481
diff
changeset
|
386 | |
479
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
387 | return 0; |
2a42ba73ecdd
add new xattr based webdav backend (unimplemented)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
388 | } |
481
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
389 | |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
390 | |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
391 | /* ----------------------- properties xattr data ----------------------- */ |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
392 | |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
393 | static int get_next_line(cxstring data, size_t *pos, cxstring *line) { |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
394 | size_t p = *pos; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
395 | cxstring str = cx_strsubs(data, p); |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
396 | size_t i; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
397 | int skip = 0; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
398 | for(i=0;i<str.length;i++) { |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
399 | if(str.ptr[i] == '\n') { |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
400 | skip = 1; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
401 | break; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
402 | } |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
403 | } |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
404 | p += i; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
405 | *pos = p + skip; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
406 | *line = cx_strsubsl(str, 0, i); |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
407 | return i > 0 ? TRUE : FALSE; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
408 | } |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
409 | |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
410 | static int webdav_xattr_parse_elm(cxstring line, cxstring *name, cxstring *prefix, cxstring *xmlns, cxstring *lang) { |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
411 | cxstring s_xmlns = CX_STR("xmlns:"); |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
412 | |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
413 | // check if line starts with 'xmlns:' |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
414 | if(!cx_strprefix(line, s_xmlns)) { |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
415 | return 1; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
416 | } |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
417 | line.ptr += 6; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
418 | line.length -= 6; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
419 | |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
420 | |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
421 | // format: <prefix>="<href>" |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
422 | // find '=' |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
423 | size_t i; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
424 | size_t token_end = 0; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
425 | for(i=0;i<line.length;i++) { |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
426 | if(line.ptr[i] == '=') { |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
427 | token_end = i; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
428 | break; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
429 | } |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
430 | } |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
431 | if(token_end == 0) { |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
432 | return 1; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
433 | } |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
434 | *prefix = cx_strn(line.ptr, token_end); |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
435 | |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
436 | // make sure the line length is big enough |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
437 | if(token_end + 4 > line.length) { |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
438 | return 1; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
439 | } |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
440 | if(line.ptr[token_end + 1] != '\"') { |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
441 | return 1; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
442 | } |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
443 | line.ptr += token_end + 2; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
444 | line.length -= token_end + 2; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
445 | |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
446 | // get <href> |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
447 | int escape = 0; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
448 | token_end = 0; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
449 | for(i=0;i<line.length;i++) { |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
450 | if(line.ptr[i] == '\\') { |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
451 | escape = 1; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
452 | continue; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
453 | } else if(!escape && line.ptr[i] == '\"') { |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
454 | token_end = i; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
455 | break; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
456 | } |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
457 | escape = 0; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
458 | } |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
459 | if(token_end == 0) { |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
460 | return 1; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
461 | } |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
462 | *xmlns = cx_strn(line.ptr, token_end); |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
463 | |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
464 | // check length |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
465 | if(token_end + 2 > line.length) { |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
466 | return 1; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
467 | } |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
468 | line.ptr += token_end + 2; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
469 | line.length -= token_end + 2; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
470 | *name = cx_strtrim(line); |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
471 | |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
472 | if(name->length == 0) { |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
473 | return 1; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
474 | } |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
475 | if(prefix->length == 0) { |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
476 | return 1; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
477 | } |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
478 | if(xmlns->length == 0) { |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
479 | return 1; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
480 | } |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
481 | |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
482 | return 0; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
483 | } |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
484 | |
484
c036a8b242a8
implement webdav xattr namespace lists
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
483
diff
changeset
|
485 | static int webdav_xattr_parse_ns(cxstring line, cxstring *prefix, cxstring *href) { |
c036a8b242a8
implement webdav xattr namespace lists
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
483
diff
changeset
|
486 | size_t i = 0; |
c036a8b242a8
implement webdav xattr namespace lists
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
483
diff
changeset
|
487 | for(i=1;i<line.length;i++) { |
c036a8b242a8
implement webdav xattr namespace lists
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
483
diff
changeset
|
488 | if(line.ptr[i] == ':') { |
c036a8b242a8
implement webdav xattr namespace lists
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
483
diff
changeset
|
489 | break; |
c036a8b242a8
implement webdav xattr namespace lists
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
483
diff
changeset
|
490 | } |
c036a8b242a8
implement webdav xattr namespace lists
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
483
diff
changeset
|
491 | } |
c036a8b242a8
implement webdav xattr namespace lists
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
483
diff
changeset
|
492 | if(i == 0 || i+1 >= line.length) { |
c036a8b242a8
implement webdav xattr namespace lists
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
483
diff
changeset
|
493 | // error: ':' not found or ':' is the last character |
c036a8b242a8
implement webdav xattr namespace lists
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
483
diff
changeset
|
494 | return 1; |
c036a8b242a8
implement webdav xattr namespace lists
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
483
diff
changeset
|
495 | } |
c036a8b242a8
implement webdav xattr namespace lists
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
483
diff
changeset
|
496 | |
c036a8b242a8
implement webdav xattr namespace lists
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
483
diff
changeset
|
497 | cxstring pre; |
c036a8b242a8
implement webdav xattr namespace lists
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
483
diff
changeset
|
498 | pre.ptr = line.ptr; |
c036a8b242a8
implement webdav xattr namespace lists
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
483
diff
changeset
|
499 | pre.length = i; |
c036a8b242a8
implement webdav xattr namespace lists
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
483
diff
changeset
|
500 | *prefix = pre; |
c036a8b242a8
implement webdav xattr namespace lists
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
483
diff
changeset
|
501 | |
c036a8b242a8
implement webdav xattr namespace lists
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
483
diff
changeset
|
502 | *href = cx_strsubs(line, i+1); |
c036a8b242a8
implement webdav xattr namespace lists
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
483
diff
changeset
|
503 | |
c036a8b242a8
implement webdav xattr namespace lists
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
483
diff
changeset
|
504 | return 0; |
c036a8b242a8
implement webdav xattr namespace lists
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
483
diff
changeset
|
505 | } |
c036a8b242a8
implement webdav xattr namespace lists
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
483
diff
changeset
|
506 | |
481
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
507 | int webdav_xattr_put_prop(CxMap *pmap, WebdavProperty *prop) { |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
508 | CxHashKey key = webdav_property_key_a( |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
509 | pmap->allocator, |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
510 | (const char*)prop->namespace->href, |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
511 | (const char*)prop->name); |
490 | 512 | if(!key.data) { |
481
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
513 | return 1; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
514 | } |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
515 | int ret = cxMapPut(pmap, key, prop); |
490 | 516 | cxFree(pmap->allocator, (void*)key.data); |
481
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
517 | return ret; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
518 | } |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
519 | |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
520 | CxMap* webdav_xattr_parse_data(CxAllocator *a, const char *data, size_t len, const char *path) { |
490 | 521 | CxMap *pmap = cxHashMapCreate(a, CX_STORE_POINTERS, 32); |
481
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
522 | if(!pmap) { |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
523 | return NULL; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
524 | } |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
525 | cxstring dat = cx_strn(data, len); |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
526 | |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
527 | cxstring s_elm = CX_STR("prop "); |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
528 | cxstring s_ns = CX_STR("ns "); |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
529 | cxstring s_data = CX_STR("data "); |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
530 | |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
531 | WebdavProperty *prop = NULL; |
484
c036a8b242a8
implement webdav xattr namespace lists
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
483
diff
changeset
|
532 | WebdavNSList *ns_begin = NULL; |
c036a8b242a8
implement webdav xattr namespace lists
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
483
diff
changeset
|
533 | WebdavNSList *ns_end = NULL; |
481
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
534 | |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
535 | int error = 0; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
536 | |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
537 | size_t elmno = 0; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
538 | cxstring line; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
539 | size_t pos = 0; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
540 | while(get_next_line(dat, &pos, &line)) { |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
541 | if(cx_strprefix(line, s_elm)) { |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
542 | if(prop) { |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
543 | if(webdav_xattr_put_prop(pmap, prop)) { |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
544 | error = 1; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
545 | break; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
546 | } |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
547 | } |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
548 | |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
549 | line = cx_strsubs(line, 5); |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
550 | |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
551 | // get prop name, namespace and lang |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
552 | cxstring name; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
553 | cxstring prefix; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
554 | cxstring xmlns; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
555 | cxstring lang; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
556 | if(webdav_xattr_parse_elm(line, &name, &prefix, &xmlns, &lang)) { |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
557 | log_ereport( |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
558 | LOG_FAILURE, |
484
c036a8b242a8
implement webdav xattr namespace lists
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
483
diff
changeset
|
559 | "webdav xattr backend: file %s: invalid xattr format[%d]: cannot parse elm line", |
481
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
560 | path, |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
561 | elmno); |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
562 | error = 1; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
563 | break; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
564 | } |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
565 | |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
566 | // create property |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
567 | prop = cxMalloc(a, sizeof(WebdavProperty)); |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
568 | if(!prop) { |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
569 | error = 1; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
570 | break; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
571 | } |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
572 | ZERO(prop, sizeof(WebdavProperty)); |
484
c036a8b242a8
implement webdav xattr namespace lists
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
483
diff
changeset
|
573 | ns_begin = NULL; |
c036a8b242a8
implement webdav xattr namespace lists
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
483
diff
changeset
|
574 | ns_end = NULL; |
481
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
575 | |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
576 | WSNamespace *ns = cxMalloc(a, sizeof(WSNamespace)); |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
577 | if(!ns) { |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
578 | error = 1; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
579 | break; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
580 | } |
484
c036a8b242a8
implement webdav xattr namespace lists
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
483
diff
changeset
|
581 | ZERO(ns, sizeof(WSNamespace)); |
481
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
582 | |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
583 | char *name_str = cx_strdup_a(a, name).ptr; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
584 | char *prefix_str = cx_strdup_a(a, prefix).ptr; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
585 | char *xmlns_str = cx_strdup_a(a, xmlns).ptr; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
586 | if(!(name_str && prefix_str && xmlns_str)) { |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
587 | error = 1; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
588 | break; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
589 | } |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
590 | |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
591 | ns->prefix = (const xmlChar*)prefix_str; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
592 | ns->href = (const xmlChar*)xmlns_str; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
593 | |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
594 | prop->name = name_str; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
595 | prop->namespace = ns; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
596 | |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
597 | elmno++; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
598 | } else if(prop) { |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
599 | if(cx_strprefix(line, s_ns)) { |
484
c036a8b242a8
implement webdav xattr namespace lists
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
483
diff
changeset
|
600 | line = cx_strsubs(line, 3); |
c036a8b242a8
implement webdav xattr namespace lists
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
483
diff
changeset
|
601 | |
c036a8b242a8
implement webdav xattr namespace lists
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
483
diff
changeset
|
602 | cxstring prefix; |
c036a8b242a8
implement webdav xattr namespace lists
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
483
diff
changeset
|
603 | cxstring href; |
c036a8b242a8
implement webdav xattr namespace lists
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
483
diff
changeset
|
604 | if(webdav_xattr_parse_ns(line, &prefix, &href)) { |
c036a8b242a8
implement webdav xattr namespace lists
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
483
diff
changeset
|
605 | log_ereport( |
c036a8b242a8
implement webdav xattr namespace lists
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
483
diff
changeset
|
606 | LOG_FAILURE, |
c036a8b242a8
implement webdav xattr namespace lists
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
483
diff
changeset
|
607 | "webdav xattr backend: file %s: invalid xattr format[%d]: cannot parse ns", |
c036a8b242a8
implement webdav xattr namespace lists
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
483
diff
changeset
|
608 | path, |
c036a8b242a8
implement webdav xattr namespace lists
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
483
diff
changeset
|
609 | elmno); |
c036a8b242a8
implement webdav xattr namespace lists
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
483
diff
changeset
|
610 | error = 1; |
c036a8b242a8
implement webdav xattr namespace lists
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
483
diff
changeset
|
611 | break; |
c036a8b242a8
implement webdav xattr namespace lists
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
483
diff
changeset
|
612 | } |
c036a8b242a8
implement webdav xattr namespace lists
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
483
diff
changeset
|
613 | |
c036a8b242a8
implement webdav xattr namespace lists
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
483
diff
changeset
|
614 | WSNamespace *ns_decl = cxMalloc(a, sizeof(WSNamespace)); |
c036a8b242a8
implement webdav xattr namespace lists
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
483
diff
changeset
|
615 | if(!ns_decl) { |
c036a8b242a8
implement webdav xattr namespace lists
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
483
diff
changeset
|
616 | error = 1; |
c036a8b242a8
implement webdav xattr namespace lists
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
483
diff
changeset
|
617 | break; |
c036a8b242a8
implement webdav xattr namespace lists
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
483
diff
changeset
|
618 | } |
c036a8b242a8
implement webdav xattr namespace lists
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
483
diff
changeset
|
619 | ZERO(ns_decl, sizeof(WSNamespace)); |
c036a8b242a8
implement webdav xattr namespace lists
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
483
diff
changeset
|
620 | |
c036a8b242a8
implement webdav xattr namespace lists
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
483
diff
changeset
|
621 | ns_decl->prefix = (const xmlChar*)cx_strdup_a(a, prefix).ptr; |
c036a8b242a8
implement webdav xattr namespace lists
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
483
diff
changeset
|
622 | ns_decl->href = (const xmlChar*)cx_strdup_a(a, href).ptr; |
c036a8b242a8
implement webdav xattr namespace lists
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
483
diff
changeset
|
623 | if(!(ns_decl->prefix && ns_decl->href)) { |
c036a8b242a8
implement webdav xattr namespace lists
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
483
diff
changeset
|
624 | error = 1; |
c036a8b242a8
implement webdav xattr namespace lists
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
483
diff
changeset
|
625 | break; |
c036a8b242a8
implement webdav xattr namespace lists
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
483
diff
changeset
|
626 | } |
c036a8b242a8
implement webdav xattr namespace lists
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
483
diff
changeset
|
627 | |
c036a8b242a8
implement webdav xattr namespace lists
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
483
diff
changeset
|
628 | if(webdav_nslist_add(a->data, &ns_begin, &ns_end, ns_decl)) { |
c036a8b242a8
implement webdav xattr namespace lists
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
483
diff
changeset
|
629 | error = 1; |
c036a8b242a8
implement webdav xattr namespace lists
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
483
diff
changeset
|
630 | break; |
c036a8b242a8
implement webdav xattr namespace lists
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
483
diff
changeset
|
631 | } |
481
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
632 | } else if(cx_strprefix(line, s_data)) { |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
633 | line = cx_strsubs(line, 5); |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
634 | |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
635 | // util_strtoint just works here, because the line ends with \n |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
636 | // the xattr content data is also garanteed to be 0-terminated |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
637 | int64_t data_len = 0; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
638 | if(!util_strtoint(line.ptr, &data_len)) { |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
639 | log_ereport( |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
640 | LOG_FAILURE, |
484
c036a8b242a8
implement webdav xattr namespace lists
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
483
diff
changeset
|
641 | "webdav xattr backend: file %s: invalid xattr format[%d]: number expected after data", |
481
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
642 | path, |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
643 | elmno); |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
644 | error = 1; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
645 | break; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
646 | } |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
647 | |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
648 | // get data |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
649 | if(data_len > 0) { |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
650 | if(data_len > dat.length - pos) { |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
651 | log_ereport( |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
652 | LOG_FAILURE, |
484
c036a8b242a8
implement webdav xattr namespace lists
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
483
diff
changeset
|
653 | "webdav xattr backend: file %s: invalid data length %" PRId64 " in prop %d", |
481
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
654 | path, |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
655 | data_len, |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
656 | elmno); |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
657 | error = 1; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
658 | break; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
659 | } |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
660 | |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
661 | cxstring propdata; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
662 | propdata.ptr = dat.ptr + pos; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
663 | propdata.length = data_len; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
664 | pos += data_len; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
665 | |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
666 | cxmutstr propdata_cp = cx_strdup_a(a, propdata); |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
667 | if(!propdata_cp.ptr) { |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
668 | error = 1; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
669 | break; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
670 | } |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
671 | prop->vtype = WS_VALUE_XML_DATA; |
484
c036a8b242a8
implement webdav xattr namespace lists
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
483
diff
changeset
|
672 | prop->value.data.namespaces = ns_begin; |
481
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
673 | prop->value.data.data = propdata_cp.ptr; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
674 | prop->value.data.length = propdata_cp.length; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
675 | |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
676 | if(pos < dat.length && dat.ptr[pos] == '\n') { |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
677 | pos++; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
678 | } |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
679 | } |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
680 | } else { |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
681 | log_ereport( |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
682 | LOG_FAILURE, |
484
c036a8b242a8
implement webdav xattr namespace lists
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
483
diff
changeset
|
683 | "webdav xattr backend: file %s: invalid xattr format[%d]: unknown element", |
481
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
684 | path, |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
685 | elmno); |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
686 | error = 1; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
687 | break; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
688 | } |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
689 | } |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
690 | } |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
691 | |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
692 | // add last property |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
693 | if(prop) { |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
694 | if(webdav_xattr_put_prop(pmap, prop)) { |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
695 | error = 1; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
696 | } |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
697 | } |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
698 | |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
699 | if(error) { |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
700 | // TODO: free pmap content |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
701 | cxMapDestroy(pmap); |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
702 | pmap = NULL; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
703 | } |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
704 | |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
705 | return pmap; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
706 | } |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
707 | |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
708 | cxmutstr webdav_xattr_serialze_map(CxAllocator *a, CxMap *pmap) { |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
709 | pool_handle_t *pool = a->data; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
710 | |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
711 | CxBuffer buf; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
712 | if(cxBufferInit(&buf, NULL, 8192, a, CX_BUFFER_AUTO_EXTEND)) { |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
713 | return (cxmutstr){NULL,0}; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
714 | } |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
715 | |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
716 | CxIterator i = cxMapIteratorValues(pmap); |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
717 | cx_foreach(WebdavProperty*, prop, i) { |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
718 | WSXmlData *property_value = NULL; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
719 | if(prop->vtype == WS_VALUE_XML_NODE) { |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
720 | property_value = wsxml_node2data(pool, prop->value.node); |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
721 | } else if(prop->vtype == WS_VALUE_XML_DATA) { |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
722 | property_value = &prop->value.data; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
723 | } |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
724 | |
483
f69d88f86b9c
add error handling to webdav_xattr_serialze_map()
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
482
diff
changeset
|
725 | int ret = cx_bprintf(&buf, "prop xmlns:%s=\"%s\" %s\n", prop->namespace->prefix, prop->namespace->href, prop->name); |
f69d88f86b9c
add error handling to webdav_xattr_serialze_map()
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
482
diff
changeset
|
726 | if(ret <= 0) { |
f69d88f86b9c
add error handling to webdav_xattr_serialze_map()
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
482
diff
changeset
|
727 | pool_free(pool, buf.space); |
f69d88f86b9c
add error handling to webdav_xattr_serialze_map()
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
482
diff
changeset
|
728 | return (cxmutstr){NULL,0}; |
f69d88f86b9c
add error handling to webdav_xattr_serialze_map()
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
482
diff
changeset
|
729 | } |
481
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
730 | if(property_value) { |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
731 | WebdavNSList *ns = property_value->namespaces; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
732 | while(ns) { |
484
c036a8b242a8
implement webdav xattr namespace lists
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
483
diff
changeset
|
733 | ret = cx_bprintf(&buf, "ns %s:%s\n", ns->namespace->prefix, ns->namespace->href); |
483
f69d88f86b9c
add error handling to webdav_xattr_serialze_map()
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
482
diff
changeset
|
734 | if(ret <= 0) { |
f69d88f86b9c
add error handling to webdav_xattr_serialze_map()
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
482
diff
changeset
|
735 | pool_free(pool, buf.space); |
f69d88f86b9c
add error handling to webdav_xattr_serialze_map()
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
482
diff
changeset
|
736 | return (cxmutstr){NULL,0}; |
f69d88f86b9c
add error handling to webdav_xattr_serialze_map()
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
482
diff
changeset
|
737 | } |
481
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
738 | ns = ns->next; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
739 | } |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
740 | |
483
f69d88f86b9c
add error handling to webdav_xattr_serialze_map()
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
482
diff
changeset
|
741 | ret = cx_bprintf(&buf, "data %zu\n", property_value->length); |
f69d88f86b9c
add error handling to webdav_xattr_serialze_map()
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
482
diff
changeset
|
742 | if(ret <= 0) { |
f69d88f86b9c
add error handling to webdav_xattr_serialze_map()
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
482
diff
changeset
|
743 | pool_free(pool, buf.space); |
f69d88f86b9c
add error handling to webdav_xattr_serialze_map()
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
482
diff
changeset
|
744 | return (cxmutstr){NULL,0}; |
f69d88f86b9c
add error handling to webdav_xattr_serialze_map()
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
482
diff
changeset
|
745 | } |
f69d88f86b9c
add error handling to webdav_xattr_serialze_map()
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
482
diff
changeset
|
746 | |
481
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
747 | cxBufferWrite(property_value->data, 1, property_value->length, &buf); |
483
f69d88f86b9c
add error handling to webdav_xattr_serialze_map()
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
482
diff
changeset
|
748 | if(cxBufferPut(&buf, '\n') < 0) { |
f69d88f86b9c
add error handling to webdav_xattr_serialze_map()
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
482
diff
changeset
|
749 | pool_free(pool, buf.space); |
f69d88f86b9c
add error handling to webdav_xattr_serialze_map()
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
482
diff
changeset
|
750 | return (cxmutstr){NULL,0}; |
f69d88f86b9c
add error handling to webdav_xattr_serialze_map()
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
482
diff
changeset
|
751 | } |
481
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
752 | } |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
753 | } |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
754 | |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
755 | return (cxmutstr){buf.space, buf.size}; |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
756 | } |
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
480
diff
changeset
|
757 |