date and time created 80/10/01 17:28:06 by bill
[unix-history] / usr / src / usr.bin / tset / reset.c
CommitLineData
2b7ef025
BJ
1static char *sccsid = "@(#)reset.c 4.1 (Berkeley) %G%";
2/*
3 * reset - set the teletype mode bits to be sensible
4 *
5 * Kurt Shoens
6 *
7 * Very useful after crapping out in raw.
8 * Modified by Mark Horton to know about tchars
9 * and to not mess with peoples chars unless they are null.
10 */
11#include <sgtty.h>
12#define chk(val, dft) (val==0 ? dft : val)
13
14main()
15{
16 struct sgttyb buf;
17 struct tchars tbuf;
18
19 gtty(2, &buf);
20 ioctl(2, TIOCGETC, &tbuf);
21 buf.sg_flags &= ~(RAW|CBREAK|VTDELAY|ALLDELAY);
22 buf.sg_flags |= XTABS|ECHO|CRMOD|ANYP;
23 buf.sg_erase = chk(buf.sg_erase, '\08'); /* ^H */
24 buf.sg_kill = chk(buf.sg_kill, '\30'); /* ^X */
25 tbuf.t_intrc = chk(tbuf.t_intrc, '\177'); /* ^? */
26 tbuf.t_quitc = chk(tbuf.t_quitc, '\34'); /* ^\ */
27 tbuf.t_startc = chk(tbuf.t_startc, '\22'); /* ^Q */
28 tbuf.t_stopc = chk(tbuf.t_stopc, '\24'); /* ^S */
29 tbuf.t_eofc = chk(tbuf.t_eofc, '\4'); /* ^D */
30 /* brkc is left alone */
31 ioctl(2, TIOCSETN, &buf);
32 ioctl(2, TIOCSETC, &tbuf);
33}