rmdel is already linked
[unix-history] / usr / src / usr.bin / tset / reset.c
CommitLineData
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
8char 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
0a44dcb6 14static char sccsid[] = "@(#)reset.c 5.2 (Berkeley) %G%";
22e155fc
DF
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
22main()
23{
24 struct sgttyb buf;
25 struct tchars tbuf;
ebb6a6df 26 struct ltchars ltbuf;
0a44dcb6 27 static int lclear = LMDMBUF|LLITOUT|LPASS8;
2b7ef025 28
56b7f01a 29 ioctl(2, TIOCGETP, &buf);
2b7ef025 30 ioctl(2, TIOCGETC, &tbuf);
ebb6a6df 31 ioctl(2, TIOCGLTC, &ltbuf);
2b7ef025
BJ
32 buf.sg_flags &= ~(RAW|CBREAK|VTDELAY|ALLDELAY);
33 buf.sg_flags |= XTABS|ECHO|CRMOD|ANYP;
56b7f01a
SL
34 reset(&buf.sg_erase, CERASE);
35 reset(&buf.sg_kill, CKILL);
36 reset(&tbuf.t_intrc, CINTR);
37 reset(&tbuf.t_quitc, CQUIT);
38 reset(&tbuf.t_startc, CSTART);
39 reset(&tbuf.t_stopc, CSTOP);
40 reset(&tbuf.t_eofc, CEOF);
41 reset(&ltbuf.t_suspc, CSUSP);
42 reset(&ltbuf.t_dsuspc, CDSUSP);
43 reset(&ltbuf.t_rprntc, CRPRNT);
44 reset(&ltbuf.t_flushc, CFLUSH);
45 reset(&ltbuf.t_lnextc, CLNEXT);
46 reset(&ltbuf.t_werasc, CWERASE);
2b7ef025 47 /* brkc is left alone */
0a44dcb6 48 ioctl(2, TIOCLBIC, &lclear);
2b7ef025
BJ
49 ioctl(2, TIOCSETN, &buf);
50 ioctl(2, TIOCSETC, &tbuf);
ebb6a6df 51 ioctl(2, TIOCSLTC, &ltbuf);
38019d2b
MH
52 execlp("tset", "tset", "-Q", "-I", 0); /* fix term dependent stuff */
53 exit(1);
ebb6a6df
BJ
54}
55
56reset(cp, def)
57 char *cp;
58 int def;
59{
60
61 if (*cp == 0 || (*cp&0377)==0377)
62 *cp = def;
2b7ef025 63}