=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/mail/send.c,v retrieving revision 1.2 retrieving revision 1.3 diff -c -r1.2 -r1.3 *** src/usr.bin/mail/send.c 1996/06/11 12:53:50 1.2 --- src/usr.bin/mail/send.c 1997/07/13 21:21:16 1.3 *************** *** 1,4 **** ! /* $OpenBSD: send.c,v 1.2 1996/06/11 12:53:50 deraadt Exp $ */ /* $NetBSD: send.c,v 1.6 1996/06/08 19:48:39 christos Exp $ */ /* --- 1,4 ---- ! /* $OpenBSD: send.c,v 1.3 1997/07/13 21:21:16 millert Exp $ */ /* $NetBSD: send.c,v 1.6 1996/06/08 19:48:39 christos Exp $ */ /* *************** *** 38,44 **** #if 0 static char sccsid[] = "@(#)send.c 8.1 (Berkeley) 6/6/93"; #else ! static char rcsid[] = "$OpenBSD: send.c,v 1.2 1996/06/11 12:53:50 deraadt Exp $"; #endif #endif /* not lint */ --- 38,44 ---- #if 0 static char sccsid[] = "@(#)send.c 8.1 (Berkeley) 6/6/93"; #else ! static char rcsid[] = "$OpenBSD: send.c,v 1.3 1997/07/13 21:21:16 millert Exp $"; #endif #endif /* not lint */ *************** *** 94,104 **** * Process headers first */ while (count > 0 && ishead) { ! if (fgets(line, LINESIZE, ibuf) == NULL) break; count -= length = strlen(line); if (firstline) { ! /* * First line is the From line, so no headers * there to worry about */ --- 94,104 ---- * Process headers first */ while (count > 0 && ishead) { ! if (fgets(line, sizeof(line), ibuf) == NULL) break; count -= length = strlen(line); if (firstline) { ! /* * First line is the From line, so no headers * there to worry about */ *************** *** 183,193 **** if (length > 1) fputs(prefix, obuf); else ! (void) fwrite(prefix, sizeof *prefix, prefixlen, obuf); ! (void) fwrite(line, sizeof *line, length, obuf); if (ferror(obuf)) ! return -1; } } /* --- 183,193 ---- if (length > 1) fputs(prefix, obuf); else ! (void) fwrite(prefix, sizeof(*prefix), prefixlen, obuf); ! (void) fwrite(line, sizeof(*line), length, obuf); if (ferror(obuf)) ! return(-1); } } /* *************** *** 197,203 **** count--; /* skip final blank line */ if (prefix != NOSTR) while (count > 0) { ! if (fgets(line, LINESIZE, ibuf) == NULL) { c = 0; break; } --- 197,203 ---- count--; /* skip final blank line */ if (prefix != NOSTR) while (count > 0) { ! if (fgets(line, sizeof(line), ibuf) == NULL) { c = 0; break; } *************** *** 209,234 **** if (c > 1) fputs(prefix, obuf); else ! (void) fwrite(prefix, sizeof *prefix, prefixlen, obuf); ! (void) fwrite(line, sizeof *line, c, obuf); if (ferror(obuf)) ! return -1; } else while (count > 0) { c = count < LINESIZE ? count : LINESIZE; ! if ((c = fread(line, sizeof *line, c, ibuf)) <= 0) break; count -= c; ! 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; } /* --- 209,234 ---- if (c > 1) fputs(prefix, obuf); else ! (void) fwrite(prefix, sizeof(*prefix), prefixlen, obuf); ! (void) fwrite(line, sizeof(*line), c, obuf); if (ferror(obuf)) ! return(-1); } else while (count > 0) { c = count < LINESIZE ? count : LINESIZE; ! if ((c = fread(line, sizeof(*line), c, ibuf)) <= 0) break; count -= c; ! 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); } /* *************** *** 322,335 **** if (value("askbcc") != NOSTR) grabh(hp, GBCC); } else { ! printf("EOT\n"); (void) fflush(stdout); } if (fsize(mtf) == 0) if (hp->h_subject == NOSTR) ! printf("No message, no subject; hope that's ok\n"); else ! printf("Null message body; hope that's ok\n"); /* * Now, take the user names from the combined * to and cc lists and do all the alias --- 322,335 ---- if (value("askbcc") != NOSTR) grabh(hp, GBCC); } else { ! puts("EOT"); (void) fflush(stdout); } if (fsize(mtf) == 0) if (hp->h_subject == NOSTR) ! puts("No message, no subject; hope that's ok"); else ! puts("Null message body; hope that's ok"); /* * Now, take the user names from the combined * to and cc lists and do all the alias *************** *** 338,344 **** senderr = 0; to = usermap(cat(hp->h_bcc, cat(hp->h_to, hp->h_cc))); if (to == NIL) { ! printf("No recipients specified\n"); senderr++; } /* --- 338,344 ---- senderr = 0; to = usermap(cat(hp->h_bcc, cat(hp->h_to, hp->h_cc))); if (to == NIL) { ! puts("No recipients specified"); senderr++; } /* *************** *** 353,369 **** goto out; fixhead(hp, to); if ((mtf = infix(hp, mtf)) == NULL) { ! fprintf(stderr, ". . . message lost, sorry.\n"); return; } namelist = unpack(cat(hp->h_smopts, to)); if (debug) { char **t; ! printf("Sendmail arguments:"); for (t = namelist; *t != NOSTR; t++) printf(" \"%s\"", *t); ! printf("\n"); goto out; } if ((cp = value("record")) != NOSTR) --- 353,369 ---- goto out; fixhead(hp, to); if ((mtf = infix(hp, mtf)) == NULL) { ! fputs(". . . message lost, sorry.\n", stderr); return; } namelist = unpack(cat(hp->h_smopts, to)); if (debug) { char **t; ! fputs("Sendmail arguments:", stdout); for (t = namelist; *t != NOSTR; t++) printf(" \"%s\"", *t); ! putchar('\n'); goto out; } if ((cp = value("record")) != NOSTR) *************** *** 375,381 **** */ pid = fork(); if (pid == -1) { ! perror("fork"); savedeadletter(mtf); goto out; } --- 375,381 ---- */ pid = fork(); if (pid == -1) { ! warn("fork"); savedeadletter(mtf); goto out; } *************** *** 394,400 **** else cp = _PATH_SENDMAIL; execv(cp, namelist); ! perror(cp); _exit(1); } if (value("verbose") != NOSTR) --- 394,400 ---- else cp = _PATH_SENDMAIL; execv(cp, namelist); ! warn(cp); _exit(1); } if (value("verbose") != NOSTR) *************** *** 402,408 **** else free_child(pid); out: ! (void) Fclose(mtf); } /* --- 402,408 ---- else free_child(pid); out: ! (void)Fclose(mtf); } /* *************** *** 445,456 **** register int c; if ((nfo = Fopen(tempMail, "w")) == NULL) { ! perror(tempMail); return(fi); } if ((nfi = Fopen(tempMail, "r")) == NULL) { ! perror(tempMail); ! (void) Fclose(nfo); return(fi); } (void) rm(tempMail); --- 445,456 ---- register int c; if ((nfo = Fopen(tempMail, "w")) == NULL) { ! warn(tempMail); return(fi); } if ((nfi = Fopen(tempMail, "r")) == NULL) { ! warn(tempMail); ! (void)Fclose(nfo); return(fi); } (void) rm(tempMail); *************** *** 461,480 **** c = getc(fi); } if (ferror(fi)) { ! perror("read"); rewind(fi); return(fi); } (void) fflush(nfo); if (ferror(nfo)) { ! perror(tempMail); ! (void) Fclose(nfo); ! (void) Fclose(nfi); rewind(fi); return(fi); } ! (void) Fclose(nfo); ! (void) Fclose(fi); rewind(nfi); return(nfi); } --- 461,480 ---- c = getc(fi); } if (ferror(fi)) { ! warn("read"); rewind(fi); return(fi); } (void) fflush(nfo); if (ferror(nfo)) { ! warn(tempMail); ! (void)Fclose(nfo); ! (void)Fclose(nfi); rewind(fi); return(fi); } ! (void)Fclose(nfo); ! (void)Fclose(fi); rewind(nfi); return(nfi); } *************** *** 555,572 **** time_t now; if ((fo = Fopen(name, "a")) == NULL) { ! perror(name); ! return (-1); } (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); if (ferror(fo)) ! perror(name); ! (void) Fclose(fo); rewind(fi); ! return (0); } --- 555,572 ---- time_t now; if ((fo = Fopen(name, "a")) == NULL) { ! warn(name); ! return(-1); } (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); if (ferror(fo)) ! warn(name); ! (void)Fclose(fo); rewind(fi); ! return(0); }