5 * hash.h Structures and prototypes
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 * Copyright 2005,2006 The FreeRADIUS server project
27 #include <freeradius-devel/ident.h>
28 RCSIDH(hash_h, "$Id$")
31 * Fast hash, which isn't too bad. Don't use for cryptography,
32 * just for hashing internal data.
34 uint32_t lrad_hash(const void *, size_t);
35 uint32_t lrad_hash_update(const void *data, size_t size, uint32_t hash);
36 uint32_t lrad_hash_string(const char *p);
39 * If you need fewer than 32-bits of hash, use this macro to get
40 * the number of bits in the hash you need. The upper bits of the
41 * hash will be set to zero.
43 uint32_t lrad_hash_fold(uint32_t hash, int bits);
45 typedef struct lrad_hash_table_t lrad_hash_table_t;
46 typedef void (*lrad_hash_table_free_t)(void *);
47 typedef uint32_t (*lrad_hash_table_hash_t)(const void *);
48 typedef int (*lrad_hash_table_cmp_t)(const void *, const void *);
49 typedef int (*lrad_hash_table_walk_t)(void * /* ctx */, void * /* data */);
51 lrad_hash_table_t *lrad_hash_table_create(lrad_hash_table_hash_t hashNode,
52 lrad_hash_table_cmp_t cmpNode,
53 lrad_hash_table_free_t freeNode);
54 void lrad_hash_table_free(lrad_hash_table_t *ht);
55 int lrad_hash_table_insert(lrad_hash_table_t *ht, void *data);
56 int lrad_hash_table_delete(lrad_hash_table_t *ht, const void *data);
57 void *lrad_hash_table_yank(lrad_hash_table_t *ht, const void *data);
58 int lrad_hash_table_replace(lrad_hash_table_t *ht, void *data);
59 void *lrad_hash_table_finddata(lrad_hash_table_t *ht, const void *data);
60 int lrad_hash_table_num_elements(lrad_hash_table_t *ht);
61 int lrad_hash_table_walk(lrad_hash_table_t *ht,
62 lrad_hash_table_walk_t callback,
64 #endif /* LRAD_HASH_H */