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