2 * Copyright (C) 1994-1995, Index Data I/S
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.4 1997-09-09 13:38:09 adam
8 * Partial port to WIN95/NT.
10 * Revision 1.3 1996/10/29 14:06:54 adam
11 * Include zebrautl.h instead of alexutil.h.
13 * Revision 1.2 1995/09/28 09:19:44 adam
14 * xfree/xmalloc used everywhere.
15 * Extract/retrieve method seems to work for text records.
17 * Revision 1.1 1995/09/06 16:11:18 adam
18 * Option: only one word key per file.
31 struct strentry *next;
37 struct strentry *ar[STR_HASH];
40 struct strtab *strtab_mk (void)
43 struct strtab *p = xmalloc (sizeof (*p));
44 for (i=0; i<STR_HASH; i++)
49 int strtab_src (struct strtab *t, const char *name, void ***infop)
55 for (i=0; name[i]; i++)
56 hash += hash*65519 + name[i];
57 hash = hash % STR_HASH;
58 for (e = t->ar[hash]; e; e = e->next)
59 if (!strcmp(e->name, name))
64 e = xmalloc (sizeof(*e));
65 e->name = xmalloc (strlen(name)+1);
66 strcpy (e->name, name);
67 e->next = t->ar[hash];
73 void strtab_del (struct strtab *t,
74 void (*func)(const char *name, void *info, void *data),
78 struct strentry *e, *e1;
80 for (i = 0; i<STR_HASH; i++)
81 for (e = t->ar[i]; e; e = e1)
84 (*func)(e->name, e->info, data);