Annotation of 43BSDTahoe/usr.lib/libtermlib/tc2.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Copyright (c) 1980 Regents of the University of California.
                      3:  * All rights reserved.  The Berkeley software License Agreement
                      4:  * specifies the terms and conditions for redistribution.
                      5:  */
                      6: 
                      7: #ifndef lint
                      8: static char sccsid[] = "@(#)tc2.c      5.1 (Berkeley) 6/5/85";
                      9: #endif not lint
                     10: 
                     11: /*
                     12:  * tc2 [term]
                     13:  * Dummy program to test out termlib.
                     14:  * Commands are "tcc\n" where t is type (s for string, f for flag,
                     15:  * or n for number) and cc is the name of the capability.
                     16:  */
                     17: #include <stdio.h>
                     18: char buf[1024];
                     19: char *getenv(), *tgetstr();
                     20: 
                     21: main(argc, argv) char **argv; {
                     22:        char *p, *q;
                     23:        int rc;
                     24:        char b[3], c;
                     25:        char area[200];
                     26: 
                     27:        if (argc < 2)
                     28:                p = getenv("TERM");
                     29:        else
                     30:                p = argv[1];
                     31:        rc = tgetent(buf,p);
                     32:        for (;;) {
                     33:                c = getchar();
                     34:                if (c < 0)
                     35:                        exit(0);
                     36:                b[0] = getchar();
                     37:                if (b[0] < ' ')
                     38:                        exit(0);
                     39:                b[1] = getchar();
                     40:                b[2] = 0;
                     41:                getchar();
                     42:                switch(c) {
                     43:                        case 'f':
                     44:                                printf("%s: %d\n",b,tgetflag(b));
                     45:                                break;
                     46:                        case 'n':
                     47:                                printf("%s: %d\n",b,tgetnum(b));
                     48:                                break;
                     49:                        case 's':
                     50:                                q = area;
                     51:                                printf("%s: %s\n",b,tgetstr(b,&q));
                     52:                                break;
                     53:                        default:
                     54:                                exit(0);
                     55:                }
                     56:        }
                     57: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.