BSD 4_3_Tahoe release
[unix-history] / usr / src / ucb / Mail / tty.c
index 248c910..e4d7188 100644 (file)
@@ -1,12 +1,18 @@
 /*
  * Copyright (c) 1980 Regents of the University of California.
 /*
  * Copyright (c) 1980 Regents of the University of California.
- * All rights reserved.  The Berkeley software License Agreement
- * specifies the terms and conditions for redistribution.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that this notice is preserved and that due credit is given
+ * to the University of California at Berkeley. The name of the University
+ * may not be used to endorse or promote products derived from this
+ * software without specific prior written permission. This software
+ * is provided ``as is'' without express or implied warranty.
  */
 
  */
 
-#ifndef lint
-static char *sccsid = "@(#)tty.c       5.2 (Berkeley) 6/21/85";
-#endif not lint
+#ifdef notdef
+static char sccsid[] = "@(#)tty.c      5.5 (Berkeley) 2/18/88";
+#endif /* notdef */
 
 /*
  * Mail -- a mail program
 
 /*
  * Mail -- a mail program
@@ -32,17 +38,13 @@ grabh(hp, gflags)
        struct header *hp;
 {
        struct sgttyb ttybuf;
        struct header *hp;
 {
        struct sgttyb ttybuf;
-       int ttycont(), signull();
 #ifndef TIOCSTI
 #ifndef TIOCSTI
-       int (*savesigs[2])();
+       int (*saveint)(), (*savequit)();
 #endif
        int (*savecont)();
 #endif
        int (*savecont)();
-       register int s;
        int errs;
 
        int errs;
 
-# ifdef VMUNIX
-       savecont = sigset(SIGCONT, signull);
-# endif VMUNIX
+       savecont = signal(SIGCONT, SIG_DFL);
        errs = 0;
 #ifndef TIOCSTI
        ttyset = 0;
        errs = 0;
 #ifndef TIOCSTI
        ttyset = 0;
@@ -56,9 +58,10 @@ grabh(hp, gflags)
 #ifndef TIOCSTI
        ttybuf.sg_erase = 0;
        ttybuf.sg_kill = 0;
 #ifndef TIOCSTI
        ttybuf.sg_erase = 0;
        ttybuf.sg_kill = 0;
-       for (s = SIGINT; s <= SIGQUIT; s++)
-               if ((savesigs[s-SIGINT] = sigset(s, SIG_IGN)) == SIG_DFL)
-                       sigset(s, SIG_DFL);
+       if ((saveint = signal(SIGINT, SIG_IGN)) == SIG_DFL)
+               signal(SIGINT, SIG_DFL);
+       if ((savequit = signal(SIGQUIT, SIG_IGN)) == SIG_DFL)
+               signal(SIGQUIT, SIG_DFL);
 #endif
        if (gflags & GTO) {
 #ifndef TIOCSTI
 #endif
        if (gflags & GTO) {
 #ifndef TIOCSTI
@@ -96,16 +99,14 @@ grabh(hp, gflags)
                if (hp->h_bcc != NOSTR)
                        hp->h_seq++;
        }
                if (hp->h_bcc != NOSTR)
                        hp->h_seq++;
        }
-# ifdef VMUNIX
-       sigset(SIGCONT, savecont);
-# endif VMUNIX
+       signal(SIGCONT, savecont);
 #ifndef TIOCSTI
        ttybuf.sg_erase = c_erase;
        ttybuf.sg_kill = c_kill;
        if (ttyset)
                stty(fileno(stdin), &ttybuf);
 #ifndef TIOCSTI
        ttybuf.sg_erase = c_erase;
        ttybuf.sg_kill = c_kill;
        if (ttyset)
                stty(fileno(stdin), &ttybuf);
-       for (s = SIGINT; s <= SIGQUIT; s++)
-               sigset(s, savesigs[s-SIGINT]);
+       signal(SIGINT, saveint);
+       signal(SIGQUIT, savequit);
 #endif
        return(errs);
 }
 #endif
        return(errs);
 }
@@ -122,8 +123,9 @@ readtty(pr, src)
        char pr[], src[];
 {
        char ch, canonb[BUFSIZ];
        char pr[], src[];
 {
        char ch, canonb[BUFSIZ];
-       int c, signull();
+       int c;
        register char *cp, *cp2;
        register char *cp, *cp2;
+       int ttycont();
 
        fputs(pr, stdout);
        fflush(stdout);
 
        fputs(pr, stdout);
        fflush(stdout);
@@ -157,9 +159,7 @@ readtty(pr, src)
        cp2 = cp;
        if (setjmp(rewrite))
                goto redo;
        cp2 = cp;
        if (setjmp(rewrite))
                goto redo;
-# ifdef VMUNIX
-       sigset(SIGCONT, ttycont);
-# endif VMUNIX
+       signal(SIGCONT, ttycont);
        clearerr(stdin);
        while (cp2 < canonb + BUFSIZ) {
                c = getc(stdin);
        clearerr(stdin);
        while (cp2 < canonb + BUFSIZ) {
                c = getc(stdin);
@@ -168,9 +168,7 @@ readtty(pr, src)
                *cp2++ = c;
        }
        *cp2 = 0;
                *cp2++ = c;
        }
        *cp2 = 0;
-# ifdef VMUNIX
-       sigset(SIGCONT, signull);
-# endif VMUNIX
+       signal(SIGCONT, SIG_DFL);
        if (c == EOF && ferror(stdin) && hadcont) {
 redo:
                hadcont = 0;
        if (c == EOF && ferror(stdin) && hadcont) {
 redo:
                hadcont = 0;
@@ -215,21 +213,12 @@ redo:
        return(savestr(canonb));
 }
 
        return(savestr(canonb));
 }
 
-# ifdef VMUNIX
 /*
  * Receipt continuation.
  */
 /*
  * Receipt continuation.
  */
+/*ARGSUSED*/
 ttycont(s)
 {
 ttycont(s)
 {
-
        hadcont++;
        longjmp(rewrite, 1);
 }
        hadcont++;
        longjmp(rewrite, 1);
 }
-# endif VMUNIX
-
-/*
- * Null routine to satisfy
- * silly system bug that denies us holding SIGCONT
- */
-signull(s)
-{}