122070Sdist /* 2*36499Sbostic * Copyright (c) 1980 The Regents of the University of California. 3*36499Sbostic * All rights reserved. 4*36499Sbostic * 5*36499Sbostic * Redistribution and use in source and binary forms are permitted 6*36499Sbostic * provided that the above copyright notice and this paragraph are 7*36499Sbostic * duplicated in all such forms and that any documentation, 8*36499Sbostic * advertising materials, and other materials related to such 9*36499Sbostic * distribution and use acknowledge that the software was developed 10*36499Sbostic * by the University of California, Berkeley. The name of the 11*36499Sbostic * University may not be used to endorse or promote products derived 12*36499Sbostic * from this software without specific prior written permission. 13*36499Sbostic * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 14*36499Sbostic * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 15*36499Sbostic * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 1622070Sdist */ 1722070Sdist 1813298Ssam #ifndef lint 19*36499Sbostic char copyright[] = 20*36499Sbostic "@(#) Copyright (c) 1980 The Regents of the University of California.\n\ 21*36499Sbostic All rights reserved.\n"; 22*36499Sbostic #endif /* not lint */ 2313298Ssam 24*36499Sbostic #ifndef lint 25*36499Sbostic static char sccsid[] = "@(#)tc2.c 5.2 (Berkeley) 01/03/89"; 26*36499Sbostic #endif /* not lint */ 27*36499Sbostic 2813298Ssam /* 2913298Ssam * tc2 [term] 3013298Ssam * Dummy program to test out termlib. 3113298Ssam * Commands are "tcc\n" where t is type (s for string, f for flag, 3213298Ssam * or n for number) and cc is the name of the capability. 3313298Ssam */ 3413298Ssam #include <stdio.h> 3513298Ssam char buf[1024]; 3613298Ssam char *getenv(), *tgetstr(); 3713298Ssam 3813298Ssam main(argc, argv) char **argv; { 3913298Ssam char *p, *q; 4013298Ssam int rc; 4113298Ssam char b[3], c; 4213298Ssam char area[200]; 4313298Ssam 4413298Ssam if (argc < 2) 4513298Ssam p = getenv("TERM"); 4613298Ssam else 4713298Ssam p = argv[1]; 4813298Ssam rc = tgetent(buf,p); 4913298Ssam for (;;) { 5013298Ssam c = getchar(); 5113298Ssam if (c < 0) 5213298Ssam exit(0); 5313298Ssam b[0] = getchar(); 5413298Ssam if (b[0] < ' ') 5513298Ssam exit(0); 5613298Ssam b[1] = getchar(); 5713298Ssam b[2] = 0; 5813298Ssam getchar(); 5913298Ssam switch(c) { 6013298Ssam case 'f': 6113298Ssam printf("%s: %d\n",b,tgetflag(b)); 6213298Ssam break; 6313298Ssam case 'n': 6413298Ssam printf("%s: %d\n",b,tgetnum(b)); 6513298Ssam break; 6613298Ssam case 's': 6713298Ssam q = area; 6813298Ssam printf("%s: %s\n",b,tgetstr(b,&q)); 6913298Ssam break; 7013298Ssam default: 7113298Ssam exit(0); 7213298Ssam } 7313298Ssam } 7413298Ssam } 75