X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=bus%2Fconfig-loader-expat.c;h=b571fda3181fd39eac73e8dd1d48d78fdf780fb9;hb=7d9239c9c78cb6d0b9c282376fcf3cda1de23209;hp=9988fb6935ed3f38e31dad8cbbb61de007cca4e7;hpb=e6809d1a692da3b1127610b527f636743458274b;p=platform%2Fupstream%2Fdbus.git diff --git a/bus/config-loader-expat.c b/bus/config-loader-expat.c index 9988fb6..b571fda 100644 --- a/bus/config-loader-expat.c +++ b/bus/config-loader-expat.c @@ -1,9 +1,9 @@ -/* -*- mode: C; c-file-style: "gnu" -*- */ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ /* config-loader-expat.c expat XML loader * * Copyright (C) 2003 Red Hat, Inc. * - * Licensed under the Academic Free License version 1.2 + * Licensed under the Academic Free License version 2.1 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,20 +17,16 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ +#include #include "config-parser.h" #include #include -static XML_Memory_Handling_Suite memsuite = -{ - dbus_malloc, - dbus_realloc, - dbus_free -}; +static XML_Memory_Handling_Suite memsuite; typedef struct { @@ -163,14 +159,17 @@ expat_CharacterDataHandler (void *userData, BusConfigParser* -bus_config_load (const DBusString *file, - DBusError *error) +bus_config_load (const DBusString *file, + dbus_bool_t is_toplevel, + const BusConfigParser *parent, + DBusError *error) { XML_Parser expat; const char *filename; BusConfigParser *parser; ExpatParseContext context; - + DBusString dirname; + _DBUS_ASSERT_ERROR_IS_CLEAR (error); parser = NULL; @@ -178,14 +177,25 @@ bus_config_load (const DBusString *file, context.error = error; context.failed = FALSE; - _dbus_string_get_const_data (file, &filename); + filename = _dbus_string_get_const_data (file); + + if (!_dbus_string_init (&context.content)) + { + dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL); + return NULL; + } - if (!_dbus_string_init (&context.content, _DBUS_INT_MAX)) + if (!_dbus_string_init (&dirname)) { dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL); + _dbus_string_free (&context.content); return NULL; } + memsuite.malloc_fcn = dbus_malloc; + memsuite.realloc_fcn = dbus_realloc; + memsuite.free_fcn = dbus_free; + expat = XML_ParserCreate_MM ("UTF-8", &memsuite, NULL); if (expat == NULL) { @@ -193,7 +203,13 @@ bus_config_load (const DBusString *file, goto failed; } - parser = bus_config_parser_new (); + if (!_dbus_string_get_dirname (file, &dirname)) + { + dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL); + goto failed; + } + + parser = bus_config_parser_new (&dirname, is_toplevel, parent); if (parser == NULL) { dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL); @@ -212,7 +228,7 @@ bus_config_load (const DBusString *file, DBusString data; const char *data_str; - if (!_dbus_string_init (&data, _DBUS_INT_MAX)) + if (!_dbus_string_init (&data)) { dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL); goto failed; @@ -224,7 +240,7 @@ bus_config_load (const DBusString *file, goto failed; } - _dbus_string_get_const_data (&data, &data_str); + data_str = _dbus_string_get_const_data (&data); if (!XML_Parse (expat, data_str, _dbus_string_get_length (&data), TRUE)) { @@ -258,6 +274,7 @@ bus_config_load (const DBusString *file, if (!bus_config_parser_finished (parser, error)) goto failed; + _dbus_string_free (&dirname); _dbus_string_free (&context.content); XML_ParserFree (expat); @@ -267,6 +284,7 @@ bus_config_load (const DBusString *file, failed: _DBUS_ASSERT_ERROR_IS_SET (error); + _dbus_string_free (&dirname); _dbus_string_free (&context.content); if (expat) XML_ParserFree (expat);