1 /* 2 ** HASH: Simple hash table implementation. 3 ** Copyright (C) 2002 Michael W. Shaffer <mwshaffer@angrypot.com> 4 ** 5 ** This program is free software; you can redistribute it and/or modify 6 ** it under the terms of the GNU General Public License as published by 7 ** the Free Software Foundation; either version 2 of the License, or 8 ** (at your option) any later version. 9 ** 10 ** This program is distributed in the hope that it will be useful, 11 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 ** GNU General Public License for more details. 14 ** 15 ** You should have received a copy of the GNU General Public License 16 ** along with this program (see the file COPYING). If not, write to: 17 ** 18 ** The Free Software Foundation, Inc. 19 ** 59 Temple Place, Suite 330, 20 ** Boston, MA 02111-1307 USA 21 */ 22 23 #ifndef HASH_H 24 #define HASH_H 25 26 struct datum { 27 void *key; 28 unsigned long ksize; 29 void *val; 30 unsigned long vsize; 31 }; 32 33 struct hash_table { 34 unsigned long size; 35 struct list *tbl; 36 }; 37 38 void hash_table_init (struct hash_table *h); 39 void hash_table_free (struct hash_table *h); 40 struct datum *hash_table_insert (struct hash_table *h, struct datum *d); 41 struct datum *hash_table_search (struct hash_table *h, struct datum *k); 42 void hash_table_delete (struct hash_table *h, struct datum *k); 43 44 #endif /* HASH_H */ 45 46