diff options
author | John (J5) Palmieri <johnp@redhat.com> | 2006-09-06 21:16:12 +0000 |
---|---|---|
committer | John (J5) Palmieri <johnp@redhat.com> | 2006-09-06 21:16:12 +0000 |
commit | 61316dd897846c6ee18daccdddaf8a78650a1406 (patch) | |
tree | 9054cac6119a0608661a305b2fae65729e88a375 /bus/driver.c | |
parent | e4f3d0ca17e2b43e5f921dd6b09c3648cbb3ba63 (diff) | |
download | dbus-61316dd897846c6ee18daccdddaf8a78650a1406.tar.gz |
* bus/driver.c:
(bus_driver_generate_introspect_string): New method for populating
a DBusString with the introspect data
(bus_driver_handle_introspect): Move introspect generation code to
bus_driver_generate_introspect_string
* bus/main.c:
(introspect): New function which prints out the intropect data and
exits
(main): Add a --introspect switch
Diffstat (limited to 'bus/driver.c')
-rw-r--r-- | bus/driver.c | 165 |
1 files changed, 87 insertions, 78 deletions
diff --git a/bus/driver.c b/bus/driver.c index 1a2c050b..69084330 100644 --- a/bus/driver.c +++ b/bus/driver.c @@ -1493,125 +1493,134 @@ write_args_for_direction (DBusString *xml, return FALSE; } -static dbus_bool_t -bus_driver_handle_introspect (DBusConnection *connection, - BusTransaction *transaction, - DBusMessage *message, - DBusError *error) +dbus_bool_t +bus_driver_generate_introspect_string (DBusString *xml) { - DBusString xml; - DBusMessage *reply; - const char *v_STRING; int i; - _dbus_verbose ("Introspect() on bus driver\n"); - - _DBUS_ASSERT_ERROR_IS_CLEAR (error); - - reply = NULL; - - if (! dbus_message_get_args (message, error, - DBUS_TYPE_INVALID)) - { - _DBUS_ASSERT_ERROR_IS_SET (error); - return FALSE; - } - - if (!_dbus_string_init (&xml)) - { - BUS_SET_OOM (error); - return FALSE; - } - - if (!_dbus_string_append (&xml, DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE)) - goto oom; - if (!_dbus_string_append (&xml, "<node>\n")) - goto oom; - if (!_dbus_string_append_printf (&xml, " <interface name=\"%s\">\n", DBUS_INTERFACE_INTROSPECTABLE)) - goto oom; - if (!_dbus_string_append (&xml, " <method name=\"Introspect\">\n")) - goto oom; - if (!_dbus_string_append_printf (&xml, " <arg name=\"data\" direction=\"out\" type=\"%s\"/>\n", DBUS_TYPE_STRING_AS_STRING)) - goto oom; - if (!_dbus_string_append (&xml, " </method>\n")) - goto oom; - if (!_dbus_string_append (&xml, " </interface>\n")) - goto oom; + if (!_dbus_string_append (xml, DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE)) + return FALSE; + if (!_dbus_string_append (xml, "<node>\n")) + return FALSE; + if (!_dbus_string_append_printf (xml, " <interface name=\"%s\">\n", DBUS_INTERFACE_INTROSPECTABLE)) + return FALSE; + if (!_dbus_string_append (xml, " <method name=\"Introspect\">\n")) + return FALSE; + if (!_dbus_string_append_printf (xml, " <arg name=\"data\" direction=\"out\" type=\"%s\"/>\n", DBUS_TYPE_STRING_AS_STRING)) + return FALSE; + if (!_dbus_string_append (xml, " </method>\n")) + return FALSE; + if (!_dbus_string_append (xml, " </interface>\n")) + return FALSE; - if (!_dbus_string_append_printf (&xml, " <interface name=\"%s\">\n", + if (!_dbus_string_append_printf (xml, " <interface name=\"%s\">\n", DBUS_INTERFACE_DBUS)) - goto oom; + return FALSE; i = 0; while (i < _DBUS_N_ELEMENTS (message_handlers)) { - if (!_dbus_string_append_printf (&xml, " <method name=\"%s\">\n", + if (!_dbus_string_append_printf (xml, " <method name=\"%s\">\n", message_handlers[i].name)) - goto oom; + return FALSE; - if (!write_args_for_direction (&xml, message_handlers[i].in_args, TRUE)) - goto oom; + if (!write_args_for_direction (xml, message_handlers[i].in_args, TRUE)) + return FALSE; - if (!write_args_for_direction (&xml, message_handlers[i].out_args, FALSE)) - goto oom; + if (!write_args_for_direction (xml, message_handlers[i].out_args, FALSE)) + return FALSE; - if (!_dbus_string_append (&xml, " </method>\n")) - goto oom; + if (!_dbus_string_append (xml, " </method>\n")) + return FALSE; ++i; } - if (!_dbus_string_append_printf (&xml, " <signal name=\"NameOwnerChanged\">\n")) - goto oom; + if (!_dbus_string_append_printf (xml, " <signal name=\"NameOwnerChanged\">\n")) + return FALSE; - if (!_dbus_string_append_printf (&xml, " <arg type=\"s\"/>\n")) - goto oom; + if (!_dbus_string_append_printf (xml, " <arg type=\"s\"/>\n")) + return FALSE; - if (!_dbus_string_append_printf (&xml, " <arg type=\"s\"/>\n")) - goto oom; + if (!_dbus_string_append_printf (xml, " <arg type=\"s\"/>\n")) + return FALSE; - if (!_dbus_string_append_printf (&xml, " <arg type=\"s\"/>\n")) - goto oom; + if (!_dbus_string_append_printf (xml, " <arg type=\"s\"/>\n")) + return FALSE; - if (!_dbus_string_append_printf (&xml, " </signal>\n")) - goto oom; + if (!_dbus_string_append_printf (xml, " </signal>\n")) + return FALSE; - if (!_dbus_string_append_printf (&xml, " <signal name=\"NameLost\">\n")) - goto oom; + if (!_dbus_string_append_printf (xml, " <signal name=\"NameLost\">\n")) + return FALSE; - if (!_dbus_string_append_printf (&xml, " <arg type=\"s\"/>\n")) - goto oom; + if (!_dbus_string_append_printf (xml, " <arg type=\"s\"/>\n")) + return FALSE; - if (!_dbus_string_append_printf (&xml, " </signal>\n")) - goto oom; + if (!_dbus_string_append_printf (xml, " </signal>\n")) + return FALSE; - if (!_dbus_string_append_printf (&xml, " <signal name=\"NameAcquired\">\n")) - goto oom; + if (!_dbus_string_append_printf (xml, " <signal name=\"NameAcquired\">\n")) + return FALSE; - if (!_dbus_string_append_printf (&xml, " <arg type=\"s\"/>\n")) - goto oom; + if (!_dbus_string_append_printf (xml, " <arg type=\"s\"/>\n")) + return FALSE; - if (!_dbus_string_append_printf (&xml, " </signal>\n")) - goto oom; - + if (!_dbus_string_append_printf (xml, " </signal>\n")) + return FALSE; + if (!_dbus_string_append (xml, " </interface>\n")) + return FALSE; - if (!_dbus_string_append (&xml, " </interface>\n")) - goto oom; + if (!_dbus_string_append (xml, "</node>\n")) + return FALSE; + + return TRUE; +} + +static dbus_bool_t +bus_driver_handle_introspect (DBusConnection *connection, + BusTransaction *transaction, + DBusMessage *message, + DBusError *error) +{ + DBusString xml; + DBusMessage *reply; + const char *v_STRING; + + _dbus_verbose ("Introspect() on bus driver\n"); - if (!_dbus_string_append (&xml, "</node>\n")) + _DBUS_ASSERT_ERROR_IS_CLEAR (error); + + reply = NULL; + + if (! dbus_message_get_args (message, error, + DBUS_TYPE_INVALID)) + { + _DBUS_ASSERT_ERROR_IS_SET (error); + return FALSE; + } + + if (!_dbus_string_init (&xml)) + { + BUS_SET_OOM (error); + return FALSE; + } + + if (!bus_driver_generate_introspect_string (&xml)) goto oom; + v_STRING = _dbus_string_get_const_data (&xml); + reply = dbus_message_new_method_return (message); if (reply == NULL) goto oom; - v_STRING = _dbus_string_get_const_data (&xml); if (! dbus_message_append_args (reply, DBUS_TYPE_STRING, &v_STRING, DBUS_TYPE_INVALID)) |