14057Seric # include "sendmail.h" 24057Seric 3*4075Seric static char SccsId[] = "@(#)stab.c 3.3 08/09/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(); 374058Seric extern bool sameword(); 384057Seric 39*4075Seric # ifdef DEBUG 40*4075Seric if (Debug > 4) 41*4075Seric printf("STAB: %s ", name); 42*4075Seric # endif DEBUG 43*4075Seric 44*4075Seric while (s != NULL && !sameword(name, s->s_name)) 454057Seric { 464057Seric ps = &s->s_next; 474057Seric s = s->s_next; 484057Seric } 494057Seric if (s != NULL || op == ST_FIND) 50*4075Seric { 51*4075Seric # ifdef DEBUG 52*4075Seric if (Debug > 4) 53*4075Seric { 54*4075Seric if (s == NULL) 55*4075Seric printf("not found\n"); 56*4075Seric else 57*4075Seric printf("type %d class %x\n", s->s_type, s->s_class); 58*4075Seric } 59*4075Seric # endif DEBUG 604057Seric return (s); 61*4075Seric } 624057Seric 63*4075Seric # ifdef DEBUG 64*4075Seric if (Debug > 4) 65*4075Seric printf("entered\n"); 66*4075Seric # endif DEBUG 67*4075Seric 684057Seric /* make new entry */ 694057Seric s = (STAB *) xalloc(sizeof *s); 704057Seric s->s_name = newstr(name); 714058Seric makelower(s->s_name); 724057Seric s->s_type = 0; 734057Seric s->s_class = 0; 744057Seric s->s_next = NULL; 754057Seric 764057Seric /* and link it in */ 774057Seric *ps = s; 784057Seric 794057Seric return (s); 804057Seric } 81