summaryrefslogtreecommitdiff
path: root/comsat/comsat.c
diff options
context:
space:
mode:
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
@@ -15,12 +15,13 @@
15 along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. */ 15 along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. */
16 16
17#include "comsat.h" 17#include "comsat.h"
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"
24#endif 25#endif
25#ifndef PATH_TTY_PFX 26#ifndef PATH_TTY_PFX
26# define PATH_TTY_PFX PATH_DEV 27# define PATH_TTY_PFX PATH_DEV
@@ -56,23 +57,42 @@ typedef struct utmp UTMP;
56#endif 57#endif
57 58
58#define MAX_TTY_SIZE (sizeof (PATH_TTY_PFX) + sizeof (((UTMP*)0)->ut_line)) 59#define MAX_TTY_SIZE (sizeof (PATH_TTY_PFX) + sizeof (((UTMP*)0)->ut_line))
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
66static void 67static void
67set_inetd_mode (struct mu_parseopt *po, struct mu_option *opt, 68set_inetd_mode (struct mu_parseopt *po, struct mu_option *opt,
68 char const *arg) 69 char const *arg)
69{ 70{
70 mu_m_server_set_mode (server, MODE_INTERACTIVE); 71 mu_m_server_set_mode (server, MODE_INTERACTIVE);
71} 72}
72 73
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
73static void 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{
77 mu_m_server_set_mode (server, MODE_DAEMON); 97 mu_m_server_set_mode (server, MODE_DAEMON);
78 if (arg) 98 if (arg)
@@ -94,15 +114,15 @@ set_foreground (struct mu_parseopt *po, struct mu_option *opt,
94 char const *arg) 114 char const *arg)
95{ 115{
96 mu_m_server_set_foreground (server, 1); 116 mu_m_server_set_foreground (server, 1);
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 },
106 { "inetd", 'i', NULL, MU_OPTION_DEFAULT, 126 { "inetd", 'i', NULL, MU_OPTION_DEFAULT,
107 N_("run in inetd mode"), 127 N_("run in inetd mode"),
108 mu_c_bool, NULL, set_inetd_mode }, 128 mu_c_bool, NULL, set_inetd_mode },
@@ -602,13 +622,13 @@ main (int argc, char **argv)
602 exit (1); 622 exit (1);
603 } 623 }
604 mu_normalize_path (biffrc); 624 mu_normalize_path (biffrc);
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
612 mu_stdstream_strerr_setup (mu_log_syslog ? 632 mu_stdstream_strerr_setup (mu_log_syslog ?
613 MU_STRERR_SYSLOG : MU_STRERR_STDERR); 633 MU_STRERR_SYSLOG : MU_STRERR_STDERR);
614 634

Return to:

Send suggestions and report system problems to the System administrator.