# HG changeset patch # User markus schnalke # Date 1288886419 10800 # Node ID 2babd21e7c75bf6876cfbdadbbe7b5762402ccbf # Parent a41c013c8458ab009db1fd1eb89c03831a1b5e55 moved run_queue to a new function plus various small cleanups, mostly cosmetic diff -r a41c013c8458 -r 2babd21e7c75 src/masqmail.c --- a/src/masqmail.c Thu Nov 04 12:32:11 2010 -0300 +++ b/src/masqmail.c Thu Nov 04 13:00:19 2010 -0300 @@ -353,38 +353,53 @@ return ok; } +static int +run_queue(gboolean do_runq, gboolean do_runq_online, char* route_name) +{ + int ret; + + /* queue runs */ + set_identity(conf.orig_uid, "queue run"); + + if (do_runq) { + ret = queue_run(); + } + + if (do_runq_online) { + if (route_name) { + conf.online_detect = g_strdup("argument"); + set_online_name(route_name); + } + ret = queue_run_online(); + } + return ret; +} + int main(int argc, char *argv[]) { - /* cmd line flags */ - gchar *conf_file = CONF_FILE; + gchar *progname; char* opt; gint arg; + mta_mode mta_mode = MODE_ACCEPT; gboolean do_listen = FALSE; gboolean do_runq = FALSE; gboolean do_runq_online = FALSE; - gboolean do_queue = FALSE; - - gboolean do_verbose = FALSE; - gint debug_level = -1; - - mta_mode mta_mode = MODE_ACCEPT; - gint queue_interval = 0; + gchar *M_cmd = NULL; gboolean opt_t = FALSE; gboolean opt_i = FALSE; gboolean exit_failure = FALSE; - - gchar *M_cmd = NULL; - gint exit_code = EXIT_SUCCESS; + gchar *conf_file = CONF_FILE; gchar *route_name = NULL; - gchar *progname; gchar *f_address = NULL; + address *return_path = NULL; /* may be changed by -f option */ gchar *full_sender_name = NULL; - address *return_path = NULL; /* may be changed by -f option */ + gboolean do_verbose = FALSE; + gint debug_level = -1; progname = get_progname(argv[0]); @@ -408,7 +423,7 @@ /* parse cmd line */ for (arg=1; arg= 0) /* if >= 0, it was given by argument */ + } + if (debug_level >= 0) { /* if >= 0, it was given by argument */ conf.debug_level = debug_level; + } /* It appears that changing to / ensures that we are never in a directory which we cannot access. This situation could be @@ -646,23 +667,9 @@ case MODE_DAEMON: mode_daemon(do_listen, queue_interval, argv); break; + case MODE_RUNQUEUE: - { - /* queue runs */ - set_identity(conf.orig_uid, "queue run"); - - if (do_runq) - exit_code = queue_run() ? EXIT_SUCCESS : EXIT_FAILURE; - - if (do_runq_online) { - if (route_name != NULL) { - conf.online_detect = g_strdup("argument"); - set_online_name(route_name); - } - exit_code = - queue_run_online() ? EXIT_SUCCESS : EXIT_FAILURE; - } - } + exit(run_queue(do_runq, do_runq_online, route_name) ? 0 : 1); break; case MODE_SMTP: @@ -691,6 +698,7 @@ break; case MODE_NONE: break; + default: fprintf(stderr, "unknown mode: %d\n", mta_mode); break;