Commit | Line | Data |
---|---|---|
22e155fc DF |
1 | /* |
2 | * Copyright (c) 1980 Regents of the University of California. | |
3 | * All rights reserved. The Berkeley software License Agreement | |
4 | * specifies the terms and conditions for redistribution. | |
5 | */ | |
6 | ||
7 | #ifndef lint | |
8 | char copyright[] = | |
9 | "@(#) Copyright (c) 1980 Regents of the University of California.\n\ | |
10 | All rights reserved.\n"; | |
11 | #endif not lint | |
12 | ||
56b7f01a | 13 | #ifndef lint |
22e155fc DF |
14 | static char sccsid[] = "@(#)reset.c 5.1 (Berkeley) %G%"; |
15 | #endif not lint | |
16 | ||
2b7ef025 | 17 | /* |
38019d2b | 18 | * reset - restore tty to sensible state after crapping out in raw mode. |
2b7ef025 BJ |
19 | */ |
20 | #include <sgtty.h> | |
ebb6a6df | 21 | |
2b7ef025 BJ |
22 | main() |
23 | { | |
24 | struct sgttyb buf; | |
25 | struct tchars tbuf; | |
ebb6a6df | 26 | struct ltchars ltbuf; |
2b7ef025 | 27 | |
56b7f01a | 28 | ioctl(2, TIOCGETP, &buf); |
2b7ef025 | 29 | ioctl(2, TIOCGETC, &tbuf); |
ebb6a6df | 30 | ioctl(2, TIOCGLTC, <buf); |
2b7ef025 BJ |
31 | buf.sg_flags &= ~(RAW|CBREAK|VTDELAY|ALLDELAY); |
32 | buf.sg_flags |= XTABS|ECHO|CRMOD|ANYP; | |
56b7f01a SL |
33 | reset(&buf.sg_erase, CERASE); |
34 | reset(&buf.sg_kill, CKILL); | |
35 | reset(&tbuf.t_intrc, CINTR); | |
36 | reset(&tbuf.t_quitc, CQUIT); | |
37 | reset(&tbuf.t_startc, CSTART); | |
38 | reset(&tbuf.t_stopc, CSTOP); | |
39 | reset(&tbuf.t_eofc, CEOF); | |
40 | reset(<buf.t_suspc, CSUSP); | |
41 | reset(<buf.t_dsuspc, CDSUSP); | |
42 | reset(<buf.t_rprntc, CRPRNT); | |
43 | reset(<buf.t_flushc, CFLUSH); | |
44 | reset(<buf.t_lnextc, CLNEXT); | |
45 | reset(<buf.t_werasc, CWERASE); | |
2b7ef025 BJ |
46 | /* brkc is left alone */ |
47 | ioctl(2, TIOCSETN, &buf); | |
48 | ioctl(2, TIOCSETC, &tbuf); | |
ebb6a6df | 49 | ioctl(2, TIOCSLTC, <buf); |
38019d2b MH |
50 | execlp("tset", "tset", "-Q", "-I", 0); /* fix term dependent stuff */ |
51 | exit(1); | |
ebb6a6df BJ |
52 | } |
53 | ||
54 | reset(cp, def) | |
55 | char *cp; | |
56 | int def; | |
57 | { | |
58 | ||
59 | if (*cp == 0 || (*cp&0377)==0377) | |
60 | *cp = def; | |
2b7ef025 | 61 | } |