From 085e7730b88a0c4a42a325c3ed4dd99f0b67185b Mon Sep 17 00:00:00 2001 From: Christian Dywan Date: Mon, 21 Jun 2010 07:13:47 +0200 Subject: [PATCH] Implement doctype check in the trivial parser This is needed for the libxml parser backend. --- bus/config-parser-trivial.c | 19 +++++++++++++++++++ bus/config-parser-trivial.h | 3 +++ 2 files changed, 22 insertions(+) diff --git a/bus/config-parser-trivial.c b/bus/config-parser-trivial.c index fd016a84..8a1f504c 100644 --- a/bus/config-parser-trivial.c +++ b/bus/config-parser-trivial.c @@ -130,6 +130,25 @@ bus_config_parser_unref (BusConfigParser *parser) dbus_free (parser); } +dbus_bool_t +bus_config_parser_check_doctype (BusConfigParser *parser, + const char *doctype, + DBusError *error) +{ + _DBUS_ASSERT_ERROR_IS_CLEAR (error); + + if (strcmp (doctype, "busconfig") != 0) + { + dbus_set_error (error, + DBUS_ERROR_FAILED, + "Configuration file has the wrong document type %s", + doctype); + return FALSE; + } + else + return TRUE; +} + dbus_bool_t bus_config_parser_start_element (BusConfigParser *parser, const char *element_name, diff --git a/bus/config-parser-trivial.h b/bus/config-parser-trivial.h index ce542bfb..6733b1f4 100644 --- a/bus/config-parser-trivial.h +++ b/bus/config-parser-trivial.h @@ -41,6 +41,9 @@ BusConfigParser* bus_config_parser_new (const DBusString *basedir, BusConfigParser* bus_config_parser_ref (BusConfigParser *parser); void bus_config_parser_unref (BusConfigParser *parser); +dbus_bool_t bus_config_parser_check_doctype (BusConfigParser *parser, + const char *doctype, + DBusError *error); dbus_bool_t bus_config_parser_start_element (BusConfigParser *parser, const char *element_name, const char **attribute_names, -- 2.34.1