=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/mail/collect.c,v retrieving revision 1.11 retrieving revision 1.12 diff -c -r1.11 -r1.12 *** src/usr.bin/mail/collect.c 1997/07/22 18:54:36 1.11 --- src/usr.bin/mail/collect.c 1997/07/24 17:27:10 1.12 *************** *** 1,4 **** ! /* $OpenBSD: collect.c,v 1.11 1997/07/22 18:54:36 millert Exp $ */ /* $NetBSD: collect.c,v 1.9 1997/07/09 05:25:45 mikel Exp $ */ /* --- 1,4 ---- ! /* $OpenBSD: collect.c,v 1.12 1997/07/24 17:27:10 millert Exp $ */ /* $NetBSD: collect.c,v 1.9 1997/07/09 05:25:45 mikel Exp $ */ /* *************** *** 38,44 **** #if 0 static char sccsid[] = "@(#)collect.c 8.2 (Berkeley) 4/19/94"; #else ! static char rcsid[] = "$OpenBSD: collect.c,v 1.11 1997/07/22 18:54:36 millert Exp $"; #endif #endif /* not lint */ --- 38,44 ---- #if 0 static char sccsid[] = "@(#)collect.c 8.2 (Berkeley) 4/19/94"; #else ! static char rcsid[] = "$OpenBSD: collect.c,v 1.12 1997/07/24 17:27:10 millert Exp $"; #endif #endif /* not lint */ *************** *** 81,90 **** int printheaders; { FILE *fbuf; ! int lc, cc, escape, eofcount; register int c, t; ! char linebuf[LINESIZE], *cp; ! extern char *tempMail; char getsub; sigset_t oset, nset; int longline, lastlong, rc; /* Can deal with lines > LINESIZE */ --- 81,89 ---- int printheaders; { FILE *fbuf; ! int lc, cc, escape, eofcount, fd; register int c, t; ! char linebuf[LINESIZE], tempname[PATHSIZE], *cp; char getsub; sigset_t oset, nset; int longline, lastlong, rc; /* Can deal with lines > LINESIZE */ *************** *** 114,120 **** savettou = signal(SIGTTOU, collstop); savettin = signal(SIGTTIN, collstop); if (sigsetjmp(collabort, 1) || sigsetjmp(colljmp, 1)) { ! rm(tempMail); goto err; } sigdelset(&oset, SIGINT); --- 113,119 ---- savettou = signal(SIGTTOU, collstop); savettin = signal(SIGTTIN, collstop); if (sigsetjmp(collabort, 1) || sigsetjmp(colljmp, 1)) { ! (void)rm(tempname); goto err; } sigdelset(&oset, SIGINT); *************** *** 122,132 **** sigprocmask(SIG_SETMASK, &oset, NULL); noreset++; ! if ((collf = Fopen(tempMail, "w+")) == NULL) { ! warn(tempMail); goto err; } ! unlink(tempMail); /* * If we are going to prompt for a subject, --- 121,134 ---- sigprocmask(SIG_SETMASK, &oset, NULL); noreset++; ! (void)snprintf(tempname, sizeof(tempname), ! "%s/mail.RsXXXXXXXXXX", tmpdir); ! if ((fd = mkstemp(tempname)) == -1 || ! (collf = Fdopen(fd, "w+")) == NULL) { ! warn(tempname); goto err; } ! (void)rm(tempname); /* * If we are going to prompt for a subject, *************** *** 350,356 **** * standard list processing garbage. * If ~f is given, we don't shift over. */ ! if (forward(linebuf + 2, collf, c) < 0) goto err; goto cont; case '?': --- 352,358 ---- * standard list processing garbage. * If ~f is given, we don't shift over. */ ! if (forward(linebuf + 2, collf, tempname, c) < 0) goto err; goto cont; case '?': *************** *** 507,521 **** char cmd[]; { FILE *nf; sig_t sigint = signal(SIGINT, SIG_IGN); ! extern char *tempEdit; ! char *shell; ! if ((nf = Fopen(tempEdit, "w+")) == NULL) { ! warn(tempEdit); goto out; } ! (void)unlink(tempEdit); /* * stdin = current message. * stdout = new message. --- 509,526 ---- char cmd[]; { FILE *nf; + int fd; sig_t sigint = signal(SIGINT, SIG_IGN); ! char *shell, tempname[PATHSIZE]; ! (void)snprintf(tempname, sizeof(tempname), ! "%s/mail.ReXXXXXXXXXX", tmpdir); ! if ((fd = mkstemp(tempname)) == -1 || ! (nf = Fdopen(fd, "w+")) == NULL) { ! warn(tempname); goto out; } ! (void)rm(tempname); /* * stdin = current message. * stdout = new message. *************** *** 551,563 **** * should shift over and 'f' if not. */ int ! forward(ms, fp, f) char ms[]; FILE *fp; int f; { register int *msgvec; - extern char *tempMail; struct ignoretab *ig; char *tabst; --- 556,568 ---- * should shift over and 'f' if not. */ int ! forward(ms, fp, fn, f) char ms[]; FILE *fp; + char *fn; int f; { register int *msgvec; struct ignoretab *ig; char *tabst; *************** *** 586,592 **** touch(mp); printf(" %d", *msgvec); if (send(mp, fp, ig, tabst) < 0) { ! warn(tempMail); return(-1); } } --- 591,597 ---- touch(mp); printf(" %d", *msgvec); if (send(mp, fp, ig, tabst) < 0) { ! warn(fn); return(-1); } }