diff options
Diffstat (limited to 'comsat/comsat.c')
-rw-r--r-- | comsat/comsat.c | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/comsat/comsat.c b/comsat/comsat.c index f317fa698..cee474572 100644 --- a/comsat/comsat.c +++ b/comsat/comsat.c @@ -20,2 +20,3 @@ #include "mailutils/sockaddr.h" +#include "mailutils/alloc.h" @@ -61,3 +62,3 @@ const char *program_version = "comsatd (" PACKAGE_STRING ")"; -int test_mode; +char *test_mode; char *biffrc = BIFF_RC; @@ -73,2 +74,21 @@ set_inetd_mode (struct mu_parseopt *po, struct mu_option *opt, static void +set_test_mode (struct mu_parseopt *po, struct mu_option *opt, + char const *arg) +{ + if (arg) + { + if (arg[0] != '/') + { + test_mode = mu_make_file_name (mu_getcwd (), arg); + if (!test_mode) + mu_alloc_die (); + } + else + test_mode = mu_strdup (arg); + } + else + test_mode = mu_strdup ("/dev/tty"); +} + +static void set_daemon_mode (struct mu_parseopt *po, struct mu_option *opt, @@ -99,5 +119,5 @@ set_foreground (struct mu_parseopt *po, struct mu_option *opt, static struct mu_option comsat_options[] = { - { "test", 't', NULL, MU_OPTION_DEFAULT, - N_("run in test mode"), - mu_c_bool, &test_mode }, + { "test", 't', N_("FILE"), MU_OPTION_ARG_OPTIONAL, + N_("run in test mode; use FILE as tty (default: /dev/tty)"), + mu_c_string, &test_mode, set_test_mode }, { "foreground", 0, NULL, MU_OPTION_DEFAULT, @@ -607,3 +627,3 @@ main (int argc, char **argv) - notify_user (user, "/dev/tty", argv[0], argv[1]); + notify_user (user, test_mode, argv[0], argv[1]); exit (0); |