|
|
1.1 ! root 1: ! 2: #ifndef lint ! 3: static char *rcsid = "$Header: /f/osi/others/quipu/uips/pod/RCS/symtab.c,v 7.0 90/06/12 13:15:53 mrose Exp $"; ! 4: #endif ! 5: ! 6: /* ! 7: * $Header: /f/osi/others/quipu/uips/pod/RCS/symtab.c,v 7.0 90/06/12 13:15:53 mrose Exp $ ! 8: */ ! 9: ! 10: /* ! 11: * $Log: symtab.c,v $ ! 12: * Revision 7.0 90/06/12 13:15:53 mrose ! 13: * *** empty log message *** ! 14: * ! 15: * Revision 1.5 90/04/26 10:21:26 emsrdsm ! 16: * *** empty log message *** ! 17: * ! 18: * Revision 1.4 90/04/25 13:47:56 emsrdsm ! 19: * i) lint'ed ! 20: * ! 21: * Revision 1.3 90/04/20 10:28:32 emsrdsm ! 22: * (i) fixed form bug ! 23: * ! 24: * Revision 1.2 90/04/18 18:48:32 emsrdsm ! 25: * i) added logging ! 26: * ! 27: * Revision 1.1 90/04/10 16:45:07 emsrdsm ! 28: * Initial revision ! 29: * ! 30: */ ! 31: ! 32: #include "symtab.h" ! 33: #include <stdio.h> ! 34: #include <string.h> ! 35: #include <ctype.h> ! 36: #include <malloc.h> ! 37: ! 38: put_symbol_value(table, name, val) ! 39: table_entry table; ! 40: char *name; ! 41: char *val; ! 42: { ! 43: if (!name) return; ! 44: ! 45: while(table && strcmp(name, table->name)) { ! 46: table = table->next; ! 47: } ! 48: if (table) { ! 49: free(table->val); ! 50: if (val) { ! 51: table->val = ! 52: (char *) malloc((unsigned int) (strlen(val) + 1)); ! 53: (void) strcpy(table->val, val); ! 54: } else ! 55: table->val = (char *) 0; ! 56: } else { ! 57: table = (table_entry ) malloc(sizeof(table_entry)); ! 58: table->next = NULLSYM; ! 59: table->name = ! 60: (char *) malloc((unsigned int) (strlen(name) + 1)); ! 61: (void) strcpy(table->name, name); ! 62: if (val) { ! 63: table->val = ! 64: (char *) malloc((unsigned int) (strlen(val) + 1)); ! 65: (void) strcpy(table->val, val); ! 66: } else ! 67: table->val = (char *) 0; ! 68: } ! 69: } ! 70: ! 71: char * ! 72: get_symbol_value(table, name) ! 73: table_entry table; ! 74: char *name; ! 75: { ! 76: while(table && strcmp(name, table->name)) table = table->next; ! 77: if (table) ! 78: return table->val; ! 79: return (char *) 0; ! 80: } ! 81: ! 82: ! 83: free_table(table) ! 84: table_entry table; ! 85: { ! 86: table_entry entry; ! 87: ! 88: while(table) { ! 89: if (table->val) ! 90: free(table->val); ! 91: free((char *) (table->name)); ! 92: entry = table; ! 93: table = table->next; ! 94: free((char *)entry); ! 95: } ! 96: } ! 97: ! 98: ! 99: ! 100: ! 101:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.