2 * Copyright (C) 1994-1995, Index Data I/S
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.3 1996-10-29 14:06:54 adam
8 * Include zebrautl.h instead of alexutil.h.
10 * Revision 1.2 1995/09/28 09:19:44 adam
11 * xfree/xmalloc used everywhere.
12 * Extract/retrieve method seems to work for text records.
14 * Revision 1.1 1995/09/06 16:11:18 adam
15 * Option: only one word key per file.
27 struct strentry *next;
33 struct strentry *ar[STR_HASH];
36 struct strtab *strtab_mk (void)
39 struct strtab *p = xmalloc (sizeof (*p));
40 for (i=0; i<STR_HASH; i++)
45 int strtab_src (struct strtab *t, const char *name, void ***infop)
51 for (i=0; name[i]; i++)
52 hash += hash*65519 + name[i];
53 hash = hash % STR_HASH;
54 for (e = t->ar[hash]; e; e = e->next)
55 if (!strcmp(e->name, name))
60 e = xmalloc (sizeof(*e));
61 e->name = xmalloc (strlen(name)+1);
62 strcpy (e->name, name);
63 e->next = t->ar[hash];
69 void strtab_del (struct strtab *t,
70 void (*func)(const char *name, void *info, void *data),
74 struct strentry *e, *e1;
76 for (i = 0; i<STR_HASH; i++)
77 for (e = t->ar[i]; e; e = e1)
80 (*func)(e->name, e->info, data);