diff options
-rw-r--r-- | usr.bin/mail/aux.c | 142 | ||||
-rw-r--r-- | usr.bin/mail/cmd1.c | 66 | ||||
-rw-r--r-- | usr.bin/mail/cmd2.c | 88 | ||||
-rw-r--r-- | usr.bin/mail/cmd3.c | 138 | ||||
-rw-r--r-- | usr.bin/mail/cmdtab.c | 155 | ||||
-rw-r--r-- | usr.bin/mail/collect.c | 43 | ||||
-rw-r--r-- | usr.bin/mail/def.h | 28 | ||||
-rw-r--r-- | usr.bin/mail/edit.c | 21 | ||||
-rw-r--r-- | usr.bin/mail/extern.h | 447 | ||||
-rw-r--r-- | usr.bin/mail/fio.c | 78 | ||||
-rw-r--r-- | usr.bin/mail/getname.c | 16 | ||||
-rw-r--r-- | usr.bin/mail/glob.h | 5 | ||||
-rw-r--r-- | usr.bin/mail/head.c | 29 | ||||
-rw-r--r-- | usr.bin/mail/lex.c | 63 | ||||
-rw-r--r-- | usr.bin/mail/list.c | 87 | ||||
-rw-r--r-- | usr.bin/mail/main.c | 32 | ||||
-rw-r--r-- | usr.bin/mail/names.c | 173 | ||||
-rw-r--r-- | usr.bin/mail/popen.c | 131 | ||||
-rw-r--r-- | usr.bin/mail/quit.c | 27 | ||||
-rw-r--r-- | usr.bin/mail/send.c | 82 | ||||
-rw-r--r-- | usr.bin/mail/strings.c | 14 | ||||
-rw-r--r-- | usr.bin/mail/temp.c | 12 | ||||
-rw-r--r-- | usr.bin/mail/tty.c | 29 | ||||
-rw-r--r-- | usr.bin/mail/v7.local.c | 23 | ||||
-rw-r--r-- | usr.bin/mail/vars.c | 55 | ||||
-rw-r--r-- | usr.bin/mail/version.c | 8 |
26 files changed, 805 insertions, 1187 deletions
diff --git a/usr.bin/mail/aux.c b/usr.bin/mail/aux.c index 043fcea28e6..299a4dc3101 100644 --- a/usr.bin/mail/aux.c +++ b/usr.bin/mail/aux.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aux.c,v 1.19 2001/11/20 20:50:00 millert Exp $ */ +/* $OpenBSD: aux.c,v 1.20 2001/11/21 15:26:39 millert Exp $ */ /* $NetBSD: aux.c,v 1.5 1997/05/13 06:15:52 mikel Exp $ */ /* @@ -36,9 +36,9 @@ #ifndef lint #if 0 -static char sccsid[] = "@(#)aux.c 8.1 (Berkeley) 6/6/93"; +static const char sccsid[] = "@(#)aux.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: aux.c,v 1.19 2001/11/20 20:50:00 millert Exp $"; +static const char rcsid[] = "$OpenBSD: aux.c,v 1.20 2001/11/21 15:26:39 millert Exp $"; #endif #endif /* not lint */ @@ -50,14 +50,13 @@ static char rcsid[] = "$OpenBSD: aux.c,v 1.19 2001/11/20 20:50:00 millert Exp $" * * Auxiliary functions. */ -static char *save2str __P((char *, char *)); +static char *save2str(char *, char *); /* * Return a pointer to a dynamic copy of the argument. */ char * -savestr(str) - char *str; +savestr(char *str) { char *new; int size = strlen(str) + 1; @@ -71,8 +70,7 @@ savestr(str) * Make a copy of new argument incorporating old one. */ static char * -save2str(str, old) - char *str, *old; +save2str(char *str, char *old) { char *new; int newsize = strlen(str) + 1; @@ -94,8 +92,7 @@ save2str(str, old) * back to the system mailbox on exit. */ void -touch(mp) - struct message *mp; +touch(struct message *mp) { mp->m_flag |= MTOUCH; @@ -108,8 +105,7 @@ touch(mp) * Return true if it is. */ int -isdir(name) - char name[]; +isdir(char *name) { struct stat sbuf; @@ -122,8 +118,7 @@ isdir(name) * Count the number of arguments in the given string raw list. */ int -argcount(argv) - char **argv; +argcount(char **argv) { char **ap; @@ -137,9 +132,7 @@ argcount(argv) * pointer (or NULL if the desired header field is not available). */ char * -hfield(field, mp) - char field[]; - struct message *mp; +hfield(char *field, struct message *mp) { FILE *ibuf; char linebuf[LINESIZE]; @@ -168,11 +161,7 @@ hfield(field, mp) * Must deal with \ continuations & other such fraud. */ int -gethfield(f, linebuf, rem, colon) - FILE *f; - char linebuf[]; - int rem; - char **colon; +gethfield(FILE *f, char *linebuf, int rem, char **colon) { char line2[LINESIZE]; char *cp, *cp2; @@ -227,9 +216,7 @@ gethfield(f, linebuf, rem, colon) */ char* -ishfield(linebuf, colon, field) - char linebuf[], field[]; - char *colon; +ishfield(char *linebuf, char *colon, char *field) { char *cp = colon; @@ -246,23 +233,34 @@ ishfield(linebuf, colon, field) /* * Copy a string, lowercasing it as we go. ``dsize'' should be - * the real size (not len) of the dest string (guarantee NULL term). + * the real size (not len) of the dest string (guarantee NUL term). */ -void -istrncpy(dest, src, dsize) - char *dest, *src; - size_t dsize; +size_t +istrlcpy(char *dst, const char *src, size_t dsize) { + char *d = dst; + const char *s = src; + size_t n = dsize; + + /* Copy as many bytes as will fit */ + if (n != 0 && --n != 0) { + do { + if (isupper(*s)) + *d++ = tolower(*s++); + else if ((*d++ = *s++) == 0) + break; + } while (--n != 0); + } - if (dsize != 0) { - while (--dsize != 0 && *src != '\0') { - if (isupper(*src)) - *dest++ = tolower(*src++); - else - *dest++ = *src++; - } - *dest = '\0'; + /* Not enough room in dst, add NUL and traverse rest of src */ + if (n == 0) { + if (dsize != 0) + *d = '\0'; /* NUL-terminate dst */ + while (*s++) + ; } + + return(s - src - 1); /* count does not include NUL */ } /* @@ -270,7 +268,6 @@ istrncpy(dest, src, dsize) * commands. All but the current file pointer are saved on * the stack. */ - static int ssp; /* Top of file stack */ struct sstack { FILE *s_file; /* File we were in. */ @@ -284,8 +281,7 @@ struct sstack { * that they are no longer reading from a tty (in all probability). */ int -source(v) - void *v; +source(void *v) { char **arglist = v; FILE *fi; @@ -318,8 +314,9 @@ source(v) * Update the "sourcing" flag as appropriate. */ int -unstack() +unstack(void) { + if (ssp <= 0) { puts("\"Source\" stack over-pop."); sourcing = 0; @@ -342,8 +339,7 @@ unstack() * This is nifty for the shell. */ void -alter(name) - char *name; +alter(char *name) { struct stat sb; struct timeval tv[2]; @@ -365,8 +361,7 @@ alter(name) * return true if it is all blanks and tabs. */ int -blankline(linebuf) - char linebuf[]; +blankline(char *linebuf) { char *cp; @@ -382,9 +377,7 @@ blankline(linebuf) * before returning it. */ char * -nameof(mp, reptype) - struct message *mp; - int reptype; +nameof(struct message *mp, int reptype) { char *cp, *cp2; @@ -405,8 +398,7 @@ nameof(mp, reptype) * Ignore it. */ char * -skip_comment(cp) - char *cp; +skip_comment(char *cp) { int nesting = 1; @@ -432,8 +424,7 @@ skip_comment(cp) * of "host-phrase." */ char * -skin(name) - char *name; +skin(char *name) { char *nbuf, *bufend, *cp, *cp2; int c, gotlt, lastsp; @@ -543,9 +534,7 @@ skin(name) * 2 -- get sender's name for Reply */ char * -name1(mp, reptype) - struct message *mp; - int reptype; +name1(struct message *mp, int reptype) { char namebuf[LINESIZE]; char linebuf[LINESIZE]; @@ -590,9 +579,8 @@ newname: first = 0; } else cp2 = strrchr(namebuf, '!') + 1; - strncpy(cp2, cp, sizeof(namebuf) - (cp2 - namebuf) - 2); - namebuf[sizeof(namebuf) - 2] = '\0'; - strcat(namebuf, "!"); + strlcpy(cp2, cp, sizeof(namebuf) - (cp2 - namebuf) - 1); + strlcat(namebuf, "!", sizeof(namebuf)); goto newname; } cp++; @@ -604,9 +592,7 @@ newname: * Count the occurances of c in str */ int -charcount(str, c) - char *str; - int c; +charcount(char *str, int c) { char *cp; int i; @@ -618,25 +604,10 @@ charcount(str, c) } /* - * Are any of the characters in the two strings the same? - */ -int -anyof(s1, s2) - char *s1, *s2; -{ - - while (*s1) - if (strchr(s2, *s1++)) - return(1); - return(0); -} - -/* * Convert c to upper case */ int -raise(c) - int c; +raise(int c) { if (islower(c)) @@ -648,8 +619,7 @@ raise(c) * Copy s1 to s2, return pointer to null in s2. */ char * -copy(s1, s2) - char *s1, *s2; +copy(char *s1, char *s2) { while ((*s2++ = *s1++) != '\0') @@ -661,9 +631,7 @@ copy(s1, s2) * See if the given header field is supposed to be ignored. */ int -isign(field, ignore) - char *field; - struct ignoretab ignore[2]; +isign(char *field, struct ignoretab ignore[2]) { char realfld[LINESIZE]; @@ -673,7 +641,7 @@ isign(field, ignore) * Lower-case the string, so that "Status" and "status" * will hash to the same place. */ - istrncpy(realfld, field, sizeof(realfld)); + istrlcpy(realfld, field, sizeof(realfld)); if (ignore[1].i_count > 0) return(!member(realfld, ignore + 1)); else @@ -681,9 +649,7 @@ isign(field, ignore) } int -member(realfield, table) - char *realfield; - struct ignoretab *table; +member(char *realfield, struct ignoretab *table) { struct ignore *igp; @@ -695,7 +661,7 @@ member(realfield, table) } void -clearnew() +clearnew(void) { struct message *mp; diff --git a/usr.bin/mail/cmd1.c b/usr.bin/mail/cmd1.c index 4d4c98fafb8..e69b57a9b6d 100644 --- a/usr.bin/mail/cmd1.c +++ b/usr.bin/mail/cmd1.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd1.c,v 1.20 2001/11/20 20:50:00 millert Exp $ */ +/* $OpenBSD: cmd1.c,v 1.21 2001/11/21 15:26:39 millert Exp $ */ /* $NetBSD: cmd1.c,v 1.9 1997/07/09 05:29:48 mikel Exp $ */ /*- @@ -36,9 +36,9 @@ #ifndef lint #if 0 -static char sccsid[] = "@(#)cmd1.c 8.2 (Berkeley) 4/20/95"; +static const char sccsid[] = "@(#)cmd1.c 8.2 (Berkeley) 4/20/95"; #else -static char rcsid[] = "$OpenBSD: cmd1.c,v 1.20 2001/11/20 20:50:00 millert Exp $"; +static const char rcsid[] = "$OpenBSD: cmd1.c,v 1.21 2001/11/21 15:26:39 millert Exp $"; #endif #endif /* not lint */ @@ -60,8 +60,7 @@ static int screen; static volatile sig_atomic_t gothdrint; int -headers(v) - void *v; +headers(void *v) { int *msgvec = v; int n, mesg, flag, size; @@ -119,8 +118,7 @@ headers(v) * Scroll to the next/previous screen */ int -scroll(v) - void *v; +scroll(void *v) { char *arg = v; int size, maxscreen; @@ -158,7 +156,7 @@ scroll(v) * Compute screen size. */ int -screensize() +screensize(void) { int s; char *cp; @@ -173,8 +171,7 @@ screensize() * in the passed message list. */ int -from(v) - void *v; +from(void *v) { int *msgvec = v; int *ip; @@ -191,8 +188,7 @@ from(v) * This is a slight improvement to the standard one. */ void -printhead(mesg) - int mesg; +printhead(int mesg) { struct message *mp; char headline[LINESIZE], wcount[LINESIZE], *subjline, dispc, curind; @@ -258,8 +254,7 @@ printhead(mesg) * Print out the value of dot. */ int -pdot(v) - void *v; +pdot(void *v) { printf("%d\n", (int)(dot - &message[0] + 1)); return(0); @@ -269,8 +264,7 @@ pdot(v) * Print out all the possible commands. */ int -pcmdlist(v) - void *v; +pcmdlist(void *v) { extern const struct cmd cmdtab[]; const struct cmd *cp; @@ -295,8 +289,7 @@ pcmdlist(v) * Pipe message to command */ int -pipeit(ml, sl) - void *ml, *sl; +pipeit(void *ml, void *sl) { int *msgvec = ml; char *cmd = sl; @@ -308,8 +301,7 @@ pipeit(ml, sl) * Paginate messages, honor ignored fields. */ int -more(v) - void *v; +more(void *v) { int *msgvec = v; return(type1(msgvec, NULL, 1, 1)); @@ -319,8 +311,7 @@ more(v) * Paginate messages, even printing ignored fields. */ int -More(v) - void *v; +More(void *v) { int *msgvec = v; @@ -331,8 +322,7 @@ More(v) * Type out messages, honor ignored fields. */ int -type(v) - void *v; +type(void *v) { int *msgvec = v; @@ -343,8 +333,7 @@ type(v) * Type out messages, even printing ignored fields. */ int -Type(v) - void *v; +Type(void *v) { int *msgvec = v; @@ -355,10 +344,7 @@ Type(v) * Type out the messages requested. */ int -type1(msgvec, cmd, doign, page) - int *msgvec; - char *cmd; - int doign, page; +type1(int *msgvec, char *cmd, int doign, int page) { int nlines, *ip, restoreterm; struct message *mp; @@ -397,7 +383,7 @@ type1(msgvec, cmd, doign, page) } /* - * send messages to the output. + * Send messages to the output. */ for (ip = msgvec; *ip && ip - msgvec < msgCount; ip++) { mp = &message[*ip - 1]; @@ -423,8 +409,7 @@ type1(msgvec, cmd, doign, page) * and defaults to 5. */ int -top(v) - void *v; +top(void * v) { int *msgvec = v; int *ip; @@ -466,8 +451,7 @@ top(v) * get mboxed. */ int -stouch(v) - void *v; +stouch(void *v) { int *msgvec = v; int *ip; @@ -484,8 +468,7 @@ stouch(v) * Make sure all passed messages get mboxed. */ int -mboxit(v) - void *v; +mboxit(void *v) { int *msgvec = v; int *ip; @@ -502,8 +485,7 @@ mboxit(v) * List the folders the user currently has. */ int -folders(v) - void *v; +folders(void *v) { char *files = (char *)v; char dirname[PATHSIZE]; @@ -525,8 +507,7 @@ folders(v) * come in since we started reading mail. */ int -inc(v) - void *v; +inc(void *v) { int nmsg, mdot; @@ -548,8 +529,7 @@ inc(v) * User hit ^C while printing the headers. */ void -hdrint(s) - int s; +hdrint(int s) { gothdrint = 1; diff --git a/usr.bin/mail/cmd2.c b/usr.bin/mail/cmd2.c index 706273cbb74..2d3d3c595bf 100644 --- a/usr.bin/mail/cmd2.c +++ b/usr.bin/mail/cmd2.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd2.c,v 1.9 2000/04/26 15:47:30 millert Exp $ */ +/* $OpenBSD: cmd2.c,v 1.10 2001/11/21 15:26:39 millert Exp $ */ /* $NetBSD: cmd2.c,v 1.7 1997/05/17 19:55:10 pk Exp $ */ /* @@ -36,9 +36,9 @@ #ifndef lint #if 0 -static char sccsid[] = "@(#)cmd2.c 8.1 (Berkeley) 6/6/93"; +static const char sccsid[] = "@(#)cmd2.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: cmd2.c,v 1.9 2000/04/26 15:47:30 millert Exp $"; +static const char rcsid[] = "$OpenBSD: cmd2.c,v 1.10 2001/11/21 15:26:39 millert Exp $"; #endif #endif /* not lint */ @@ -51,7 +51,7 @@ static char rcsid[] = "$OpenBSD: cmd2.c,v 1.9 2000/04/26 15:47:30 millert Exp $" * * More user commands. */ -static int igcomp __P((const void *, const void *)); +static int igcomp(const void *, const void *); /* * If any arguments were given, go to the next applicable argument @@ -59,28 +59,24 @@ static int igcomp __P((const void *, const void *)); * If given as first command with no arguments, print first message. */ int -next(v) - void *v; +next(void *v) { struct message *mp; int *msgvec = v; int *ip, *ip2, list[2], mdot; if (*msgvec != NULL) { - /* * If some messages were supplied, find the * first applicable one following dot using * wrap around. */ - mdot = dot - &message[0] + 1; /* * Find the first message in the supplied * message list which follows dot. */ - for (ip = msgvec; *ip != NULL; ip++) if (*ip > mdot) break; @@ -106,7 +102,6 @@ next(v) * If this is the first command, select message 1. * Note that this must exist for us to get here at all. */ - if (!sawcom) goto hitit; @@ -114,7 +109,6 @@ next(v) * Just find the next good message after dot, no * wraparound. */ - for (mp = dot+1; mp < &message[msgCount]; mp++) if ((mp->m_flag & (MDELETED|MSAVED)) == 0) break; @@ -127,7 +121,6 @@ hitit: /* * Print dot. */ - list[0] = dot - &message[0] + 1; list[1] = NULL; return(type(list)); @@ -138,8 +131,7 @@ hitit: * so we can discard when the user quits. */ int -save(v) - void *v; +save(void *v) { char *str = v; @@ -150,8 +142,7 @@ save(v) * Copy a message to a file without affected its saved-ness */ int -copycmd(v) - void *v; +copycmd(void *v) { char *str = v; @@ -163,11 +154,7 @@ copycmd(v) * If mark is true, mark the message "saved." */ int -save1(str, mark, cmd, ignore) - char str[]; - int mark; - char *cmd; - struct ignoretab *ignore; +save1(char *str, int mark, char *cmd, struct ignoretab *ignore) { struct message *mp; char *file, *disp; @@ -223,8 +210,7 @@ save1(str, mark, cmd, ignore) * file name, minus header and trailing blank line. */ int -swrite(v) - void *v; +swrite(void *v) { char *str = v; @@ -239,11 +225,8 @@ swrite(v) * unless the file name is the only thing on the line, in * which case, return 0 in the reference flag variable. */ - char * -snarf(linebuf, flag) - char linebuf[]; - int *flag; +snarf(char *linebuf, int *flag) { char *cp; @@ -253,7 +236,6 @@ snarf(linebuf, flag) /* * Strip away trailing blanks. */ - while (cp > linebuf && isspace(*cp)) cp--; *++cp = 0; @@ -261,7 +243,6 @@ snarf(linebuf, flag) /* * Now search for the beginning of the file name. */ - while (cp > linebuf && !isspace(*cp)) cp--; if (*cp == '\0') { @@ -279,10 +260,10 @@ snarf(linebuf, flag) * Delete messages. */ int -delete(v) - void *v; +delete(void *v) { int *msgvec = v; + delm(msgvec); return(0); } @@ -291,8 +272,7 @@ delete(v) * Delete messages, then type the new dot. */ int -deltype(v) - void *v; +deltype(void *v) { int *msgvec = v; int list[2]; @@ -318,8 +298,7 @@ deltype(v) * Internal interface. */ int -delm(msgvec) - int *msgvec; +delm(int *msgvec) { struct message *mp; int *ip, last; @@ -348,7 +327,6 @@ delm(msgvec) /* * Following can't happen -- it keeps lint happy */ - return(-1); } @@ -356,8 +334,7 @@ delm(msgvec) * Undelete the indicated messages. */ int -undeletecmd(v) - void *v; +undeletecmd(void *v) { int *msgvec = v; int *ip; @@ -376,10 +353,9 @@ undeletecmd(v) * Interactively dump core on "core" */ int -core(v) - void *v; +core(void *v) { - int pid; + pid_t pid; extern int wait_status; switch (pid = vfork()) { @@ -404,8 +380,7 @@ core(v) * Clobber as many bytes of stack as the user requests. */ int -clobber(v) - void *v; +clobber(void *v) { char **argv = v; int times; @@ -440,8 +415,7 @@ clob1(n) * If no arguments, print the current list of retained fields. */ int -retfield(v) - void *v; +retfield(void *v) { char **list = v; @@ -453,8 +427,7 @@ retfield(v) * If no arguments, print the current list of ignored fields. */ int -igfield(v) - void *v; +igfield(void *v) { char **list = v; @@ -462,8 +435,7 @@ igfield(v) } int -saveretfield(v) - void *v; +saveretfield(void *v) { char **list = v; @@ -471,8 +443,7 @@ saveretfield(v) } int -saveigfield(v) - void *v; +saveigfield(void *v) { char **list = v; @@ -480,10 +451,7 @@ saveigfield(v) } int -ignore1(list, tab, which) - char *list[]; - struct ignoretab *tab; - char *which; +ignore1(char **list, struct ignoretab *tab, char *which) { char field[LINESIZE]; char **ap; @@ -493,7 +461,7 @@ ignore1(list, tab, which) if (*list == NULL) return(igshow(tab, which)); for (ap = list; *ap != 0; ap++) { - istrncpy(field, *ap, sizeof(field)); + istrlcpy(field, *ap, sizeof(field)); if (member(field, tab)) continue; h = hash(field); @@ -511,9 +479,7 @@ ignore1(list, tab, which) * Print out all currently retained fields. */ int -igshow(tab, which) - struct ignoretab *tab; - char *which; +igshow(struct ignoretab *tab, char *which) { int h; struct ignore *igp; @@ -539,8 +505,8 @@ igshow(tab, which) * Compare two names for sorting ignored field list. */ static int -igcomp(l, r) - const void *l, *r; +igcomp(const void *l, const void *r) { + return(strcmp(*(char **)l, *(char **)r)); } diff --git a/usr.bin/mail/cmd3.c b/usr.bin/mail/cmd3.c index 845350a765f..f9eee9df8a4 100644 --- a/usr.bin/mail/cmd3.c +++ b/usr.bin/mail/cmd3.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd3.c,v 1.16 2001/11/20 20:50:00 millert Exp $ */ +/* $OpenBSD: cmd3.c,v 1.17 2001/11/21 15:26:39 millert Exp $ */ /* $NetBSD: cmd3.c,v 1.8 1997/07/09 05:29:49 mikel Exp $ */ /* @@ -36,9 +36,9 @@ #ifndef lint #if 0 -static char sccsid[] = "@(#)cmd3.c 8.2 (Berkeley) 4/20/95"; +static const char sccsid[] = "@(#)cmd3.c 8.2 (Berkeley) 4/20/95"; #else -static char rcsid[] = "$OpenBSD: cmd3.c,v 1.16 2001/11/20 20:50:00 millert Exp $"; +static const char rcsid[] = "$OpenBSD: cmd3.c,v 1.17 2001/11/21 15:26:39 millert Exp $"; #endif #endif /* not lint */ @@ -50,15 +50,14 @@ static char rcsid[] = "$OpenBSD: cmd3.c,v 1.16 2001/11/20 20:50:00 millert Exp $ * * Still more user commands. */ -static int diction __P((const void *, const void *)); +static int diction(const void *, const void *); /* * Process a shell escape by saving signals, ignoring signals, * and forking a sh -c */ int -shell(v) - void *v; +shell(void *v) { char *str = v; char *shell; @@ -83,8 +82,7 @@ shell(v) */ /*ARGSUSED*/ int -dosh(v) - void *v; +dosh(void *v) { char *shell; struct sigaction oact; @@ -104,9 +102,7 @@ dosh(v) * last issued command where possible. */ int -bangexp(str, strsize) - char *str; - size_t strsize; +bangexp(char *str, size_t strsize) { char bangbuf[BUFSIZ]; static char lastbang[BUFSIZ]; @@ -124,8 +120,7 @@ overf: return(-1); } changed++; - strncpy(cp2, lastbang, sizeof(bangbuf) - (cp2 - bangbuf) - 1); - bangbuf[sizeof(bangbuf) - 1] = '\0'; + strlcpy(cp2, lastbang, sizeof(bangbuf) - (cp2 - bangbuf)); cp2 += strlen(lastbang); n -= strlen(lastbang); cp++; @@ -147,10 +142,8 @@ overf: (void)printf("!%s\n", bangbuf); (void)fflush(stdout); } - (void)strncpy(str, bangbuf, strsize - 1); - str[strsize - 1] = '\0'; - (void)strncpy(lastbang, bangbuf, sizeof(lastbang) - 1); - lastbang[sizeof(lastbang) - 1] = '\0'; + (void)strlcpy(str, bangbuf, strsize); + (void)strlcpy(lastbang, bangbuf, sizeof(lastbang)); return(0); } @@ -158,8 +151,7 @@ overf: * Print out a nice help message from some file or another. */ int -help(v) - void *v; +help(void *v) { (void)run_command(value("PAGER"), 0, -1, -1, _PATH_HELP, NULL); @@ -170,8 +162,7 @@ help(v) * Change user's working directory. */ int -schdir(v) - void *v; +schdir(void *v) { char **arglist = v; char *cp; @@ -192,10 +183,10 @@ schdir(v) } int -respond(v) - void *v; +respond(void *v) { int *msgvec = v; + if (value("Replyall") == NULL) return(_respond(msgvec)); else @@ -230,7 +221,7 @@ _respond(msgvec) else if ((cp = skin(hfield("to", mp))) != NULL) np = extract(cp, GTO); else - np = NIL; + np = NULL; np = elide(np); /* * Delete my name from the reply list, @@ -240,9 +231,9 @@ _respond(msgvec) if (altnames) for (ap = altnames; *ap; ap++) np = delname(np, *ap); - if (np != NIL && replyto == NULL) + if (np != NULL && replyto == NULL) np = cat(np, extract(rcv, GTO)); - else if (np == NIL) { + else if (np == NULL) { if (replyto != NULL) puts("Empty reply-to field -- replying to author"); np = extract(rcv, GTO); @@ -259,9 +250,9 @@ _respond(msgvec) np = delname(np, *ap); head.h_cc = np; } else - head.h_cc = NIL; - head.h_bcc = NIL; - head.h_smopts = NIL; + head.h_cc = NULL; + head.h_bcc = NULL; + head.h_smopts = NULL; mail1(&head, 1); return(0); } @@ -271,8 +262,7 @@ _respond(msgvec) * it does not already. */ char * -reedit(subj) - char *subj; +reedit(char *subj) { char *newsubj; @@ -293,8 +283,7 @@ reedit(subj) * mailbox as unread. */ int -marknew(v) - void *v; +marknew(void *v) { int *msgvec = v; int *ip; @@ -312,8 +301,7 @@ marknew(v) * back to the system mailbox. */ int -preserve(v) - void *v; +preserve(void *v) { int *msgvec = v; int *ip, mesg; @@ -337,8 +325,7 @@ preserve(v) * Mark all given messages as unread. */ int -unread(v) - void *v; +unread(void *v) { int *msgvec = v; int *ip; @@ -355,8 +342,7 @@ unread(v) * Print the size of each message. */ int -messize(v) - void *v; +messize(void *v) { int *msgvec = v; struct message *mp; @@ -375,9 +361,9 @@ messize(v) * by returning an error. */ int -rexit(v) - void *v; +rexit(void *v) { + if (sourcing) return(1); exit(0); @@ -389,8 +375,7 @@ rexit(v) * of csh. */ int -set(v) - void *v; +set(void *v) { char **arglist = v; struct var *vp; @@ -400,11 +385,11 @@ set(v) if (*arglist == NULL) { for (h = 0, s = 1; h < HSHSIZE; h++) - for (vp = variables[h]; vp != NOVAR; vp = vp->v_link) + for (vp = variables[h]; vp != NULL; vp = vp->v_link) s++; ap = (char **)salloc(s * sizeof(*ap)); for (h = 0, p = ap; h < HSHSIZE; h++) - for (vp = variables[h]; vp != NOVAR; vp = vp->v_link) + for (vp = variables[h]; vp != NULL; vp = vp->v_link) *p++ = vp->v_name; *p = NULL; sort(ap); @@ -437,8 +422,7 @@ set(v) * Unset a bunch of variable values. */ int -unset(v) - void *v; +unset(void *v) { char **arglist = v; struct var *vp, *vp2; @@ -447,7 +431,7 @@ unset(v) errs = 0; for (ap = arglist; *ap != NULL; ap++) { - if ((vp2 = lookup(*ap)) == NOVAR) { + if ((vp2 = lookup(*ap)) == NULL) { if (!sourcing) { printf("\"%s\": undefined variable\n", *ap); errs++; @@ -476,8 +460,7 @@ unset(v) * Put add users to a group. */ int -group(v) - void *v; +group(void *v) { char **argv = v; struct grouphead *gh; @@ -487,11 +470,11 @@ group(v) if (*argv == NULL) { for (h = 0, s = 1; h < HSHSIZE; h++) - for (gh = groups[h]; gh != NOGRP; gh = gh->g_link) + for (gh = groups[h]; gh != NULL; gh = gh->g_link) s++; ap = (char **)salloc(s * sizeof(*ap)); for (h = 0, p = ap; h < HSHSIZE; h++) - for (gh = groups[h]; gh != NOGRP; gh = gh->g_link) + for (gh = groups[h]; gh != NULL; gh = gh->g_link) *p++ = gh->g_name; *p = NULL; sort(ap); @@ -505,10 +488,10 @@ group(v) } gname = *argv; h = hash(gname); - if ((gh = findgroup(gname)) == NOGRP) { + if ((gh = findgroup(gname)) == NULL) { gh = (struct grouphead *)calloc(sizeof(*gh), 1); gh->g_name = vcopy(gname); - gh->g_list = NOGE; + gh->g_list = NULL; gh->g_link = groups[h]; groups[h] = gh; } @@ -533,8 +516,7 @@ group(v) * order. */ void -sort(list) - char **list; +sort(char **list) { char **ap; @@ -550,21 +532,20 @@ sort(list) * qsort. */ static int -diction(a, b) - const void *a, *b; +diction(const void *a, const void *b) { + return(strcmp(*(char **)a, *(char **)b)); } /* * The do nothing command for comments. */ - /*ARGSUSED*/ int -null(v) - void *v; +null(void *v) { + return(0); } @@ -573,8 +554,7 @@ null(v) * the current file. */ int -file(v) - void *v; +file(void *v) { char **argv = v; @@ -593,8 +573,7 @@ file(v) * Expand file names like echo */ int -echo(v) - void *v; +echo(void *v) { char **argv = v; char **ap, *cp; @@ -612,10 +591,10 @@ echo(v) } int -Respond(v) - void *v; +Respond(void *v) { int *msgvec = v; + if (value("Replyall") == NULL) return(_Respond(msgvec)); else @@ -628,15 +607,14 @@ Respond(v) * reply. */ int -_Respond(msgvec) - int msgvec[]; +_Respond(int *msgvec) { struct header head; struct message *mp; int *ap; char *cp; - head.h_to = NIL; + head.h_to = NULL; for (ap = msgvec; *ap != 0; ap++) { mp = &message[*ap - 1]; touch(mp); @@ -645,15 +623,15 @@ _Respond(msgvec) cp = skin(nameof(mp, 2)); head.h_to = cat(head.h_to, extract(cp, GTO)); } - if (head.h_to == NIL) + if (head.h_to == NULL) return(0); mp = &message[msgvec[0] - 1]; if ((head.h_subject = hfield("subject", mp)) == NULL) head.h_subject = hfield("subj", mp); head.h_subject = reedit(head.h_subject); - head.h_cc = NIL; - head.h_bcc = NIL; - head.h_smopts = NIL; + head.h_cc = NULL; + head.h_bcc = NULL; + head.h_smopts = NULL; mail1(&head, 1); return(0); } @@ -663,8 +641,7 @@ _Respond(msgvec) * .mailrc and do some things if sending, others if receiving. */ int -ifcmd(v) - void *v; +ifcmd(void *v) { char **argv = v; char *cp; @@ -696,8 +673,7 @@ ifcmd(v) * flip over the conditional flag. */ int -elsecmd(v) - void *v; +elsecmd(void *v) { switch (cond) { @@ -725,8 +701,7 @@ elsecmd(v) * End of if statement. Just set cond back to anything. */ int -endifcmd(v) - void *v; +endifcmd(void *v) { if (cond == CANY) { @@ -741,8 +716,7 @@ endifcmd(v) * Set the list of alternate names. */ int -alternates(v) - void *v; +alternates(void *v) { char **namelist = v; char **ap, **ap2, *cp; diff --git a/usr.bin/mail/cmdtab.c b/usr.bin/mail/cmdtab.c index efc4020ab47..2c673c42682 100644 --- a/usr.bin/mail/cmdtab.c +++ b/usr.bin/mail/cmdtab.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmdtab.c,v 1.5 2001/01/16 05:36:08 millert Exp $ */ +/* $OpenBSD: cmdtab.c,v 1.6 2001/11/21 15:26:39 millert Exp $ */ /* $NetBSD: cmdtab.c,v 1.7 1996/12/28 07:10:59 tls Exp $ */ /* @@ -36,9 +36,9 @@ #ifndef lint #if 0 -static char sccsid[] = "@(#)cmdtab.c 8.2 (Berkeley) 4/20/95"; +static const char sccsid[] = "@(#)cmdtab.c 8.2 (Berkeley) 4/20/95"; #else -static char rcsid[] = "$OpenBSD: cmdtab.c,v 1.5 2001/01/16 05:36:08 millert Exp $"; +static const char rcsid[] = "$OpenBSD: cmdtab.c,v 1.6 2001/11/21 15:26:39 millert Exp $"; #endif #endif /* not lint */ @@ -50,82 +50,83 @@ static char rcsid[] = "$OpenBSD: cmdtab.c,v 1.5 2001/01/16 05:36:08 millert Exp * * Define all of the command names and bindings. */ - const struct cmd cmdtab[] = { /* msgmask msgflag */ /* command function argtype result & mask */ /* ------- -------- ------- ------- -------- */ - { "next", next, NDMLIST, 0, MMNDEL }, - { "alias", group, M|RAWLIST, 0, 1000 }, - { "print", type, MSGLIST, 0, MMNDEL }, - { "type", type, MSGLIST, 0, MMNDEL }, - { "Type", Type, MSGLIST, 0, MMNDEL }, - { "Print", Type, MSGLIST, 0, MMNDEL }, - { "visual", visual, I|MSGLIST, 0, MMNORM }, - { "top", top, MSGLIST, 0, MMNDEL }, - { "touch", stouch, W|MSGLIST, 0, MMNDEL }, - { "preserve", preserve, W|MSGLIST, 0, MMNDEL }, - { "delete", delete, W|P|MSGLIST, 0, MMNDEL }, - { "dp", deltype, W|MSGLIST, 0, MMNDEL }, - { "dt", deltype, W|MSGLIST, 0, MMNDEL }, - { "undelete", undeletecmd, P|MSGLIST, MDELETED,MMNDEL }, - { "unset", unset, M|RAWLIST, 1, 1000 }, - { "mail", sendmail, R|M|I|STRLIST, 0, 0 }, - { "mbox", mboxit, W|MSGLIST, 0, 0 }, - { "pipe", pipeit, MSGLIST|STRLIST,0, MMNDEL }, - { "|", pipeit, MSGLIST|STRLIST,0, MMNDEL }, - { "more", more, MSGLIST, 0, MMNDEL }, - { "page", more, MSGLIST, 0, MMNDEL }, - { "More", More, MSGLIST, 0, MMNDEL }, - { "Page", More, MSGLIST, 0, MMNDEL }, - { "unread", unread, MSGLIST, 0, MMNDEL }, - { "!", shell, I|STRLIST, 0, 0 }, - { "copy", copycmd, M|STRLIST, 0, 0 }, - { "chdir", schdir, M|RAWLIST, 0, 1 }, - { "cd", schdir, M|RAWLIST, 0, 1 }, - { "save", save, STRLIST, 0, 0 }, - { "source", source, M|RAWLIST, 1, 1 }, - { "set", set, M|RAWLIST, 0, 1000 }, - { "shell", dosh, I|NOLIST, 0, 0 }, - { "version", pversion, M|NOLIST, 0, 0 }, - { "group", group, M|RAWLIST, 0, 1000 }, - { "write", swrite, STRLIST, 0, 0 }, - { "from", from, MSGLIST, 0, MMNORM }, - { "file", file, T|M|RAWLIST, 0, 1 }, - { "folder", file, T|M|RAWLIST, 0, 1 }, - { "folders", folders, T|M|STRLIST, 0, 0 }, - { "?", help, M|NOLIST, 0, 0 }, - { "z", scroll, M|STRLIST, 0, 0 }, - { "headers", headers, MSGLIST, 0, MMNDEL }, - { "help", help, M|NOLIST, 0, 0 }, - { "=", pdot, NOLIST, 0, 0 }, - { "Reply", Respond, R|I|MSGLIST, 0, MMNDEL }, - { "Respond", Respond, R|I|MSGLIST, 0, MMNDEL }, - { "reply", respond, R|I|MSGLIST, 0, MMNDEL }, - { "respond", respond, R|I|MSGLIST, 0, MMNDEL }, - { "edit", editor, I|MSGLIST, 0, MMNORM }, - { "echo", echo, M|RAWLIST, 0, 1000 }, - { "quit", quitcmd, NOLIST, 0, 0 }, - { "list", pcmdlist, M|NOLIST, 0, 0 }, - { "xit", rexit, M|NOLIST, 0, 0 }, - { "exit", rexit, M|NOLIST, 0, 0 }, - { "size", messize, MSGLIST, 0, MMNDEL }, - { "hold", preserve, W|MSGLIST, 0, MMNDEL }, - { "if", ifcmd, F|M|RAWLIST, 1, 1 }, - { "else", elsecmd, F|M|RAWLIST, 0, 0 }, - { "endif", endifcmd, F|M|RAWLIST, 0, 0 }, - { "alternates", alternates, M|RAWLIST, 0, 1000 }, - { "ignore", igfield, M|RAWLIST, 0, 1000 }, - { "discard", igfield, M|RAWLIST, 0, 1000 }, - { "retain", retfield, M|RAWLIST, 0, 1000 }, - { "saveignore", saveigfield, M|RAWLIST, 0, 1000 }, - { "savediscard",saveigfield, M|RAWLIST, 0, 1000 }, - { "saveretain", saveretfield, M|RAWLIST, 0, 1000 }, -/* { "Header", Header, STRLIST, 0, 1000 }, */ - { "core", core, M|NOLIST, 0, 0 }, - { "#", null, M|NOLIST, 0, 0 }, - { "clobber", clobber, M|RAWLIST, 0, 1 }, - { "inc", inc, T|NOLIST, 0, 0 }, - { "new", marknew, MSGLIST, 0, MMNDEL }, - { 0, 0, 0, 0, 0 } + { "next", { next }, NDMLIST, 0, MMNDEL }, + { "alias", { group }, M|RAWLIST, 0, 1000 }, + { "print", { type }, MSGLIST, 0, MMNDEL }, + { "type", { type }, MSGLIST, 0, MMNDEL }, + { "Type", { Type }, MSGLIST, 0, MMNDEL }, + { "Print", { Type }, MSGLIST, 0, MMNDEL }, + { "visual", { visual }, I|MSGLIST, 0, MMNORM }, + { "top", { top }, MSGLIST, 0, MMNDEL }, + { "touch", { stouch }, W|MSGLIST, 0, MMNDEL }, + { "preserve", { preserve }, W|MSGLIST, 0, MMNDEL }, + { "delete", { delete }, W|P|MSGLIST, 0, MMNDEL }, + { "dp", { deltype }, W|MSGLIST, 0, MMNDEL }, + { "dt", { deltype }, W|MSGLIST, 0, MMNDEL }, + { "undelete", { undeletecmd }, P|MSGLIST, MDELETED,MMNDEL }, + { "unset", { unset }, M|RAWLIST, 1, 1000 }, + { "mail", { sendmail }, R|M|I|STRLIST, 0, 0 }, + { "mbox", { mboxit }, W|MSGLIST, 0, 0 }, + { "pipe", { pipeit }, MSGLIST|STRLIST,0, MMNDEL }, + { "|", { pipeit }, MSGLIST|STRLIST,0, MMNDEL }, + { "more", { more }, MSGLIST, 0, MMNDEL }, + { "page", { more }, MSGLIST, 0, MMNDEL }, + { "More", { More }, MSGLIST, 0, MMNDEL }, + { "Page", { More }, MSGLIST, 0, MMNDEL }, + { "unread", { unread }, MSGLIST, 0, MMNDEL }, + { "!", { shell }, I|STRLIST, 0, 0 }, + { "copy", { copycmd }, M|STRLIST, 0, 0 }, + { "chdir", { schdir }, M|RAWLIST, 0, 1 }, + { "cd", { schdir }, M|RAWLIST, 0, 1 }, + { "save", { save }, STRLIST, 0, 0 }, + { "source", { source }, M|RAWLIST, 1, 1 }, + { "set", { set }, M|RAWLIST, 0, 1000 }, + { "shell", { dosh }, I|NOLIST, 0, 0 }, + { "version", { pversion }, M|NOLIST, 0, 0 }, + { "group", { group }, M|RAWLIST, 0, 1000 }, + { "write", { swrite }, STRLIST, 0, 0 }, + { "from", { from }, MSGLIST, 0, MMNORM }, + { "file", { file }, T|M|RAWLIST, 0, 1 }, + { "folder", { file }, T|M|RAWLIST, 0, 1 }, + { "folders", { folders }, T|M|STRLIST, 0, 0 }, + { "?", { help }, M|NOLIST, 0, 0 }, + { "z", { scroll }, M|STRLIST, 0, 0 }, + { "headers", { headers }, MSGLIST, 0, MMNDEL }, + { "help", { help }, M|NOLIST, 0, 0 }, + { "=", { pdot }, NOLIST, 0, 0 }, + { "Reply", { Respond }, R|I|MSGLIST, 0, MMNDEL }, + { "Respond", { Respond }, R|I|MSGLIST, 0, MMNDEL }, + { "reply", { respond }, R|I|MSGLIST, 0, MMNDEL }, + { "respond", { respond }, R|I|MSGLIST, 0, MMNDEL }, + { "edit", { editor }, I|MSGLIST, 0, MMNORM }, + { "echo", { echo }, M|RAWLIST, 0, 1000 }, + { "quit", { quitcmd }, NOLIST, 0, 0 }, + { "list", { pcmdlist }, M|NOLIST, 0, 0 }, + { "xit", { rexit }, M|NOLIST, 0, 0 }, + { "exit", { rexit }, M|NOLIST, 0, 0 }, + { "size", { messize }, MSGLIST, 0, MMNDEL }, + { "hold", { preserve }, W|MSGLIST, 0, MMNDEL }, + { "if", { ifcmd }, F|M|RAWLIST, 1, 1 }, + { "else", { elsecmd }, F|M|RAWLIST, 0, 0 }, + { "endif", { endifcmd }, F|M|RAWLIST, 0, 0 }, + { "alternates", { alternates }, M|RAWLIST, 0, 1000 }, + { "ignore", { igfield }, M|RAWLIST, 0, 1000 }, + { "discard", { igfield }, M|RAWLIST, 0, 1000 }, + { "retain", { retfield }, M|RAWLIST, 0, 1000 }, + { "saveignore", { saveigfield }, M|RAWLIST, 0, 1000 }, + { "savediscard",{ saveigfield }, M|RAWLIST, 0, 1000 }, + { "saveretain", { saveretfield }, M|RAWLIST, 0, 1000 }, +#if 0 + { "Header", { Header }, STRLIST, 0, 1000 }, +#endif + { "core", { core }, M|NOLIST, 0, 0 }, + { "#", { null }, M|NOLIST, 0, 0 }, + { "clobber", { clobber }, M|RAWLIST, 0, 1 }, + { "inc", { inc }, T|NOLIST, 0, 0 }, + { "new", { marknew }, MSGLIST, 0, MMNDEL }, + { 0, { 0 }, 0, 0, 0 } }; diff --git a/usr.bin/mail/collect.c b/usr.bin/mail/collect.c index 60d14da6a70..e376d0b1636 100644 --- a/usr.bin/mail/collect.c +++ b/usr.bin/mail/collect.c @@ -1,4 +1,4 @@ -/* $OpenBSD: collect.c,v 1.22 2001/11/20 20:50:00 millert Exp $ */ +/* $OpenBSD: collect.c,v 1.23 2001/11/21 15:26:39 millert Exp $ */ /* $NetBSD: collect.c,v 1.9 1997/07/09 05:25:45 mikel Exp $ */ /* @@ -36,9 +36,9 @@ #ifndef lint #if 0 -static char sccsid[] = "@(#)collect.c 8.2 (Berkeley) 4/19/94"; +static const char sccsid[] = "@(#)collect.c 8.2 (Berkeley) 4/19/94"; #else -static char rcsid[] = "$OpenBSD: collect.c,v 1.22 2001/11/20 20:50:00 millert Exp $"; +static const char rcsid[] = "$OpenBSD: collect.c,v 1.23 2001/11/21 15:26:39 millert Exp $"; #endif #endif /* not lint */ @@ -62,14 +62,11 @@ static char rcsid[] = "$OpenBSD: collect.c,v 1.22 2001/11/20 20:50:00 millert Ex * receipt of an interrupt signal, the partial message can be salted * away on dead.letter. */ - static FILE *collf; /* File for saving away */ static int hadintr; /* Have seen one SIGINT so far */ FILE * -collect(hp, printheaders) - struct header *hp; - int printheaders; +collect(struct header *hp, int printheaders) { FILE *fbuf; int lc, cc, fd, c, t, lastlong, rc, sig; @@ -252,8 +249,8 @@ cont: hp->h_bcc = cat(hp->h_bcc, extract(&linebuf[2], GBCC)); break; case 'd': - strncpy(linebuf + 2, getdeadletter(), sizeof(linebuf) - 3); - linebuf[sizeof(linebuf) - 1] = '\0'; + linebuf[2] = '\0'; + strlcat(linebuf, getdeadletter(), sizeof(linebuf)); /* fall into . . . */ case 'r': case '<': @@ -399,10 +396,7 @@ out: * Write a file, ex-like if f set. */ int -exwrite(name, fp, f) - char name[]; - FILE *fp; - int f; +exwrite(char *name, FILE *fp, int f) { FILE *of; int c; @@ -447,9 +441,7 @@ exwrite(name, fp, f) * On return, make the edit file the new temp file. */ void -mesedit(fp, c) - FILE *fp; - int c; +mesedit(FILE *fp, int c) { FILE *nf; struct sigaction oact; @@ -473,9 +465,7 @@ mesedit(fp, c) * Sh -c must return 0 to accept the new message. */ void -mespipe(fp, cmd) - FILE *fp; - char cmd[]; +mespipe(FILE *fp, char *cmd) { FILE *nf; int fd; @@ -527,11 +517,7 @@ out: * should shift over and 'f' if not. */ int -forward(ms, fp, fn, f) - char ms[]; - FILE *fp; - char *fn; - int f; +forward(char *ms, FILE *fp, char *fn, int f) { int *msgvec; struct ignoretab *ig; @@ -575,7 +561,7 @@ forward(ms, fp, fn, f) * Save the partial message in ~/dead.letter. */ int -collabort() +collabort(void) { /* * the control flow is subtle, because we can be called from ~q. @@ -601,8 +587,7 @@ collabort() } void -savedeadletter(fp) - FILE *fp; +savedeadletter(FILE *fp) { FILE *dbuf; int c; @@ -623,9 +608,7 @@ savedeadletter(fp) } int -gethfromtty(hp, gflags) - struct header *hp; - int gflags; +gethfromtty(struct header *hp, int gflags) { hadintr = 0; diff --git a/usr.bin/mail/def.h b/usr.bin/mail/def.h index 2403d47607d..0035ca9918d 100644 --- a/usr.bin/mail/def.h +++ b/usr.bin/mail/def.h @@ -1,5 +1,6 @@ -/* $OpenBSD: def.h,v 1.8 2001/11/20 20:50:00 millert Exp $ */ +/* $OpenBSD: def.h,v 1.9 2001/11/21 15:26:39 millert Exp $ */ /* $NetBSD: def.h,v 1.9 1996/12/28 07:11:00 tls Exp $ */ + /* * Copyright (c) 1980, 1993 * The Regents of the University of California. All rights reserved. @@ -33,7 +34,7 @@ * SUCH DAMAGE. * * @(#)def.h 8.4 (Berkeley) 4/20/95 - * $OpenBSD: def.h,v 1.8 2001/11/20 20:50:00 millert Exp $ + * $OpenBSD: def.h,v 1.9 2001/11/21 15:26:39 millert Exp $ */ /* @@ -83,7 +84,6 @@ struct message { /* * flag bits. */ - #define MUSED (1<<0) /* entry is used, but this bit isn't */ #define MDELETED (1<<1) /* entry has been deleted */ #define MSAVED (1<<2) /* entry has been saved */ @@ -123,14 +123,12 @@ struct cmd { }; /* Yechh, can't initialize unions */ - #define c_minargs c_msgflag /* Minimum argcount for RAWLIST */ #define c_maxargs c_msgmask /* Max argcount for RAWLIST */ /* * Argument types. */ - #define MSGLIST 0x0001 /* Message list type */ #define STRLIST 0x0002 /* A pure string */ #define RAWLIST 0x0004 /* Shell string list */ @@ -148,7 +146,6 @@ struct cmd { /* * Oft-used mask values */ - #define MMNORM (MDELETED|MSAVED)/* Look at both save and delete bits */ #define MMNDEL MDELETED /* Look only at deleted bit */ @@ -156,7 +153,6 @@ struct cmd { * Structure used to return a break down of a head * line (hats off to Bill Joy!) */ - struct headline { char *l_from; /* The name of the sender */ char *l_tty; /* His tty string (if any) */ @@ -178,7 +174,6 @@ struct headline { * Structure used to pass about the current * state of the user-typed message header. */ - struct header { struct name *h_to; /* Dynamic "To:" string */ char *h_subject; /* Subject string */ @@ -192,7 +187,6 @@ struct header { * the recipients of mail and aliases and all that * kind of stuff. */ - struct name { struct name *n_flink; /* Forward link in list. */ struct name *n_blink; /* Backward list link */ @@ -223,12 +217,6 @@ struct grouphead { struct group *g_list; /* Users in group. */ }; -#define NIL ((struct name *) 0) /* The nil pointer for namelists */ -#define NONE ((struct cmd *) 0) /* The nil pointer to command tab */ -#define NOVAR ((struct var *) 0) /* The nil pointer to variables */ -#define NOGRP ((struct grouphead *) 0)/* The nil grouphead pointer */ -#define NOGE ((struct group *) 0) /* The nil group pointer */ - /* * Structure of the hash table of ignored header fields */ @@ -244,7 +232,6 @@ struct ignoretab { * Token values returned by the scanner used for argument lists. * Also, sizes of scanner-related things. */ - #define TEOL 0 /* End of the command line */ #define TNUMBER 1 /* A message number */ #define TDASH 2 /* A simple dash */ @@ -262,10 +249,9 @@ struct ignoretab { #define STRINGLEN 1024 /* Maximum length of string token */ /* - * Constants for conditional commands. These describe whether - * we should be executing stuff or not. + * Constants for conditional commands. + * These describe whether we should be executing stuff or not. */ - #define CANY 0 /* Execute in send or receive mode */ #define CRCV 1 /* Execute in receive mode only */ #define CSEND 2 /* Execute in send mode only */ @@ -275,9 +261,9 @@ struct ignoretab { * useful just before closing an old file that was opened * for read/write. */ -#define trunc(stream) { \ +#define trunc(stream) do { \ (void)fflush(stream); \ (void)ftruncate(fileno(stream), (off_t)ftell(stream)); \ -} +} while(0) #endif /* MAIL_DEF_H */ diff --git a/usr.bin/mail/edit.c b/usr.bin/mail/edit.c index 86cbda720fb..af6839ebaed 100644 --- a/usr.bin/mail/edit.c +++ b/usr.bin/mail/edit.c @@ -1,4 +1,4 @@ -/* $OpenBSD: edit.c,v 1.10 2001/11/20 20:50:00 millert Exp $ */ +/* $OpenBSD: edit.c,v 1.11 2001/11/21 15:26:39 millert Exp $ */ /* $NetBSD: edit.c,v 1.5 1996/06/08 19:48:20 christos Exp $ */ /* @@ -36,9 +36,9 @@ #ifndef lint #if 0 -static char sccsid[] = "@(#)edit.c 8.1 (Berkeley) 6/6/93"; +static const char sccsid[] = "@(#)edit.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: edit.c,v 1.10 2001/11/20 20:50:00 millert Exp $"; +static const char rcsid[] = "$OpenBSD: edit.c,v 1.11 2001/11/21 15:26:39 millert Exp $"; #endif #endif /* not lint */ @@ -56,8 +56,7 @@ static char rcsid[] = "$OpenBSD: edit.c,v 1.10 2001/11/20 20:50:00 millert Exp $ * Edit a message list. */ int -editor(v) - void *v; +editor(void *v) { int *msgvec = v; @@ -68,8 +67,7 @@ editor(v) * Invoke the visual editor on a message list. */ int -visual(v) - void *v; +visual(void *v) { int *msgvec = v; @@ -82,9 +80,7 @@ visual(v) * We get the editor from the stuff above. */ int -edit1(msgvec, type) - int *msgvec; - int type; +edit1(int *msgvec, int type) { int c, i; FILE *fp; @@ -147,10 +143,7 @@ edit1(msgvec, type) * "Type" is 'e' for _PATH_EX, 'v' for _PATH_VI. */ FILE * -run_editor(fp, size, type, readonly) - FILE *fp; - off_t size; - int type, readonly; +run_editor(FILE *fp, off_t size, int type, int readonly) { FILE *nf = NULL; int t; diff --git a/usr.bin/mail/extern.h b/usr.bin/mail/extern.h index 16024b82f3d..5fba26f565f 100644 --- a/usr.bin/mail/extern.h +++ b/usr.bin/mail/extern.h @@ -1,4 +1,4 @@ -/* $OpenBSD: extern.h,v 1.18 2001/11/20 20:50:00 millert Exp $ */ +/* $OpenBSD: extern.h,v 1.19 2001/11/21 15:26:39 millert Exp $ */ /* $NetBSD: extern.h,v 1.7 1997/07/09 05:22:00 mikel Exp $ */ /*- @@ -34,240 +34,239 @@ * SUCH DAMAGE. * * @(#)extern.h 8.2 (Berkeley) 4/20/95 - * $OpenBSD: extern.h,v 1.18 2001/11/20 20:50:00 millert Exp $ + * $OpenBSD: extern.h,v 1.19 2001/11/21 15:26:39 millert Exp $ */ struct name; -struct name *cat __P((struct name *, struct name *)); -struct name *delname __P((struct name *, char [])); -struct name *elide __P((struct name *)); -struct name *extract __P((char [], int)); +struct name *cat(struct name *, struct name *); +struct name *delname(struct name *, char *); +struct name *elide(struct name *); +struct name *extract(char *, int); struct grouphead; -struct name *gexpand __P((struct name *, struct grouphead *, int, int)); -struct name *nalloc __P((char [], int)); +struct name *gexpand(struct name *, struct grouphead *, int, int); +struct name *nalloc(char *, int); struct header; -struct name *outof __P((struct name *, FILE *, struct header *)); -struct name *put __P((struct name *, struct name *)); -struct name *tailof __P((struct name *)); -struct name *usermap __P((struct name *)); -FILE *Fdopen __P((int, char *)); -FILE *Fopen __P((char *, char *)); -FILE *Popen __P((char *, char *)); -FILE *collect __P((struct header *, int)); -char *copy __P((char *, char *)); -char *copyin __P((char *, char **)); -char *detract __P((struct name *, int)); -char *expand __P((char *)); -char *getdeadletter __P((void)); -char *getname __P((int)); +struct name *outof(struct name *, FILE *, struct header *); +struct name *put(struct name *, struct name *); +struct name *tailof(struct name *); +struct name *usermap(struct name *); +FILE *Fdopen(int, char *); +FILE *Fopen(char *, char *); +FILE *Popen(char *, char *); +FILE *collect(struct header *, int); +char *copy(char *, char *); +char *copyin(char *, char **); +char *detract(struct name *, int); +char *expand(char *); +char *getdeadletter(void); +char *getname(uid_t); struct message; -char *hfield __P((char [], struct message *)); -FILE *infix __P((struct header *, FILE *)); -char *ishfield __P((char [], char[], char *)); -char *name1 __P((struct message *, int)); -char *nameof __P((struct message *, int)); -char *nextword __P((char *, char *)); -char *readtty __P((char [], char [])); -char *reedit __P((char *)); -FILE *run_editor __P((FILE *, off_t, int, int)); -char *salloc __P((int)); -char *savestr __P((char *)); -FILE *setinput __P((struct message *)); -char *skin __P((char *)); -char *skip_comment __P((char *)); -char *snarf __P((char [], int *)); -char *username __P((void)); -char *value __P((char [])); -char *vcopy __P((char [])); -char *yankword __P((char *, char [])); -int Fclose __P((FILE *)); -int More __P((void *)); -int Pclose __P((FILE *)); -int Respond __P((void *)); -int Type __P((void *)); -int _Respond __P((int [])); -int _respond __P((int *)); -void alter __P((char *)); -int alternates __P((void *)); -void announce __P((void)); -int anyof __P((char *, char *)); -int append __P((struct message *, FILE *)); -int argcount __P((char **)); -void assign __P((char [], char [])); -int bangexp __P((char *, size_t)); -int blankline __P((char [])); -int charcount __P((char *, int)); -int check __P((int, int)); -void clearnew __P((void)); -void clob1 __P((int)); -int clobber __P((void *)); -void close_all_files __P((void)); -int cmatch __P((char *, char *)); -int collabort __P((void)); -void commands __P((void)); -int copycmd __P((void *)); -int core __P((void *)); -int count __P((struct name *)); -int delete __P((void *)); -int delm __P((int [])); -int deltype __P((void *)); -void demail __P((void)); -void dointr __P((void)); -int dosh __P((void *)); -int dot_lock __P((const char *, int, FILE *, const char *)); -void dot_unlock __P((const char *)); -int echo __P((void *)); -int edit1 __P((int *, int)); -int editor __P((void *)); -int edstop __P((void)); -int elsecmd __P((void *)); -int endifcmd __P((void *)); -int evalcol __P((int)); -int execute __P((char [], int)); -int exwrite __P((char [], FILE *, int)); -void fail __P((char [], char [])); -int file __P((void *)); +char *hfield(char *, struct message *); +FILE *infix(struct header *, FILE *); +char *ishfield(char *, char *, char *); +char *name1(struct message *, int); +char *nameof(struct message *, int); +char *nextword(char *, char *); +char *readtty(char *, char *); +char *reedit(char *); +FILE *run_editor(FILE *, off_t, int, int); +char *salloc(int); +char *savestr(char *); +FILE *setinput(struct message *); +char *skin(char *); +char *skip_comment(char *); +char *snarf(char *, int *); +char *username(void); +char *value(char *); +char *vcopy(char *); +char *yankword(char *, char *); +int Fclose(FILE *); +int More(void *); +int Pclose(FILE *); +int Respond(void *); +int Type(void *); +int _Respond(int *); +int _respond(int *); +void alter(char *); +int alternates(void *); +void announce(void); +int append(struct message *, FILE *); +int argcount(char **); +void assign(char *, char *); +int bangexp(char *, size_t); +int blankline(char *); +int charcount(char *, int); +int check(int, int); +void clearnew(void); +void clob1(int); +int clobber(void *); +void close_all_files(void); +int cmatch(char *, char *); +int collabort(void); +void commands(void); +int copycmd(void *); +int core(void *); +int count(struct name *); +int delete(void *); +int delm(int *); +int deltype(void *); +void demail(void); +void dointr(void); +int dosh(void *); +int dot_lock(const char *, int, FILE *, const char *); +void dot_unlock(const char *); +int echo(void *); +int edit1(int *, int); +int editor(void *); +int edstop(void); +int elsecmd(void *); +int endifcmd(void *); +int evalcol(int); +int execute(char *, int); +int exwrite(char *, FILE *, int); +void fail(char *, char *); +int file(void *); struct grouphead * - findgroup __P((char [])); -void findmail __P((char *, char *, int)); -void fioint __P((int)); -int first __P((int, int)); -void fixhead __P((struct header *, struct name *)); -void fmt __P((char *, struct name *, FILE *, int)); -int folders __P((void *)); -int forward __P((char [], FILE *, char *, int)); -void free_child __P((int)); -int from __P((void *)); -off_t fsize __P((FILE *)); -int getfold __P((char *, int)); -int gethfield __P((FILE *, char [], int, char **)); -int gethfromtty __P((struct header *, int)); -int getmsglist __P((char *, int *, int)); -int getrawlist __P((char [], char **, int)); -int getuserid __P((char [])); -int grabh __P((struct header *, int)); -int group __P((void *)); -int hash __P((char *)); -void hdrint __P((int)); -int headers __P((void *)); -int help __P((void *)); -void holdsigs __P((void)); -int ifcmd __P((void *)); -int igfield __P((void *)); + findgroup(char *); +void findmail(char *, char *, int); +void fioint(int); +int first(int, int); +void fixhead(struct header *, struct name *); +void fmt(char *, struct name *, FILE *, int); +int folders(void *); +int forward(char *, FILE *, char *, int); +void free_child(pid_t); +int from(void *); +off_t fsize(FILE *); +int getfold(char *, int); +int gethfield(FILE *, char *, int, char **); +int gethfromtty(struct header *, int); +int getmsglist(char *, int *, int); +int getrawlist(char *, char **, int); +uid_t getuserid(char *); +int grabh(struct header *, int); +int group(void *); +int hash(char *); +void hdrint(int); +int headers(void *); +int help(void *); +void holdsigs(void); +int ifcmd(void *); +int igfield(void *); struct ignoretab; -int ignore1 __P((char *[], struct ignoretab *, char *)); -int ignoresig __P((int, struct sigaction *, sigset_t *)); -int igshow __P((struct ignoretab *, char *)); -void intr __P((int)); -int inc __P((void *)); -int incfile __P((void)); -int isdate __P((char [])); -int isdir __P((char [])); -int isfileaddr __P((char *)); -int ishead __P((char [])); -int isign __P((char *, struct ignoretab [])); -int isprefix __P((char *, char *)); -void istrncpy __P((char *, char *, size_t)); +int ignore1(char **, struct ignoretab *, char *); +int ignoresig(int, struct sigaction *, sigset_t *); +int igshow(struct ignoretab *, char *); +void intr(int); +int inc(void *); +int incfile(void); +int isdate(char *); +int isdir(char *); +int isfileaddr(char *); +int ishead(char *); +int isign(char *, struct ignoretab *); +int isprefix(char *, char *); +size_t istrlcpy(char *, const char *, size_t); const struct cmd * - lex __P((char [])); -void load __P((char *)); + lex(char *); +void load(char *); struct var * - lookup __P((char [])); -int mail __P((struct name *, - struct name *, struct name *, struct name *, char *)); -void mail1 __P((struct header *, int)); -void makemessage __P((FILE *, int)); -void mark __P((int)); -int markall __P((char [], int)); -int marknew __P((void *)); -int matchsender __P((char *, int)); -int matchsubj __P((char *, int)); -int mboxit __P((void *)); -int member __P((char *, struct ignoretab *)); -void mesedit __P((FILE *, int)); -void mespipe __P((FILE *, char [])); -int messize __P((void *)); -int metamess __P((int, int)); -int more __P((void *)); -int newfileinfo __P((int)); -int next __P((void *)); -int null __P((void *)); + lookup(char *); +int mail (struct name *, struct name *, struct name *, struct name *, + char *); +void mail1(struct header *, int); +void makemessage(FILE *, int); +void mark(int); +int markall(char *, int); +int marknew(void *); +int matchsender(char *, int); +int matchsubj(char *, int); +int mboxit(void *); +int member(char *, struct ignoretab *); +void mesedit(FILE *, int); +void mespipe(FILE *, char *); +int messize(void *); +int metamess(int, int); +int more(void *); +int newfileinfo(int); +int next(void *); +int null(void *); struct headline; -void parse __P((char [], struct headline *, char [])); -int pcmdlist __P((void *)); -int pdot __P((void *)); -int pipeit __P((void *, void *)); -void prepare_child __P((sigset_t *, int, int)); -int preserve __P((void *)); -void prettyprint __P((struct name *)); -void printgroup __P((char [])); -void printhead __P((int)); -int puthead __P((struct header *, FILE *, int)); -int putline __P((FILE *, char *, int)); -int pversion __P((void *)); -int quit __P((void)); -int quitcmd __P((void *)); -int raise __P((int)); -int readline __P((FILE *, char *, int, int *)); -void register_file __P((FILE *, int, int)); -void regret __P((int)); -void relsesigs __P((void)); -int respond __P((void *)); -int retfield __P((void *)); -int rexit __P((void *)); -int rm __P((char *)); -int run_command __P((char *cmd, sigset_t *nset, int infd, int outfd, ...)); -int save __P((void *)); -int save1 __P((char [], int, char *, struct ignoretab *)); -void savedeadletter __P((FILE *)); -int saveigfield __P((void *)); -int savemail __P((char [], FILE *)); -int saveretfield __P((void *)); -int scan __P((char **)); -void scaninit __P((void)); -int schdir __P((void *)); -int screensize __P((void)); -int scroll __P((void *)); -int sendmessage __P((struct message *, FILE *, struct ignoretab *, char *)); -int sendmail __P((void *)); -int set __P((void *)); -int setfile __P((char *)); -void setmsize __P((int)); -void setptr __P((FILE *, off_t)); -void setscreensize __P((void)); -int shell __P((void *)); -void sigchild __P((int)); -void sort __P((char **)); -int source __P((void *)); -int spool_lock __P((void)); -int spool_unlock __P((void)); -void spreserve __P((void)); -void sreset __P((void)); -int start_command __P((char *cmd, sigset_t *nset, int infd, int outfd, ...)); -int start_commandv __P((char *, sigset_t *, int, int, _BSD_VA_LIST_)); -void statusput __P((struct message *, FILE *, char *)); -void stop __P((int)); -int stouch __P((void *)); -int swrite __P((void *)); -void tinit __P((void)); -int top __P((void *)); -void touch __P((struct message *)); -void ttyint __P((int)); -void ttystop __P((int)); -int type __P((void *)); -int type1 __P((int *, char *, int, int)); -int undeletecmd __P((void *)); -void unmark __P((int)); -char **unpack __P((struct name *, struct name *)); -int unread __P((void *)); -void unregister_file __P((FILE *)); -int unset __P((void *)); -int unstack __P((void)); -void vfree __P((char *)); -int visual __P((void *)); -int wait_child __P((int)); -int wait_command __P((int)); -int writeback __P((FILE *)); +void parse(char *, struct headline *, char *); +int pcmdlist(void *); +int pdot(void *); +int pipeit(void *, void *); +void prepare_child(sigset_t *, int, int); +int preserve(void *); +void prettyprint(struct name *); +void printgroup(char *); +void printhead(int); +int puthead(struct header *, FILE *, int); +int putline(FILE *, char *, int); +int pversion(void *); +int quit(void); +int quitcmd(void *); +int raise(int); +int readline(FILE *, char *, int, int *); +void register_file(FILE *, int, pid_t); +void regret(int); +void relsesigs(void); +int respond(void *); +int retfield(void *); +int rexit(void *); +int rm(char *); +int run_command(char *cmd, sigset_t *nset, int infd, int outfd, ...); +int save(void *); +int save1(char *, int, char *, struct ignoretab *); +void savedeadletter(FILE *); +int saveigfield(void *); +int savemail(char *, FILE *); +int saveretfield(void *); +int scan(char **); +void scaninit(void); +int schdir(void *); +int screensize(void); +int scroll(void *); +int sendmessage(struct message *, FILE *, struct ignoretab *, char *); +int sendmail(void *); +int set(void *); +int setfile(char *); +void setmsize(int); +void setptr(FILE *, off_t); +void setscreensize(void); +int shell(void *); +void sigchild(int); +void sort(char **); +int source(void *); +int spool_lock(void); +int spool_unlock(void); +void spreserve(void); +void sreset(void); +pid_t start_command(char *cmd, sigset_t *nset, int infd, int outfd, ...); +pid_t start_commandv(char *, sigset_t *, int, int, _BSD_VA_LIST_); +void statusput(struct message *, FILE *, char *); +void stop(int); +int stouch(void *); +int swrite(void *); +void tinit(void); +int top(void *); +void touch(struct message *); +void ttyint(int); +void ttystop(int); +int type(void *); +int type1(int *, char *, int, int); +int undeletecmd(void *); +void unmark(int); +char **unpack(struct name *, struct name *); +int unread(void *); +void unregister_file(FILE *); +int unset(void *); +int unstack(void); +void vfree(char *); +int visual(void *); +int wait_child(pid_t); +int wait_command(int); +int writeback(FILE *); extern char *__progname; extern char *tmpdir; diff --git a/usr.bin/mail/fio.c b/usr.bin/mail/fio.c index 3fef0ff1b8a..41f48a6a9b2 100644 --- a/usr.bin/mail/fio.c +++ b/usr.bin/mail/fio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fio.c,v 1.19 2001/11/20 20:50:00 millert Exp $ */ +/* $OpenBSD: fio.c,v 1.20 2001/11/21 15:26:39 millert Exp $ */ /* $NetBSD: fio.c,v 1.8 1997/07/07 22:57:55 phil Exp $ */ /* @@ -36,9 +36,9 @@ #ifndef lint #if 0 -static char sccsid[] = "@(#)fio.c 8.2 (Berkeley) 4/20/95"; +static const char sccsid[] = "@(#)fio.c 8.2 (Berkeley) 4/20/95"; #else -static char rcsid[] = "$OpenBSD: fio.c,v 1.19 2001/11/20 20:50:00 millert Exp $"; +static const char rcsid[] = "$OpenBSD: fio.c,v 1.20 2001/11/21 15:26:39 millert Exp $"; #endif #endif /* not lint */ @@ -63,10 +63,7 @@ static volatile sig_atomic_t fiosignal; * Wrapper for read() to catch EINTR. */ ssize_t -myread(fd, buf, len) - int fd; - char *buf; - int len; +myread(int fd, char *buf, int len) { ssize_t nread; @@ -79,9 +76,7 @@ myread(fd, buf, len) * Set up the input pointers while copying the mail file into /tmp. */ void -setptr(ibuf, offset) - FILE *ibuf; - off_t offset; +setptr(FILE *ibuf, off_t offset) { int c, count; char *cp, *cp2; @@ -184,10 +179,7 @@ setptr(ibuf, offset) * characters written, including the newline if requested. */ int -putline(obuf, linebuf, outlf) - FILE *obuf; - char *linebuf; - int outlf; +putline(FILE *obuf, char *linebuf, int outlf) { int c; @@ -208,11 +200,7 @@ putline(obuf, linebuf, outlf) * include the newline (or carriage return) at the end. */ int -readline(ibuf, linebuf, linesize, signo) - FILE *ibuf; - char *linebuf; - int linesize; - int *signo; +readline(FILE *ibuf, char *linebuf, int linesize, int *signo) { struct sigaction act; struct sigaction savetstp; @@ -277,8 +265,7 @@ readline(ibuf, linebuf, linesize, signo) * passed message pointer. */ FILE * -setinput(mp) - struct message *mp; +setinput(struct message *mp) { fflush(otf); @@ -292,9 +279,7 @@ setinput(mp) * a dynamically allocated message structure. */ void -makemessage(f, omsgCount) - FILE *f; - int omsgCount; +makemessage(FILE *f, int omsgCount) { size_t size = (msgCount + 1) * sizeof(struct message); @@ -326,10 +311,9 @@ makemessage(f, omsgCount) * If the write fails, return 1, else 0 */ int -append(mp, f) - struct message *mp; - FILE *f; +append(struct message *mp, FILE *f) { + return(fwrite((char *) mp, sizeof(*mp), 1, f) != 1); } @@ -337,8 +321,7 @@ append(mp, f) * Delete or truncate a file, but only if the file is a plain file. */ int -rm(name) - char *name; +rm(char *name) { struct stat sb; @@ -363,7 +346,7 @@ static sigset_t nset, oset; * Hold signals SIGHUP, SIGINT, and SIGQUIT. */ void -holdsigs() +holdsigs(void) { if (sigdepth++ == 0) { @@ -379,7 +362,7 @@ holdsigs() * Release signals SIGHUP, SIGINT, and SIGQUIT. */ void -relsesigs() +relsesigs(void) { if (--sigdepth == 0) @@ -390,10 +373,7 @@ relsesigs() * Unblock and ignore a signal */ int -ignoresig(sig, oact, oset) - int sig; - struct sigaction *oact; - sigset_t *oset; +ignoresig(int sig, struct sigaction *oact, sigset_t *oset) { struct sigaction act; sigset_t nset; @@ -419,8 +399,7 @@ ignoresig(sig, oact, oset) * the passed buffer. */ off_t -fsize(iob) - FILE *iob; +fsize(FILE *iob) { struct stat sbuf; @@ -441,12 +420,12 @@ fsize(iob) * Return the file name as a dynamic string. */ char * -expand(name) - char *name; +expand(char *name) { char xname[PATHSIZE]; char cmdbuf[PATHSIZE]; /* also used for file names */ - int pid, l; + pid_t pid; + int l; char *cp, *shell; int pivec[2]; struct stat sbuf; @@ -484,8 +463,9 @@ expand(name) (void)snprintf(xname, sizeof(xname), "%s%s", homedir, name + 1); name = savestr(xname); } - if (!anyof(name, "~{[*?$`'\"\\")) + if (strpbrk(name, "~{[*?$`'\"\\") == NULL) return(name); + /* XXX - just use glob(3) and env expansion instead? */ if (pipe(pivec) < 0) { warn("pipe"); return(name); @@ -533,18 +513,15 @@ expand(name) * Determine the current folder directory name. */ int -getfold(name, namelen) - char *name; - int namelen; +getfold(char *name, int namelen) { char *folder; if ((folder = value("folder")) == NULL) return(-1); - if (*folder == '/') { - strncpy(name, folder, namelen-1); - name[namelen-1] = '\0'; - } else + if (*folder == '/') + strlcpy(name, folder, namelen); + else (void)snprintf(name, namelen, "%s/%s", homedir ? homedir : ".", folder); return(0); @@ -554,7 +531,7 @@ getfold(name, namelen) * Return the name of the dead.letter file. */ char * -getdeadletter() +getdeadletter(void) { char *cp; @@ -574,8 +551,7 @@ getdeadletter() * SIGTTOU, SIGTTIN. */ void -fioint(s) - int s; +fioint(int s) { fiosignal = s; diff --git a/usr.bin/mail/getname.c b/usr.bin/mail/getname.c index 8314a21cfcc..c675f8e87fb 100644 --- a/usr.bin/mail/getname.c +++ b/usr.bin/mail/getname.c @@ -1,4 +1,4 @@ -/* $OpenBSD: getname.c,v 1.4 1997/07/14 00:24:27 millert Exp $ */ +/* $OpenBSD: getname.c,v 1.5 2001/11/21 15:26:39 millert Exp $ */ /* $NetBSD: getname.c,v 1.4 1996/06/08 19:48:23 christos Exp $ */ /* @@ -36,9 +36,9 @@ #ifndef lint #if 0 -static char sccsid[] = "@(#)getname.c 8.1 (Berkeley) 6/6/93"; +static const char sccsid[] = "@(#)getname.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: getname.c,v 1.4 1997/07/14 00:24:27 millert Exp $"; +static const char rcsid[] = "$OpenBSD: getname.c,v 1.5 2001/11/21 15:26:39 millert Exp $"; #endif #endif /* not lint */ @@ -52,8 +52,7 @@ static char rcsid[] = "$OpenBSD: getname.c,v 1.4 1997/07/14 00:24:27 millert Exp * Search the passwd file for a uid. Return name on success, NULL on failure */ char * -getname(uid) - int uid; +getname(uid_t uid) { struct passwd *pw; @@ -66,13 +65,12 @@ getname(uid) * Convert the passed name to a user id and return it. Return -1 * on error. */ -int -getuserid(name) - char name[]; +uid_t +getuserid(char *name) { struct passwd *pw; if ((pw = getpwnam(name)) == NULL) - return(-1); + return(UID_MAX); return(pw->pw_uid); } diff --git a/usr.bin/mail/glob.h b/usr.bin/mail/glob.h index d82df7d78a0..014f27b3769 100644 --- a/usr.bin/mail/glob.h +++ b/usr.bin/mail/glob.h @@ -1,4 +1,4 @@ -/* $OpenBSD: glob.h,v 1.5 2001/11/20 20:50:00 millert Exp $ */ +/* $OpenBSD: glob.h,v 1.6 2001/11/21 15:26:39 millert Exp $ */ /* $NetBSD: glob.h,v 1.4 1996/06/08 19:48:25 christos Exp $ */ /* @@ -41,7 +41,6 @@ * A bunch of global variable declarations lie herein. * def.h must be included first. */ - int msgCount; /* Count of messages read in */ int rcvmode; /* True if receiving mail */ int sawcom; /* Set after first command */ @@ -86,14 +85,12 @@ int realscreenheight; /* the real screen height */ int uflag; /* Are we in -u mode? */ sigset_t intset; /* Signal set that is just SIGINT */ - /* * The pointers for the string allocation routines, * there are NSPACE independent areas. * The first holds STRINGSIZE bytes, the next * twice as much, and so on. */ - #define NSPACE 25 /* Total number of string spaces */ struct strings { char *s_topFree; /* Beginning of this area */ diff --git a/usr.bin/mail/head.c b/usr.bin/mail/head.c index ebeb418e9fc..d63a86f9143 100644 --- a/usr.bin/mail/head.c +++ b/usr.bin/mail/head.c @@ -1,4 +1,4 @@ -/* $OpenBSD: head.c,v 1.6 2001/01/19 04:11:28 millert Exp $ */ +/* $OpenBSD: head.c,v 1.7 2001/11/21 15:26:39 millert Exp $ */ /* $NetBSD: head.c,v 1.6 1996/12/28 07:11:03 tls Exp $ */ /* @@ -36,9 +36,9 @@ #ifndef lint #if 0 -static char sccsid[] = "@(#)head.c 8.2 (Berkeley) 4/20/95"; +static const char sccsid[] = "@(#)head.c 8.2 (Berkeley) 4/20/95"; #else -static char rcsid[] = "$OpenBSD: head.c,v 1.6 2001/01/19 04:11:28 millert Exp $"; +static const char rcsid[] = "$OpenBSD: head.c,v 1.7 2001/11/21 15:26:39 millert Exp $"; #endif #endif /* not lint */ @@ -57,8 +57,7 @@ static char rcsid[] = "$OpenBSD: head.c,v 1.6 2001/01/19 04:11:28 millert Exp $" * accomodate all funny formats. */ int -ishead(linebuf) - char linebuf[]; +ishead(char *linebuf) { char *cp; struct headline hl; @@ -85,8 +84,7 @@ ishead(linebuf) /*ARGSUSED*/ void -fail(linebuf, reason) - char linebuf[], reason[]; +fail(char *linebuf, char *reason) { /* @@ -103,9 +101,7 @@ fail(linebuf, reason) * structure. Actually, it scans. */ void -parse(line, hl, pbuf) - char line[], pbuf[]; - struct headline *hl; +parse(char *line, struct headline *hl, char *pbuf) { char *cp, *sp; char word[LINESIZE]; @@ -137,9 +133,7 @@ parse(line, hl, pbuf) * the left string into it. */ char * -copyin(src, space) - char *src; - char **space; +copyin(char *src, char **space) { char *cp, *top; @@ -191,8 +185,7 @@ static char *date_formats[] = { }; int -isdate(date) - char date[]; +isdate(char *date) { int i; @@ -208,8 +201,7 @@ isdate(date) * Return 1 if they match, 0 if they don't */ int -cmatch(cp, tp) - char *cp, *tp; +cmatch(char *cp, char *tp) { while (*cp && *tp) @@ -264,8 +256,7 @@ cmatch(cp, tp) * or NULL if none follow. */ char * -nextword(wp, wbuf) - char *wp, *wbuf; +nextword(char *wp, char *wbuf) { int c; diff --git a/usr.bin/mail/lex.c b/usr.bin/mail/lex.c index a17a2d89b4a..3f1643a5651 100644 --- a/usr.bin/mail/lex.c +++ b/usr.bin/mail/lex.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lex.c,v 1.25 2001/11/20 20:50:00 millert Exp $ */ +/* $OpenBSD: lex.c,v 1.26 2001/11/21 15:26:39 millert Exp $ */ /* $NetBSD: lex.c,v 1.10 1997/05/17 19:55:13 pk Exp $ */ /* @@ -36,9 +36,9 @@ #ifndef lint #if 0 -static char sccsid[] = "@(#)lex.c 8.2 (Berkeley) 4/20/95"; +static const char sccsid[] = "@(#)lex.c 8.2 (Berkeley) 4/20/95"; #else -static char rcsid[] = "$OpenBSD: lex.c,v 1.25 2001/11/20 20:50:00 millert Exp $"; +static const char rcsid[] = "$OpenBSD: lex.c,v 1.26 2001/11/21 15:26:39 millert Exp $"; #endif #endif /* not lint */ @@ -64,8 +64,7 @@ const struct cmd *com; /* command we are running */ * signficance for mbox and so forth. */ int -setfile(name) - char *name; +setfile(char *name) { FILE *ibuf; int i, fd; @@ -114,7 +113,6 @@ setfile(name) * while we are reading the new file, else we will ruin * the message[] data structure. */ - holdsigs(); if (shudclob) quit(); @@ -123,9 +121,8 @@ setfile(name) * Copy the messages into /tmp * and set pointers. */ - readonly = 0; - if ((i = open(name, 1)) < 0) + if ((i = open(name, O_WRONLY, 0)) < 0) readonly++; else (void)close(i); @@ -136,10 +133,8 @@ setfile(name) shudclob = 1; edit = isedit; strcpy(prevfile, mailname); - if (name != mailname) { - strncpy(mailname, name, sizeof(mailname) - 1); - mailname[sizeof(mailname) - 1] = '\0'; - } + if (name != mailname) + strlcpy(mailname, name, sizeof(mailname)); mailsize = fsize(ibuf); (void)snprintf(tempname, sizeof(tempname), "%s/mail.RxXXXXXXXXXX", tmpdir); @@ -175,7 +170,7 @@ nomail: * started reading mail. */ int -incfile() +incfile(void) { int newsize; int omsgCount = msgCount; @@ -216,7 +211,7 @@ int reset_on_stop; /* reset prompt if stopped */ * print no prompt. */ void -commands() +commands(void) { int n, sig, *sigp; int eofloop = 0; @@ -301,9 +296,7 @@ commands() * Contxt is non-zero if called while composing mail. */ int -execute(linebuf, contxt) - char linebuf[]; - int contxt; +execute(char *linebuf, int contxt) { char word[LINESIZE]; char *arglist[MAXARGC]; @@ -321,7 +314,6 @@ execute(linebuf, contxt) * Handle ! escapes differently to get the correct * lexical conventions. */ - for (cp = linebuf; isspace(*cp); cp++) ; if (*cp == '!') { @@ -344,11 +336,10 @@ execute(linebuf, contxt) * however, we ignore blank lines to eliminate * confusion. */ - if (sourcing && *word == '\0') return(0); com = lex(word); - if (com == NONE) { + if (com == NULL) { printf("Unknown command: \"%s\"\n", word); goto out; } @@ -357,7 +348,6 @@ execute(linebuf, contxt) * See if we should execute the command -- if a conditional * we always execute it, otherwise, check the state of cond. */ - if ((com->c_argtype & F) == 0) if ((cond == CRCV && !rcvmode) || (cond == CSEND && rcvmode)) return(0); @@ -368,7 +358,6 @@ execute(linebuf, contxt) * If we are sourcing an interactive command, it's * an error. */ - if (!rcvmode && (com->c_argtype & M) == 0) { printf("May not execute \"%s\" while sending\n", com->c_name); @@ -547,8 +536,7 @@ out: * lists to message list functions. */ void -setmsize(sz) - int sz; +setmsize(int sz) { if (msgvec != 0) @@ -562,8 +550,7 @@ setmsize(sz) */ const struct cmd * -lex(word) - char word[]; +lex(char *word) { extern const struct cmd cmdtab[]; const struct cmd *cp; @@ -573,7 +560,7 @@ lex(word) for (cp = &cmdtab[0]; cp->c_name != NULL; cp++) if (isprefix(word, cp->c_name)) return(cp); - return(NONE); + return(NULL); } /* @@ -581,8 +568,7 @@ lex(word) * Return true if yep. */ int -isprefix(as1, as2) - char *as1, *as2; +isprefix(char *as1, char *as2) { char *s1, *s2; @@ -601,11 +587,10 @@ isprefix(as1, as2) * Close all open files except 0, 1, 2, and the temporary. * Also, unstack all source files. */ - int inithdr; /* am printing startup headers */ void -dointr() +dointr(void) { noreset = 0; @@ -629,7 +614,7 @@ dointr() * give the message count, and print a header listing. */ void -announce() +announce(void) { int vec[2], mdot; @@ -649,8 +634,7 @@ announce() * Return a likely place to set dot. */ int -newfileinfo(omsgCount) - int omsgCount; +newfileinfo(int omsgCount) { struct message *mp; int u, n, mdot, d, s; @@ -680,7 +664,7 @@ newfileinfo(omsgCount) } ename = mailname; if (getfold(fname, sizeof(fname)) >= 0) { - strncat(fname, "/", sizeof(fname) - strlen(fname) - 1); + strlcat(fname, "/", sizeof(fname)); if (strncmp(fname, mailname, strlen(fname)) == 0) { (void)snprintf(zname, sizeof(zname), "+%s", mailname + strlen(fname)); @@ -709,13 +693,11 @@ newfileinfo(omsgCount) /* * Print the current version number. */ - /*ARGSUSED*/ int -pversion(v) - void *v; +pversion(void *v) { - extern char *version; + extern const char version[]; printf("Version %s\n", version); return(0); @@ -725,8 +707,7 @@ pversion(v) * Load a file of user definitions. */ void -load(name) - char *name; +load(char *name) { FILE *in, *oldin; diff --git a/usr.bin/mail/list.c b/usr.bin/mail/list.c index dc9ddb7d725..04375fb28d4 100644 --- a/usr.bin/mail/list.c +++ b/usr.bin/mail/list.c @@ -1,4 +1,4 @@ -/* $OpenBSD: list.c,v 1.10 2001/01/16 05:36:08 millert Exp $ */ +/* $OpenBSD: list.c,v 1.11 2001/11/21 15:26:39 millert Exp $ */ /* $NetBSD: list.c,v 1.7 1997/07/09 05:23:36 mikel Exp $ */ /* @@ -36,9 +36,9 @@ #ifndef lint #if 0 -static char sccsid[] = "@(#)list.c 8.4 (Berkeley) 5/1/95"; +static const char sccsid[] = "@(#)list.c 8.4 (Berkeley) 5/1/95"; #else -static char rcsid[] = "$OpenBSD: list.c,v 1.10 2001/01/16 05:36:08 millert Exp $"; +static const char rcsid[] = "$OpenBSD: list.c,v 1.11 2001/11/21 15:26:39 millert Exp $"; #endif #endif /* not lint */ @@ -46,7 +46,7 @@ static char rcsid[] = "$OpenBSD: list.c,v 1.10 2001/01/16 05:36:08 millert Exp $ #include <ctype.h> #include "extern.h" -int matchto __P((char *, int)); +int matchto(char *, int); /* * Mail -- a mail program @@ -61,9 +61,7 @@ int matchto __P((char *, int)); * Returns the count of messages picked up or -1 on error. */ int -getmsglist(buf, vector, flags) - char *buf; - int *vector, flags; +getmsglist(char *buf, int *vector, int flags) { int *ip; struct message *mp; @@ -91,7 +89,6 @@ getmsglist(buf, vector, flags) /* * Bit values for colon modifiers. */ - #define CMNEW 01 /* New messages */ #define CMOLD 02 /* Old messages */ #define CMUNREAD 04 /* Unread messages */ @@ -102,7 +99,6 @@ getmsglist(buf, vector, flags) * The following table describes the letters which can follow * the colon and gives the corresponding modifier bit. */ - struct coltab { char co_char; /* What to find past : */ int co_bit; /* Associated modifier bit */ @@ -117,12 +113,10 @@ struct coltab { { 0, 0, 0, 0 } }; -static int lastcolmod; +static int lastcolmod; int -markall(buf, f) - char buf[]; - int f; +markall(char *buf, int f) { char **np; int i; @@ -265,7 +259,6 @@ number: * so that we can unmark any whose sender was not selected * if any user names were given. */ - if ((np > namelist || colmod != 0) && mc == 0) for (i = 1; i <= msgCount; i++) if ((message[i-1].m_flag & MDELETED) == f) @@ -275,7 +268,6 @@ number: * If any names were given, go through and eliminate any * messages whose senders were not requested. */ - if (np > namelist) { for (i = 1; i <= msgCount; i++) { for (mc = 0, np = &namelist[0]; *np != NULL; np++) @@ -298,7 +290,6 @@ number: /* * Make sure we got some decent messages. */ - mc = 0; for (i = 1; i <= msgCount; i++) if (message[i-1].m_flag & MMARK) { @@ -319,7 +310,6 @@ number: * If any colon modifiers were given, go through and * unmark any messages which do not satisfy the modifiers. */ - if (colmod != 0) { for (i = 1; i <= msgCount; i++) { struct coltab *colp; @@ -330,7 +320,6 @@ number: if ((mp->m_flag & colp->co_mask) != colp->co_equal) unmark(i); - } for (mp = &message[0]; mp < &message[msgCount]; mp++) if (mp->m_flag & MMARK) @@ -354,8 +343,7 @@ number: * value. */ int -evalcol(col) - int col; +evalcol(int col) { struct coltab *colp; @@ -373,8 +361,7 @@ evalcol(col) * has to be undeleted. */ int -check(mesg, f) - int mesg, f; +check(int mesg, int f) { struct message *mp; @@ -395,10 +382,7 @@ check(mesg, f) * for a RAWLIST. */ int -getrawlist(line, argv, argc) - char line[]; - char **argv; - int argc; +getrawlist(char *line, char **argv, int argc) { char c, *cp, *cp2, quotec; int argn; @@ -500,12 +484,11 @@ getrawlist(line, argv, argc) } /* - * scan out a single lexical item and return its token number, + * Scan out a single lexical item and return its token number, * updating the string pointer passed **p. Also, store the value * of the number or string scanned in lexnumber or lexstring as * appropriate. In any event, store the scanned `thing' in lexstring. */ - struct lex { char l_char; char l_token; @@ -522,8 +505,7 @@ struct lex { }; int -scan(sp) - char **sp; +scan(char **sp) { char *cp, *cp2; int c; @@ -542,7 +524,6 @@ scan(sp) /* * strip away leading white space. */ - while (c == ' ' || c == '\t') c = *cp++; @@ -550,7 +531,6 @@ scan(sp) * If no characters remain, we are at end of line, * so report that. */ - if (c == '\0') { *sp = --cp; return(TEOL); @@ -561,7 +541,6 @@ scan(sp) * the number and convert it on the fly. * Return TNUMBER when done. */ - if (isdigit(c)) { lexnumber = 0; while (isdigit(c)) { @@ -578,7 +557,6 @@ scan(sp) * Check for single character tokens; return such * if found. */ - for (lp = &singles[0]; lp->l_char != 0; lp++) if (c == lp->l_char) { lexstring[0] = c; @@ -594,7 +572,6 @@ scan(sp) * If the lead character is a " or ', save it * and scan until you get another. */ - quotec = 0; if (c == '\'' || c == '"') { quotec = c; @@ -624,9 +601,9 @@ scan(sp) * Unscan the named token by pushing it onto the regret stack. */ void -regret(token) - int token; +regret(int token) { + if (++regretp >= REGDEP) errx(1, "Too many regrets"); regretstack[regretp] = token; @@ -639,8 +616,9 @@ regret(token) * Reset all the scanner global variables. */ void -scaninit() +scaninit(void) { + regretp = -1; } @@ -649,8 +627,7 @@ scaninit() * its message number. */ int -first(f, m) - int f, m; +first(int f, int m) { struct message *mp; @@ -672,9 +649,7 @@ first(f, m) * if so. */ int -matchsender(str, mesg) - char *str; - int mesg; +matchsender(char *str, int mesg) { char *cp, *cp2, *backup; @@ -697,12 +672,10 @@ matchsender(str, mesg) * See if the passed name received the passed message number. Return true * if so. */ - static char *to_fields[] = { "to", "cc", "bcc", NULL }; int -matchto(str, mesg) - char *str; +matchto(char *str, int mesg) { struct message *mp; char *cp, *cp2, *backup, **to; @@ -741,12 +714,10 @@ matchto(str, mesg) * have the form "/search-string." If it is of the form "/," we use the * previous search string. */ - char lastscan[STRINGLEN]; + int -matchsubj(str, mesg) - char *str; - int mesg; +matchsubj(char *str, int mesg) { struct message *mp; char *cp, *cp2, *backup; @@ -754,16 +725,13 @@ matchsubj(str, mesg) str++; if (*str == '\0') str = lastscan; - else { - strncpy(lastscan, str, sizeof(lastscan) - 1); - lastscan[sizeof(lastscan) - 1] = '\0'; - } + else + strlcpy(lastscan, str, sizeof(lastscan)); mp = &message[mesg-1]; /* * Now look, ignoring case, for the word in the string. */ - if (value("searchheaders") && (cp = strchr(str, ':'))) { /* Check for special case "/To:" */ if (raise(str[0]) == 'T' && raise(str[1]) == 'O' && @@ -795,8 +763,7 @@ matchsubj(str, mesg) * Mark the named message by setting its mark bit. */ void -mark(mesg) - int mesg; +mark(int mesg) { int i; @@ -810,8 +777,7 @@ mark(mesg) * Unmark the named message. */ void -unmark(mesg) - int mesg; +unmark(int mesg) { int i; @@ -825,8 +791,7 @@ unmark(mesg) * Return the message number corresponding to the passed meta character. */ int -metamess(meta, f) - int meta, f; +metamess(int meta, int f) { int c, m; struct message *mp; diff --git a/usr.bin/mail/main.c b/usr.bin/mail/main.c index e08b15135fd..a10237355ab 100644 --- a/usr.bin/mail/main.c +++ b/usr.bin/mail/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.15 2001/11/20 20:50:00 millert Exp $ */ +/* $OpenBSD: main.c,v 1.16 2001/11/21 15:26:39 millert Exp $ */ /* $NetBSD: main.c,v 1.7 1997/05/13 06:15:57 mikel Exp $ */ /* @@ -35,16 +35,16 @@ */ #ifndef lint -static char copyright[] = +static const char copyright[] = "@(#) Copyright (c) 1980, 1993\n\ The Regents of the University of California. All rights reserved.\n"; #endif /* not lint */ #ifndef lint #if 0 -static char sccsid[] = "@(#)main.c 8.2 (Berkeley) 4/20/95"; +static const char sccsid[] = "@(#)main.c 8.2 (Berkeley) 4/20/95"; #else -static char rcsid[] = "$OpenBSD: main.c,v 1.15 2001/11/20 20:50:00 millert Exp $"; +static const char rcsid[] = "$OpenBSD: main.c,v 1.16 2001/11/21 15:26:39 millert Exp $"; #endif #endif /* not lint */ @@ -53,8 +53,8 @@ static char rcsid[] = "$OpenBSD: main.c,v 1.15 2001/11/20 20:50:00 millert Exp $ #include <sys/ioctl.h> #include "extern.h" -int main __P((int, char **)); -__dead void usage __P((void)); +__dead void usage(void); + int main(int, char **); /* * Mail -- a mail program @@ -63,9 +63,7 @@ __dead void usage __P((void)); */ int -main(argc, argv) - int argc; - char *argv[]; +main(int argc, char **argv) { int i; struct name *to, *cc, *bcc, *smopts; @@ -93,10 +91,10 @@ main(argc, argv) * first of these users. */ ef = NULL; - to = NIL; - cc = NIL; - bcc = NIL; - smopts = NIL; + to = NULL; + cc = NULL; + bcc = NULL; + smopts = NULL; subject = NULL; while ((i = getopt(argc, argv, "INT:b:c:dfins:u:v")) != -1) { switch (i) { @@ -200,9 +198,9 @@ main(argc, argv) /* * Check for inconsistent arguments. */ - if (to == NIL && (subject != NULL || cc != NIL || bcc != NIL)) + if (to == NULL && (subject != NULL || cc != NULL || bcc != NULL)) errx(1, "You must specify direct recipients with -s, -c, or -b"); - if (ef != NULL && to != NIL) + if (ef != NULL && to != NULL) errx(1, "Cannot give -f and people to send to"); /* * Block SIGINT except where we install an explicit handler for it. @@ -266,7 +264,7 @@ main(argc, argv) * Width is either 80 or ws_col; */ void -setscreensize() +setscreensize(void) { struct termios tbuf; struct winsize ws; @@ -293,7 +291,7 @@ setscreensize() } __dead void -usage() +usage(void) { fprintf(stderr, "usage: %s [-iInv] [-s subject] [-c cc-addr] " diff --git a/usr.bin/mail/names.c b/usr.bin/mail/names.c index 4f9601785a2..8c3d13c72b6 100644 --- a/usr.bin/mail/names.c +++ b/usr.bin/mail/names.c @@ -1,4 +1,4 @@ -/* $OpenBSD: names.c,v 1.13 2001/01/16 05:36:08 millert Exp $ */ +/* $OpenBSD: names.c,v 1.14 2001/11/21 15:26:39 millert Exp $ */ /* $NetBSD: names.c,v 1.5 1996/06/08 19:48:32 christos Exp $ */ /* @@ -36,9 +36,9 @@ #ifndef lint #if 0 -static char sccsid[] = "@(#)names.c 8.1 (Berkeley) 6/6/93"; +static const char sccsid[] = "@(#)names.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: names.c,v 1.13 2001/01/16 05:36:08 millert Exp $"; +static const char rcsid[] = "$OpenBSD: names.c,v 1.14 2001/11/21 15:26:39 millert Exp $"; #endif #endif /* not lint */ @@ -58,15 +58,13 @@ static char rcsid[] = "$OpenBSD: names.c,v 1.13 2001/01/16 05:36:08 millert Exp * name and return it. */ struct name * -nalloc(str, ntype) - char str[]; - int ntype; +nalloc(char *str, int ntype) { struct name *np; np = (struct name *)salloc(sizeof(*np)); - np->n_flink = NIL; - np->n_blink = NIL; + np->n_flink = NULL; + np->n_blink = NULL; np->n_type = ntype; np->n_name = savestr(str); return(np); @@ -76,15 +74,14 @@ nalloc(str, ntype) * Find the tail of a list and return it. */ struct name * -tailof(name) - struct name *name; +tailof(struct name *name) { struct name *np; np = name; - if (np == NIL) - return(NIL); - while (np->n_flink != NIL) + if (np == NULL) + return(NULL); + while (np->n_flink != NULL) np = np->n_flink; return(np); } @@ -92,27 +89,25 @@ tailof(name) /* * Extract a list of names from a line, * and make a list of names from it. - * Return the list or NIL if none found. + * Return the list or NULL if none found. */ struct name * -extract(line, ntype) - char line[]; - int ntype; +extract(char *line, int ntype) { char *cp; struct name *top, *np, *t; char *nbuf; if (line == NULL || *line == '\0') - return(NIL); + return(NULL); if ((nbuf = (char *)malloc(strlen(line) + 1)) == NULL) errx(1, "Out of memory"); - top = NIL; - np = NIL; + top = NULL; + np = NULL; cp = line; while ((cp = yankword(cp, nbuf)) != NULL) { t = nalloc(nbuf, ntype); - if (top == NIL) + if (top == NULL) top = t; else np->n_flink = t; @@ -127,22 +122,20 @@ extract(line, ntype) * Turn a list of names into a string of the same names. */ char * -detract(np, ntype) - struct name *np; - int ntype; +detract(struct name *np, int ntype) { int s, comma; char *cp, *top; struct name *p; comma = ntype & GCOMMA; - if (np == NIL) + if (np == NULL) return(NULL); ntype &= ~GCOMMA; s = 0; if (debug && comma) fputs("detract asked to insert commas\n", stderr); - for (p = np; p != NIL; p = p->n_flink) { + for (p = np; p != NULL; p = p->n_flink) { if (ntype && (p->n_type & GMASK) != ntype) continue; s += strlen(p->n_name) + 1; @@ -154,11 +147,11 @@ detract(np, ntype) s += 2; top = salloc(s); cp = top; - for (p = np; p != NIL; p = p->n_flink) { + for (p = np; p != NULL; p = p->n_flink) { if (ntype && (p->n_type & GMASK) != ntype) continue; cp = copy(p->n_name, cp); - if (comma && p->n_flink != NIL) + if (comma && p->n_flink != NULL) *cp++ = ','; *cp++ = ' '; } @@ -173,8 +166,7 @@ detract(np, ntype) * Throw away things between ()'s, and take anything between <>. */ char * -yankword(ap, wbuf) - char *ap, wbuf[]; +yankword(char *ap, char *wbuf) { char *cp, *cp2; @@ -221,10 +213,7 @@ yankword(ap, wbuf) * program and removed. */ struct name * -outof(names, fo, hp) - struct name *names; - FILE *fo; - struct header *hp; +outof(struct name *names, FILE *fo, struct header *hp) { int c, ispipe; struct name *np, *top; @@ -236,7 +225,7 @@ outof(names, fo, hp) np = names; (void)time(&now); date = ctime(&now); - while (np != NIL) { + while (np != NULL) { if (!isfileaddr(np->n_name) && np->n_name[0] != '|') { np = np->n_flink; continue; @@ -251,7 +240,6 @@ outof(names, fo, hp) * See if we have copied the complete message out yet. * If not, do so. */ - if (image < 0) { int fd; char tempname[PATHSIZE]; @@ -290,9 +278,8 @@ outof(names, fo, hp) * or give it as the standard input to the desired * program as appropriate. */ - if (ispipe) { - int pid; + pid_t pid; char *shell; sigset_t nset; @@ -365,8 +352,7 @@ cant: * be a filename. We cheat with .'s to allow path names like ./... */ int -isfileaddr(name) - char *name; +isfileaddr(char *name) { char *cp; @@ -387,19 +373,17 @@ isfileaddr(name) * Changed after all these months of service to recursively * expand names (2/14/80). */ - struct name * -usermap(names) - struct name *names; +usermap(struct name *names) { struct name *new, *np, *cp; struct grouphead *gh; int metoo; - new = NIL; + new = NULL; np = names; metoo = (value("metoo") != NULL); - while (np != NIL) { + while (np != NULL) { if (np->n_name[0] == '\\') { cp = np->n_flink; new = put(new, np); @@ -408,7 +392,7 @@ usermap(names) } gh = findgroup(np->n_name); cp = np->n_flink; - if (gh != NOGRP) + if (gh != NULL) new = gexpand(new, gh, metoo, np->n_type); else new = put(new, np); @@ -422,12 +406,8 @@ usermap(names) * fixed level to keep things from going haywire. * Direct recursion is not expanded for convenience. */ - struct name * -gexpand(nlist, gh, metoo, ntype) - struct name *nlist; - struct grouphead *gh; - int metoo, ntype; +gexpand(struct name *nlist, struct grouphead *gh, int metoo, int ntype) { struct group *gp; struct grouphead *ngh; @@ -440,13 +420,13 @@ gexpand(nlist, gh, metoo, ntype) return(nlist); } depth++; - for (gp = gh->g_list; gp != NOGE; gp = gp->ge_link) { + for (gp = gh->g_list; gp != NULL; gp = gp->ge_link) { cp = gp->ge_name; if (*cp == '\\') goto quote; if (strcmp(cp, gh->g_name) == 0) goto quote; - if ((ngh = findgroup(cp)) != NOGRP) { + if ((ngh = findgroup(cp)) != NULL) { nlist = gexpand(nlist, ngh, metoo, ntype); continue; } @@ -456,7 +436,7 @@ quote: * At this point should allow to expand * to self if only person in group */ - if (gp == gh->g_list && gp->ge_link == NOGE) + if (gp == gh->g_list && gp->ge_link == NULL) goto skip; if (!metoo && strcmp(cp, myname) == 0) np->n_type |= GDEL; @@ -471,14 +451,13 @@ skip: * Concatenate the two passed name lists, return the result. */ struct name * -cat(n1, n2) - struct name *n1, *n2; +cat(struct name *n1, struct name *n2) { struct name *tail; - if (n1 == NIL) + if (n1 == NULL) return(n2); - if (n2 == NIL) + if (n2 == NULL) return(n1); tail = tailof(n1); tail->n_flink = n2; @@ -491,8 +470,7 @@ cat(n1, n2) * Return an error if the name list won't fit. */ char ** -unpack(sm, np) - struct name *np, *sm; +unpack(struct name *np, struct name *sm) { char **ap, **top; int t, extra, metoo, verbose; @@ -522,11 +500,11 @@ unpack(sm, np) *ap++ = "-m"; if (verbose) *ap++ = "-v"; - for (; sm != NIL; sm = sm->n_flink) + for (; sm != NULL; sm = sm->n_flink) if ((sm->n_type & GDEL) == 0) *ap++ = sm->n_name; *ap++ = "--"; - for (; np != NIL; np = np->n_flink) + for (; np != NULL; np = np->n_flink) if ((np->n_type & GDEL) == 0) *ap++ = np->n_name; *ap = NULL; @@ -539,24 +517,23 @@ unpack(sm, np) * Return the head of the new list. */ struct name * -elide(names) - struct name *names; +elide(struct name *names) { struct name *np, *t, *new; struct name *x; - if (names == NIL) - return(NIL); + if (names == NULL) + return(NULL); new = names; np = names; np = np->n_flink; - if (np != NIL) - np->n_blink = NIL; - new->n_flink = NIL; - while (np != NIL) { + if (np != NULL) + np->n_blink = NULL; + new->n_flink = NULL; + while (np != NULL) { t = new; while (strcasecmp(t->n_name, np->n_name) < 0) { - if (t->n_flink == NIL) + if (t->n_flink == NULL) break; t = t->n_flink; } @@ -565,13 +542,12 @@ elide(names) * If we ran out of t's, put the new entry after * the current value of t. */ - if (strcasecmp(t->n_name, np->n_name) < 0) { t->n_flink = np; np->n_blink = t; t = np; np = np->n_flink; - t->n_flink = NIL; + t->n_flink = NULL; continue; } @@ -580,13 +556,12 @@ elide(names) * current t. If at the front of the list, * the new guy becomes the new head of the list. */ - if (t == new) { t = np; np = np->n_flink; t->n_flink = new; new->n_blink = t; - t->n_blink = NIL; + t->n_blink = NULL; new = t; continue; } @@ -595,7 +570,6 @@ elide(names) * The normal case -- we are inserting into the * middle of the list. */ - x = np; np = np->n_flink; x->n_flink = t; @@ -608,14 +582,13 @@ elide(names) * Now the list headed up by new is sorted. * Go through it and remove duplicates. */ - np = new; - while (np != NIL) { + while (np != NULL) { t = np; - while (t->n_flink != NIL && + while (t->n_flink != NULL && strcasecmp(np->n_name, t->n_flink->n_name) == 0) t = t->n_flink; - if (t == np || t == NIL) { + if (t == np || t == NULL) { np = np->n_flink; continue; } @@ -624,9 +597,8 @@ elide(names) * Now t points to the last entry with the same name * as np. Make np point beyond t. */ - np->n_flink = t->n_flink; - if (t->n_flink != NIL) + if (t->n_flink != NULL) t->n_flink->n_blink = np; np = np->n_flink; } @@ -638,12 +610,11 @@ elide(names) * the list. */ struct name * -put(list, node) - struct name *list, *node; +put(struct name *list, struct name *node) { node->n_flink = list; - node->n_blink = NIL; - if (list != NIL) + node->n_blink = NULL; + if (list != NULL) list->n_blink = node; return(node); } @@ -653,12 +624,11 @@ put(list, node) * a name list and return it. */ int -count(np) - struct name *np; +count(struct name *np) { int c; - for (c = 0; np != NIL; np = np->n_flink) + for (c = 0; np != NULL; np = np->n_flink) if ((np->n_type & GDEL) == 0) c++; return(c); @@ -668,26 +638,24 @@ count(np) * Delete the given name from a namelist. */ struct name * -delname(np, name) - struct name *np; - char name[]; +delname(struct name *np, char *name) { struct name *p; - for (p = np; p != NIL; p = p->n_flink) + for (p = np; p != NULL; p = p->n_flink) if ((strcasecmp(p->n_name, name) == 0) || (value("allnet") && strncasecmp(p->n_name, name, strlen(name)) == 0 && *(p->n_name+strlen(name)) == '@')) { - if (p->n_blink == NIL) { - if (p->n_flink != NIL) - p->n_flink->n_blink = NIL; + if (p->n_blink == NULL) { + if (p->n_flink != NULL) + p->n_flink->n_blink = NULL; np = p->n_flink; continue; } - if (p->n_flink == NIL) { - if (p->n_blink != NIL) - p->n_blink->n_flink = NIL; + if (p->n_flink == NULL) { + if (p->n_blink != NULL) + p->n_blink->n_flink = NULL; continue; } p->n_blink->n_flink = p->n_flink; @@ -700,8 +668,7 @@ delname(np, name) * Pretty print a name list * Uncomment it if you need it. */ - -/* +#if 0 void prettyprint(name) struct name *name; @@ -709,10 +676,10 @@ prettyprint(name) struct name *np; np = name; - while (np != NIL) { + while (np != NULL) { fprintf(stderr, "%s(%d) ", np->n_name, np->n_type); np = np->n_flink; } putc('\n', stderr); } -*/ +#endif diff --git a/usr.bin/mail/popen.c b/usr.bin/mail/popen.c index ebfc6f37e51..33961df1dbc 100644 --- a/usr.bin/mail/popen.c +++ b/usr.bin/mail/popen.c @@ -1,4 +1,4 @@ -/* $OpenBSD: popen.c,v 1.28 2001/11/20 23:19:44 millert Exp $ */ +/* $OpenBSD: popen.c,v 1.29 2001/11/21 15:26:39 millert Exp $ */ /* $NetBSD: popen.c,v 1.6 1997/05/13 06:48:42 mikel Exp $ */ /* @@ -36,9 +36,9 @@ #ifndef lint #if 0 -static char sccsid[] = "@(#)popen.c 8.1 (Berkeley) 6/6/93"; +static const char sccsid[] = "@(#)popen.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: popen.c,v 1.28 2001/11/20 23:19:44 millert Exp $"; +static const char rcsid[] = "$OpenBSD: popen.c,v 1.29 2001/11/21 15:26:39 millert Exp $"; #endif #endif /* not lint */ @@ -46,11 +46,7 @@ static char rcsid[] = "$OpenBSD: popen.c,v 1.28 2001/11/20 23:19:44 millert Exp #include <sys/wait.h> #include <fcntl.h> #include <errno.h> -#ifdef __STDC__ #include <stdarg.h> -#else -#include <varargs.h> -#endif #include "extern.h" #define READ 0 @@ -59,27 +55,27 @@ static char rcsid[] = "$OpenBSD: popen.c,v 1.28 2001/11/20 23:19:44 millert Exp struct fp { FILE *fp; int pipe; - int pid; + pid_t pid; struct fp *link; }; static struct fp *fp_head; struct child { - int pid; + pid_t pid; char done; char free; int status; struct child *link; }; static struct child *child, *child_freelist = NULL; -static struct child *findchild __P((int, int)); -static void delchild __P((struct child *)); -static int file_pid __P((FILE *)); -static int handle_spool_locks __P((int)); + +static struct child *findchild(pid_t, int); +static void delchild(struct child *); +static pid_t file_pid(FILE *); +static int handle_spool_locks(int); FILE * -Fopen(file, mode) - char *file, *mode; +Fopen(char *file, char *mode) { FILE *fp; @@ -91,9 +87,7 @@ Fopen(file, mode) } FILE * -Fdopen(fd, mode) - int fd; - char *mode; +Fdopen(int fd, char *mode) { FILE *fp; @@ -105,21 +99,19 @@ Fdopen(fd, mode) } int -Fclose(fp) - FILE *fp; +Fclose(FILE *fp) { + unregister_file(fp); return(fclose(fp)); } FILE * -Popen(cmd, mode) - char *cmd; - char *mode; +Popen(char *cmd, char *mode) { int p[2]; int myside, hisside, fd0, fd1; - int pid; + pid_t pid; sigset_t nset; FILE *fp; @@ -156,8 +148,7 @@ Popen(cmd, mode) } int -Pclose(ptr) - FILE *ptr; +Pclose(FILE *ptr) { int i; sigset_t nset, oset; @@ -175,7 +166,7 @@ Pclose(ptr) } void -close_all_files() +close_all_files(void) { while (fp_head) @@ -186,9 +177,7 @@ close_all_files() } void -register_file(fp, pipe, pid) - FILE *fp; - int pipe, pid; +register_file(FILE *fp, int pipe, pid_t pid) { struct fp *fpp; @@ -202,8 +191,7 @@ register_file(fp, pipe, pid) } void -unregister_file(fp) - FILE *fp; +unregister_file(FILE *fp) { struct fp **pp, *p; @@ -216,9 +204,8 @@ unregister_file(fp) errx(1, "Invalid file pointer"); } -static int -file_pid(fp) - FILE *fp; +static pid_t +file_pid(FILE *fp) { struct fp *p; @@ -237,14 +224,10 @@ file_pid(fp) * "nset" contains the signals to ignore in the new process. * SIGINT is enabled unless it's in "nset". */ -int -start_commandv(cmd, nset, infd, outfd, args) - char *cmd; - sigset_t *nset; - int infd, outfd; - va_list args; +pid_t +start_commandv(char *cmd, sigset_t *nset, int infd, int outfd, va_list args) { - int pid; + pid_t pid; if ((pid = fork()) < 0) { warn("fork"); @@ -266,25 +249,12 @@ start_commandv(cmd, nset, infd, outfd, args) } int -#ifdef __STDC__ run_command(char *cmd, sigset_t *nset, int infd, int outfd, ...) -#else -run_command(cmd, nset, infd, outfd, va_alist) - char *cmd; - sigset_t *nset; - int infd; - int outfd; - va_dcl -#endif { - int pid; + pid_t pid; va_list args; -#ifdef __STDC__ va_start(args, outfd); -#else - va_start(args); -#endif pid = start_commandv(cmd, nset, infd, outfd, args); va_end(args); if (pid < 0) @@ -293,34 +263,19 @@ run_command(cmd, nset, infd, outfd, va_alist) } int -#ifdef __STDC__ start_command(char *cmd, sigset_t *nset, int infd, int outfd, ...) -#else -start_command(cmd, nset, infd, outfd, va_alist) - char *cmd; - sigset_t *nset; - int infd; - int outfd; - va_dcl -#endif { va_list args; int r; -#ifdef __STDC__ va_start(args, outfd); -#else - va_start(args); -#endif r = start_commandv(cmd, nset, infd, outfd, args); va_end(args); return(r); } void -prepare_child(nset, infd, outfd) - sigset_t *nset; - int infd, outfd; +prepare_child(sigset_t *nset, int infd, int outfd) { int i; sigset_t eset; @@ -352,8 +307,7 @@ prepare_child(nset, infd, outfd) } int -wait_command(pid) - int pid; +wait_command(pid_t pid) { if (wait_child(pid) < 0) { @@ -364,9 +318,7 @@ wait_command(pid) } static struct child * -findchild(pid, dont_alloc) - int pid; - int dont_alloc; +findchild(pid_t pid, int dont_alloc) { struct child **cpp; @@ -389,8 +341,7 @@ findchild(pid, dont_alloc) } static void -delchild(cp) - struct child *cp; +delchild(struct child *cp) { struct child **cpp; @@ -402,10 +353,9 @@ delchild(cp) } void -sigchild(signo) - int signo; +sigchild(int signo) { - int pid; + pid_t pid; int status; struct child *cp; int save_errno = errno; @@ -431,8 +381,7 @@ int wait_status; * Wait for a specific child to die. */ int -wait_child(pid) - int pid; +wait_child(pid_t pid) { struct child *cp; sigset_t nset, oset; @@ -464,8 +413,7 @@ wait_child(pid) * Mark a child as don't care. */ void -free_child(pid) - int pid; +free_child(pid_t pid) { struct child *cp; sigset_t nset, oset; @@ -487,11 +435,10 @@ free_child(pid) * Returns 1 for success, 0 for failure, -1 for bad usage. */ static int -handle_spool_locks(action) - int action; +handle_spool_locks(int action) { static FILE *lockfp = NULL; - static int lock_pid; + static pid_t lock_pid; if (action == 0) { /* Clear the lock */ @@ -535,13 +482,15 @@ handle_spool_locks(action) } int -spool_lock() +spool_lock(void) { + return(handle_spool_locks(1)); } int -spool_unlock() +spool_unlock(void) { + return(handle_spool_locks(0)); } diff --git a/usr.bin/mail/quit.c b/usr.bin/mail/quit.c index 2f2ba2987e6..3e54de63aec 100644 --- a/usr.bin/mail/quit.c +++ b/usr.bin/mail/quit.c @@ -1,4 +1,4 @@ -/* $OpenBSD: quit.c,v 1.15 2001/11/20 20:50:00 millert Exp $ */ +/* $OpenBSD: quit.c,v 1.16 2001/11/21 15:26:39 millert Exp $ */ /* $NetBSD: quit.c,v 1.6 1996/12/28 07:11:07 tls Exp $ */ /* @@ -36,9 +36,9 @@ #ifndef lint #if 0 -static char sccsid[] = "@(#)quit.c 8.2 (Berkeley) 4/28/95"; +static const char sccsid[] = "@(#)quit.c 8.2 (Berkeley) 4/28/95"; #else -static char rcsid[] = "$OpenBSD: quit.c,v 1.15 2001/11/20 20:50:00 millert Exp $"; +static const char rcsid[] = "$OpenBSD: quit.c,v 1.16 2001/11/21 15:26:39 millert Exp $"; #endif #endif /* not lint */ @@ -56,8 +56,7 @@ static char rcsid[] = "$OpenBSD: quit.c,v 1.15 2001/11/20 20:50:00 millert Exp $ * The "quit" command. */ int -quitcmd(v) - void *v; +quitcmd(void *v) { /* * If we are sourcing, then return 1 so execute() can handle it. @@ -74,7 +73,7 @@ quitcmd(v) * Remove the system mailbox, if none saved there. */ int -quit() +quit(void) { int mcount, p, modify, autohold, anystat, holdbit, nohold; FILE *ibuf = NULL, *obuf, *fbuf, *rbuf, *readstat = NULL, *abuf; @@ -89,6 +88,7 @@ quit() */ if (readonly) return(0); + /* * If editing (not reading system mail box), then do the work * in edstop() @@ -105,7 +105,6 @@ quit() * If all the messages are to be preserved, just exit with * a message. */ - fbuf = Fopen(mailname, "r+"); if (fbuf == NULL) goto newmail; @@ -116,7 +115,7 @@ quit() } if (!spool_lock()) { (void)Fclose(fbuf); - return(-1); /* lockspool printed error for us */ + return(-1); /* lockspool printed the error for us */ } rbuf = NULL; if (fstat(fileno(fbuf), &minfo) >= 0 && minfo.st_size > mailsize) { @@ -148,7 +147,6 @@ quit() /* * Adjust the message flags in each message. */ - anystat = 0; autohold = value("hold") != NULL; holdbit = autohold ? MPRESERVE : MBOX; @@ -211,7 +209,6 @@ quit() * If he has specified "append" don't copy his mailbox, * just copy saveable entries at the end. */ - mbox = expand("&"); mcount = c; if (value("append") == NULL) { @@ -280,7 +277,6 @@ quit() * to the end of the stuff we just saved. * If we are appending, this is unnecessary. */ - if (value("append") == NULL) { rewind(ibuf); c = getc(ibuf); @@ -311,7 +307,6 @@ quit() * Now we are ready to copy back preserved files to * the system mailbox, if any were requested. */ - if (p != 0) { writeback(rbuf); (void)Fclose(fbuf); @@ -323,7 +318,6 @@ quit() * Finally, remove his /var/mail file. * If new mail has arrived, copy it back. */ - cream: if (rbuf != NULL) { abuf = Fopen(mailname, "r+"); @@ -360,8 +354,7 @@ newmail: * Incorporate the any new mail that we found. */ int -writeback(res) - FILE *res; +writeback(FILE *res) { struct message *mp; int p, c; @@ -414,7 +407,7 @@ writeback(res) * file from the temporary. Save any new stuff appended to the file. */ int -edstop() +edstop(void) { int gotcha, c; struct message *mp; @@ -456,6 +449,8 @@ edstop() if ((fd = mkstemp(tempname)) == -1 || (obuf = Fdopen(fd, "w")) == NULL) { warn("%s", tempname); + if (fd != -1) + close(fd); relsesigs(); return(-1); } diff --git a/usr.bin/mail/send.c b/usr.bin/mail/send.c index 0c0685427bb..2e1bc95382e 100644 --- a/usr.bin/mail/send.c +++ b/usr.bin/mail/send.c @@ -1,4 +1,4 @@ -/* $OpenBSD: send.c,v 1.13 2001/01/16 05:36:09 millert Exp $ */ +/* $OpenBSD: send.c,v 1.14 2001/11/21 15:26:39 millert Exp $ */ /* $NetBSD: send.c,v 1.6 1996/06/08 19:48:39 christos Exp $ */ /* @@ -36,9 +36,9 @@ #ifndef lint #if 0 -static char sccsid[] = "@(#)send.c 8.1 (Berkeley) 6/6/93"; +static const char sccsid[] = "@(#)send.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: send.c,v 1.13 2001/01/16 05:36:09 millert Exp $"; +static const char rcsid[] = "$OpenBSD: send.c,v 1.14 2001/11/21 15:26:39 millert Exp $"; #endif #endif /* not lint */ @@ -59,11 +59,8 @@ static char rcsid[] = "$OpenBSD: send.c,v 1.13 2001/01/16 05:36:09 millert Exp $ * prefix is a string to prepend to each output line. */ int -sendmessage(mp, obuf, doign, prefix) - struct message *mp; - FILE *obuf; - struct ignoretab *doign; - char *prefix; +sendmessage(struct message *mp, FILE *obuf, struct ignoretab *doign, + char *prefix) { int count; FILE *ibuf; @@ -236,10 +233,7 @@ sendmessage(mp, obuf, doign, prefix) * Output a reasonable looking status field. */ void -statusput(mp, obuf, prefix) - struct message *mp; - FILE *obuf; - char *prefix; +statusput(struct message *mp, FILE *obuf, char *prefix) { char statout[3]; char *cp = statout; @@ -259,9 +253,8 @@ statusput(mp, obuf, prefix) * which does all the dirty work. */ int -mail(to, cc, bcc, smopts, subject) - struct name *to, *cc, *bcc, *smopts; - char *subject; +mail(struct name *to, struct name *cc, struct name *bcc, struct name *smopts, + char *subject) { struct header head; @@ -280,17 +273,16 @@ mail(to, cc, bcc, smopts, subject) * the mail routine below. */ int -sendmail(v) - void *v; +sendmail(void *v) { char *str = v; struct header head; head.h_to = extract(str, GTO); head.h_subject = NULL; - head.h_cc = NIL; - head.h_bcc = NIL; - head.h_smopts = NIL; + head.h_cc = NULL; + head.h_bcc = NULL; + head.h_smopts = NULL; mail1(&head, 0); return(0); } @@ -300,12 +292,10 @@ sendmail(v) * in the passed header. (Internal interface). */ void -mail1(hp, printheaders) - struct header *hp; - int printheaders; +mail1(struct header *hp, int printheaders) { char *cp; - int pid; + pid_t pid; char **namelist; struct name *to; FILE *mtf; @@ -329,7 +319,7 @@ mail1(hp, printheaders) */ senderr = 0; to = usermap(cat(hp->h_bcc, cat(hp->h_to, hp->h_cc))); - if (to == NIL) { + if (to == NULL) { puts("No recipients specified"); senderr++; } @@ -403,16 +393,14 @@ out: * the distribution list into the appropriate fields. */ void -fixhead(hp, tolist) - struct header *hp; - struct name *tolist; +fixhead(struct header *hp, struct name *tolist) { struct name *np; - hp->h_to = NIL; - hp->h_cc = NIL; - hp->h_bcc = NIL; - for (np = tolist; np != NIL; np = np->n_flink) + hp->h_to = NULL; + hp->h_cc = NULL; + hp->h_bcc = NULL; + for (np = tolist; np != NULL; np = np->n_flink) if ((np->n_type & GMASK) == GTO) hp->h_to = cat(hp->h_to, nalloc(np->n_name, np->n_type)); @@ -429,9 +417,7 @@ fixhead(hp, tolist) * and return the new file. */ FILE * -infix(hp, fi) - struct header *hp; - FILE *fi; +infix(struct header *hp, FILE *fi) { FILE *nfo, *nfi; int c, fd; @@ -481,21 +467,18 @@ infix(hp, fi) * passed file buffer. */ int -puthead(hp, fo, w) - struct header *hp; - FILE *fo; - int w; +puthead(struct header *hp, FILE *fo, int w) { int gotcha; gotcha = 0; - if (hp->h_to != NIL && w & GTO) + if (hp->h_to != NULL && w & GTO) fmt("To:", hp->h_to, fo, w&GCOMMA), gotcha++; if (hp->h_subject != NULL && w & GSUBJECT) fprintf(fo, "Subject: %s\n", hp->h_subject), gotcha++; - if (hp->h_cc != NIL && w & GCC) + if (hp->h_cc != NULL && w & GCC) fmt("Cc:", hp->h_cc, fo, w&GCOMMA), gotcha++; - if (hp->h_bcc != NIL && w & GBCC) + if (hp->h_bcc != NULL && w & GBCC) fmt("Bcc:", hp->h_bcc, fo, w&GCOMMA), gotcha++; if (gotcha && w & GNL) (void)putc('\n', fo); @@ -506,11 +489,7 @@ puthead(hp, fo, w) * Format the given header line to not exceed 72 characters. */ void -fmt(str, np, fo, comma) - char *str; - struct name *np; - FILE *fo; - int comma; +fmt(char *str, struct name *np, FILE *fo, int comma) { int col, len; @@ -518,8 +497,8 @@ fmt(str, np, fo, comma) col = strlen(str); if (col) fputs(str, fo); - for (; np != NIL; np = np->n_flink) { - if (np->n_flink == NIL) + for (; np != NULL; np = np->n_flink) { + if (np->n_flink == NULL) comma = 0; len = strlen(np->n_name); col++; /* for the space */ @@ -539,12 +518,9 @@ fmt(str, np, fo, comma) /* * Save the outgoing mail on the passed file. */ - /*ARGSUSED*/ int -savemail(name, fi) - char name[]; - FILE *fi; +savemail(char *name, FILE *fi) { FILE *fo; char buf[BUFSIZ]; diff --git a/usr.bin/mail/strings.c b/usr.bin/mail/strings.c index 5d1ad9196fc..f36549061ef 100644 --- a/usr.bin/mail/strings.c +++ b/usr.bin/mail/strings.c @@ -1,4 +1,4 @@ -/* $OpenBSD: strings.c,v 1.6 1997/11/14 00:23:58 millert Exp $ */ +/* $OpenBSD: strings.c,v 1.7 2001/11/21 15:26:39 millert Exp $ */ /* $NetBSD: strings.c,v 1.5 1996/06/08 19:48:40 christos Exp $ */ /* @@ -36,9 +36,9 @@ #ifndef lint #if 0 -static char sccsid[] = "@(#)strings.c 8.1 (Berkeley) 6/6/93"; +static const char sccsid[] = "@(#)strings.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: strings.c,v 1.6 1997/11/14 00:23:58 millert Exp $"; +static const char rcsid[] = "$OpenBSD: strings.c,v 1.7 2001/11/21 15:26:39 millert Exp $"; #endif #endif /* not lint */ @@ -60,10 +60,8 @@ static char rcsid[] = "$OpenBSD: strings.c,v 1.6 1997/11/14 00:23:58 millert Exp * The string spaces are of exponentially increasing size, to satisfy * the occasional user with enormous string size requests. */ - char * -salloc(size) - int size; +salloc(int size) { char *t; int s; @@ -103,7 +101,7 @@ salloc(size) * since last reset. */ void -sreset() +sreset(void) { struct strings *sp; int index; @@ -125,7 +123,7 @@ sreset() * Meant to be called in main, after initialization. */ void -spreserve() +spreserve(void) { struct strings *sp; diff --git a/usr.bin/mail/temp.c b/usr.bin/mail/temp.c index 350107cbf37..e37474fa41d 100644 --- a/usr.bin/mail/temp.c +++ b/usr.bin/mail/temp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: temp.c,v 1.11 2000/08/02 04:10:48 millert Exp $ */ +/* $OpenBSD: temp.c,v 1.12 2001/11/21 15:26:39 millert Exp $ */ /* $NetBSD: temp.c,v 1.5 1996/06/08 19:48:42 christos Exp $ */ /* @@ -36,9 +36,9 @@ #ifndef lint #if 0 -static char sccsid[] = "@(#)temp.c 8.1 (Berkeley) 6/6/93"; +static const char sccsid[] = "@(#)temp.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: temp.c,v 1.11 2000/08/02 04:10:48 millert Exp $"; +static const char rcsid[] = "$OpenBSD: temp.c,v 1.12 2001/11/21 15:26:39 millert Exp $"; #endif #endif /* not lint */ @@ -51,10 +51,10 @@ static char rcsid[] = "$OpenBSD: temp.c,v 1.11 2000/08/02 04:10:48 millert Exp $ * Give names to all the temporary files that we will need. */ -char *tmpdir; +char *tmpdir; void -tinit() +tinit(void) { char *cp; @@ -75,7 +75,7 @@ tinit() * do a spreserve() after us. */ if (myname != NULL) { - if (getuserid(myname) < 0) + if (getuserid(myname) == UID_MAX) errx(1, "\"%s\" is not a user of this system", myname); } else { if ((cp = username()) == NULL) { diff --git a/usr.bin/mail/tty.c b/usr.bin/mail/tty.c index 0acd5bf1861..e0b344adb12 100644 --- a/usr.bin/mail/tty.c +++ b/usr.bin/mail/tty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty.c,v 1.13 2001/11/20 20:50:00 millert Exp $ */ +/* $OpenBSD: tty.c,v 1.14 2001/11/21 15:26:39 millert Exp $ */ /* $NetBSD: tty.c,v 1.7 1997/07/09 05:25:46 mikel Exp $ */ /* @@ -36,9 +36,9 @@ #ifndef lint #if 0 -static char sccsid[] = "@(#)tty.c 8.2 (Berkeley) 4/20/95"; +static const char sccsid[] = "@(#)tty.c 8.2 (Berkeley) 4/20/95"; #else -static char rcsid[] = "$OpenBSD: tty.c,v 1.13 2001/11/20 20:50:00 millert Exp $"; +static const char rcsid[] = "$OpenBSD: tty.c,v 1.14 2001/11/21 15:26:39 millert Exp $"; #endif #endif /* not lint */ @@ -63,11 +63,8 @@ static volatile sig_atomic_t ttysignal; /* Interrupted by a signal? */ /* * Read all relevant header fields. */ - int -grabh(hp, gflags) - struct header *hp; - int gflags; +grabh(struct header *hp, int gflags) { struct termios ttybuf; #ifndef TIOCSTI @@ -120,7 +117,7 @@ grabh(hp, gflags) #endif if (gflags & GTO) { #ifndef TIOCSTI - if (!ttyset && hp->h_to != NIL) + if (!ttyset && hp->h_to != NULL) ttyset++, tcsetattr(fileno(stdin), TCSADRAIN, &ttybuf); #endif s = readtty("To: ", detract(hp->h_to, 0)); @@ -140,7 +137,7 @@ grabh(hp, gflags) } if (gflags & GCC) { #ifndef TIOCSTI - if (!ttyset && hp->h_cc != NIL) + if (!ttyset && hp->h_cc != NULL) ttyset++, tcsetattr(fileno(stdin), TCSADRAIN, &ttybuf); #endif s = readtty("Cc: ", detract(hp->h_cc, 0)); @@ -150,7 +147,7 @@ grabh(hp, gflags) } if (gflags & GBCC) { #ifndef TIOCSTI - if (!ttyset && hp->h_bcc != NIL) + if (!ttyset && hp->h_bcc != NULL) ttyset++, tcsetattr(fileno(stdin), TCSADRAIN, &ttybuf); #endif s = readtty("Bcc: ", detract(hp->h_bcc, 0)); @@ -187,15 +184,13 @@ out: * be read. * */ - char * -readtty(pr, src) - char pr[], src[]; +readtty(char *pr, char *src) { struct sigaction act, oact; - sigset_t oset; char ch, canonb[BUFSIZ]; char *cp, *cp2; + sigset_t oset; int c; fputs(pr, stdout); @@ -316,8 +311,7 @@ redo: * Receipt continuation. */ void -ttystop(s) - int s; +ttystop(int s) { struct sigaction act, oact; sigset_t nset; @@ -344,8 +338,7 @@ ttystop(s) /*ARGSUSED*/ void -ttyint(s) - int s; +ttyint(int s) { ttysignal = s; diff --git a/usr.bin/mail/v7.local.c b/usr.bin/mail/v7.local.c index 050052f1246..b9b8f4464c4 100644 --- a/usr.bin/mail/v7.local.c +++ b/usr.bin/mail/v7.local.c @@ -1,4 +1,4 @@ -/* $OpenBSD: v7.local.c,v 1.12 1998/06/12 17:51:50 millert Exp $ */ +/* $OpenBSD: v7.local.c,v 1.13 2001/11/21 15:26:39 millert Exp $ */ /* $NetBSD: v7.local.c,v 1.8 1997/05/13 06:15:58 mikel Exp $ */ /* @@ -36,9 +36,9 @@ #ifndef lint #if 0 -static char sccsid[] = "@(#)v7.local.c 8.1 (Berkeley) 6/6/93"; +static const char sccsid[] = "@(#)v7.local.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: v7.local.c,v 1.12 1998/06/12 17:51:50 millert Exp $"; +static const char rcsid[] = "$OpenBSD: v7.local.c,v 1.13 2001/11/21 15:26:39 millert Exp $"; #endif #endif /* not lint */ @@ -60,9 +60,7 @@ static char rcsid[] = "$OpenBSD: v7.local.c,v 1.12 1998/06/12 17:51:50 millert E * mail is queued). */ void -findmail(user, buf, buflen) - char *user, *buf; - int buflen; +findmail(char *user, char *buf, int buflen) { char *mbox; struct stat sb; @@ -72,10 +70,9 @@ findmail(user, buf, buflen) sb.st_uid != getuid() && sb.st_uid != geteuid()) mbox = NULL; - if (mbox) { - (void)strncpy(buf, mbox, buflen - 1); - buf[buflen - 1] = '\0'; - } else + if (mbox) + (void)strlcpy(buf, mbox, buflen); + else (void)snprintf(buf, buflen, "%s/%s", _PATH_MAILDIR, user); } @@ -83,7 +80,7 @@ findmail(user, buf, buflen) * Get rid of the queued mail. */ void -demail() +demail(void) { if (value("keep") != NULL || rm(mailname) < 0) @@ -94,7 +91,7 @@ demail() * Discover user login name. */ char * -username() +username(void) { char *np; uid_t uid; @@ -105,6 +102,8 @@ username() return(np); if ((np = getname(uid = getuid())) != NULL) return(np); + if ((np = getlogin()) != NULL) + return(np); printf("Cannot associate a name with uid %u\n", (unsigned)uid); return(NULL); } diff --git a/usr.bin/mail/vars.c b/usr.bin/mail/vars.c index 2a1eed995d4..a4477122a54 100644 --- a/usr.bin/mail/vars.c +++ b/usr.bin/mail/vars.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vars.c,v 1.6 2001/01/16 05:36:09 millert Exp $ */ +/* $OpenBSD: vars.c,v 1.7 2001/11/21 15:26:39 millert Exp $ */ /* $NetBSD: vars.c,v 1.4 1996/06/08 19:48:45 christos Exp $ */ /* @@ -36,9 +36,9 @@ #ifndef lint #if 0 -static char sccsid[] = "@(#)vars.c 8.1 (Berkeley) 6/6/93"; +static const char sccsid[] = "@(#)vars.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: vars.c,v 1.6 2001/01/16 05:36:09 millert Exp $"; +static const char rcsid[] = "$OpenBSD: vars.c,v 1.7 2001/11/21 15:26:39 millert Exp $"; #endif #endif /* not lint */ @@ -55,15 +55,14 @@ static char rcsid[] = "$OpenBSD: vars.c,v 1.6 2001/01/16 05:36:09 millert Exp $" * Assign a value to a variable. */ void -assign(name, value) - char name[], value[]; +assign(char *name, char *value) { struct var *vp; int h; h = hash(name); vp = lookup(name); - if (vp == NOVAR) { + if (vp == NULL) { vp = (struct var *)calloc(sizeof(*vp), 1); vp->v_name = vcopy(name); vp->v_link = variables[h]; @@ -80,9 +79,9 @@ assign(name, value) * Thus, we cannot free same! */ void -vfree(cp) - char *cp; +vfree(char *cp) { + if (*cp) (void)free(cp); } @@ -91,20 +90,15 @@ vfree(cp) * Copy a variable value into permanent (ie, not collected after each * command) space. Do not bother to alloc space for "" */ - char * -vcopy(str) - char str[]; +vcopy(char *str) { char *new; - unsigned len; if (*str == '\0') return(""); - len = strlen(str) + 1; - if ((new = (char *)malloc(len)) == NULL) + if ((new = strdup(str)) == NULL) errx(1, "Out of memory"); - (void)memcpy(new, str, len); return(new); } @@ -114,13 +108,12 @@ vcopy(str) */ char * -value(name) - char name[]; +value(char *name) { struct var *vp; char *env; - if ((vp = lookup(name)) != NOVAR) + if ((vp = lookup(name)) != NULL) return(vp->v_value); else if ((env = getenv(name))) return(env); @@ -139,51 +132,46 @@ value(name) * Locate a variable and return its variable * node. */ - struct var * -lookup(name) - char name[]; +lookup(char *name) { struct var *vp; - for (vp = variables[hash(name)]; vp != NOVAR; vp = vp->v_link) + for (vp = variables[hash(name)]; vp != NULL; vp = vp->v_link) if (*vp->v_name == *name && equal(vp->v_name, name)) return(vp); - return(NOVAR); + return(NULL); } /* * Locate a group name and return it. */ - struct grouphead * -findgroup(name) - char name[]; +findgroup(char *name) { struct grouphead *gh; - for (gh = groups[hash(name)]; gh != NOGRP; gh = gh->g_link) + for (gh = groups[hash(name)]; gh != NULL; gh = gh->g_link) if (*gh->g_name == *name && equal(gh->g_name, name)) return(gh); - return(NOGRP); + return(NULL); } /* * Print a group out on stdout */ void -printgroup(name) - char name[]; +printgroup(char *name) { struct grouphead *gh; struct group *gp; - if ((gh = findgroup(name)) == NOGRP) { + if ((gh = findgroup(name)) == NULL) { printf("\"%s\": not a group\n", name); return; } printf("%s\t", gh->g_name); - for (gp = gh->g_list; gp != NOGE; gp = gp->ge_link) + for (gp = gh->g_list; gp != NULL; gp = gp->ge_link) printf(" %s", gp->ge_name); putchar('\n'); } @@ -193,8 +181,7 @@ printgroup(name) * the variable or group hash table. */ int -hash(name) - char *name; +hash(char *name) { int h = 0; diff --git a/usr.bin/mail/version.c b/usr.bin/mail/version.c index 02482700450..aa736bf0db0 100644 --- a/usr.bin/mail/version.c +++ b/usr.bin/mail/version.c @@ -1,4 +1,4 @@ -/* $OpenBSD: version.c,v 1.4 2001/01/16 05:36:09 millert Exp $ */ +/* $OpenBSD: version.c,v 1.5 2001/11/21 15:26:39 millert Exp $ */ /* $NetBSD: version.c,v 1.4 1996/06/08 19:48:46 christos Exp $ */ /* @@ -36,9 +36,9 @@ #ifndef lint #if 0 -static char sccsid[] = "@(#)version.c 8.1 (Berkeley) 6/6/93"; +static const char sccsid[] = "@(#)version.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: version.c,v 1.4 2001/01/16 05:36:09 millert Exp $"; +static const char rcsid[] = "$OpenBSD: version.c,v 1.5 2001/11/21 15:26:39 millert Exp $"; #endif #endif /* not lint */ @@ -46,4 +46,4 @@ static char rcsid[] = "$OpenBSD: version.c,v 1.4 2001/01/16 05:36:09 millert Exp * Just keep track of the date/sid of this version of Mail. * Load this file first to get a "total" Mail version. */ -char *version = "8.1.2 01/15/2001"; +const char version[] = "8.1.2 01/15/2001"; |