1: /*
   2:  * Copyright (c) 1985 University of Alberta *
   3:  *
   4:  * This file contains two fuctions for parameter decoding;
   5:  * "inicodes" is an initialization function and must be called once,
   6:  * before "decode" can be used; "decode" is the actual parameter
   7:  * decoding function;
   8:  */
   9: 
  10: #ifndef lint
  11: static char *rcsid_decode_c = "$Header: decode.c,v 10.2 86/02/01 15:59:43 tony Rel $";
  12: #endif
  13: 
  14: #include "imPdefs.h"
  15: #include "imPcodes.h"
  16: #define CMDPLEN(code)   (017&cmdpars[code&0177])
  17: #define CMDPMIX(code)   (017&(cmdpars[code&0177]>>4))
  18: char    cmdpars[128];
  19: 
  20: #define NOPMSK  (15<<4)
  21: #define B   (0<<4)
  22: 
  23: 
  24: 
  25: #define BA  (0<<4)
  26: #define W   (1<<4)
  27: #define BB  (2<<4)
  28: #define BBB (3<<4)
  29: #define WWW (4<<4)
  30: #define BBA (5<<4)
  31: #define WBBBBBA (6<<4)
  32: #define WWWWWWA (7<<4)
  33: #define BWA (8<<4)
  34: #define BBBA    (9<<4)
  35: #define WA  (10<<4)
  36: #define NOPARS  NOPMSK+0
  37: 
  38: char    *cmdpmsk[16] = {
  39:     "B", "W", "BB", "BBB", "WWW", "BBA", "WBBBBBA", "WWWWWWA",
  40:     "BWA", "BBBA", "WA", "", "", "", "", ""};
  41: 
  42: inicodes ()
  43: {
  44:     int i;
  45: 
  46:     for (i=0; i<128; i++)
  47:         cmdpars[i] = NOPARS;
  48: 
  49:     cmdpars[ASP0&0177] = NOPARS;
  50:     cmdpars[ASP1&0177] = NOPARS;
  51: 
  52:     cmdpars[ASRULE&0177] = BBB+3;
  53:     cmdpars[ABRULE&0177] = WWW+6;
  54: 
  55:     cmdpars[AM&0177] = BB+2;
  56:     cmdpars[AMP&0177]= NOPARS;
  57:     cmdpars[AMM&0177]= NOPARS;
  58:     cmdpars[AH&0177] = W+2;
  59:     cmdpars[AV&0177] = W+2;
  60:     cmdpars[AN&0177] = NOPARS;
  61: 
  62:     cmdpars[ASGLY&0177] = WBBBBBA+7;
  63:     cmdpars[ABGLY&0177] = WWWWWWA+12;
  64:     cmdpars[ADELG&0177] = W+2;
  65:     cmdpars[ADELC&0177] = W+2;
  66:     cmdpars[ADELF&0177] = B+1;
  67:     cmdpars[AFONT&0177] = BA+1;
  68: 
  69:     cmdpars[APAGOR&0177] = B+1;
  70:     cmdpars[AROTMS&0177] = B+1;
  71: 
  72:     cmdpars[AF&0177] = B+1;
  73:     cmdpars[ABSKIP&0177] = W+2;
  74:     cmdpars[AMARGIN&0177] = W+2;
  75:     cmdpars[ASETSP&0177] = W+2;
  76: 
  77:     cmdpars[APUSH&0177] = NOPARS;
  78:     cmdpars[APOP&0177] = NOPARS;
  79: 
  80:     cmdpars[APAGE&0177] = NOPARS;
  81:     cmdpars[AEND&0177] = NOPARS;
  82: 
  83:     cmdpars[AEOF&0177] = NOPARS;
  84:     cmdpars[ANOP&0177] = NOPARS;
  85: 
  86:     cmdpars[ASET_HV_SYS&0177] = B+1;
  87:     cmdpars[ASET_ABS_H&0177] = W+2;
  88:     cmdpars[ASET_ABS_V&0177] = W+2;
  89:     cmdpars[ASET_REL_H&0177] = W+2;
  90:     cmdpars[ASET_REL_V&0177] = W+2;
  91: 
  92:     cmdpars[AMMOVE&0177] = W+2;
  93:     cmdpars[ASMOVE&0177] = W+2;
  94: 
  95:     cmdpars[ACREATE_MAP&0177] = BB+2;
  96:     cmdpars[ACREATE_FAMILY&0177] = BB+2;
  97:     cmdpars[AFORCE_GLY_DELETE&0177] = NOPARS;
  98: 
  99:     cmdpars[ASET_PATH&0177] = WA+2;
 100:     cmdpars[ASET_TEXTURE&0177] = BB+2;
 101:     cmdpars[ASET_PEN&0177] = B+1;
 102:     cmdpars[ADRAW_PATH&0177] = B+1;
 103:     cmdpars[AFILL_PATH&0177] = B+1;
 104:     cmdpars[ABIT_MAP&0177] = BBBA+3;
 105:     cmdpars[ASET_MAGNIFICATION&0177] = B+1;
 106:     cmdpars[ASET_PUSH_MASK&0177] = W+2;
 107: 
 108:     cmdpars[ADEFINE_MACRO&0177] = BWA+3;
 109:     cmdpars[AEXECUTE_MACRO&0177] = B+1;
 110: }
 111: 
 112: decode(ccode)
 113: char    ccode;
 114: {
 115:     register parva  *parap;
 116:     register char   *sp;
 117:     register int    i;
 118:     register char   *Cinpcurr;
 119:     char    inp[20];
 120: 
 121:     Cinpcurr = inp;
 122:     for (i=CMDPLEN(ccode); i; i--)
 123:         *Cinpcurr++ = gc();
 124:     Cinpcurr = inp;
 125: 
 126:     parap = param+1;
 127:     sp = cmdpmsk[CMDPMIX(ccode)];
 128:     while (*sp!=0) {
 129:         if (*sp == 'B') {
 130:             parap->pval2.hival = 0;
 131:             parap->pval2.loval = *Cinpcurr;
 132:             Cinpcurr++;
 133:         }
 134:         else if (*sp == 'W') {
 135:             parap->pval = ((*Cinpcurr & 0377) << 8)
 136:                 | (Cinpcurr[1] & 0377);
 137:             Cinpcurr += 2;
 138:         }
 139:         else parap->pptr = Cinpcurr;
 140:         sp++;
 141:         parap++;
 142:     }
 143: }
 144: 
 145: getint()
 146: {
 147:     register parva  *parap;
 148:     register int c = gc();
 149: 
 150:     parap = param+1;
 151:     parap->pval = ((c & 0377) << 8) | (gc() & 0377);
 152:     return(V(1));
 153: }

Defined functions

decode defined in line 112; used 1 times
getint defined in line 145; used 4 times
inicodes defined in line 42; used 1 times

Defined variables

cmdpars defined in line 18; used 51 times
cmdpmsk defined in line 38; used 1 times
rcsid_decode_c defined in line 11; never used

Defined macros

B defined in line 21; used 10 times
BA defined in line 25; used 1 times
  • in line 67
BB defined in line 27; used 4 times
BBA defined in line 30; never used
BBB defined in line 28; used 1 times
  • in line 52
BBBA defined in line 34; used 1 times
BWA defined in line 33; used 1 times
CMDPLEN defined in line 16; used 1 times
CMDPMIX defined in line 17; used 1 times
NOPARS defined in line 36; used 13 times
NOPMSK defined in line 20; used 1 times
  • in line 36
W defined in line 26; used 14 times
WA defined in line 35; used 1 times
  • in line 99
WBBBBBA defined in line 31; used 1 times
  • in line 62
WWW defined in line 29; used 1 times
  • in line 53
WWWWWWA defined in line 32; used 1 times
  • in line 63
Last modified: 1986-02-01
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1402
Valid CSS Valid XHTML 1.0 Strict