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