Deleted Added
full compact
geom_xml2tree.c (253469) geom_xml2tree.c (280687)
1/*-
2 * Copyright (c) 2003 Poul-Henning Kamp
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 12 unchanged lines hidden (view full) ---

21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
1/*-
2 * Copyright (c) 2003 Poul-Henning Kamp
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 12 unchanged lines hidden (view full) ---

21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * $FreeBSD: head/lib/libgeom/geom_xml2tree.c 253469 2013-07-19 06:42:15Z scottl $
29 * $FreeBSD: head/lib/libgeom/geom_xml2tree.c 280687 2015-03-26 12:17:47Z mav $
30 */
31
32#include <stdio.h>
33#include <inttypes.h>
34#include <stdlib.h>
35#include <string.h>
36#include <unistd.h>
37#include <errno.h>

--- 143 unchanged lines hidden (view full) ---

181 }
182 }
183}
184
185static void
186EndElement(void *userData, const char *name)
187{
188 struct mystate *mt;
30 */
31
32#include <stdio.h>
33#include <inttypes.h>
34#include <stdlib.h>
35#include <string.h>
36#include <unistd.h>
37#include <errno.h>

--- 143 unchanged lines hidden (view full) ---

181 }
182 }
183}
184
185static void
186EndElement(void *userData, const char *name)
187{
188 struct mystate *mt;
189 struct gconf *c;
189 struct gconfig *gc;
190 char *p;
191
192 mt = userData;
193 p = NULL;
194 if (sbuf_finish(mt->sbuf[mt->level]) == 0)
195 p = strdup(sbuf_data(mt->sbuf[mt->level]));
196 sbuf_delete(mt->sbuf[mt->level]);

--- 57 unchanged lines hidden (view full) ---

254 return;
255 }
256
257 if (!strcmp(name, "config")) {
258 mt->config = NULL;
259 return;
260 }
261
190 struct gconfig *gc;
191 char *p;
192
193 mt = userData;
194 p = NULL;
195 if (sbuf_finish(mt->sbuf[mt->level]) == 0)
196 p = strdup(sbuf_data(mt->sbuf[mt->level]));
197 sbuf_delete(mt->sbuf[mt->level]);

--- 57 unchanged lines hidden (view full) ---

255 return;
256 }
257
258 if (!strcmp(name, "config")) {
259 mt->config = NULL;
260 return;
261 }
262
262 if (mt->config != NULL) {
263 if (mt->config != NULL || (!strcmp(name, "wither") &&
264 (mt->provider != NULL || mt->geom != NULL))) {
265 if (mt->config != NULL)
266 c = mt->config;
267 else if (mt->provider != NULL)
268 c = &mt->provider->lg_config;
269 else
270 c = &mt->geom->lg_config;
263 gc = calloc(1, sizeof *gc);
264 if (gc == NULL) {
265 mt->error = errno;
266 XML_StopParser(mt->parser, 0);
267 warn("Cannot allocate memory during processing of '%s' "
268 "element", name);
269 return;
270 }
271 gc->lg_name = strdup(name);
272 if (gc->lg_name == NULL) {
271 gc = calloc(1, sizeof *gc);
272 if (gc == NULL) {
273 mt->error = errno;
274 XML_StopParser(mt->parser, 0);
275 warn("Cannot allocate memory during processing of '%s' "
276 "element", name);
277 return;
278 }
279 gc->lg_name = strdup(name);
280 if (gc->lg_name == NULL) {
281 free(gc);
273 mt->error = errno;
274 XML_StopParser(mt->parser, 0);
275 warn("Cannot allocate memory during processing of '%s' "
276 "element", name);
277 return;
278 }
282 mt->error = errno;
283 XML_StopParser(mt->parser, 0);
284 warn("Cannot allocate memory during processing of '%s' "
285 "element", name);
286 return;
287 }
279 gc->lg_val = p;
280 LIST_INSERT_HEAD(mt->config, gc, lg_config);
288 gc->lg_val = p ? p : strdup("1");
289 LIST_INSERT_HEAD(c, gc, lg_config);
281 return;
282 }
283
284 if (p != NULL) {
285#if DEBUG_LIBGEOM > 0
286 printf("Unexpected XML: name=%s data=\"%s\"\n", name, p);
287#endif
288 free(p);

--- 231 unchanged lines hidden ---
290 return;
291 }
292
293 if (p != NULL) {
294#if DEBUG_LIBGEOM > 0
295 printf("Unexpected XML: name=%s data=\"%s\"\n", name, p);
296#endif
297 free(p);

--- 231 unchanged lines hidden ---