summaryrefslogtreecommitdiff
path: root/comsat/comsat.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2019-09-03 17:47:14 +0300
committerSergey Poznyakoff <gray@gnu.org>2019-09-03 17:50:54 +0300
commit016c4a978a69cc8990b5aab6c88cbac6fda57203 (patch)
treef451622ce35a0b64e52522aeef82bd3064faef06 /comsat/comsat.c
parentddfa689bff19d877170add6fed3381f3d5b79a8e (diff)
downloadmailutils-016c4a978a69cc8990b5aab6c88cbac6fda57203.tar.gz
mailutils-016c4a978a69cc8990b5aab6c88cbac6fda57203.tar.bz2
comsatd: optional argument to the --test option supplies the name of the tty to use
* NEWS: Document changes. * comsat/action.c (open_default_tty): Remove. (open_tty): Examine the tty device (or file) and construct a suitable filter chain. Use append mode when opening it. * comsat/comsat.c: The --test option takes optional argument. * comsat/tests/testsuite.at: Use local file instead of the tty. * doc/texinfo/programs/comsatd.texi: Document changes.
Diffstat (limited to 'comsat/comsat.c')
-rw-r--r--comsat/comsat.c32
1 files changed, 26 insertions, 6 deletions
diff --git a/comsat/comsat.c b/comsat/comsat.c
index f317fa698..cee474572 100644
--- a/comsat/comsat.c
+++ b/comsat/comsat.c
@@ -18,6 +18,7 @@
#include "mailutils/syslog.h"
#include "mailutils/cli.h"
#include "mailutils/sockaddr.h"
+#include "mailutils/alloc.h"
#ifndef PATH_DEV
# define PATH_DEV "/dev"
@@ -59,7 +60,7 @@ typedef struct utmp UTMP;
const char *program_version = "comsatd (" PACKAGE_STRING ")";
-int test_mode;
+char *test_mode;
char *biffrc = BIFF_RC;
mu_m_server_t server;
@@ -69,7 +70,26 @@ set_inetd_mode (struct mu_parseopt *po, struct mu_option *opt,
{
mu_m_server_set_mode (server, MODE_INTERACTIVE);
}
-
+
+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,
char const *arg)
@@ -97,9 +117,9 @@ 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,
N_("remain in foreground"),
mu_c_bool, NULL, set_foreground },
@@ -605,7 +625,7 @@ main (int argc, char **argv)
free (cwd);
}
- notify_user (user, "/dev/tty", argv[0], argv[1]);
+ notify_user (user, test_mode, argv[0], argv[1]);
exit (0);
}

Return to:

Send suggestions and report system problems to the System administrator.