From: Florent Bruneau Date: Mon, 8 Sep 2008 13:04:19 +0000 (+0200) Subject: More readable. X-Git-Url: http://git.madism.org/?a=commitdiff_plain;h=36003695aa2db17ee573d951bf19717796271d38;p=apps%2Fpfixtools.git More readable. Signed-off-by: Florent Bruneau --- diff --git a/main-postlicyd.c b/main-postlicyd.c index febc1e2..0431b95 100644 --- a/main-postlicyd.c +++ b/main-postlicyd.c @@ -274,6 +274,7 @@ void usage(void) int main(int argc, char *argv[]) { + bool unsafe = false; const char *pidfile = NULL; bool daemonize = true; int port = DEFAULT_PORT; @@ -283,6 +284,9 @@ int main(int argc, char *argv[]) case 'p': pidfile = optarg; break; + case 'u': + unsafe = true; + break; case 'l': port = atoi(optarg); break; @@ -300,14 +304,11 @@ int main(int argc, char *argv[]) return EXIT_FAILURE; } - if (common_setup(pidfile, false, RUNAS_USER, RUNAS_GROUP, daemonize) - != EXIT_SUCCESS) { + if (common_setup(pidfile, false, RUNAS_USER, RUNAS_GROUP, + daemonize) != EXIT_SUCCESS + || start_listener(port) < 0) { return EXIT_FAILURE; } - - if (start_listener(port) < 0) - return EXIT_FAILURE; - return server_loop(query_starter, (delete_client_t)query_delete, policy_run, NULL); } diff --git a/main-srsd.c b/main-srsd.c index 89e21de..2989a2f 100644 --- a/main-srsd.c +++ b/main-srsd.c @@ -240,8 +240,7 @@ int main(int argc, char *argv[]) int port_enc = DEFAULT_ENCODER_PORT; int port_dec = DEFAULT_DECODER_PORT; const char *pidfile = NULL; - - srs_t *srs; + srs_config_t config; for (int c = 0; (c = getopt(argc, argv, "hfu" "e:d:p:")) >= 0; ) { switch (c) { @@ -271,26 +270,14 @@ int main(int argc, char *argv[]) return EXIT_FAILURE; } - srs = srs_read_secrets(argv[optind + 1]); - if (!srs) { - return EXIT_FAILURE; - } - - if (common_setup(pidfile, unsafe, RUNAS_USER, RUNAS_GROUP, daemonize) - != EXIT_SUCCESS) { + config.domain = argv[optind]; + config.srs = srs_read_secrets(argv[optind + 1]); + if (!config.srs + || common_setup(pidfile, unsafe, RUNAS_USER, RUNAS_GROUP, + daemonize) != EXIT_SUCCESS + || start_listener(port_enc, false) < 0 + || start_listener(port_dec, true) < 0) { return EXIT_FAILURE; } - { - srs_config_t config = { - .srs = srs, - .domain = argv[optind] - }; - - if (start_listener(port_enc, false) < 0) - return EXIT_FAILURE; - if (start_listener(port_dec, true) < 0) - return EXIT_FAILURE; - - return server_loop(srsd_stater, NULL, process_srs, &config); - } + return server_loop(srsd_stater, NULL, process_srs, &config); }