int main(int argc, char **argv) { argv0 = argv[0]; const char *config_path = DEFAULT_CONFIG_PATH; const char *python_pkgdir = DEFAULT_DISPATCH_PYTHON_DIR; const char *pidfile = 0; const char *user = 0; bool daemon_mode = false; static struct option long_options[] = { {"config", required_argument, 0, 'c'}, {"include", required_argument, 0, 'I'}, {"daemon", no_argument, 0, 'd'}, {"pidfile", required_argument, 0, 'P'}, {"user", required_argument, 0, 'U'}, {"help", no_argument, 0, 'h'}, {"version", no_argument, 0, 'v'}, {0, 0, 0, 0} }; while (1) { int c = getopt_long(argc, argv, "c:I:dP:U:h:v", long_options, 0); if (c == -1) break; switch (c) { case 'c' : config_path = optarg; break; case 'I' : python_pkgdir = optarg; break; case 'd' : daemon_mode = true; break; case 'P' : pidfile = optarg; break; case 'U' : user = optarg; break; case 'h' : usage(argv); exit(0); case 'v' : fprintf(stdout, "Qpid Dispatch Router %s\n", QPID_DISPATCH_VERSION); exit(0); case '?' : usage(argv); exit(1); } } if (optind < argc) { fprintf(stderr, "Unexpected arguments:"); for (; optind < argc; ++optind) fprintf(stderr, " %s", argv[optind]); fprintf(stderr, "\n\n"); usage(argv); exit(1); } if (daemon_mode) daemon_process(config_path, python_pkgdir, pidfile, user); else main_process(config_path, python_pkgdir, 2); return 0; }
int main(int argc, char **argv) { const char *address = "127.0.0.1:amqp"; const char *ns_pid = 0; const char *pidfile = 0; const char *user = 0; bool daemon_mode = false; static struct option long_options[] = { {"daemon", no_argument, 0, 'd'}, {"pidfile", required_argument, 0, 'P'}, {"user", required_argument, 0, 'U'}, {"help", no_argument, 0, 'h'}, {0, 0, 0, 0} }; while (1) { int c = getopt_long(argc, argv, "a:dP:U:h", long_options, 0); if (c == -1) break; switch (c) { case 'a' : address = optarg; break; case 'd' : daemon_mode = true; break; case 'P' : pidfile = optarg; break; case 'U' : user = optarg; break; case 'h' : printf("Usage: %s [OPTIONS]\n\n", argv[0]); printf(" -a, --address Message bus connection address\n"); printf(" -d, --daemon Run process as a SysV-style daemon\n"); printf(" -P, --pidfile If daemon, the file for the stored daemon pid\n"); printf(" -U, --user If daemon, the username to run as\n"); printf(" -h, --help Print this help\n"); exit(0); case '?' : exit(1); } } if (daemon_mode) daemon_process(ns_pid, pidfile, address, user); else main_process(ns_pid, address, -1); return 0; }