2 * Copyright (C) 1994-1999, Index Data
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.5 1999-02-02 14:51:08 adam
8 * Updated WIN32 code specific sections. Changed header.
10 * Revision 1.4 1997/09/09 13:38:09 adam
11 * Partial port to WIN95/NT.
13 * Revision 1.3 1996/10/29 14:06:54 adam
14 * Include zebrautl.h instead of alexutil.h.
16 * Revision 1.2 1995/09/28 09:19:44 adam
17 * xfree/xmalloc used everywhere.
18 * Extract/retrieve method seems to work for text records.
20 * Revision 1.1 1995/09/06 16:11:18 adam
21 * Option: only one word key per file.
34 struct strentry *next;
40 struct strentry *ar[STR_HASH];
43 struct strtab *strtab_mk (void)
46 struct strtab *p = xmalloc (sizeof (*p));
47 for (i=0; i<STR_HASH; i++)
52 int strtab_src (struct strtab *t, const char *name, void ***infop)
58 for (i=0; name[i]; i++)
59 hash += hash*65519 + name[i];
60 hash = hash % STR_HASH;
61 for (e = t->ar[hash]; e; e = e->next)
62 if (!strcmp(e->name, name))
67 e = xmalloc (sizeof(*e));
68 e->name = xmalloc (strlen(name)+1);
69 strcpy (e->name, name);
70 e->next = t->ar[hash];
76 void strtab_del (struct strtab *t,
77 void (*func)(const char *name, void *info, void *data),
81 struct strentry *e, *e1;
83 for (i = 0; i<STR_HASH; i++)
84 for (e = t->ar[i]; e; e = e1)
87 (*func)(e->name, e->info, data);