xref: /csrg-svn/lib/libterm/TEST/tc2.c (revision 61370)
147926Sbostic /*-
2*61370Sbostic  * Copyright (c) 1983, 1993
3*61370Sbostic  *	The Regents of the University of California.  All rights reserved.
436499Sbostic  *
547926Sbostic  * %sccs.include.redist.c%
622070Sdist  */
722070Sdist 
813298Ssam #ifndef lint
9*61370Sbostic static char copyright[] =
10*61370Sbostic "@(#) Copyright (c) 1983, 1993\n\
11*61370Sbostic 	The Regents of the University of California.  All rights reserved.\n";
1236499Sbostic #endif /* not lint */
1313298Ssam 
1436499Sbostic #ifndef lint
15*61370Sbostic static char sccsid[] = "@(#)tc2.c	8.1 (Berkeley) 06/04/93";
1636499Sbostic #endif /* not lint */
1736499Sbostic 
1813298Ssam /*
1913298Ssam  * tc2 [term]
2013298Ssam  * Dummy program to test out termlib.
2113298Ssam  * Commands are "tcc\n" where t is type (s for string, f for flag,
2213298Ssam  * or n for number) and cc is the name of the capability.
2313298Ssam  */
2413298Ssam #include <stdio.h>
2513298Ssam char buf[1024];
2613298Ssam char *getenv(), *tgetstr();
2713298Ssam 
main(argc,argv)2813298Ssam main(argc, argv) char **argv; {
2913298Ssam 	char *p, *q;
3013298Ssam 	int rc;
3113298Ssam 	char b[3], c;
3213298Ssam 	char area[200];
3313298Ssam 
3413298Ssam 	if (argc < 2)
3513298Ssam 		p = getenv("TERM");
3613298Ssam 	else
3713298Ssam 		p = argv[1];
3813298Ssam 	rc = tgetent(buf,p);
3913298Ssam 	for (;;) {
4013298Ssam 		c = getchar();
4113298Ssam 		if (c < 0)
4213298Ssam 			exit(0);
4313298Ssam 		b[0] = getchar();
4413298Ssam 		if (b[0] < ' ')
4513298Ssam 			exit(0);
4613298Ssam 		b[1] = getchar();
4713298Ssam 		b[2] = 0;
4813298Ssam 		getchar();
4913298Ssam 		switch(c) {
5013298Ssam 			case 'f':
5113298Ssam 				printf("%s: %d\n",b,tgetflag(b));
5213298Ssam 				break;
5313298Ssam 			case 'n':
5413298Ssam 				printf("%s: %d\n",b,tgetnum(b));
5513298Ssam 				break;
5613298Ssam 			case 's':
5713298Ssam 				q = area;
5813298Ssam 				printf("%s: %s\n",b,tgetstr(b,&q));
5913298Ssam 				break;
6013298Ssam 			default:
6113298Ssam 				exit(0);
6213298Ssam 		}
6313298Ssam 	}
6413298Ssam }
65