install with -s
[unix-history] / usr / src / usr.bin / tset / reset.c
index 4f964ec..2b5aaee 100644 (file)
@@ -1,10 +1,23 @@
-static char *sccsid = "@(#)reset.c     4.2 (Berkeley) %G%";
 /*
 /*
- * reset 
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved.  The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
  */
  */
-#include <sgtty.h>
 
 
-#define        CTRL(x) ('x'&037)
+#ifndef lint
+char copyright[] =
+"@(#) Copyright (c) 1980 Regents of the University of California.\n\
+ All rights reserved.\n";
+#endif not lint
+
+#ifndef lint
+static char sccsid[] = "@(#)reset.c    5.1 (Berkeley) %G%";
+#endif not lint
+
+/*
+ * reset - restore tty to sensible state after crapping out in raw mode.
+ */
+#include <sgtty.h>
 
 main()
 {
 
 main()
 {
@@ -12,28 +25,30 @@ main()
        struct tchars tbuf;
        struct ltchars ltbuf;
 
        struct tchars tbuf;
        struct ltchars ltbuf;
 
-       gtty(2, &buf);
+       ioctl(2, TIOCGETP, &buf);
        ioctl(2, TIOCGETC, &tbuf);
        ioctl(2, TIOCGLTC, &ltbuf);
        buf.sg_flags &= ~(RAW|CBREAK|VTDELAY|ALLDELAY);
        buf.sg_flags |= XTABS|ECHO|CRMOD|ANYP;
        ioctl(2, TIOCGETC, &tbuf);
        ioctl(2, TIOCGLTC, &ltbuf);
        buf.sg_flags &= ~(RAW|CBREAK|VTDELAY|ALLDELAY);
        buf.sg_flags |= XTABS|ECHO|CRMOD|ANYP;
-       reset(&buf.sg_erase, CTRL(h));
-       reset(&buf.sg_kill, '@');
-       reset(&tbuf.t_intrc, 0177);
-       reset(&tbuf.t_quitc, CTRL(\\\\));
-       reset(&tbuf.t_startc, CTRL(q));
-       reset(&tbuf.t_stopc, CTRL(s));
-       reset(&tbuf.t_eofc, CTRL(d));
-       reset(&ltbuf.t_suspc, CTRL(z));
-       reset(&ltbuf.t_dsuspc, CTRL(y));
-       reset(&ltbuf.t_rprntc, CTRL(r));
-       reset(&ltbuf.t_flushc, CTRL(o));
-       reset(&ltbuf.t_lnextc, CTRL(v));
-       reset(&ltbuf.t_werasc, CTRL(w));
+       reset(&buf.sg_erase, CERASE);
+       reset(&buf.sg_kill, CKILL);
+       reset(&tbuf.t_intrc, CINTR);
+       reset(&tbuf.t_quitc, CQUIT);
+       reset(&tbuf.t_startc, CSTART);
+       reset(&tbuf.t_stopc, CSTOP);
+       reset(&tbuf.t_eofc, CEOF);
+       reset(&ltbuf.t_suspc, CSUSP);
+       reset(&ltbuf.t_dsuspc, CDSUSP);
+       reset(&ltbuf.t_rprntc, CRPRNT);
+       reset(&ltbuf.t_flushc, CFLUSH);
+       reset(&ltbuf.t_lnextc, CLNEXT);
+       reset(&ltbuf.t_werasc, CWERASE);
        /* brkc is left alone */
        ioctl(2, TIOCSETN, &buf);
        ioctl(2, TIOCSETC, &tbuf);
        ioctl(2, TIOCSLTC, &ltbuf);
        /* brkc is left alone */
        ioctl(2, TIOCSETN, &buf);
        ioctl(2, TIOCSETC, &tbuf);
        ioctl(2, TIOCSLTC, &ltbuf);
+       execlp("tset", "tset", "-Q", "-I", 0);  /* fix term dependent stuff */
+       exit(1);
 }
 
 reset(cp, def)
 }
 
 reset(cp, def)