1: /*
   2:  *	Copyright 1984, 1985 by the Regents of the University of
   3:  *	California and by Gregory Glenn Minshall.
   4:  *
   5:  *	Permission to use, copy, modify, and distribute these
   6:  *	programs and their documentation for any purpose and
   7:  *	without fee is hereby granted, provided that this
   8:  *	copyright and permission appear on all copies and
   9:  *	supporting documentation, the name of the Regents of
  10:  *	the University of California not be used in advertising
  11:  *	or publicity pertaining to distribution of the programs
  12:  *	without specific prior permission, and notice be given in
  13:  *	supporting documentation that copying and distribution is
  14:  *	by permission of the Regents of the University of California
  15:  *	and by Gregory Glenn Minshall.  Neither the Regents of the
  16:  *	University of California nor Gregory Glenn Minshall make
  17:  *	representations about the suitability of this software
  18:  *	for any purpose.  It is provided "as is" without
  19:  *	express or implied warranty.
  20:  */
  21: 
  22: 
  23: /* this program outputs the user's 3270 mapping table in a form suitable
  24:  *	for inclusion in the environment.  Typically, this might be used
  25:  *	by:
  26:  *		setenv MAP3270 "`mset`"
  27:  */
  28: 
  29: #include <curses.h>
  30: #include "state.h"
  31: #define LETS_SEE_ASCII
  32: #include "m4.out"
  33: 
  34: static char array[5000];        /* lot's of room */
  35: 
  36: char *
  37: addString(string, character)
  38: char *string;
  39: char character;
  40: {
  41:     *string++ = character;
  42:     return(string);
  43: }
  44: 
  45: char *
  46: deleteString(string)
  47: char *string;
  48: {
  49:     return(string-1);
  50: }
  51: 
  52: printString(string, character, tc)
  53: register char *string;
  54: char character;
  55: int tc;
  56: {
  57:     register char *st1;
  58:     register int pchar;
  59: 
  60:     *string++ = character;
  61:     st1 = array;
  62: 
  63:     printf("%s='", TC_Ascii[tc-TC_LOWEST].tc_name);
  64:     while (st1 != string) {
  65:     pchar = 0xff&(*st1++);
  66:     switch (pchar) {
  67:     case '\\':
  68:     case '^':
  69:     case '\'':
  70:         printf("%c%c", '\\', pchar);
  71:         break;
  72:     default:
  73:         printf("%s", unctrl(pchar));
  74:         break;
  75:     }
  76:     }
  77:     printf("';");
  78: }
  79: 
  80: recurse(string, head)
  81: char *string;
  82: state *head;
  83: {
  84:         /*	if there is a left,
  85: 		 *	    recurse on left,
  86: 		 *	if there is no down,
  87: 		 *	    print the string to here
  88: 		 *	else,
  89: 		 *	     add the current match to the string,
  90: 		 *	     recurse.
  91: 		 *	exit.
  92: 		 */
  93:     if (head->next) {
  94:     recurse(string, head->next);
  95:     }
  96:     if (head->result != TC_GOTO) {
  97:     printString(string, head->match, head->result);
  98:     } else {
  99:     string = addString(string, head->match);
 100:     recurse(string, head->address);
 101:     string = deleteString(string);
 102:     }
 103:     return;
 104: }
 105: main()
 106: {
 107:     state *head;
 108:     state *InitControl();
 109:     char *termPointer;
 110:     char *getenv();
 111: 
 112:     head = InitControl();
 113:     if (!head) {
 114:     return(1);
 115:     }
 116:     termPointer = getenv("TERM");
 117:     if (termPointer == 0) {
 118:     termPointer = "3a"; /* use 3a as the terminal */
 119:     }
 120:     printf("%s{", termPointer);
 121:     /* now, run through the table printing out entries */
 122:     recurse(array, head);
 123:     printf("}\n");
 124:     return(0);
 125: }

Defined functions

addString defined in line 36; used 1 times
  • in line 99
deleteString defined in line 45; used 1 times
main defined in line 105; never used
printString defined in line 52; used 1 times
  • in line 97
recurse defined in line 80; used 3 times

Defined variables

array defined in line 34; used 2 times

Defined macros

LETS_SEE_ASCII defined in line 31; never used
Last modified: 1994-01-01
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1103
Valid CSS Valid XHTML 1.0 Strict