1 /* -*- mode: C; c-file-style: "gnu" -*- */
2 /* gather-introspect.c Dump introspection data from service to stdout
4 * Copyright (C) 2005 Red Hat, Inc.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 #include <dbus/dbus-glib.h>
29 usage (char *name, int ecode)
31 fprintf (stderr, "Usage: %s <service> <destination object path>\n", name);
36 main (int argc, char *argv[])
38 DBusGConnection *connection;
40 DBusGPendingCall *call;
44 const char *introspect_data;
55 connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
56 if (connection == NULL)
58 fprintf (stderr, "Failed to open connection to session bus: %s\n",
60 g_clear_error (&error);
64 proxy = dbus_g_proxy_new_for_name (connection,
66 DBUS_INTERFACE_INTROSPECTABLE);
67 call = dbus_g_proxy_begin_call (proxy, "Introspect", DBUS_TYPE_INVALID);
68 if (!dbus_g_proxy_end_call (proxy, call, &error, DBUS_TYPE_STRING,
69 &introspect_data, DBUS_TYPE_INVALID))
71 fprintf (stderr, "Failed to get introspection data: %s\n",
73 g_clear_error (&error);
77 printf ("%s", introspect_data);
79 dbus_g_pending_call_unref (call);
80 g_object_unref (proxy);