1 # include "sendmail.h" 2 3 static char SccsId[] = "@(#)stab.c 3.1 08/08/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 38 while (s != NULL && strcmp(name, s->s_name) != '\0') 39 { 40 ps = &s->s_next; 41 s = s->s_next; 42 } 43 if (s != NULL || op == ST_FIND) 44 return (s); 45 46 /* make new entry */ 47 s = (STAB *) xalloc(sizeof *s); 48 s->s_name = newstr(name); 49 s->s_type = 0; 50 s->s_class = 0; 51 s->s_next = NULL; 52 53 /* and link it in */ 54 *ps = s; 55 56 return (s); 57 } 58