static void
usage (int ecode)
{
- fprintf (stderr, "Usage: %s [--help] [--system | --session | --address=ADDRESS] [--dest=NAME] [--type=TYPE] [--print-reply[=literal]] [--reply-timeout=MSEC] <destination object path> <message name> [contents ...]\n", appname);
+ fprintf (stderr, "Usage: %s [--help] [--system | --session | --bus=ADDRESS | --peer=ADDRESS] [--dest=NAME] [--type=TYPE] [--print-reply[=literal]] [--reply-timeout=MSEC] <destination object path> <message name> [contents ...]\n", appname);
exit (ecode);
}
int message_type = DBUS_MESSAGE_TYPE_SIGNAL;
const char *type_str = NULL;
const char *address = NULL;
+ int is_bus = FALSE;
int session_or_system = FALSE;
appname = argv[0];
type = DBUS_BUS_SESSION;
session_or_system = TRUE;
}
- else if (strstr (arg, "--address=") == arg)
+ else if ((strstr (arg, "--bus=") == arg) || (strstr (arg, "--peer=") == arg) || (strstr (arg, "--address=") == arg))
{
- if (*(strchr (arg, '=') + 1) == '\0')
+ if (arg[2] == 'b') /* bus */
{
- fprintf (stderr, "\"--address=\" requires an ADDRESS\n");
- usage (1);
+ is_bus = TRUE;
+ }
+ else if (arg[2] == 'p') /* peer */
+ {
+ is_bus = FALSE;
+ }
+ else /* address; keeping backwards compatibility */
+ {
+ is_bus = FALSE;
}
+
address = strchr (arg, '=') + 1;
+
+ if (address[0] == '\0')
+ {
+ fprintf (stderr, "\"--peer=\" and \"--bus=\" require an ADDRESS\n");
+ usage (1);
+ }
}
else if (strncmp (arg, "--print-reply", 13) == 0)
{
if (session_or_system &&
(address != NULL))
{
- fprintf (stderr, "\"--address\" may not be used with \"--system\" or \"--session\"\n");
+ fprintf (stderr, "\"--peer\" and \"--bus\" may not be used with \"--system\" or \"--session\"\n");
usage (1);
}
dbus_error_free (&error);
exit (1);
}
+ else if ((address != NULL) && is_bus)
+ {
+ if (!dbus_bus_register (connection, &error))
+ {
+ fprintf (stderr, "Failed to register on connection to \"%s\" message bus: %s\n",
+ address, error.message);
+ dbus_error_free (&error);
+ exit (1);
+ }
+ }
if (message_type == DBUS_MESSAGE_TYPE_METHOD_CALL)
{