1: #ifndef lint
   2: static  char *sccsid = "@(#)reset.c	4.3 (Berkeley) 12/3/80";
   3: #endif
   4: /*
   5:  * reset - restore tty to sensible state after crapping out in raw mode.
   6:  */
   7: #include <sgtty.h>
   8: 
   9: #define CTRL(x) ('x'&037)
  10: 
  11: main()
  12: {
  13:     struct sgttyb buf;
  14:     struct tchars tbuf;
  15:     struct ltchars ltbuf;
  16: 
  17:     gtty(2, &buf);
  18:     ioctl(2, TIOCGETC, &tbuf);
  19:     ioctl(2, TIOCGLTC, &ltbuf);
  20:     buf.sg_flags &= ~(RAW|CBREAK|VTDELAY|ALLDELAY);
  21:     buf.sg_flags |= XTABS|ECHO|CRMOD|ANYP;
  22:     reset(&buf.sg_erase, CTRL(h));
  23:     reset(&buf.sg_kill, '@');
  24:     reset(&tbuf.t_intrc, 0177);
  25:     reset(&tbuf.t_quitc, CTRL(\\\\));
  26:     reset(&tbuf.t_startc, CTRL(q));
  27:     reset(&tbuf.t_stopc, CTRL(s));
  28:     reset(&tbuf.t_eofc, CTRL(d));
  29:     reset(&ltbuf.t_suspc, CTRL(z));
  30:     reset(&ltbuf.t_dsuspc, CTRL(y));
  31:     reset(&ltbuf.t_rprntc, CTRL(r));
  32:     reset(&ltbuf.t_flushc, CTRL(o));
  33:     reset(&ltbuf.t_lnextc, CTRL(v));
  34:     reset(&ltbuf.t_werasc, CTRL(w));
  35:     /* brkc is left alone */
  36:     ioctl(2, TIOCSETN, &buf);
  37:     ioctl(2, TIOCSETC, &tbuf);
  38:     ioctl(2, TIOCSLTC, &ltbuf);
  39:     execlp("tset", "tset", "-Q", "-I", 0);  /* fix term dependent stuff */
  40:     exit(1);
  41: }
  42: 
  43: reset(cp, def)
  44:     char *cp;
  45:     int def;
  46: {
  47: 
  48:     if (*cp == 0 || (*cp&0377)==0377)
  49:         *cp = def;
  50: }

Defined functions

main defined in line 11; never used
reset defined in line 43; used 13 times

Defined variables

sccsid defined in line 2; never used

Defined macros

CTRL defined in line 9; used 11 times
Last modified: 1982-09-04
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 708
Valid CSS Valid XHTML 1.0 Strict