Sat, 15 Dec 2012 16:05:03 +0100
added support for asynchronous safs
13 | 1 | /* |
2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. | |
3 | * | |
4 | * Copyright 2011 Olaf Wintermann. All rights reserved. | |
5 | * | |
6 | * Redistribution and use in source and binary forms, with or without | |
7 | * modification, are permitted provided that the following conditions are met: | |
8 | * | |
9 | * 1. Redistributions of source code must retain the above copyright | |
10 | * notice, this list of conditions and the following disclaimer. | |
11 | * | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | |
15 | * | |
16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |
17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | |
20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
26 | * POSSIBILITY OF SUCH DAMAGE. | |
27 | */ | |
28 | ||
29 | #include <stdio.h> | |
30 | #include <stdlib.h> | |
31 | #include <string.h> | |
32 | ||
15
cff9c4101dd7
Replaced old utils with ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
33 | #include "../ucx/string.h" |
14
b8bf95b39952
New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
13
diff
changeset
|
34 | #include "../ucx/dlist.h" |
b8bf95b39952
New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
13
diff
changeset
|
35 | #include "../util/pool.h" |
13 | 36 | |
37 | #include "saxhandler.h" | |
38 | ||
25
5dee29c7c530
Fixed config parser bug
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
39 | using namespace std; |
13 | 40 | |
30
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
41 | void xstack_push(UcxDlist **stack, XmlElement *elm) { |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
42 | *stack = ucx_dlist_prepend(*stack, elm); |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
43 | } |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
44 | |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
45 | XmlElement* xstack_pop(UcxDlist **stack) { |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
46 | if(*stack == NULL) { |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
47 | return NULL; |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
48 | } |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
49 | XmlElement* ret = (XmlElement*)(*stack)->data; |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
50 | UcxDlist *newstack = ucx_dlist_remove(*stack, *stack); |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
51 | *stack = newstack; |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
52 | return ret; |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
53 | } |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
54 | |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
55 | |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
56 | |
13 | 57 | PropfindHandler::PropfindHandler(PropfindRequest *rq, pool_handle_t *p) { |
58 | davrq = rq; | |
59 | pool = p; | |
60 | ||
61 | davPropTag = false; | |
62 | property = NULL; | |
63 | } | |
64 | ||
65 | PropfindHandler::~PropfindHandler() { | |
66 | ||
67 | } | |
68 | ||
69 | void PropfindHandler::startElement( | |
70 | const XMLCh *const uri, | |
71 | const XMLCh* const localname, | |
72 | const XMLCh* const qname, | |
73 | const Attributes& attrs) | |
74 | { | |
75 | char *ns = XMLString::transcode(uri); | |
76 | char *name = XMLString::transcode(localname); | |
77 | ||
78 | if(!strcmp(ns, "DAV:") && !strcmp(name, "prop")) { | |
79 | davPropTag = true; | |
80 | } else if(davPropTag && property == NULL) { | |
81 | //property = (DavProperty*)pool_malloc(pool, sizeof(DavProperty)); | |
82 | property = (DavProperty*)malloc(sizeof(DavProperty)); | |
83 | /* Ultra TODO: pool_malloc makes big mistakes!! */ | |
84 | ||
85 | size_t nslen = strlen(ns); | |
86 | size_t namelen = strlen(name); | |
87 | if(nslen > 0) { | |
88 | property->xmlns = (char*)pool_malloc(pool, nslen + 1); | |
89 | property->xmlns[nslen] = 0; | |
90 | memcpy(property->xmlns, ns, nslen); | |
91 | } else { | |
92 | property->xmlns = NULL; | |
93 | } | |
94 | ||
95 | if(namelen > 0) { | |
96 | property->name = (char*)pool_malloc(pool, namelen + 1); | |
97 | property->name[namelen] = 0; | |
98 | memcpy(property->name, name, namelen); | |
99 | } else { | |
100 | property->name = NULL; | |
101 | } | |
102 | } | |
103 | ||
104 | XMLString::release(&ns); | |
105 | XMLString::release(&name); | |
106 | } | |
107 | ||
108 | ||
109 | void PropfindHandler::endElement( | |
110 | const XMLCh* const uri, | |
111 | const XMLCh* const localname, | |
112 | const XMLCh* const qname) | |
113 | { | |
114 | char *ns = XMLString::transcode(uri); | |
115 | char *name = XMLString::transcode(localname); | |
116 | ||
117 | if(property != NULL) { | |
118 | const char *xmlns = (property->xmlns) ? property->xmlns : ""; | |
119 | ||
120 | if(!strcmp(ns, xmlns) && !strcmp(name, property->name)) { | |
121 | // add property to DavRequest | |
122 | UcxDlist *elm = (UcxDlist*)pool_malloc(pool, sizeof(UcxDlist)); | |
123 | elm->prev = NULL; | |
124 | elm->next = NULL; | |
125 | elm->data = property; | |
126 | //printf("saxhandler: add property: {%s}\n", property->name); | |
127 | davrq->properties = ucx_dlist_concat(davrq->properties, elm); | |
128 | ||
129 | property = NULL; | |
130 | } | |
131 | } | |
132 | ||
133 | XMLString::release(&ns); | |
134 | XMLString::release(&name); | |
135 | } | |
136 | ||
137 | void PropfindHandler::startDocument() { | |
138 | ||
139 | } | |
140 | ||
141 | void PropfindHandler::endDocument() { | |
142 | ||
143 | } | |
144 | ||
29
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
25
diff
changeset
|
145 | |
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
25
diff
changeset
|
146 | /************* PropPatch Handler **************/ |
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
25
diff
changeset
|
147 | |
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
25
diff
changeset
|
148 | ProppatchHandler::ProppatchHandler(ProppatchRequest *rq, pool_handle_t *p) { |
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
25
diff
changeset
|
149 | davrq = rq; |
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
25
diff
changeset
|
150 | pool = p; |
30
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
151 | |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
152 | davPropTag = false; |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
153 | rootElement = NULL; |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
154 | xmlStack = NULL; |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
155 | newElement = NULL; |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
156 | |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
157 | updateMode = -1; |
29
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
25
diff
changeset
|
158 | } |
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
25
diff
changeset
|
159 | |
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
25
diff
changeset
|
160 | ProppatchHandler::~ProppatchHandler() { |
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
25
diff
changeset
|
161 | |
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
25
diff
changeset
|
162 | } |
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
25
diff
changeset
|
163 | |
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
25
diff
changeset
|
164 | void ProppatchHandler::startElement( |
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
25
diff
changeset
|
165 | const XMLCh *const uri, |
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
25
diff
changeset
|
166 | const XMLCh* const localname, |
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
25
diff
changeset
|
167 | const XMLCh* const qname, |
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
25
diff
changeset
|
168 | const Attributes& attrs) |
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
25
diff
changeset
|
169 | { |
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
25
diff
changeset
|
170 | char *ns = XMLString::transcode(uri); |
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
25
diff
changeset
|
171 | char *name = XMLString::transcode(localname); |
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
25
diff
changeset
|
172 | |
30
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
173 | if(!strcmp(ns, "DAV:") && !strcmp(name, "set")) { |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
174 | updateMode = 0; |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
175 | } else if(!strcmp(ns, "DAV:") && !strcmp(name, "remove")) { |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
176 | updateMode = 1; |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
177 | } else if(!strcmp(ns, "DAV:") && !strcmp(name, "prop")) { |
29
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
25
diff
changeset
|
178 | davPropTag = true; |
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
25
diff
changeset
|
179 | } else if(davPropTag) { |
30
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
180 | newElement = (XmlElement*)pool_calloc(pool, 1, sizeof(XmlElement)); |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
181 | newElement->name = sstr(pool_strdup(pool, name)); |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
182 | newElement->xmlns = xmlnsmap_put(davrq->nsmap, ns); |
29
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
25
diff
changeset
|
183 | |
30
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
184 | /* |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
185 | * the xml stack manages the xml hierarchy |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
186 | * new elements will be added to the top element on the stack |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
187 | */ |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
188 | |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
189 | XmlElement *currentElm = XSTACK_CUR(); |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
190 | if(currentElm) { |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
191 | xmlelm_add_child(currentElm, newElement); |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
192 | } |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
193 | |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
194 | /* newElement is now the parent for future elements */ |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
195 | XSTACK_PUSH(newElement); |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
196 | |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
197 | /* if the root element isn't set, the first new element is the root */ |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
198 | if(!rootElement) { |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
199 | rootElement = newElement; |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
200 | } |
29
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
25
diff
changeset
|
201 | } |
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
25
diff
changeset
|
202 | |
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
25
diff
changeset
|
203 | XMLString::release(&ns); |
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
25
diff
changeset
|
204 | XMLString::release(&name); |
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
25
diff
changeset
|
205 | } |
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
25
diff
changeset
|
206 | |
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
25
diff
changeset
|
207 | |
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
25
diff
changeset
|
208 | void ProppatchHandler::endElement( |
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
25
diff
changeset
|
209 | const XMLCh* const uri, |
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
25
diff
changeset
|
210 | const XMLCh* const localname, |
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
25
diff
changeset
|
211 | const XMLCh* const qname) |
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
25
diff
changeset
|
212 | { |
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
25
diff
changeset
|
213 | char *ns = XMLString::transcode(uri); |
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
25
diff
changeset
|
214 | char *name = XMLString::transcode(localname); |
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
25
diff
changeset
|
215 | |
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
25
diff
changeset
|
216 | if(!strcmp(ns, "DAV:") && !strcmp(name, "set")) { |
30
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
217 | updateMode = -1; |
29
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
25
diff
changeset
|
218 | } else if(!strcmp(ns, "DAV:") && !strcmp(name, "remove")) { |
30
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
219 | updateMode = -1; |
29
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
25
diff
changeset
|
220 | } else if(!strcmp(ns, "DAV:") && !strcmp(name, "prop")) { |
30
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
221 | davPropTag = false; |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
222 | } else if(davPropTag) { |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
223 | XmlElement *elm = XSTACK_POP(); |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
224 | if(xmlStack == NULL) { |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
225 | /* property complete */ |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
226 | |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
227 | /* |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
228 | XmlElement *r = rootElement; |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
229 | printf("<%s>\n", sstrdup(r->name).ptr); |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
230 | printf("%s\n", r->content); |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
231 | printf("</%s>\n", sstrdup(r->name).ptr); |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
232 | */ |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
233 | |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
234 | /* add the property to the proppatch request */ |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
235 | switch(updateMode) { |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
236 | case 0: { |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
237 | davrq->setProps = ucx_dlist_append( |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
238 | davrq->setProps, |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
239 | rootElement); |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
240 | break; |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
241 | } |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
242 | case 1: { |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
243 | davrq->removeProps = ucx_dlist_append( |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
244 | davrq->removeProps, |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
245 | rootElement); |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
246 | break; |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
247 | } |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
248 | } |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
249 | |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
250 | rootElement = NULL; |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
251 | |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
252 | } |
29
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
25
diff
changeset
|
253 | } |
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
25
diff
changeset
|
254 | |
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
25
diff
changeset
|
255 | |
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
25
diff
changeset
|
256 | XMLString::release(&ns); |
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
25
diff
changeset
|
257 | XMLString::release(&name); |
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
25
diff
changeset
|
258 | } |
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
25
diff
changeset
|
259 | |
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
25
diff
changeset
|
260 | void ProppatchHandler::characters( |
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
25
diff
changeset
|
261 | const XMLCh *const chars, |
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
25
diff
changeset
|
262 | const XMLSize_t length) |
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
25
diff
changeset
|
263 | { |
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
25
diff
changeset
|
264 | |
30
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
265 | XMLString::trim((XMLCh *const)chars); |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
266 | if(chars[0] == 0) { |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
267 | return; |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
268 | } |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
269 | |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
270 | XmlElement *currentElm = XSTACK_CUR(); |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
271 | if(currentElm) { |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
272 | xmlch_t *str = (xmlch_t*)pool_calloc(pool, sizeof(xmlch_t), length + 1); |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
273 | for(int i=0;i<length;i++) { |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
274 | str[i] = chars[i]; |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
275 | } |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
276 | |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
277 | currentElm->content = str; |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
278 | currentElm->ctlen = length; |
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
279 | } |
29
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
25
diff
changeset
|
280 | } |
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
25
diff
changeset
|
281 | |
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
25
diff
changeset
|
282 | void ProppatchHandler::startDocument() { |
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
25
diff
changeset
|
283 | |
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
25
diff
changeset
|
284 | } |
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
25
diff
changeset
|
285 | |
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
25
diff
changeset
|
286 | void ProppatchHandler::endDocument() { |
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
25
diff
changeset
|
287 | |
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
25
diff
changeset
|
288 | } |
e8619defde14
added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
25
diff
changeset
|
289 |