-
-#define UNIX_BUS_PATH "unix:path=/run/dbus/system_bus_socket"
-#define KERNEL_BUS_PATH "kernel:path=/dev/kdbus/0-system/bus"
-
-#ifdef ENABLE_KDBUS
-# define DEFAULT_BUS_PATH KERNEL_BUS_PATH ";" UNIX_BUS_PATH
-#else
-# define DEFAULT_BUS_PATH UNIX_BUS_PATH
-#endif
-
-static const char *arg_address = DEFAULT_BUS_PATH;
-static char *arg_command_line_buffer = NULL;
-
-static int help(void) {
-
- printf("%s [OPTIONS...]\n\n"
- "Connect STDIO or a socket to a given bus address.\n\n"
- " -h --help Show this help\n"
- " --version Show package version\n"
- " --address=ADDRESS Connect to the bus specified by ADDRESS\n"
- " (default: " DEFAULT_BUS_PATH ")\n",
- program_invocation_short_name);
-
- return 0;
-}
-
-static int parse_argv(int argc, char *argv[]) {
-
- enum {
- ARG_VERSION = 0x100,
- ARG_ADDRESS,
- };
-
- static const struct option options[] = {
- { "help", no_argument, NULL, 'h' },
- { "version", no_argument, NULL, ARG_VERSION },
- { "address", required_argument, NULL, ARG_ADDRESS },
- { NULL, 0, NULL, 0 }
- };
-
- int c;
-
- assert(argc >= 0);
- assert(argv);
-
- while ((c = getopt_long(argc, argv, "h", options, NULL)) >= 0) {
-
- switch (c) {
-
- case 'h':
- help();
- return 0;
-
- case ARG_VERSION:
- puts(PACKAGE_STRING);
- puts(SYSTEMD_FEATURES);
- return 0;
-
- case ARG_ADDRESS:
- arg_address = optarg;
- break;
-
- case '?':
- return -EINVAL;
-
- default:
- assert_not_reached("Unhandled option");
- }
- }
-
- /* If the first command line argument is only "x" characters
- * we'll write who we are talking to into it, so that "ps" is
- * explanatory */
- arg_command_line_buffer = argv[optind];
- if (argc > optind + 1 ||
- (arg_command_line_buffer && arg_command_line_buffer[strspn(arg_command_line_buffer, "x")] != 0)) {
- log_error("Too many arguments");
- return -EINVAL;
- }
-
- return 1;