X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/blobdiff_plain/3dffb9c85547d13da590a6071678a9d4efc6eece..d28ecfdfb24e5bc1c005d62e0d417b0b20c56c70:/usr/src/usr.bin/mail/collect.c diff --git a/usr/src/usr.bin/mail/collect.c b/usr/src/usr.bin/mail/collect.c index 3a2d81bd3f..6da97516b0 100644 --- a/usr/src/usr.bin/mail/collect.c +++ b/usr/src/usr.bin/mail/collect.c @@ -7,7 +7,7 @@ * ~ escapes. */ -static char *SccsId = "@(#)collect.c 1.5 %G%"; +static char *SccsId = "@(#)collect.c 2.5 %G%"; #include "rcv.h" #include @@ -40,13 +40,13 @@ collect(hp) struct header *hp; { FILE *ibuf, *fbuf, *obuf; - int lc, cc, escape, collrub(), intack(), stopdot, collhup, collcont(); + int lc, cc, escape, collrub(), intack(), collhup, collcont(), eof; register int c, t; char linebuf[LINESIZE], *cp; extern char tempMail[]; + int notify(); noreset++; - stopdot = (value("dot") != NOSTR) && intty; ibuf = obuf = NULL; if (value("ignore") != NOSTR) hf = 1; @@ -93,15 +93,26 @@ collect(hp) escape = ESCAPE; if ((cp = value("escape")) != NOSTR) escape = *cp; + eof = 0; for (;;) { setjmp(coljmp); sigrelse(SIGINT); sigrelse(SIGHUP); flush(); - if (readline(stdin, linebuf) <= 0) + if (readline(stdin, linebuf) <= 0) { + if (intty && value("ignoreeof") != NOSTR) { + if (++eof > 35) + break; + printf("Use \".\" to terminate letter\n", + escape); + continue; + } break; + } + eof = 0; hadintr = 0; - if (stopdot && equal(".", linebuf)) + if (intty && equal(".", linebuf) && + (value("dot") != NOSTR || value("ignoreeof") != NOSTR)) break; if (linebuf[0] != escape || rflag != NOSTR) { if ((t = putline(obuf, linebuf)) < 0) @@ -370,6 +381,7 @@ eof: rewind(ibuf); sigset(SIGINT, savesig); sigset(SIGHUP, savehup); + sigset(SIGCONT, savecont); noreset = 0; return(ibuf); @@ -460,12 +472,13 @@ mesedit(ibuf, obuf, c) int pid, s; FILE *fbuf; register int t; - int (*sig)(); + int (*sig)(), (*scont)(), foonly(); struct stat sbuf; extern char tempMail[], tempEdit[]; register char *edit; sig = sigset(SIGINT, SIG_IGN); + scont = sigset(SIGCONT, foonly); if (stat(tempEdit, &sbuf) >= 0) { printf("%s: file exists\n", tempEdit); goto out; @@ -535,11 +548,19 @@ mesedit(ibuf, obuf, c) fix: perror(tempEdit); out: + sigset(SIGCONT, scont); sigset(SIGINT, sig); newi = ibuf; return(obuf); } +/* + * Currently, Berkeley virtual VAX/UNIX will not let you change the + * disposition of SIGCONT, except to trap it somewhere new. + * Hence, sigset(SIGCONT, foonly) is used to ignore continue signals. + */ +foonly() {} + /* * Pipe the message through the command. * Old message is on stdin of command; @@ -736,13 +757,11 @@ collrub(s) register FILE *dbuf; register int c; - if (s == SIGINT) - sigset(SIGCONT, collrub); if (s == SIGINT && hadintr == 0) { hadintr++; clrbuf(stdout); printf("\n(Interrupt -- one more to kill letter)\n"); - sigset(s, collrub); + sigrelse(s); longjmp(coljmp, 1); } fclose(newo); @@ -778,7 +797,6 @@ done: intack(s) { - sigrelse(SIGCONT); puts("@"); fflush(stdout); clearerr(stdin);