1: #ifndef lint
   2: static char sccsid[] = "@(#)mem.c	4.3	(Berkeley)	5/15/86";
   3: #endif not lint
   4: 
   5: # include "stdio.h"
   6: # include "lrnref.h"
   7: # define SAME 0
   8: 
   9: struct keys {
  10:     char *k_wd;
  11:     int k_val;
  12: } keybuff[] = {
  13:     {"ready",   READY},
  14:     {"answer",  READY},
  15:     {"#print",  PRINT},
  16:     {"#copyin", COPYIN},
  17:     {"#uncopyin",   UNCOPIN},
  18:     {"#copyout",    COPYOUT},
  19:     {"#uncopyout",  UNCOPOUT},
  20:     {"#pipe",   PIPE},
  21:     {"#unpipe", UNPIPE},
  22:     {"#succeed",    SUCCEED},
  23:     {"#fail",   FAIL},
  24:     {"bye",     BYE},
  25:     {"chdir",   CHDIR},
  26:     {"cd",      CHDIR},
  27:     {"learn",   LEARN},
  28:     {"#log",    LOG},
  29:     {"yes",     YES},
  30:     {"no",      NO},
  31:     {"again",   AGAIN},
  32:     {"#mv",     MV},
  33:     {"#user",   USER},
  34:     {"#next",   NEXT},
  35:     {"skip",    SKIP},
  36:     {"where",   WHERE},
  37:     {"#match",  MATCH},
  38:     {"#bad",    BAD},
  39:     {"#create", CREATE},
  40:     {"#cmp",    CMP},
  41:     {"hint",    HINT},
  42:     {"#once",   ONCE},
  43:     {"#",       NOP},
  44:     {NULL,      0}
  45: };
  46: 
  47: int *action(s)
  48: char *s;
  49: {
  50:     struct keys *kp;
  51:     for (kp=keybuff; kp->k_wd; kp++)
  52:         if (strcmp(kp->k_wd, s) == SAME)
  53:             return(&(kp->k_val));
  54:     return(NULL);
  55: }
  56: 
  57: # define NW 100
  58: # define NWCH 800
  59: struct whichdid {
  60:     char *w_less;
  61:     int w_seq;
  62: } which[NW];
  63: int nwh = 0;
  64: char whbuff[NWCH];
  65: char *whcp = whbuff;
  66: static struct whichdid *pw;
  67: 
  68: setdid(lesson, sequence)
  69: char *lesson;
  70: int sequence;
  71: {
  72:     if (already(lesson)) {
  73:         pw->w_seq = sequence;
  74:         return;
  75:     }
  76:     pw = which+nwh++;
  77:     if (nwh >= NW) {
  78:         fprintf(stderr, "Setdid:  too many lessons\n");
  79:         tellwhich();
  80:         wrapup(1);
  81:     }
  82:     pw->w_seq = sequence;
  83:     pw->w_less = whcp;
  84:     while (*whcp++ = *lesson++);
  85:     if (whcp >= whbuff + NWCH) {
  86:         fprintf(stderr, "Setdid:  lesson names too long\n");
  87:         tellwhich();
  88:         wrapup(1);
  89:     }
  90: }
  91: 
  92: unsetdid(lesson)
  93: char *lesson;
  94: {
  95:     if (!already(lesson))
  96:         return;
  97:     nwh = pw - which;   /* pretend the rest have not been done */
  98:     whcp = pw->w_less;
  99: }
 100: 
 101: already(lesson)
 102: char *lesson;
 103: {
 104:     for (pw=which; pw < which+nwh; pw++)
 105:         if (strcmp(pw->w_less, lesson) == SAME)
 106:             return(1);
 107:     return(0);
 108: }
 109: 
 110: tellwhich()
 111: {
 112:     for (pw=which; pw < which+nwh; pw++)
 113:         printf("%3d lesson %7s sequence %3d\n",
 114:             pw-which, pw->w_less, pw->w_seq);
 115: }

Defined functions

action defined in line 47; used 3 times
already defined in line 101; used 3 times
setdid defined in line 68; used 2 times
tellwhich defined in line 110; used 3 times
unsetdid defined in line 92; used 1 times

Defined variables

keybuff defined in line 12; used 1 times
  • in line 51
nwh defined in line 63; used 5 times
pw defined in line 66; used 16 times
sccsid defined in line 2; never used
whbuff defined in line 64; used 2 times
whcp defined in line 65; used 4 times
which defined in line 62; used 7 times

Defined struct's

keys defined in line 9; used 2 times
  • in line 50(2)
whichdid defined in line 59; used 2 times
  • in line 66(2)

Defined macros

NW defined in line 57; used 2 times
NWCH defined in line 58; used 2 times
SAME defined in line 7; used 2 times
Last modified: 1986-05-16
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2815
Valid CSS Valid XHTML 1.0 Strict