1: # include "stdio.h"
   2: # include "lrnref"
   3: # define SAME 0
   4: 
   5: struct keys {
   6:     char *k_wd;
   7:     int k_val;
   8: } keybuff[] = {
   9:     {"ready",   READY},
  10:     {"answer",  READY},
  11:     {"#print",  PRINT},
  12:     {"#copyin", COPYIN},
  13:     {"#uncopyin",   UNCOPIN},
  14:     {"#copyout",    COPYOUT},
  15:     {"#uncopyout",  UNCOPOUT},
  16:     {"#pipe",   PIPE},
  17:     {"#unpipe", UNPIPE},
  18:     {"#succeed",    SUCCEED},
  19:     {"#fail",   FAIL},
  20:     {"bye",     BYE},
  21:     {"chdir",   CHDIR},
  22:     {"cd",      CHDIR},
  23:     {"learn",   LEARN},
  24:     {"#log",    LOG},
  25:     {"yes",     YES},
  26:     {"no",      NO},
  27:     {"#mv",     MV},
  28:     {"#user",   USER},
  29:     {"#next",   NEXT},
  30:     {"skip",    SKIP},
  31:     {"#where",  WHERE},
  32:     {"#match",  MATCH},
  33:     {"#bad",    BAD},
  34:     {"#create", CREATE},
  35:     {"#cmp",    CMP},
  36:     {"#goto",   GOTO},
  37:     {"#once",   ONCE},
  38:     {"#",       NOP},
  39:     {NULL,      0}
  40: };
  41: 
  42: int *action(s)
  43: char *s;
  44: {
  45:     struct keys *kp;
  46:     for (kp=keybuff; kp->k_wd; kp++)
  47:         if (strcmp(kp->k_wd, s) == SAME)
  48:             return(&(kp->k_val));
  49:     return(NULL);
  50: }
  51: 
  52: # define NW 100
  53: # define NWCH 800
  54: struct whichdid {
  55:     char *w_less;
  56:     int w_seq;
  57: } which[NW];
  58: int nwh = 0;
  59: char whbuff[NWCH];
  60: char *whcp = whbuff;
  61: 
  62: setdid(lesson, sequence)
  63: char *lesson;
  64: {
  65:     struct whichdid *pw;
  66:     for(pw=which; pw < which+nwh; pw++)
  67:         if (strcmp(pw->w_less, lesson) == SAME)
  68:             {
  69:             pw->w_seq = sequence;
  70:             return;
  71:             }
  72:     pw=which+nwh++;
  73:     if (nwh >= NW) {
  74:         fprintf(stderr, "nwh>=NW\n");
  75:         wrapup(1);
  76:     }
  77:     pw->w_seq = sequence;
  78:     pw->w_less = whcp;
  79:     while (*whcp++ = *lesson++);
  80:     if (whcp >= whbuff + NWCH) {
  81:         fprintf(stderr, "lesson name too long\n");
  82:         wrapup(1);
  83:     }
  84: }
  85: 
  86: already(lesson, sequence)
  87: char *lesson;
  88: {
  89:     struct whichdid *pw;
  90:     for (pw=which; pw < which+nwh; pw++)
  91:         if (strcmp(pw->w_less, lesson) == SAME)
  92:             return(1);
  93:     return(0);
  94: }

Defined functions

action defined in line 42; used 3 times
already defined in line 86; used 1 times
setdid defined in line 62; used 1 times

Defined variables

keybuff defined in line 8; used 1 times
  • in line 46
nwh defined in line 58; used 4 times
whbuff defined in line 59; used 2 times
whcp defined in line 60; used 3 times
which defined in line 57; used 5 times

Defined struct's

keys defined in line 5; used 2 times
  • in line 45(2)
whichdid defined in line 54; used 4 times
  • in line 65(2), 89(2)

Defined macros

NW defined in line 52; used 2 times
NWCH defined in line 53; used 2 times
SAME defined in line 3; used 3 times
Last modified: 1981-07-10
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 793
Valid CSS Valid XHTML 1.0 Strict