LibMB 1.12
hash.h
1/* libmb
2 * Copyright (C) 2002 Matthew Allum
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
18 */
19
20#include <stdio.h>
21#include <stdlib.h>
22#include <string.h>
23
24#define HASHSIZE 101
25
26struct hash {
27 struct nlist **hashtab;
28 int size;
29};
30
31struct nlist {
32 struct nlist *next;
33 char *key;
34 unsigned char *value;
35};
36
37struct hash* hash_new(int size);
38unsigned int hashfunc(struct hash *h, char *s);
39struct nlist *hash_lookup(struct hash *h, char *s);
40struct nlist *hash_add(struct hash *h, char *key, char *val);
41void hash_empty();
42void hash_destroy(struct hash *h);