src/server/webdav/xattrbackend.c

Sun, 19 Mar 2023 11:14:10 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sun, 19 Mar 2023 11:14:10 +0100
changeset 482
b02da778362e
parent 481
31affbf33911
child 483
f69d88f86b9c
permissions
-rw-r--r--

implement propfind for webdav xattr backend

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
9f69e4b8b695 add libxattr
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 479
diff changeset
34 #include "../util/util.h"
9f69e4b8b695 add libxattr
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 479
diff changeset
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
9f69e4b8b695 add libxattr
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 479
diff changeset
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
9f69e4b8b695 add libxattr
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 479
diff changeset
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
9f69e4b8b695 add libxattr
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 479
diff changeset
112 // make sure the sys vfs is used, because currently only
9f69e4b8b695 add libxattr
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 479
diff changeset
113 // native sysfs xattr is supported
9f69e4b8b695 add libxattr
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 479
diff changeset
114 if(rq->rq->vfs) {
9f69e4b8b695 add libxattr
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 479
diff changeset
115 log_ereport(LOG_FAILURE, "webdav-propfind: xattr backend unsupported with non-native VFS");
9f69e4b8b695 add libxattr
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 479
diff changeset
116 return 1;
9f69e4b8b695 add libxattr
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 479
diff changeset
117 }
9f69e4b8b695 add libxattr
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 479
diff changeset
118
9f69e4b8b695 add libxattr
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 479
diff changeset
119 XAttrPropfind *xprop = pool_malloc(rq->sn->pool, sizeof(XAttrPropfind));
9f69e4b8b695 add libxattr
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 479
diff changeset
120 if(!xprop) {
9f69e4b8b695 add libxattr
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 479
diff changeset
121 return 1;
9f69e4b8b695 add libxattr
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 479
diff changeset
122 }
9f69e4b8b695 add libxattr
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 479
diff changeset
123 rq->userdata = xprop;
9f69e4b8b695 add libxattr
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 479
diff changeset
124
9f69e4b8b695 add libxattr
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 479
diff changeset
125 xprop->base_href = href;
9f69e4b8b695 add libxattr
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 479
diff changeset
126 xprop->base_path = path;
9f69e4b8b695 add libxattr
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 479
diff changeset
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
9f69e4b8b695 add libxattr
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 479
diff changeset
138 Session *sn = request->sn;
9f69e4b8b695 add libxattr
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 479
diff changeset
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
9f69e4b8b695 add libxattr
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 479
diff changeset
141
9f69e4b8b695 add libxattr
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 479
diff changeset
142 WebdavXAttrBackend *xdav = request->dav->instance;
9f69e4b8b695 add libxattr
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 479
diff changeset
143 WebdavXAttrRepository *repo = xdav->repo;
9f69e4b8b695 add libxattr
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 479
diff changeset
144 XAttrPropfind *xprop = request->userdata;
9f69e4b8b695 add libxattr
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 479
diff changeset
145
482
b02da778362e implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 481
diff changeset
146 // get resource path
480
9f69e4b8b695 add libxattr
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 479
diff changeset
147 const char *path;
9f69e4b8b695 add libxattr
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 479
diff changeset
148 char *path_dp = NULL;
9f69e4b8b695 add libxattr
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 479
diff changeset
149 if(!parent) {
9f69e4b8b695 add libxattr
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 479
diff changeset
150 // use base path
9f69e4b8b695 add libxattr
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 479
diff changeset
151 path = xprop->base_path;
9f69e4b8b695 add libxattr
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 479
diff changeset
152 } else {
9f69e4b8b695 add libxattr
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 479
diff changeset
153 size_t base_href_len = strlen(xprop->base_href);
9f69e4b8b695 add libxattr
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 479
diff changeset
154 size_t base_path_len = strlen(xprop->base_path);
9f69e4b8b695 add libxattr
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 479
diff changeset
155 char *res_path = resource->href + base_href_len;
9f69e4b8b695 add libxattr
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 479
diff changeset
156 size_t res_path_len = strlen(res_path);
9f69e4b8b695 add libxattr
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 479
diff changeset
157
9f69e4b8b695 add libxattr
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 479
diff changeset
158 path_dp = pool_malloc(sn->pool, base_path_len + res_path_len + 2);
9f69e4b8b695 add libxattr
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 479
diff changeset
159 memcpy(path_dp, xprop->base_path, base_path_len);
9f69e4b8b695 add libxattr
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 479
diff changeset
160 int s = 0;
9f69e4b8b695 add libxattr
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 479
diff changeset
161 if(path_dp[base_path_len-1] != '/' && res_path[0] != '/') {
9f69e4b8b695 add libxattr
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 479
diff changeset
162 path_dp[base_path_len] = '/';
9f69e4b8b695 add libxattr
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 479
diff changeset
163 s = 1;
9f69e4b8b695 add libxattr
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 479
diff changeset
164 }
9f69e4b8b695 add libxattr
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 479
diff changeset
165 memcpy(path_dp + base_path_len + s, res_path, res_path_len);
9f69e4b8b695 add libxattr
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 479
diff changeset
166 path_dp[base_path_len + s + res_path_len] = 0;
9f69e4b8b695 add libxattr
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 479
diff changeset
167
9f69e4b8b695 add libxattr
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 479
diff changeset
168 path = path_dp;
9f69e4b8b695 add libxattr
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 479
diff changeset
169 }
9f69e4b8b695 add libxattr
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 479
diff changeset
170
9f69e4b8b695 add libxattr
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 479
diff changeset
171 ssize_t xattr_data_len = 0;
9f69e4b8b695 add libxattr
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 479
diff changeset
172 char *xattr_data = xattr_get_alloc(
9f69e4b8b695 add libxattr
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 479
diff changeset
173 sn->pool,
9f69e4b8b695 add libxattr
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 479
diff changeset
174 (libxattr_malloc_func)pool_malloc,
9f69e4b8b695 add libxattr
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 479
diff changeset
175 (libxattr_free_func)pool_free,
9f69e4b8b695 add libxattr
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 479
diff changeset
176 path,
9f69e4b8b695 add libxattr
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 479
diff changeset
177 repo->xattr_name,
9f69e4b8b695 add libxattr
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 479
diff changeset
178 &xattr_data_len);
9f69e4b8b695 add libxattr
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 479
diff changeset
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
9f69e4b8b695 add libxattr
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 479
diff changeset
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);
b02da778362e implement propfind for webdav xattr backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 481
diff changeset
222 if(!key.data.str) {
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
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
302 pmap = cxHashMapCreate(a, request->setcount + 8);
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);
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
324 if(!key.data.str) {
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 }
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
328 void *rmprop = cxMapRemove(pmap, key);
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
329 cxFree(a, key.data.str);
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
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
485 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
486 CxHashKey key = webdav_property_key_a(
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
487 pmap->allocator,
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
488 (const char*)prop->namespace->href,
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
489 (const char*)prop->name);
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
490 if(!key.data.str) {
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
491 return 1;
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
492 }
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
493 int ret = cxMapPut(pmap, key, prop);
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
494 cxFree(pmap->allocator, key.data.str);
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
495 return ret;
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
496 }
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
497
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
498 CxMap* webdav_xattr_parse_data(CxAllocator *a, const char *data, size_t len, const char *path) {
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
499 CxMap *pmap = cxHashMapCreate(a, 32);
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
500 if(!pmap) {
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
501 return NULL;
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
502 }
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
503 cxstring dat = cx_strn(data, len);
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
504
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
505 printf("\n\n");
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
506
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
507 cxstring s_elm = CX_STR("prop ");
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
508 cxstring s_ns = CX_STR("ns ");
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
509 cxstring s_data = CX_STR("data ");
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
510
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
511 WebdavProperty *prop = NULL;
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
512
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
513 int error = 0;
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 size_t elmno = 0;
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
516 cxstring line;
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
517 size_t pos = 0;
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
518 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
519 if(cx_strprefix(line, s_elm)) {
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
520 if(prop) {
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
521 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
522 error = 1;
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
523 break;
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 }
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 line = cx_strsubs(line, 5);
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
528
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
529 // get prop name, namespace and lang
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
530 cxstring name;
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
531 cxstring prefix;
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
532 cxstring xmlns;
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
533 cxstring lang;
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
534 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
535 log_ereport(
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
536 LOG_FAILURE,
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
537 "webdav xattr backend: %file %s: invalid xattr format[%d]: cannot parse elm line",
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
538 path,
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
539 elmno);
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
540 error = 1;
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
541 break;
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
542 }
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
543
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
544 // create property
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
545 prop = cxMalloc(a, sizeof(WebdavProperty));
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
546 if(!prop) {
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
547 error = 1;
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
548 break;
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
549 }
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
550 ZERO(prop, sizeof(WebdavProperty));
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
551
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
552 WSNamespace *ns = cxMalloc(a, sizeof(WSNamespace));
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
553 if(!ns) {
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
554 error = 1;
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
555 break;
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
556 }
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
557
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
558 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
559 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
560 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
561 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
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 ns->prefix = (const xmlChar*)prefix_str;
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
567 ns->href = (const xmlChar*)xmlns_str;
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
568
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
569 prop->name = name_str;
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
570 prop->namespace = ns;
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 elmno++;
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
573 } else if(prop) {
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
574 if(cx_strprefix(line, s_ns)) {
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
575 // TODO
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
576 } 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
577 line = cx_strsubs(line, 5);
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
578
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
579 // 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
580 // 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
581 int64_t data_len = 0;
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
582 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
583 log_ereport(
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
584 LOG_FAILURE,
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
585 "webdav xattr backend: %file %s: invalid xattr format[%d]: number expected after data",
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
586 path,
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
587 elmno);
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
588 error = 1;
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
589 break;
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
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
592 // get data
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
593 if(data_len > 0) {
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
594 if(data_len > dat.length - pos) {
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
595 log_ereport(
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
596 LOG_FAILURE,
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
597 "webdav xattr backend: %file %s: invalid data length %" PRId64 " in prop %d",
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
598 path,
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
599 data_len,
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
600 elmno);
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
601 error = 1;
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
602 break;
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
603 }
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
604
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
605 cxstring propdata;
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
606 propdata.ptr = dat.ptr + pos;
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
607 propdata.length = data_len;
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
608 pos += data_len;
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
609
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
610 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
611 if(!propdata_cp.ptr) {
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
612 error = 1;
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
613 break;
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
614 }
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
615 prop->vtype = WS_VALUE_XML_DATA;
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
616 prop->value.data.namespaces = NULL;
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
617 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
618 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
619
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
620 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
621 pos++;
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
622 }
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
623 }
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
624 } else {
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
625 log_ereport(
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
626 LOG_FAILURE,
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
627 "webdav xattr backend: %file %s: invalid xattr format[%d]: unknown element",
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
628 path,
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
629 elmno);
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
630 error = 1;
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
631 break;
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
632 }
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
633 }
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 //printf("line: {%.*s}\n", (int)line.length, line.ptr);
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
636 //fflush(stdout);
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
637 }
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
638
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
639 // add last property
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
640 if(prop) {
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
641 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
642 error = 1;
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
643 }
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
644 }
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
645
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
646 if(error) {
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
647 // TODO: free pmap content
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
648 cxMapDestroy(pmap);
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
649 pmap = NULL;
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
650 }
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
651
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
652 //printf("\n\n");
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
653 //fflush(stdout);
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
654
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
655
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
656 return pmap;
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
657 }
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
658
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
659 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
660 pool_handle_t *pool = a->data;
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
661
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
662 CxBuffer buf;
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
663 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
664 return (cxmutstr){NULL,0};
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
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
667 CxIterator i = cxMapIteratorValues(pmap);
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
668 cx_foreach(WebdavProperty*, prop, i) {
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
669 WSXmlData *property_value = NULL;
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
670 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
671 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
672 } 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
673 property_value = &prop->value.data;
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
674 }
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 cx_bprintf(&buf, "prop xmlns:%s=\"%s\" %s\n", prop->namespace->prefix, prop->namespace->href, prop->name);
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
677 if(property_value) {
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
678 WebdavNSList *ns = property_value->namespaces;
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
679 while(ns) {
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
680 cx_bprintf(&buf, "ns %s:%s\n", prop->namespace->prefix, prop->namespace->href);
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
681 ns = ns->next;
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
682 }
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
683
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
684 cx_bprintf(&buf, "data %zu\n", property_value->length);
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
685 cxBufferWrite(property_value->data, 1, property_value->length, &buf);
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
686 cxBufferPut(&buf, '\n');
31affbf33911 implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 480
diff changeset
687 }
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 return (cxmutstr){buf.space, buf.size};
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

mercurial