1*4057Seric # include "sendmail.h" 2*4057Seric 3*4057Seric static char SccsId[] = "@(#)stab.c 3.1 08/08/81"; 4*4057Seric 5*4057Seric /* 6*4057Seric ** STAB -- manage the symbol table 7*4057Seric ** 8*4057Seric ** Parameters: 9*4057Seric ** name -- the name to be looked up or inserted. 10*4057Seric ** op -- what to do: 11*4057Seric ** ST_ENTER -- enter the name if not 12*4057Seric ** already present. 13*4057Seric ** ST_FIND -- find it only. 14*4057Seric ** 15*4057Seric ** Returns: 16*4057Seric ** pointer to a STAB entry for this name. 17*4057Seric ** NULL if not found and not entered. 18*4057Seric ** 19*4057Seric ** Side Effects: 20*4057Seric ** can update the symbol table. 21*4057Seric ** 22*4057Seric ** Notes: 23*4057Seric ** Obviously, this deserves a better algorithm. But 24*4057Seric ** for the moment...... 25*4057Seric */ 26*4057Seric 27*4057Seric static STAB *SymTab; 28*4057Seric 29*4057Seric STAB * 30*4057Seric stab(name, op) 31*4057Seric char *name; 32*4057Seric int op; 33*4057Seric { 34*4057Seric register STAB *s = SymTab; 35*4057Seric register STAB **ps = &SymTab; 36*4057Seric extern char *newstr(); 37*4057Seric 38*4057Seric while (s != NULL && strcmp(name, s->s_name) != '\0') 39*4057Seric { 40*4057Seric ps = &s->s_next; 41*4057Seric s = s->s_next; 42*4057Seric } 43*4057Seric if (s != NULL || op == ST_FIND) 44*4057Seric return (s); 45*4057Seric 46*4057Seric /* make new entry */ 47*4057Seric s = (STAB *) xalloc(sizeof *s); 48*4057Seric s->s_name = newstr(name); 49*4057Seric s->s_type = 0; 50*4057Seric s->s_class = 0; 51*4057Seric s->s_next = NULL; 52*4057Seric 53*4057Seric /* and link it in */ 54*4057Seric *ps = s; 55*4057Seric 56*4057Seric return (s); 57*4057Seric } 58