-#
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifndef lint
+static char *sccsid = "@(#)tty.c 5.2 (Berkeley) %G%";
+#endif not lint
/*
* Mail -- a mail program
*/
#include "rcv.h"
-#include <sgtty.h>
-
-static char *SccsId = "@(#)tty.c 1.1 %G%";
static int c_erase; /* Current erase char */
static int c_kill; /* Current kill char */
+static int hadcont; /* Saw continue signal */
+static jmp_buf rewrite; /* Place to go when continued */
#ifndef TIOCSTI
static int ttyset; /* We must now do erase/kill */
#endif
struct header *hp;
{
struct sgttyb ttybuf;
+ int ttycont(), signull();
#ifndef TIOCSTI
int (*savesigs[2])();
#endif
+ int (*savecont)();
register int s;
int errs;
+# ifdef VMUNIX
+ savecont = sigset(SIGCONT, signull);
+# endif VMUNIX
errs = 0;
#ifndef TIOCSTI
ttyset = 0;
ttybuf.sg_erase = 0;
ttybuf.sg_kill = 0;
for (s = SIGINT; s <= SIGQUIT; s++)
- if ((savesigs[s-SIGINT] = signal(s, SIG_IGN)) == SIG_DFL)
- signal(s, SIG_DFL);
+ if ((savesigs[s-SIGINT] = sigset(s, SIG_IGN)) == SIG_DFL)
+ sigset(s, SIG_DFL);
#endif
if (gflags & GTO) {
#ifndef TIOCSTI
if (hp->h_bcc != NOSTR)
hp->h_seq++;
}
+# ifdef VMUNIX
+ sigset(SIGCONT, savecont);
+# endif VMUNIX
#ifndef TIOCSTI
ttybuf.sg_erase = c_erase;
ttybuf.sg_kill = c_kill;
if (ttyset)
stty(fileno(stdin), &ttybuf);
for (s = SIGINT; s <= SIGQUIT; s++)
- signal(s, savesigs[s-SIGINT]);
+ sigset(s, savesigs[s-SIGINT]);
#endif
return(errs);
}
readtty(pr, src)
char pr[], src[];
{
- char canonb[BUFSIZ];
- int c, ch;
+ char ch, canonb[BUFSIZ];
+ int c, signull();
register char *cp, *cp2;
- fputs(pr, stdout); fflush(stdout);
+ fputs(pr, stdout);
+ fflush(stdout);
if (src != NOSTR && strlen(src) > BUFSIZ - 2) {
printf("too long to edit\n");
return(src);
fputs(canonb, stdout);
fflush(stdout);
#else
- for (cp = src; c = *cp; cp++) {
+ cp = src == NOSTR ? "" : src;
+ while (c = *cp++) {
if (c == c_erase || c == c_kill) {
ch = '\\';
ioctl(0, TIOCSTI, &ch);
}
- ioctl(0, TIOCSTI, &c);
+ ch = c;
+ ioctl(0, TIOCSTI, &ch);
}
cp = canonb;
+ *cp = 0;
#endif
- cp2 = fgets(cp, BUFSIZ - (cp - canonb), stdin);
- canonb[strlen(canonb) - 1] = '\0';
+ cp2 = cp;
+ while (cp2 < canonb + BUFSIZ)
+ *cp2++ = 0;
+ cp2 = cp;
+ if (setjmp(rewrite))
+ goto redo;
+# ifdef VMUNIX
+ sigset(SIGCONT, ttycont);
+# endif VMUNIX
+ clearerr(stdin);
+ while (cp2 < canonb + BUFSIZ) {
+ c = getc(stdin);
+ if (c == EOF || c == '\n')
+ break;
+ *cp2++ = c;
+ }
+ *cp2 = 0;
+# ifdef VMUNIX
+ sigset(SIGCONT, signull);
+# endif VMUNIX
+ if (c == EOF && ferror(stdin) && hadcont) {
+redo:
+ hadcont = 0;
+ cp = strlen(canonb) > 0 ? canonb : NOSTR;
+ clearerr(stdin);
+ return(readtty(pr, cp));
+ }
#ifndef TIOCSTI
- if (cp2 == NOSTR || *cp2 == '\0')
+ if (cp == NOSTR || *cp == '\0')
return(src);
- cp = cp2;
+ cp2 = cp;
if (!ttyset)
return(strlen(canonb) > 0 ? savestr(canonb) : NOSTR);
while (*cp != '\0') {
return(NOSTR);
return(savestr(canonb));
}
+
+# ifdef VMUNIX
+/*
+ * Receipt continuation.
+ */
+ttycont(s)
+{
+
+ hadcont++;
+ longjmp(rewrite, 1);
+}
+# endif VMUNIX
+
+/*
+ * Null routine to satisfy
+ * silly system bug that denies us holding SIGCONT
+ */
+signull(s)
+{}