1 # include "sendmail.h" 2 3 static char SccsId[] = "@(#)stab.c 3.4 08/09/81"; 4 5 /* 6 ** STAB -- manage the symbol table 7 ** 8 ** Parameters: 9 ** name -- the name to be looked up or inserted. 10 ** op -- what to do: 11 ** ST_ENTER -- enter the name if not 12 ** already present. 13 ** ST_FIND -- find it only. 14 ** 15 ** Returns: 16 ** pointer to a STAB entry for this name. 17 ** NULL if not found and not entered. 18 ** 19 ** Side Effects: 20 ** can update the symbol table. 21 ** 22 ** Notes: 23 ** Obviously, this deserves a better algorithm. But 24 ** for the moment...... 25 */ 26 27 static STAB *SymTab; 28 29 STAB * 30 stab(name, op) 31 char *name; 32 int op; 33 { 34 register STAB *s = SymTab; 35 register STAB **ps = &SymTab; 36 extern bool sameword(); 37 38 # ifdef DEBUG 39 if (Debug > 4) 40 printf("STAB: %s ", name); 41 # endif DEBUG 42 43 while (s != NULL && !sameword(name, s->s_name)) 44 { 45 ps = &s->s_next; 46 s = s->s_next; 47 } 48 if (s != NULL || op == ST_FIND) 49 { 50 # ifdef DEBUG 51 if (Debug > 4) 52 { 53 if (s == NULL) 54 printf("not found\n"); 55 else 56 printf("type %d class %x\n", s->s_type, s->s_class); 57 } 58 # endif DEBUG 59 return (s); 60 } 61 62 # ifdef DEBUG 63 if (Debug > 4) 64 printf("entered\n"); 65 # endif DEBUG 66 67 /* make new entry */ 68 s = (STAB *) xalloc(sizeof *s); 69 s->s_name = newstr(name); 70 makelower(s->s_name); 71 s->s_type = 0; 72 s->s_class = 0; 73 s->s_next = NULL; 74 75 /* and link it in */ 76 *ps = s; 77 78 return (s); 79 } 80