diff options
author | mikeh <mikeh@FreeBSD.org> | 2001-05-27 20:26:22 +0000 |
---|---|---|
committer | mikeh <mikeh@FreeBSD.org> | 2001-05-27 20:26:22 +0000 |
commit | aa40e2eac7ab213ab193707b4dec5e4bb0a8325b (patch) | |
tree | 35781af5ff6a267c8e45e7cc6091e7df70c229ce /usr.bin/mail/send.c | |
parent | 83f67b8f31f7864baf3998922833c641684ff0f0 (diff) | |
download | FreeBSD-src-aa40e2eac7ab213ab193707b4dec5e4bb0a8325b.zip FreeBSD-src-aa40e2eac7ab213ab193707b4dec5e4bb0a8325b.tar.gz |
Cleanup mail(1)'s varying styles by converting to using style(9).
Also take a stab at cleaning up BDECFLAGS and convert all uses of
NOSTR, NIL, NONE, NOVAR, NOGRP, NOGE to NULL. Also kill 'register' to
get diffs somewhat closer to OpenBSD/NetBSD.
There are no functional changes however.
Reviewed by: nra (visual inspection)
Diffstat (limited to 'usr.bin/mail/send.c')
-rw-r--r-- | usr.bin/mail/send.c | 219 |
1 files changed, 108 insertions, 111 deletions
diff --git a/usr.bin/mail/send.c b/usr.bin/mail/send.c index 9ffc05b..4d4e2de 100644 --- a/usr.bin/mail/send.c +++ b/usr.bin/mail/send.c @@ -57,29 +57,26 @@ static const char rcsid[] = */ int sendmessage(mp, obuf, doign, prefix) - register struct message *mp; + struct message *mp; FILE *obuf; struct ignoretab *doign; char *prefix; { long count; - register FILE *ibuf; - char line[LINESIZE]; + FILE *ibuf; + char *cp, *cp2, line[LINESIZE]; int ishead, infld, ignoring, dostat, firstline; - register char *cp, *cp2; - register int c; - int length; - int prefixlen; + int c, length, prefixlen; /* * Compute the prefix string, without trailing whitespace */ - if (prefix != NOSTR) { + if (prefix != NULL) { cp2 = 0; - for (cp = prefix; *cp; cp++) + for (cp = prefix; *cp != '\0'; cp++) if (*cp != ' ' && *cp != '\t') cp2 = cp; - prefixlen = cp2 == 0 ? 0 : cp2 - prefix + 1; + prefixlen = cp2 == NULL ? 0 : cp2 - prefix + 1; } ibuf = setinput(mp); count = mp->m_size; @@ -125,7 +122,8 @@ sendmessage(mp, obuf, doign, prefix) /* * Pick up the header field if we have one. */ - for (cp = line; (c = *cp++) && c != ':' && !isspace(c);) + for (cp = line; (c = *cp++) != '\0' && c != ':' && + !isspace(c);) ; cp2 = --cp; while (isspace(*cp++)) @@ -142,7 +140,7 @@ sendmessage(mp, obuf, doign, prefix) } if (doign != ignoreall) /* add blank line */ - (void) putc('\n', obuf); + (void)putc('\n', obuf); ishead = 0; ignoring = 0; } else { @@ -150,7 +148,7 @@ sendmessage(mp, obuf, doign, prefix) * If it is an ignored field and * we care about such things, skip it. */ - *cp2 = 0; /* temporarily null terminate */ + *cp2 = '\0'; /* temporarily null terminate */ if (doign && isign(line, doign)) ignoring = 1; else if ((line[0] == 's' || line[0] == 'S') && @@ -176,16 +174,16 @@ sendmessage(mp, obuf, doign, prefix) * Strip trailing whitespace from prefix * if line is blank. */ - if (prefix != NOSTR) { + if (prefix != NULL) { if (length > 1) fputs(prefix, obuf); else - (void) fwrite(prefix, sizeof *prefix, - prefixlen, obuf); + (void)fwrite(prefix, sizeof(*prefix), + prefixlen, obuf); } - (void) fwrite(line, sizeof *line, length, obuf); + (void)fwrite(line, sizeof(*line), length, obuf); if (ferror(obuf)) - return -1; + return (-1); } } /* @@ -193,7 +191,7 @@ sendmessage(mp, obuf, doign, prefix) */ if (doign == ignoreall) count--; /* skip final blank line */ - if (prefix != NOSTR) + if (prefix != NULL) while (count > 0) { if (fgets(line, sizeof(line), ibuf) == NULL) { c = 0; @@ -207,26 +205,26 @@ sendmessage(mp, obuf, doign, prefix) if (c > 1) fputs(prefix, obuf); else - (void) fwrite(prefix, sizeof *prefix, - prefixlen, obuf); - (void) fwrite(line, sizeof *line, c, obuf); + (void)fwrite(prefix, sizeof(*prefix), + prefixlen, obuf); + (void)fwrite(line, sizeof(*line), c, obuf); if (ferror(obuf)) - return -1; + return (-1); } else while (count > 0) { c = count < LINESIZE ? count : LINESIZE; - if ((c = fread(line, sizeof *line, c, ibuf)) <= 0) + if ((c = fread(line, sizeof(*line), c, ibuf)) <= 0) break; count -= c; - if (fwrite(line, sizeof *line, c, obuf) != c) - return -1; + if (fwrite(line, sizeof(*line), c, obuf) != c) + return (-1); } if (doign == ignoreall && c > 0 && line[c - 1] != '\n') /* no final blank line */ if ((c = getc(ibuf)) != EOF && putc(c, obuf) == EOF) - return -1; - return 0; + return (-1); + return (0); } /* @@ -234,21 +232,21 @@ sendmessage(mp, obuf, doign, prefix) */ void statusput(mp, obuf, prefix) - register struct message *mp; + struct message *mp; FILE *obuf; char *prefix; { char statout[3]; - register char *cp = statout; + char *cp = statout; if (mp->m_flag & MREAD) *cp++ = 'R'; if ((mp->m_flag & MNEW) == 0) *cp++ = 'O'; - *cp = 0; - if (statout[0]) + *cp = '\0'; + if (statout[0] != '\0') fprintf(obuf, "%sStatus: %s\n", - prefix == NOSTR ? "" : prefix, statout); + prefix == NULL ? "" : prefix, statout); } /* @@ -268,9 +266,9 @@ mail(to, cc, bcc, smopts, subject, replyto) head.h_bcc = bcc; head.h_smopts = smopts; head.h_replyto = replyto; - head.h_inreplyto = NOSTR; + head.h_inreplyto = NULL; mail1(&head, 0); - return(0); + return (0); } @@ -285,15 +283,15 @@ sendmail(str) struct header head; head.h_to = extract(str, GTO); - head.h_subject = NOSTR; - head.h_cc = NIL; - head.h_bcc = NIL; - head.h_smopts = NIL; + head.h_subject = NULL; + head.h_cc = NULL; + head.h_bcc = NULL; + head.h_smopts = NULL; if ((head.h_replyto = getenv("REPLYTO")) == NULL) - head.h_replyto = NOSTR; - head.h_inreplyto = NOSTR; + head.h_replyto = NULL; + head.h_inreplyto = NULL; mail1(&head, 0); - return(0); + return (0); } /* @@ -317,16 +315,16 @@ mail1(hp, printheaders) */ if ((mtf = collect(hp, printheaders)) == NULL) return; - if (value("interactive") != NOSTR) { - if (value("askcc") != NOSTR) + if (value("interactive") != NULL) { + if (value("askcc") != NULL) grabh(hp, GCC); else { printf("EOT\n"); - (void) fflush(stdout); + (void)fflush(stdout); } } if (fsize(mtf) == 0) { - if (hp->h_subject == NOSTR) + if (hp->h_subject == NULL) printf("No message, no subject; hope that's ok\n"); else printf("Null message body; hope that's ok\n"); @@ -338,7 +336,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) { printf("No recipients specified\n"); senderr++; } @@ -362,13 +360,13 @@ mail1(hp, printheaders) char **t; printf("Sendmail arguments:"); - for (t = namelist; *t != NOSTR; t++) + for (t = namelist; *t != NULL; t++) printf(" \"%s\"", *t); printf("\n"); goto out; } - if ((cp = value("record")) != NOSTR) - (void) savemail(expand(cp), mtf); + if ((cp = value("record")) != NULL) + (void)savemail(expand(cp), mtf); /* * Fork, set up the temporary mail file as standard * input for "mail", and exec with the user list we generated @@ -384,7 +382,7 @@ mail1(hp, printheaders) prepare_child(sigmask(SIGHUP)|sigmask(SIGINT)|sigmask(SIGQUIT)| sigmask(SIGTSTP)|sigmask(SIGTTIN)|sigmask(SIGTTOU), fileno(mtf), -1); - if ((cp = value("sendmail")) != NOSTR) + if ((cp = value("sendmail")) != NULL) cp = expand(cp); else cp = _PATH_SENDMAIL; @@ -392,12 +390,12 @@ mail1(hp, printheaders) warn("%s", cp); _exit(1); } - if (value("verbose") != NOSTR) - (void) wait_child(pid); + if (value("verbose") != NULL) + (void)wait_child(pid); else free_child(pid); out: - (void) Fclose(mtf); + (void)Fclose(mtf); } /* @@ -409,21 +407,21 @@ fixhead(hp, tolist) struct header *hp; struct name *tolist; { - register struct name *np; + 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)); + cat(hp->h_to, nalloc(np->n_name, np->n_type)); else if ((np->n_type & GMASK) == GCC) hp->h_cc = - cat(hp->h_cc, nalloc(np->n_name, np->n_type)); + cat(hp->h_cc, nalloc(np->n_name, np->n_type)); else if ((np->n_type & GMASK) == GBCC) hp->h_bcc = - cat(hp->h_bcc, nalloc(np->n_name, np->n_type)); + cat(hp->h_bcc, nalloc(np->n_name, np->n_type)); } /* @@ -435,48 +433,48 @@ infix(hp, fi) struct header *hp; FILE *fi; { - register FILE *nfo, *nfi; - register int c; - int fd; + FILE *nfo, *nfi; + int c, fd; char tempname[PATHSIZE]; - snprintf(tempname, sizeof(tempname), "%s/mail.RsXXXXXXXXXX", tmpdir); + (void)snprintf(tempname, sizeof(tempname), + "%s/mail.RsXXXXXXXXXX", tmpdir); if ((fd = mkstemp(tempname)) == -1 || (nfo = Fdopen(fd, "w")) == NULL) { warn("%s", tempname); - return(fi); + return (fi); } if ((nfi = Fopen(tempname, "r")) == NULL) { warn("%s", tempname); - (void) Fclose(nfo); - (void) rm(tempname); - return(fi); + (void)Fclose(nfo); + (void)rm(tempname); + return (fi); } - (void) rm(tempname); - (void) puthead(hp, nfo, - GTO|GSUBJECT|GCC|GBCC|GREPLYTO|GINREPLYTO|GNL|GCOMMA); + (void)rm(tempname); + (void)puthead(hp, nfo, + GTO|GSUBJECT|GCC|GBCC|GREPLYTO|GINREPLYTO|GNL|GCOMMA); c = getc(fi); while (c != EOF) { - (void) putc(c, nfo); + (void)putc(c, nfo); c = getc(fi); } if (ferror(fi)) { warnx("read"); rewind(fi); - return(fi); + return (fi); } - (void) fflush(nfo); + (void)fflush(nfo); if (ferror(nfo)) { warn("%s", tempname); - (void) Fclose(nfo); - (void) Fclose(nfi); + (void)Fclose(nfo); + (void)Fclose(nfi); rewind(fi); - return(fi); + return (fi); } - (void) Fclose(nfo); - (void) Fclose(fi); + (void)Fclose(nfo); + (void)Fclose(fi); rewind(nfi); - return(nfi); + return (nfi); } /* @@ -489,24 +487,24 @@ puthead(hp, fo, w) FILE *fo; int w; { - register int gotcha; + 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 != NOSTR && w & GSUBJECT) + 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 (hp->h_replyto != NOSTR && w & GREPLYTO) + if (hp->h_replyto != NULL && w & GREPLYTO) fprintf(fo, "Reply-To: %s\n", hp->h_replyto), gotcha++; - if (hp->h_inreplyto != NOSTR && w & GINREPLYTO) + if (hp->h_inreplyto != NULL && w & GINREPLYTO) fprintf(fo, "In-Reply-To: <%s>\n", hp->h_inreplyto), gotcha++; if (gotcha && w & GNL) - (void) putc('\n', fo); - return(0); + (void)putc('\n', fo); + return (0); } /* @@ -514,33 +512,33 @@ puthead(hp, fo, w) */ void fmt(str, np, fo, comma) - char *str; - register struct name *np; + const char *str; + struct name *np; FILE *fo; int comma; { - register col, len; + int col, len; comma = comma ? 1 : 0; 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 */ if (col + len + comma > 72 && col > 4) { - fputs("\n ", fo); + fprintf(fo, "\n "); col = 4; } else - putc(' ', fo); + fprintf(fo, " "); fputs(np->n_name, fo); if (comma) - putc(',', fo); + fprintf(fo, ","); col += len + comma; } - putc('\n', fo); + fprintf(fo, "\n"); } /* @@ -551,27 +549,26 @@ fmt(str, np, fo, comma) int savemail(name, fi) char name[]; - register FILE *fi; + FILE *fi; { - register FILE *fo; + FILE *fo; char buf[BUFSIZ]; - register i; - time_t now, time(); - char *ctime(); + int i; + time_t now; if ((fo = Fopen(name, "a")) == NULL) { warn("%s", name); return (-1); } - (void) time(&now); + (void)time(&now); fprintf(fo, "From %s %s", myname, ctime(&now)); - while ((i = fread(buf, 1, sizeof buf, fi)) > 0) - (void) fwrite(buf, 1, i, fo); - (void) putc('\n', fo); - (void) fflush(fo); + while ((i = fread(buf, 1, sizeof(buf), fi)) > 0) + (void)fwrite(buf, 1, i, fo); + fprintf(fo, "\n"); + (void)fflush(fo); if (ferror(fo)) warn("%s", name); - (void) Fclose(fo); + (void)Fclose(fo); rewind(fi); return (0); } |