[PATCH] Implement doctype check in the trivial parser
Christian Dywan
christian.dywan at lanedo.com
Sun Jun 20 22:13:47 PDT 2010
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(+), 0 deletions(-)
diff --git a/bus/config-parser-trivial.c b/bus/config-parser-trivial.c
index a35226a..59ec2ba 100644
--- a/bus/config-parser-trivial.c
+++ b/bus/config-parser-trivial.c
@@ -132,6 +132,25 @@ bus_config_parser_unref (BusConfigParser *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,
const char **attribute_names,
diff --git a/bus/config-parser-trivial.h b/bus/config-parser-trivial.h
index 70e5d5b..31ddef6 100644
--- a/bus/config-parser-trivial.h
+++ b/bus/config-parser-trivial.h
@@ -39,6 +39,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,
--
1.7.1
--MP_/2jKz3C3bl5J=7+9hdZgoVwI--
More information about the dbus
mailing list