home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume26 / mytinfo / part01 / clear.c < prev    next >
C/C++ Source or Header  |  1992-12-26  |  1KB  |  109 lines

  1. /*
  2.  * clear.c
  3.  *
  4.  * By Ross Ridge
  5.  * Public Domain
  6.  * 92/02/01 07:29:47
  7.  *
  8.  * clear
  9.  * 
  10.  * clears the terminal's screen
  11.  *
  12.  */
  13.  
  14. #include "defs.h"
  15.  
  16. static const char SCCSid[] = "@(#) mytinfo clear.c 3.2 92/02/01 public domain, By Ross Ridge";
  17.  
  18. #ifndef USE_TERMINFO
  19.  
  20. #ifdef USE_SGTTY
  21. #include <sgtty.h>
  22. #endif
  23. #ifdef USE_TERMIO
  24. #include <termio.h>
  25. #endif
  26.  
  27. char PC;
  28. short ospeed;
  29.  
  30. int
  31. putch(c)
  32. int c; {
  33.     return putchar(c);
  34. }
  35.  
  36. int
  37. main(argc, argv)
  38. int argc;
  39. char **argv; {
  40. #ifdef USE_PROTYPES
  41.     char *tgetstr(char *, char **);
  42. #else
  43.     char *tgetstr();
  44. #endif
  45.     char *term;
  46.     char buf[MAX_BUF];
  47.     char CL[MAX_LINE];
  48.     char *s, *pc;
  49.  
  50. #ifdef USE_SGTTY
  51.     struct sgttyb tty;
  52.  
  53.     gtty(1, &tty);
  54.     ospeed = tty.sg_ospeed;
  55. #else
  56. #ifdef USE_TERMIO
  57.     struct termio tty;
  58.  
  59.     ioctl(1, TCGETA, &tty);
  60.     ospeed = tty.c_cflag & CBAUD;
  61. #else
  62.     ospeed = 0;
  63. #endif
  64. #endif
  65.  
  66.     term = getenv("TERM");
  67.     if (term == NULL)
  68.         exit(1);
  69.  
  70.     if (tgetent(buf, term) != 1)
  71.         exit(1);
  72.  
  73.     s = CL;
  74.     pc = tgetstr("pc", &s);
  75.     if (pc != NULL)
  76.         PC = *pc;
  77.  
  78.     s = CL;
  79.     tgetstr("cl", &s);
  80.  
  81.     if (CL != NULL) {
  82.         tputs(CL, tgetnum("li"), putch);
  83.         exit(1);
  84.     }
  85.  
  86.     return 0;
  87. }
  88.  
  89. #else /* USE_TERMINFO */
  90.  
  91. #include "term.h"
  92.  
  93. int
  94. putch(c)
  95. int c; {
  96.     return putchar(c);
  97. }
  98.  
  99. int
  100. main() {
  101.     setupterm((char *) 0, 1, (int *) 0); 
  102.     if (clear_screen == (char *) 0)
  103.         exit(1);
  104.     tputs(clear_screen, lines > 0 ? lines : 1, putch);
  105.     return 0;
  106. }
  107.  
  108. #endif /* USE_TERMINFO */
  109.