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: #if !defined(lint) && !defined(NOSCCS)
   8: static char sccsid[] = "@(#)tc3.c	5.1 (Berkeley) 6/5/85";
   9: #endif not lint
  10: 
  11: /*
  12:  * tc3 [term]
  13:  * Dummy program to test out termlib.
  14:  * Input two numbers and it prints out the tgoto string generated.
  15:  */
  16: #include <stdio.h>
  17: char buf[1024];
  18: char *getenv(), *tgetstr();
  19: char *rdchar();
  20: char *tgoto();
  21: char *CM;
  22: char cmbuff[30];
  23: char *x;
  24: char *UP;
  25: char *tgout;
  26: 
  27: main(argc, argv) char **argv; {
  28:     char *p;
  29:     int rc;
  30:     int row, col;
  31: 
  32:     if (argc < 2)
  33:         p = getenv("TERM");
  34:     else
  35:         p = argv[1];
  36:     rc = tgetent(buf,p);
  37:     x = cmbuff;
  38:     UP = tgetstr("up", &x);
  39:     printf("UP = %x = ", UP); pr(UP); printf("\n");
  40:     if (UP && *UP==0)
  41:         UP = 0;
  42:     CM = tgetstr("cm", &x);
  43:     printf("CM = "); pr(CM); printf("\n");
  44:     for (;;) {
  45:         if (scanf("%d %d", &row, &col) < 2)
  46:             exit(0);
  47:         tgout = tgoto(CM, row, col);
  48:         pr(tgout);
  49:         printf("\n");
  50:     }
  51: }
  52: 
  53: pr(p)
  54: register char *p;
  55: {
  56:     for (; *p; p++)
  57:         printf("%s", rdchar(*p));
  58: }
  59: 
  60: /*
  61:  * rdchar: returns a readable representation of an ASCII char, using ^ notation.
  62:  */
  63: #include <ctype.h>
  64: char *rdchar(c)
  65: char c;
  66: {
  67:     static char ret[4];
  68:     register char *p;
  69: 
  70:     /*
  71: 	 * Due to a bug in isprint, this prints spaces as ^`, but this is OK
  72: 	 * because we want something to show up on the screen.
  73: 	 */
  74:     ret[0] = ((c&0377) > 0177) ? '\'' : ' ';
  75:     c &= 0177;
  76:     ret[1] = isprint(c) ? ' ' : '^';
  77:     ret[2] = isprint(c) ?  c  : c^0100;
  78:     ret[3] = 0;
  79:     for (p=ret; *p==' '; p++)
  80:         ;
  81:     return (p);
  82: }

Defined functions

main defined in line 27; never used
pr defined in line 53; used 3 times
rdchar defined in line 64; used 2 times

Defined variables

CM defined in line 21; used 3 times
UP defined in line 24; used 6 times
buf defined in line 17; used 1 times
  • in line 36
cmbuff defined in line 22; used 1 times
  • in line 37
sccsid defined in line 8; never used
tgout defined in line 25; used 2 times
x defined in line 23; used 3 times
Last modified: 1989-05-08
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2340
Valid CSS Valid XHTML 1.0 Strict