2 * Copyright (C) 1994-1995, Index Data I/S
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.1 1995-09-06 16:11:18 adam
8 * Option: only one word key per file.
21 struct strentry *next;
27 struct strentry *ar[STR_HASH];
30 struct strtab *strtab_mk (void)
33 struct strtab *p = xmalloc (sizeof (*p));
34 for (i=0; i<STR_HASH; i++)
39 int strtab_src (struct strtab *t, const char *name, void ***infop)
45 for (i=0; name[i]; i++)
46 hash += hash*65519 + name[i];
47 hash = hash % STR_HASH;
48 for (e = t->ar[hash]; e; e = e->next)
49 if (!strcmp(e->name, name))
54 e = xmalloc (sizeof(*e));
55 e->name = xmalloc (strlen(name)+1);
56 strcpy (e->name, name);
57 e->next = t->ar[hash];
63 void strtab_del (struct strtab *t,
64 void (*func)(const char *name, void *info, void *data),
68 struct strentry *e, *e1;
70 for (i = 0; i<STR_HASH; i++)
71 for (e = t->ar[i]; e; e = e1)
74 (*func)(e->name, e->info, data);