1 /* $Id: symtab.c,v 1.13 2007-01-15 15:10:17 adam Exp $
2 Copyright (C) 1995-2007
5 This file is part of the Zebra server.
7 Zebra is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
12 Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27 #include <yaz/xmalloc.h>
32 struct strentry *next;
38 struct strentry *ar[STR_HASH];
41 struct strtab *strtab_mk (void)
44 struct strtab *p = (struct strtab *) xmalloc (sizeof (*p));
45 for (i=0; i<STR_HASH; i++)
50 int strtab_src (struct strtab *t, const char *name, void ***infop)
56 for (i=0; name[i]; i++)
57 hash += hash*65519 + name[i];
58 hash = hash % STR_HASH;
59 for (e = t->ar[hash]; e; e = e->next)
60 if (!strcmp(e->name, name))
65 e = (struct strentry *) xmalloc (sizeof(*e));
66 e->name = (char *) xmalloc (strlen(name)+1);
67 strcpy (e->name, name);
68 e->next = t->ar[hash];
74 void strtab_del (struct strtab *t,
75 void (*func)(const char *name, void *info, void *data),
79 struct strentry *e, *e1;
81 for (i = 0; i<STR_HASH; i++)
82 for (e = t->ar[i]; e; e = e1)
85 (*func)(e->name, e->info, data);
94 * indent-tabs-mode: nil
96 * vim: shiftwidth=4 tabstop=8 expandtab