1 # include "sendmail.h" 2 3 static char SccsId[] = "@(#)stab.c 3.3 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 char *newstr(); 37 extern bool sameword(); 38 39 # ifdef DEBUG 40 if (Debug > 4) 41 printf("STAB: %s ", name); 42 # endif DEBUG 43 44 while (s != NULL && !sameword(name, s->s_name)) 45 { 46 ps = &s->s_next; 47 s = s->s_next; 48 } 49 if (s != NULL || op == ST_FIND) 50 { 51 # ifdef DEBUG 52 if (Debug > 4) 53 { 54 if (s == NULL) 55 printf("not found\n"); 56 else 57 printf("type %d class %x\n", s->s_type, s->s_class); 58 } 59 # endif DEBUG 60 return (s); 61 } 62 63 # ifdef DEBUG 64 if (Debug > 4) 65 printf("entered\n"); 66 # endif DEBUG 67 68 /* make new entry */ 69 s = (STAB *) xalloc(sizeof *s); 70 s->s_name = newstr(name); 71 makelower(s->s_name); 72 s->s_type = 0; 73 s->s_class = 0; 74 s->s_next = NULL; 75 76 /* and link it in */ 77 *ps = s; 78 79 return (s); 80 } 81