14057Seric # include "sendmail.h" 24057Seric 3*4103Seric static char SccsId[] = "@(#)stab.c 3.5 08/10/81"; 44057Seric 54057Seric /* 64057Seric ** STAB -- manage the symbol table 74057Seric ** 84057Seric ** Parameters: 94057Seric ** name -- the name to be looked up or inserted. 10*4103Seric ** type -- the type of symbol. 114057Seric ** op -- what to do: 124057Seric ** ST_ENTER -- enter the name if not 134057Seric ** already present. 144057Seric ** ST_FIND -- find it only. 154057Seric ** 164057Seric ** Returns: 174057Seric ** pointer to a STAB entry for this name. 184057Seric ** NULL if not found and not entered. 194057Seric ** 204057Seric ** Side Effects: 214057Seric ** can update the symbol table. 224057Seric ** 234057Seric ** Notes: 244057Seric ** Obviously, this deserves a better algorithm. But 254057Seric ** for the moment...... 264057Seric */ 274057Seric 284057Seric static STAB *SymTab; 294057Seric 304057Seric STAB * 31*4103Seric stab(name, type, op) 324057Seric char *name; 33*4103Seric int type; 344057Seric int op; 354057Seric { 364057Seric register STAB *s = SymTab; 374057Seric register STAB **ps = &SymTab; 384058Seric extern bool sameword(); 394057Seric 404075Seric # ifdef DEBUG 414075Seric if (Debug > 4) 42*4103Seric printf("STAB: %s %d ", name, type); 434075Seric # endif DEBUG 444075Seric 45*4103Seric while (s != NULL && !sameword(name, s->s_name) && s->s_type != type) 464057Seric { 474057Seric ps = &s->s_next; 484057Seric s = s->s_next; 494057Seric } 504057Seric if (s != NULL || op == ST_FIND) 514075Seric { 524075Seric # ifdef DEBUG 534075Seric if (Debug > 4) 544075Seric { 554075Seric if (s == NULL) 564075Seric printf("not found\n"); 574075Seric else 584075Seric printf("type %d class %x\n", s->s_type, s->s_class); 594075Seric } 604075Seric # endif DEBUG 614057Seric return (s); 624075Seric } 634057Seric 644075Seric # ifdef DEBUG 654075Seric if (Debug > 4) 664075Seric printf("entered\n"); 674075Seric # endif DEBUG 684075Seric 694057Seric /* make new entry */ 704057Seric s = (STAB *) xalloc(sizeof *s); 71*4103Seric clear((char *) s, sizeof *s); 724057Seric s->s_name = newstr(name); 734058Seric makelower(s->s_name); 74*4103Seric s->s_type = type; 754057Seric 764057Seric /* and link it in */ 774057Seric *ps = s; 784057Seric 794057Seric return (s); 804057Seric } 81