rmdel is already linked
[unix-history] / usr / src / usr.bin / tset / reset.c
... / ...
CommitLineData
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
13#ifndef lint
14static char sccsid[] = "@(#)reset.c 5.2 (Berkeley) %G%";
15#endif not lint
16
17/*
18 * reset - restore tty to sensible state after crapping out in raw mode.
19 */
20#include <sgtty.h>
21
22main()
23{
24 struct sgttyb buf;
25 struct tchars tbuf;
26 struct ltchars ltbuf;
27 static int lclear = LMDMBUF|LLITOUT|LPASS8;
28
29 ioctl(2, TIOCGETP, &buf);
30 ioctl(2, TIOCGETC, &tbuf);
31 ioctl(2, TIOCGLTC, &ltbuf);
32 buf.sg_flags &= ~(RAW|CBREAK|VTDELAY|ALLDELAY);
33 buf.sg_flags |= XTABS|ECHO|CRMOD|ANYP;
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);
47 /* brkc is left alone */
48 ioctl(2, TIOCLBIC, &lclear);
49 ioctl(2, TIOCSETN, &buf);
50 ioctl(2, TIOCSETC, &tbuf);
51 ioctl(2, TIOCSLTC, &ltbuf);
52 execlp("tset", "tset", "-Q", "-I", 0); /* fix term dependent stuff */
53 exit(1);
54}
55
56reset(cp, def)
57 char *cp;
58 int def;
59{
60
61 if (*cp == 0 || (*cp&0377)==0377)
62 *cp = def;
63}