2 * Copyright (C) 1994-1999, Index Data
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.6 1999-05-26 07:49:13 adam
10 * Revision 1.5 1999/02/02 14:51:08 adam
11 * Updated WIN32 code specific sections. Changed header.
13 * Revision 1.4 1997/09/09 13:38:09 adam
14 * Partial port to WIN95/NT.
16 * Revision 1.3 1996/10/29 14:06:54 adam
17 * Include zebrautl.h instead of alexutil.h.
19 * Revision 1.2 1995/09/28 09:19:44 adam
20 * xfree/xmalloc used everywhere.
21 * Extract/retrieve method seems to work for text records.
23 * Revision 1.1 1995/09/06 16:11:18 adam
24 * Option: only one word key per file.
37 struct strentry *next;
43 struct strentry *ar[STR_HASH];
46 struct strtab *strtab_mk (void)
49 struct strtab *p = (struct strtab *) xmalloc (sizeof (*p));
50 for (i=0; i<STR_HASH; i++)
55 int strtab_src (struct strtab *t, const char *name, void ***infop)
61 for (i=0; name[i]; i++)
62 hash += hash*65519 + name[i];
63 hash = hash % STR_HASH;
64 for (e = t->ar[hash]; e; e = e->next)
65 if (!strcmp(e->name, name))
70 e = (struct strentry *) xmalloc (sizeof(*e));
71 e->name = (char *) xmalloc (strlen(name)+1);
72 strcpy (e->name, name);
73 e->next = t->ar[hash];
79 void strtab_del (struct strtab *t,
80 void (*func)(const char *name, void *info, void *data),
84 struct strentry *e, *e1;
86 for (i = 0; i<STR_HASH; i++)
87 for (e = t->ar[i]; e; e = e1)
90 (*func)(e->name, e->info, data);