14057Seric # include "sendmail.h" 24057Seric 3*4058Seric static char SccsId[] = "@(#)stab.c 3.2 08/08/81"; 44057Seric 54057Seric /* 64057Seric ** STAB -- manage the symbol table 74057Seric ** 84057Seric ** Parameters: 94057Seric ** name -- the name to be looked up or inserted. 104057Seric ** op -- what to do: 114057Seric ** ST_ENTER -- enter the name if not 124057Seric ** already present. 134057Seric ** ST_FIND -- find it only. 144057Seric ** 154057Seric ** Returns: 164057Seric ** pointer to a STAB entry for this name. 174057Seric ** NULL if not found and not entered. 184057Seric ** 194057Seric ** Side Effects: 204057Seric ** can update the symbol table. 214057Seric ** 224057Seric ** Notes: 234057Seric ** Obviously, this deserves a better algorithm. But 244057Seric ** for the moment...... 254057Seric */ 264057Seric 274057Seric static STAB *SymTab; 284057Seric 294057Seric STAB * 304057Seric stab(name, op) 314057Seric char *name; 324057Seric int op; 334057Seric { 344057Seric register STAB *s = SymTab; 354057Seric register STAB **ps = &SymTab; 364057Seric extern char *newstr(); 37*4058Seric extern bool sameword(); 384057Seric 39*4058Seric while (s != NULL && sameword(name, s->s_name)) 404057Seric { 414057Seric ps = &s->s_next; 424057Seric s = s->s_next; 434057Seric } 444057Seric if (s != NULL || op == ST_FIND) 454057Seric return (s); 464057Seric 474057Seric /* make new entry */ 484057Seric s = (STAB *) xalloc(sizeof *s); 494057Seric s->s_name = newstr(name); 50*4058Seric makelower(s->s_name); 514057Seric s->s_type = 0; 524057Seric s->s_class = 0; 534057Seric s->s_next = NULL; 544057Seric 554057Seric /* and link it in */ 564057Seric *ps = s; 574057Seric 584057Seric return (s); 594057Seric } 60