BSD 4 development
[unix-history] / .ref-5cb41021d721f4e0ac572d592613f963e495d1ff / .ref-BSD-3 / usr / src / cmd / clear.c
CommitLineData
508b145c
BJ
1/* load me with -ltermlib */
2/* #include <retrofit.h> on version 6 */
3/*
4 * clear - clear the screen
5 */
6
7#include <stdio.h>
8#include <sgtty.h>
9
10char *getenv();
11char *tgetstr();
12char PC;
13short ospeed;
14#undef putchar
15int putchar();
16
17main()
18{
19 char *cp = getenv("TERM");
20 char clbuf[20];
21 char pcbuf[20];
22 char *clbp = clbuf;
23 char *pcbp = pcbuf;
24 char *clear;
25 char buf[1024];
26 char *pc;
27 struct sgttyb tty;
28
29 gtty(1, &tty);
30 ospeed = tty.sg_ospeed;
31 if (cp == (char *) 0)
32 exit(1);
33 if (tgetent(buf, cp) != 1)
34 exit(1);
35 pc = tgetstr("pc", &pcbp);
36 if (pc)
37 PC = *pc;
38 clear = tgetstr("cl", &clbp);
39 if (clear)
40 tputs(clear, tgetnum("li"), putchar);
41 exit (clear != (char *) 0);
42}