summaryrefslogtreecommitdiff
path: root/comsat/comsat.c
diff options
context:
space:
mode:
Diffstat (limited to 'comsat/comsat.c')
-rw-r--r--comsat/comsat.c30
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
@@ -18,6 +18,7 @@
18#include "mailutils/syslog.h" 18#include "mailutils/syslog.h"
19#include "mailutils/cli.h" 19#include "mailutils/cli.h"
20#include "mailutils/sockaddr.h" 20#include "mailutils/sockaddr.h"
21#include "mailutils/alloc.h"
21 22
22#ifndef PATH_DEV 23#ifndef PATH_DEV
23# define PATH_DEV "/dev" 24# define PATH_DEV "/dev"
@@ -59,7 +60,7 @@ typedef struct utmp UTMP;
59 60
60const char *program_version = "comsatd (" PACKAGE_STRING ")"; 61const char *program_version = "comsatd (" PACKAGE_STRING ")";
61 62
62int test_mode; 63char *test_mode;
63char *biffrc = BIFF_RC; 64char *biffrc = BIFF_RC;
64mu_m_server_t server; 65mu_m_server_t server;
65 66
@@ -71,6 +72,25 @@ set_inetd_mode (struct mu_parseopt *po, struct mu_option *opt,
71} 72}
72 73
73static void 74static void
75set_test_mode (struct mu_parseopt *po, struct mu_option *opt,
76 char const *arg)
77{
78 if (arg)
79 {
80 if (arg[0] != '/')
81 {
82 test_mode = mu_make_file_name (mu_getcwd (), arg);
83 if (!test_mode)
84 mu_alloc_die ();
85 }
86 else
87 test_mode = mu_strdup (arg);
88 }
89 else
90 test_mode = mu_strdup ("/dev/tty");
91}
92
93static void
74set_daemon_mode (struct mu_parseopt *po, struct mu_option *opt, 94set_daemon_mode (struct mu_parseopt *po, struct mu_option *opt,
75 char const *arg) 95 char const *arg)
76{ 96{
@@ -97,9 +117,9 @@ set_foreground (struct mu_parseopt *po, struct mu_option *opt,
97} 117}
98 118
99static struct mu_option comsat_options[] = { 119static struct mu_option comsat_options[] = {
100 { "test", 't', NULL, MU_OPTION_DEFAULT, 120 { "test", 't', N_("FILE"), MU_OPTION_ARG_OPTIONAL,
101 N_("run in test mode"), 121 N_("run in test mode; use FILE as tty (default: /dev/tty)"),
102 mu_c_bool, &test_mode }, 122 mu_c_string, &test_mode, set_test_mode },
103 { "foreground", 0, NULL, MU_OPTION_DEFAULT, 123 { "foreground", 0, NULL, MU_OPTION_DEFAULT,
104 N_("remain in foreground"), 124 N_("remain in foreground"),
105 mu_c_bool, NULL, set_foreground }, 125 mu_c_bool, NULL, set_foreground },
@@ -605,7 +625,7 @@ main (int argc, char **argv)
605 free (cwd); 625 free (cwd);
606 } 626 }
607 627
608 notify_user (user, "/dev/tty", argv[0], argv[1]); 628 notify_user (user, test_mode, argv[0], argv[1]);
609 exit (0); 629 exit (0);
610 } 630 }
611 631

Return to:

Send suggestions and report system problems to the System administrator.