opkg: fix some compiler warnings
[oweals/opkg-lede.git] / hash_table.h
1 /* hash.h - hash tables for opkg
2
3    Steven M. Ayer, Jamey Hicks
4    
5    Copyright (C) 2002 Compaq Computer Corporation
6
7    This program is free software; you can redistribute it and/or
8    modify it under the terms of the GNU General Public License as
9    published by the Free Software Foundation; either version 2, or (at
10    your option) any later version.
11
12    This program is distributed in the hope that it will be useful, but
13    WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15    General Public License for more details.
16 */
17
18 #ifndef _HASH_TABLE_H_
19 #define _HASH_TABLE_H_
20
21 typedef struct hash_entry hash_entry_t;
22 typedef struct hash_table hash_table_t;
23
24 struct hash_entry {
25   const char * key;
26   void * data;
27   struct hash_entry * next;
28 };
29
30 struct hash_table {
31   const char *name; 
32   hash_entry_t * entries;  
33   int n_entries; /* number of buckets */
34   int n_elements;
35   const char * (*hash_entry_key)(void * data);
36 };
37
38 int hash_table_init(const char *name, hash_table_t *hash, int len);
39 void hash_table_deinit(hash_table_t *hash);
40 void *hash_table_get(hash_table_t *hash, const char *key);
41 int hash_table_insert(hash_table_t *hash, const char *key, void *value);
42 void hash_table_foreach(hash_table_t *hash, void (*f)(const char *key, void *entry, void *data), void *data);
43
44 #endif /* _HASH_TABLE_H_ */