1: /*
   2:  * tc2 [term]
   3:  * Dummy program to test out termlib.
   4:  * Commands are "tcc\n" where t is type (s for string, f for flag,
   5:  * or n for number) and cc is the name of the capability.
   6:  */
   7: #include <stdio.h>
   8: char buf[1024];
   9: char *getenv(), *tgetstr();
  10: 
  11: main(argc, argv) char **argv; {
  12:     char *p, *q;
  13:     int rc;
  14:     char b[3], c;
  15:     char area[200];
  16: 
  17:     if (argc < 2)
  18:         p = getenv("TERM");
  19:     else
  20:         p = argv[1];
  21:     rc = tgetent(buf,p);
  22:     for (;;) {
  23:         c = getchar();
  24:         if (c < 0)
  25:             exit(0);
  26:         b[0] = getchar();
  27:         if (b[0] < ' ')
  28:             exit(0);
  29:         b[1] = getchar();
  30:         b[2] = 0;
  31:         getchar();
  32:         switch(c) {
  33:             case 'f':
  34:                 printf("%s: %d\n",b,tgetflag(b));
  35:                 break;
  36:             case 'n':
  37:                 printf("%s: %d\n",b,tgetnum(b));
  38:                 break;
  39:             case 's':
  40:                 q = area;
  41:                 printf("%s: %s\n",b,tgetstr(b,&q));
  42:                 break;
  43:             default:
  44:                 exit(0);
  45:         }
  46:     }
  47: }

Defined functions

main defined in line 11; never used

Defined variables

buf defined in line 8; used 1 times
  • in line 21
Last modified: 1979-11-11
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 620
Valid CSS Valid XHTML 1.0 Strict