|
|
1.1 ! root 1: #ifndef lint ! 2: static char sccsid[] = "@(#)tc2.c 4.1 (Berkeley) 6/27/83"; ! 3: #endif ! 4: ! 5: /* ! 6: * tc2 [term] ! 7: * Dummy program to test out termlib. ! 8: * Commands are "tcc\n" where t is type (s for string, f for flag, ! 9: * or n for number) and cc is the name of the capability. ! 10: */ ! 11: #include <stdio.h> ! 12: char buf[1024]; ! 13: char *getenv(), *tgetstr(); ! 14: ! 15: main(argc, argv) char **argv; { ! 16: char *p, *q; ! 17: int rc; ! 18: char b[3], c; ! 19: char area[200]; ! 20: ! 21: if (argc < 2) ! 22: p = getenv("TERM"); ! 23: else ! 24: p = argv[1]; ! 25: rc = tgetent(buf,p); ! 26: for (;;) { ! 27: c = getchar(); ! 28: if (c < 0) ! 29: exit(0); ! 30: b[0] = getchar(); ! 31: if (b[0] < ' ') ! 32: exit(0); ! 33: b[1] = getchar(); ! 34: b[2] = 0; ! 35: getchar(); ! 36: switch(c) { ! 37: case 'f': ! 38: printf("%s: %d\n",b,tgetflag(b)); ! 39: break; ! 40: case 'n': ! 41: printf("%s: %d\n",b,tgetnum(b)); ! 42: break; ! 43: case 's': ! 44: q = area; ! 45: printf("%s: %s\n",b,tgetstr(b,&q)); ! 46: break; ! 47: default: ! 48: exit(0); ! 49: } ! 50: } ! 51: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.