diff -ruN dbus-0.23/tools/dbus-monitor.1 dbus-0.23.by-address/tools/dbus-monitor.1 --- dbus-0.23/tools/dbus-monitor.1 2003-06-21 18:20:30.000000000 -0400 +++ dbus-0.23.by-address/tools/dbus-monitor.1 2005-01-31 19:10:32.801745607 -0500 @@ -8,7 +8,7 @@ .SH SYNOPSIS .PP .B dbus-monitor -[\-\-system | \-\-session] +[\-\-system | \-\-session | \-\-address=ADDRESS] .SH DESCRIPTION @@ -36,6 +36,9 @@ .TP .I "--session" Monitor the session message bus. (This is the default.) +.TP +.I "--address=ADDRESS" +Monitor an arbitrary message bus given at ADDRESS. .SH AUTHOR dbus-monitor was written by Philip Blundell. diff -ruN dbus-0.23/tools/dbus-monitor.c dbus-0.23.by-address/tools/dbus-monitor.c --- dbus-0.23/tools/dbus-monitor.c 2004-10-29 14:52:30.000000000 -0400 +++ dbus-0.23.by-address/tools/dbus-monitor.c 2005-01-31 19:10:21.676282123 -0500 @@ -27,6 +27,12 @@ #include #include "dbus-print-message.h" +#if defined (__GNUC__) +# define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__)) +#else +# define ATTRIBUTE_NORETURN +#endif + static DBusHandlerResult filter_func (DBusConnection *connection, DBusMessage *message, @@ -46,10 +52,10 @@ return DBUS_HANDLER_RESULT_HANDLED; } -static void +static void ATTRIBUTE_NORETURN usage (char *name, int ecode) { - fprintf (stderr, "Usage: %s [--system | --session]\n", name); + fprintf (stderr, "Usage: %s [--system | --session | --address=ADDRESS]\n", name); exit (ecode); } @@ -59,6 +65,7 @@ DBusConnection *connection; DBusError error; DBusBusType type = DBUS_BUS_SESSION; + const char *address = NULL; GMainLoop *loop; int i; @@ -70,6 +77,23 @@ type = DBUS_BUS_SYSTEM; else if (!strcmp (arg, "--session")) type = DBUS_BUS_SESSION; + else if (!strncmp (arg, "--address", sizeof("--address")-1)) + { + if (!strcmp (arg, "--address")) + { + if (i+1 < argc) + address = argv[++i]; + else + usage (argv[0], 1); + } + else + { + address = strchr (arg, '='); + if (address == NULL) + usage (argv[0], 1); + address++; + } + } else if (!strcmp (arg, "--help")) usage (argv[0], 0); else if (!strcmp (arg, "--")) @@ -78,20 +102,39 @@ usage (argv[0], 1); } - if (argc > 2) - usage (argv[0], 1); - loop = g_main_loop_new (NULL, FALSE); dbus_error_init (&error); - connection = dbus_bus_get (type, &error); - if (connection == NULL) + + if (address == NULL) + { + connection = dbus_bus_get (type, &error); + if (connection == NULL) + { + fprintf (stderr, "Failed to open connection to %s message bus: %s\n", + (type == DBUS_BUS_SYSTEM) ? "system" : "session", + error.message); + dbus_error_free (&error); + exit (1); + } + } + else { - fprintf (stderr, "Failed to open connection to %s message bus: %s\n", - (type == DBUS_BUS_SYSTEM) ? "system" : "session", - error.message); - dbus_error_free (&error); - exit (1); + connection = dbus_connection_open (address, &error); + if (connection == NULL) + { + fprintf (stderr, "Failed to open connection to bus at %s: %s\n", + address, error.message); + dbus_error_free (&error); + exit (1); + } + if (!dbus_bus_register (connection, &error)) + { + fprintf (stderr, "Failed to register connection to bus at %s: %s\n", + address, error.message); + dbus_error_free (&error); + exit (1); + } } dbus_connection_setup_with_g_main (connection, NULL); diff -ruN dbus-0.23/tools/dbus-send.1 dbus-0.23.by-address/tools/dbus-send.1 --- dbus-0.23/tools/dbus-send.1 2005-01-31 19:04:52.109796470 -0500 +++ dbus-0.23.by-address/tools/dbus-send.1 2005-01-31 19:10:40.703654288 -0500 @@ -8,7 +8,7 @@ .SH SYNOPSIS .PP .B dbus-send -[\-\-system | \-\-session] [\-\-dest=SERVICE] [\-\-print-reply] +[\-\-system | \-\-session | \-\-address=ADDRESS] [\-\-dest=SERVICE] [\-\-print-reply] [\-\-type=TYPE] [contents ...] .SH DESCRIPTION @@ -69,6 +69,9 @@ .I "--session" Send to the session message bus. (This is the default.) .TP +.I "--address=ADDRESS" +Monitor an arbitrary message bus given at ADDRESS. +.TP .I "--type=TYPE" Specify "method_call" or "signal" (defaults to "signal"). diff -ruN dbus-0.23/tools/dbus-send.c dbus-0.23.by-address/tools/dbus-send.c --- dbus-0.23/tools/dbus-send.c 2004-08-11 10:59:33.000000000 -0400 +++ dbus-0.23.by-address/tools/dbus-send.c 2005-01-31 19:09:57.291649827 -0500 @@ -27,10 +27,16 @@ #include "dbus-print-message.h" -static void +#if defined (__GNUC__) +# define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__)) +#else +# define ATTRIBUTE_NORETURN /* ignore warnings about optarg possibly being unused */ +#endif + +static void ATTRIBUTE_NORETURN usage (char *name, int ecode) { - fprintf (stderr, "Usage: %s [--help] [--system | --session] [--dest=SERVICE] [--type=TYPE] [--print-reply] [--reply-timeout=MSEC] [contents ...]\n", name); + fprintf (stderr, "Usage: %s [--help] [--system | --session | --address=ADDRESS] [--dest=SERVICE] [--type=TYPE] [--print-reply] [--reply-timeout=MSEC] [contents ...]\n", name); exit (ecode); } @@ -48,6 +54,7 @@ const char *dest = NULL; const char *name = NULL; const char *path = NULL; + const char *address = NULL; int message_type = DBUS_MESSAGE_TYPE_SIGNAL; const char *type_str = NULL; @@ -59,7 +66,7 @@ for (i = 1; i < argc && name == NULL; i++) { - char *arg = argv[i]; + const char *arg = argv[i], *optarg; if (strcmp (arg, "--system") == 0) type = DBUS_BUS_SYSTEM; @@ -70,15 +77,79 @@ print_reply = TRUE; message_type = DBUS_MESSAGE_TYPE_METHOD_CALL; } - else if (strstr (arg, "--reply-timeout=") == arg) + else if (!strncmp (arg, "--reply-timeout", sizeof("--reply-timeout")-1)) { - reply_timeout = strtol (strchr (arg, '=') + 1, + if (!strcmp (arg, "--reply-timeout")) + { + if (i+1 < argc) + optarg = argv[++i]; + else + usage (argv[0], 1); + } + else + { + optarg = strchr (arg, '='); + if (optarg == NULL) + usage (argv[0], 1); + optarg++; + } + reply_timeout = strtol (optarg, NULL, 10); } - else if (strstr (arg, "--dest=") == arg) - dest = strchr (arg, '=') + 1; - else if (strstr (arg, "--type=") == arg) - type_str = strchr (arg, '=') + 1; + else if (!strncmp (arg, "--dest", sizeof("--dest")-1)) + { + if (!strcmp (arg, "--dest")) + { + if (i+1 < argc) + optarg = argv[++i]; + else + usage (argv[0], 1); + } + else + { + optarg = strchr (arg, '='); + if (optarg == NULL) + usage (argv[0], 1); + optarg++; + } + dest = optarg; + } + else if (!strncmp (arg, "--type", sizeof("--type")-1)) + { + if (!strcmp (arg, "--type")) + { + if (i+1 < argc) + optarg = argv[++i]; + else + usage (argv[0], 1); + } + else + { + optarg = strchr (arg, '='); + if (optarg == NULL) + usage (argv[0], 1); + optarg++; + } + type_str = optarg; + } + else if (!strncmp (arg, "--address", sizeof("--address")-1)) + { + if (!strcmp (arg, "--address")) + { + if (i+1 < argc) + optarg = argv[++i]; + else + usage (argv[0], 1); + } + else + { + optarg = strchr (arg, '='); + if (optarg == NULL) + usage (argv[0], 1); + optarg++; + } + address = optarg; + } else if (!strcmp(arg, "--help")) usage (argv[0], 0); else if (arg[0] == '-') @@ -107,15 +178,38 @@ } dbus_error_init (&error); - connection = dbus_bus_get (type, &error); - if (connection == NULL) + + if (address == NULL) { - fprintf (stderr, "Failed to open connection to %s message bus: %s\n", - (type == DBUS_BUS_SYSTEM) ? "system" : "session", - error.message); - dbus_error_free (&error); - exit (1); + connection = dbus_bus_get (type, &error); + if (connection == NULL) + { + fprintf (stderr, "Failed to open connection to %s message bus: %s\n", + (type == DBUS_BUS_SYSTEM) ? "system" : "session", + error.message); + dbus_error_free (&error); + exit (1); + } } + else + { + connection = dbus_connection_open (address, &error); + if (connection == NULL) + { + fprintf (stderr, "Failed to open connection to bus at %s: %s\n", + address, error.message); + dbus_error_free (&error); + exit (1); + } + if (!dbus_bus_register (connection, &error)) + { + fprintf (stderr, "Failed to register connection to bus at %s: %s\n", + address, error.message); + dbus_error_free (&error); + exit (1); + } + } + if (message_type == DBUS_MESSAGE_TYPE_METHOD_CALL) {