home *** CD-ROM | disk | FTP | other *** search
- /*
- * clear.c
- *
- * By Ross Ridge
- * Public Domain
- * 92/02/01 07:29:47
- *
- * clear
- *
- * clears the terminal's screen
- *
- */
-
- #include "defs.h"
-
- static const char SCCSid[] = "@(#) mytinfo clear.c 3.2 92/02/01 public domain, By Ross Ridge";
-
- #ifndef USE_TERMINFO
-
- #ifdef USE_SGTTY
- #include <sgtty.h>
- #endif
- #ifdef USE_TERMIO
- #include <termio.h>
- #endif
-
- char PC;
- short ospeed;
-
- int
- putch(c)
- int c; {
- return putchar(c);
- }
-
- int
- main(argc, argv)
- int argc;
- char **argv; {
- #ifdef USE_PROTYPES
- char *tgetstr(char *, char **);
- #else
- char *tgetstr();
- #endif
- char *term;
- char buf[MAX_BUF];
- char CL[MAX_LINE];
- char *s, *pc;
-
- #ifdef USE_SGTTY
- struct sgttyb tty;
-
- gtty(1, &tty);
- ospeed = tty.sg_ospeed;
- #else
- #ifdef USE_TERMIO
- struct termio tty;
-
- ioctl(1, TCGETA, &tty);
- ospeed = tty.c_cflag & CBAUD;
- #else
- ospeed = 0;
- #endif
- #endif
-
- term = getenv("TERM");
- if (term == NULL)
- exit(1);
-
- if (tgetent(buf, term) != 1)
- exit(1);
-
- s = CL;
- pc = tgetstr("pc", &s);
- if (pc != NULL)
- PC = *pc;
-
- s = CL;
- tgetstr("cl", &s);
-
- if (CL != NULL) {
- tputs(CL, tgetnum("li"), putch);
- exit(1);
- }
-
- return 0;
- }
-
- #else /* USE_TERMINFO */
-
- #include "term.h"
-
- int
- putch(c)
- int c; {
- return putchar(c);
- }
-
- int
- main() {
- setupterm((char *) 0, 1, (int *) 0);
- if (clear_screen == (char *) 0)
- exit(1);
- tputs(clear_screen, lines > 0 ? lines : 1, putch);
- return 0;
- }
-
- #endif /* USE_TERMINFO */
-