1 /*-
2  * Copyright (c) 1983, 1993
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  * 3. Neither the name of the University nor the names of its contributors
14  *    may be used to endorse or promote products derived from this software
15  *    without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  */
29 
30 #ifndef lint
31 static char copyright[] =
32 "@(#) Copyright (c) 1983, 1993\n\
33 	The Regents of the University of California.  All rights reserved.\n";
34 #endif /* not lint */
35 
36 #ifndef lint
37 static char sccsid[] = "@(#)tc2.c	8.1 (Berkeley) 6/4/93";
38 #endif /* not lint */
39 
40 /*
41  * tc2 [term]
42  * Dummy program to test out termlib.
43  * Commands are "tcc\n" where t is type (s for string, f for flag,
44  * or n for number) and cc is the name of the capability.
45  */
46 #include <stdio.h>
47 char buf[1024];
48 char *getenv(), *tgetstr();
49 
main(argc,argv)50 main(argc, argv) char **argv; {
51 	char *p, *q;
52 	int rc;
53 	char b[3], c;
54 	char area[200];
55 
56 	if (argc < 2)
57 		p = getenv("TERM");
58 	else
59 		p = argv[1];
60 	rc = tgetent(buf,p);
61 	for (;;) {
62 		c = getchar();
63 		if (c < 0)
64 			exit(0);
65 		b[0] = getchar();
66 		if (b[0] < ' ')
67 			exit(0);
68 		b[1] = getchar();
69 		b[2] = 0;
70 		getchar();
71 		switch(c) {
72 			case 'f':
73 				printf("%s: %d\n",b,tgetflag(b));
74 				break;
75 			case 'n':
76 				printf("%s: %d\n",b,tgetnum(b));
77 				break;
78 			case 's':
79 				q = area;
80 				printf("%s: %s\n",b,tgetstr(b,&q));
81 				break;
82 			default:
83 				exit(0);
84 		}
85 	}
86 }
87