BSD 2 development
[unix-history] / src / clear.c
CommitLineData
783c5c09
BJ
1/* Copyright (c) 1979 Regents of the University of California */
2#include <retrofit.h>
3#include <sgtty.h>
4/*
5 * clear - clear the screen
6 */
7
8#include <stdio.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[BUFSIZ];
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}