=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/mail/quit.c,v retrieving revision 1.6 retrieving revision 1.7 diff -c -r1.6 -r1.7 *** src/usr.bin/mail/quit.c 1997/07/14 00:24:29 1.6 --- src/usr.bin/mail/quit.c 1997/07/24 16:23:39 1.7 *************** *** 1,4 **** ! /* $OpenBSD: quit.c,v 1.6 1997/07/14 00:24:29 millert Exp $ */ /* $NetBSD: quit.c,v 1.6 1996/12/28 07:11:07 tls Exp $ */ /* --- 1,4 ---- ! /* $OpenBSD: quit.c,v 1.7 1997/07/24 16:23:39 millert Exp $ */ /* $NetBSD: quit.c,v 1.6 1996/12/28 07:11:07 tls Exp $ */ /* *************** *** 38,44 **** #if 0 static char sccsid[] = "@(#)quit.c 8.2 (Berkeley) 4/28/95"; #else ! static char rcsid[] = "$OpenBSD: quit.c,v 1.6 1997/07/14 00:24:29 millert Exp $"; #endif #endif /* not lint */ --- 38,44 ---- #if 0 static char sccsid[] = "@(#)quit.c 8.2 (Berkeley) 4/28/95"; #else ! static char rcsid[] = "$OpenBSD: quit.c,v 1.7 1997/07/24 16:23:39 millert Exp $"; #endif #endif /* not lint */ *************** *** 79,88 **** int mcount, p, modify, autohold, anystat, holdbit, nohold; FILE *ibuf = NULL, *obuf, *fbuf, *rbuf, *readstat = NULL, *abuf; register struct message *mp; ! register int c; ! extern char *tempQuit, *tempResid; struct stat minfo; ! char *mbox; /* * If we are read only, we can't do anything, --- 79,87 ---- int mcount, p, modify, autohold, anystat, holdbit, nohold; FILE *ibuf = NULL, *obuf, *fbuf, *rbuf, *readstat = NULL, *abuf; register struct message *mp; ! int c, fd; struct stat minfo; ! char *mbox, tempname[MAXPATHLEN]; /* * If we are read only, we can't do anything, *************** *** 124,131 **** rbuf = NULL; if (fstat(fileno(fbuf), &minfo) >= 0 && minfo.st_size > mailsize) { puts("New mail has arrived."); ! rbuf = Fopen(tempResid, "w"); ! if (rbuf == NULL || fbuf == NULL) goto newmail; #ifdef APPEND fseek(fbuf, (long)mailsize, 0); --- 123,132 ---- rbuf = NULL; if (fstat(fileno(fbuf), &minfo) >= 0 && minfo.st_size > mailsize) { puts("New mail has arrived."); ! (void)snprintf(tempname, sizeof(tempname), ! "%s/mail.RqXXXXXXXXXX", tmpdir); ! if ((fd = mkstemp(tempname)) == -1 || ! (rbuf = Fdopen(fd, "w")) == NULL) goto newmail; #ifdef APPEND fseek(fbuf, (long)mailsize, 0); *************** *** 141,149 **** } #endif (void)Fclose(rbuf); ! if ((rbuf = Fopen(tempResid, "r")) == NULL) goto newmail; ! rm(tempResid); } /* --- 142,150 ---- } #endif (void)Fclose(rbuf); ! if ((rbuf = Fopen(tempname, "r")) == NULL) goto newmail; ! rm(tempname); } /* *************** *** 216,243 **** mbox = expand("&"); mcount = c; if (value("append") == NULL) { ! if ((obuf = Fopen(tempQuit, "w")) == NULL) { ! warn(tempQuit); (void)Fclose(fbuf); spool_unlock(); return; } ! if ((ibuf = Fopen(tempQuit, "r")) == NULL) { ! warn(tempQuit); ! rm(tempQuit); (void)Fclose(obuf); (void)Fclose(fbuf); spool_unlock(); return; } ! rm(tempQuit); if ((abuf = Fopen(mbox, "r")) != NULL) { while ((c = getc(abuf)) != EOF) (void)putc(c, obuf); (void)Fclose(abuf); } if (ferror(obuf)) { ! warn(tempQuit); (void)Fclose(ibuf); (void)Fclose(obuf); (void)Fclose(fbuf); --- 217,247 ---- mbox = expand("&"); mcount = c; if (value("append") == NULL) { ! (void)snprintf(tempname, sizeof(tempname), ! "%s/mail.RmXXXXXXXXXX", tmpdir); ! if ((fd = mkstemp(tempname)) == -1 || ! (obuf = Fdopen(fd, "w")) == NULL) { ! warn(tempname); (void)Fclose(fbuf); spool_unlock(); return; } ! if ((ibuf = Fopen(tempname, "r")) == NULL) { ! warn(tempname); ! rm(tempname); (void)Fclose(obuf); (void)Fclose(fbuf); spool_unlock(); return; } ! rm(tempname); if ((abuf = Fopen(mbox, "r")) != NULL) { while ((c = getc(abuf)) != EOF) (void)putc(c, obuf); (void)Fclose(abuf); } if (ferror(obuf)) { ! warn(tempname); (void)Fclose(ibuf); (void)Fclose(obuf); (void)Fclose(fbuf); *************** *** 414,420 **** void edstop() { - extern char *tmpdir; register int gotcha, c; register struct message *mp; FILE *obuf, *ibuf, *readstat = NULL; --- 418,423 ---- *************** *** 450,457 **** if (stat(mailname, &statb) >= 0 && statb.st_size > mailsize) { int fd; ! snprintf(tempname, sizeof(tempname), "%s/%s", tmpdir, ! "mboxXXXXXXXXXX"); if ((fd = mkstemp(tempname)) == -1 || (obuf = Fdopen(fd, "w")) == NULL) { warn(tempname); --- 453,460 ---- if (stat(mailname, &statb) >= 0 && statb.st_size > mailsize) { int fd; ! snprintf(tempname, sizeof(tempname), "%s/mbox.XXXXXXXXXX", ! tmpdir); if ((fd = mkstemp(tempname)) == -1 || (obuf = Fdopen(fd, "w")) == NULL) { warn(tempname);