diff options
author | Alain Magloire <alainm@gnu.org> | 2001-11-13 14:08:35 +0000 |
---|---|---|
committer | Alain Magloire <alainm@gnu.org> | 2001-11-13 14:08:35 +0000 |
commit | 8ccd48fd24ee193c02dd13d65f4bd4981293ddb1 (patch) | |
tree | 990bf4e714b8840c9bc85b983f530222fd8fdb64 /comsat/comsat.c | |
parent | 9bcb4c72fbd5d9da96da87feaf705d4ed6f8f33f (diff) | |
download | mailutils-8ccd48fd24ee193c02dd13d65f4bd4981293ddb1.tar.gz mailutils-8ccd48fd24ee193c02dd13d65f4bd4981293ddb1.tar.bz2 |
Try to use const whenever appropriate to make it clear
that a string should not be modified. Nuke some
trailing spaces, thanks to emacs. Reduce the scope
of functions with static. GNU ident style for
switch() promote a empty line after the break;
* comsat/action.c (expand_escape): size and lncount
could have been use uninitialized.
(expand_escape): const char *cr.
(expand_line): cr == "\n\r" make it const.
variable i and size unneeded.
variable c initialize to zero.
(expand_line): obstack_1grow() pass *p instead of c.
(defaul_action): const char*.
(run_user_action): fprintf () missing argument.
(open_rc): const char *filename.
* comsat/comsat.c (username): const char *username.
(mailbox_path): const prototype.
(change_user): const prototype.
(notify_user): const prototype.
body and header unneeded variables.
(find_user): const prototype.
* comsat/comsat.h: Prototype updates.
Diffstat (limited to 'comsat/comsat.c')
-rw-r--r-- | comsat/comsat.c | 40 |
1 files changed, 23 insertions, 17 deletions
diff --git a/comsat/comsat.c b/comsat/comsat.c index 1a57e27bc..8566ecd5d 100644 --- a/comsat/comsat.c +++ b/comsat/comsat.c @@ -76,17 +76,17 @@ int port = 512; /* Default biff port */ int timeout = 0; int maxlines = 5; char hostname[MAXHOSTNAMELEN]; -char *username; +const char *username; static void comsat_init (void); static void comsat_daemon_init (void); -static void comsat_daemon (int port); +static void comsat_daemon (int _port); static int comsat_main (int fd); -static void notify_user (char *user, char *device, char *path, off_t offset); -static int find_user (char *name, char *tty); +static void notify_user (const char *user, const char *device, const char *path, off_t offset); +static int find_user (const char *name, char *tty); static void help (void); -char *mailbox_path (const char *user); -void change_user (char *user); +static char *mailbox_path (const char *user); +static void change_user (const char *user); static int xargc; static char **xargv; @@ -105,25 +105,32 @@ main(int argc, char **argv) case 'c': config_file = optarg; break; + case 'd': mode = MODE_DAEMON; break; + case 'h': help (); /*NOTREACHED*/ + case 'i': mode = MODE_INETD; break; + case 'p': port = strtoul (optarg, NULL, 10); break; + case 't': timeout = strtoul (optarg, NULL, 10); break; + case 'v': printf (IMPL " ("PACKAGE " " VERSION ")\n"); exit (EXIT_SUCCESS); break; + default: exit (EXIT_FAILURE); } @@ -162,7 +169,7 @@ main(int argc, char **argv) return c != 0; } -RETSIGTYPE +static RETSIGTYPE sig_hup (int sig) { syslog (LOG_NOTICE, "restarting"); @@ -386,7 +393,7 @@ comsat_main (int fd) exit (0); } -char * +static const char * get_newline_str (FILE *fp) { #if defined(OPOST) && defined(ONLCR) @@ -404,15 +411,14 @@ get_newline_str (FILE *fp) /* NOTE: Do not bother to free allocated memory, as the program exits immediately after executing this */ -void -notify_user (char *user, char *device, char *path, off_t offset) +static void +notify_user (const char *user, const char *device, const char *path, off_t offset) { FILE *fp; - char *cr, *p, *blurb; + const char *cr; + char *blurb; mailbox_t mbox = NULL, tmp = NULL; message_t msg; - body_t body = NULL; - header_t header = NULL; stream_t stream = NULL; int status; size_t size, count, n; @@ -491,8 +497,8 @@ notify_user (char *user, char *device, char *path, off_t offset) } /* Search utmp for the local user */ -int -find_user (char *name, char *tty) +static int +find_user (const char *name, char *tty) { UTMP *uptr; int status; @@ -520,7 +526,7 @@ find_user (char *name, char *tty) ftty[sizeof (ftty) - 1] = 0; mu_normalize_path (ftty, "/"); - if (strncmp (ftty, PATH_TTY_PFX, strlen(PATH_TTY_PFX))) + if (strncmp (ftty, PATH_TTY_PFX, strlen (PATH_TTY_PFX))) { /* An attempt to break security... */ syslog (LOG_ALERT, "bad line name in utmp record: %s", ftty); @@ -557,7 +563,7 @@ find_user (char *name, char *tty) } void -change_user (char *user) +change_user (const char *user) { struct passwd *pw; |