src/server/webdav/parser.c

Tue, 09 Jul 2013 20:56:01 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Tue, 09 Jul 2013 20:56:01 +0200
changeset 86
49bb6c8ceb2b
parent 85
b62e77d8e80c
child 87
bdec069d2239
permissions
-rw-r--r--

replaced usage of deprecated openldap functions

85
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1 /*
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
3 *
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
4 * Copyright 2013 Olaf Wintermann. All rights reserved.
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
5 *
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
6 * Redistribution and use in source and binary forms, with or without
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
7 * modification, are permitted provided that the following conditions are met:
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
8 *
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
9 * 1. Redistributions of source code must retain the above copyright
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
10 * notice, this list of conditions and the following disclaimer.
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
11 *
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
12 * 2. Redistributions in binary form must reproduce the above copyright
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
13 * notice, this list of conditions and the following disclaimer in the
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
14 * documentation and/or other materials provided with the distribution.
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
15 *
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
b62e77d8e80c replaced propfind parser with new libxml2 parser
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
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
26 * POSSIBILITY OF SUCH DAMAGE.
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
27 */
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
28
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
29 #include <stdio.h>
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
30 #include <stdlib.h>
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
31 #include <unistd.h>
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
32
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
33 #include "parser.h"
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
34
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
35
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
36 void xmlerrorfnc(void * ctx, const char * msg, ... ) {
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
37 // nothing
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
38 }
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
39
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
40 static int xinit = 0;
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
41
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
42 PropfindRequest* dav_parse_propfind2(
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
43 Session *sn,
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
44 Request *rq,
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
45 char *xml,
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
46 size_t len)
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
47 {
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
48 if(!xinit) {
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
49 xmlGenericErrorFunc fnc = xmlerrorfnc;
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
50 initGenericErrorDefaultFunc(&fnc);
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
51 xinit = 1;
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
52 }
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
53
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
54 PropfindRequest *davrq = (PropfindRequest*)pool_calloc(
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
55 sn->pool,
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
56 1,
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
57 sizeof(PropfindRequest));
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
58 davrq->nsmap = xmlnsmap_create(sn->pool);
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
59 xmlnsmap_put(davrq->nsmap, (char*)"DAV:");
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
60 davrq->allprop = 0;
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
61 davrq->propname = 0;
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
62 davrq->prop = 0;
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
63 davrq->properties = NULL;
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
64 davrq->forbiddenProps = NULL;
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
65 davrq->notFoundProps = NULL;
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
66 davrq->mgrdata = NULL;
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
67
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
68
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
69 xmlTextReaderPtr reader = xmlReaderForMemory(xml, len, NULL, NULL, 0);
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
70 int r = 0;
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
71
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
72 if(!reader) {
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
73 fprintf(stderr, "Cannot create xmlReader\n");
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
74 return davrq;
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
75 }
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
76
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
77 PropfindParser *parser = pool_malloc(sn->pool, sizeof(PropfindParser));
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
78 parser->pool = sn->pool;
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
79 parser->rq = davrq;
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
80 parser->property = NULL;
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
81 parser->davPropTag = 0;
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
82
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
83 while((r = xmlTextReaderRead(reader)) == 1) {
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
84 int nodetype = xmlTextReaderNodeType(reader);
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
85 const xmlChar *name = xmlTextReaderConstLocalName(reader);
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
86 if(nodetype == XML_READER_TYPE_ELEMENT) {
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
87 if(propfind_begin_elm(parser, reader)) {
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
88 fprintf(stderr, "propfind xml error\n");
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
89 break;
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
90 }
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
91 } else if(nodetype == XML_READER_TYPE_END_ELEMENT) {
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
92 if(propfind_end_elm(parser, reader)) {
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
93 fprintf(stderr, "propfind xml error\n");
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
94 break;
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
95 }
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
96 }
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
97 }
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
98
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
99 pool_free(sn->pool, parser);
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
100
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
101 return davrq;
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
102 }
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
103
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
104 int propfind_begin_elm(PropfindParser *p, xmlTextReaderPtr elm) {
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
105 pool_handle_t *pool = p->pool;
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
106 const xmlChar *ns = xmlTextReaderConstNamespaceUri(elm);
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
107 const xmlChar *name = xmlTextReaderConstLocalName(elm);
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
108
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
109 if(ns == NULL) {
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
110 fprintf(stderr, "ERROR: namespace is null!\n");
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
111 return -1;
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
112 }
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
113
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
114 int dav_ns = xstreq(ns, "DAV:") ? 1 : 0;
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
115
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
116 if(dav_ns && xstreq(name, "allprop")) {
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
117 p->rq->allprop = 1;
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
118 } else if(dav_ns && xstreq(name, "prop")) {
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
119 p->davPropTag = 1;
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
120 } else if(p->davPropTag && !p->property && !p->rq->allprop) {
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
121 DavProperty *property = pool_malloc(pool, sizeof(DavProperty));
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
122 size_t nslen = strlen(ns);
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
123 size_t namelen = strlen(name);
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
124 if(nslen > 0) {
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
125 property->xmlns = xmlnsmap_put(p->rq->nsmap, (char*)ns);
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
126 } else {
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
127 property->xmlns = NULL;
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
128 }
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
129
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
130 property->name = pool_malloc(pool, namelen + 1);
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
131 property->name[namelen] = 0;
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
132 memcpy(property->name, name, namelen);
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
133
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
134 // add property to DavRequest
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
135 UcxDlist *elm = pool_malloc(pool, sizeof(UcxDlist));
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
136 elm->prev = NULL;
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
137 elm->next = NULL;
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
138 elm->data = property;
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
139 p->rq->properties = ucx_dlist_concat(p->rq->properties, elm);
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
140 }
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
141
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
142 return 0;
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
143 }
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
144
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
145 int propfind_end_elm(PropfindParser *p, xmlTextReaderPtr elm) {
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
146 pool_handle_t *pool = p->pool;
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
147 const xmlChar *ns = xmlTextReaderConstNamespaceUri(elm);
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
148 const xmlChar *name = xmlTextReaderConstLocalName(elm);
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
149
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
150 if(ns == NULL) {
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
151 fprintf(stderr, "ERROR: namespace is null!\n");
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
152 return -1;
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
153 }
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
154
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
155 // nothing here yet
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
156
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
157 return 0;
b62e77d8e80c replaced propfind parser with new libxml2 parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
158 }

mercurial