All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
hash.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 2 of the License, or
5  * (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software
14  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
15  */
16 #ifndef _FR_HASH_H
17 #define _FR_HASH_H
18 /**
19  * $Id: d5174be650a3320debbd821fe8b78a25cf669d11 $
20  *
21  * @file include/hash.h
22  * @brief Structures and prototypes for fast hashing.
23  *
24  * @copyright 2005,2006 The FreeRADIUS server project
25  */
26 RCSIDH(hash_h, "$Id: d5174be650a3320debbd821fe8b78a25cf669d11 $")
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 /*
33  * Fast hash, which isn't too bad. Don't use for cryptography,
34  * just for hashing internal data.
35  */
36 uint32_t fr_hash(void const *, size_t);
37 uint32_t fr_hash_update(void const *data, size_t size, uint32_t hash);
38 uint32_t fr_hash_string(char const *p);
39 
41 typedef void (*fr_hash_table_free_t)(void *);
42 typedef uint32_t (*fr_hash_table_hash_t)(void const *);
43 typedef int (*fr_hash_table_cmp_t)(void const *, void const *);
44 typedef int (*fr_hash_table_walk_t)(void * /* ctx */, void * /* data */);
45 
46 fr_hash_table_t *fr_hash_table_create(TALLOC_CTX *ctx,
47  fr_hash_table_hash_t hashNode,
48  fr_hash_table_cmp_t cmpNode,
49  fr_hash_table_free_t freeNode);
51 int fr_hash_table_insert(fr_hash_table_t *ht, void const *data);
52 int fr_hash_table_delete(fr_hash_table_t *ht, void const *data);
53 void *fr_hash_table_yank(fr_hash_table_t *ht, void const *data);
54 int fr_hash_table_replace(fr_hash_table_t *ht, void const *data);
55 void *fr_hash_table_finddata(fr_hash_table_t *ht, void const *data);
58  fr_hash_table_walk_t callback,
59  void *ctx);
60 
61 #ifdef __cplusplus
62 }
63 #endif
64 
65 #endif /* _FR_HASH_H */
#define RCSIDH(h, id)
Definition: build.h:136
int fr_hash_table_insert(fr_hash_table_t *ht, void const *data)
Definition: hash.c:405
void * fr_hash_table_yank(fr_hash_table_t *ht, void const *data)
Definition: hash.c:514
void * fr_hash_table_finddata(fr_hash_table_t *ht, void const *data)
Definition: hash.c:496
uint32_t fr_hash(void const *, size_t)
Definition: hash.c:727
int fr_hash_table_replace(fr_hash_table_t *ht, void const *data)
Definition: hash.c:473
uint32_t fr_hash_string(char const *p)
Definition: hash.c:778
static unsigned int hash(char const *username, unsigned int tablesize)
Definition: rlm_passwd.c:124
uint32_t fr_hash_update(void const *data, size_t size, uint32_t hash)
Definition: hash.c:761
uint32_t(* fr_hash_table_hash_t)(void const *)
Definition: hash.h:42
void(* fr_hash_table_free_t)(void *)
Definition: hash.h:41
void fr_hash_table_free(fr_hash_table_t *ht)
Definition: hash.c:562
int(* fr_hash_table_walk_t)(void *, void *)
Definition: hash.h:44
uint8_t data[]
Definition: eap_pwd.h:625
fr_hash_table_t * fr_hash_table_create(TALLOC_CTX *ctx, fr_hash_table_hash_t hashNode, fr_hash_table_cmp_t cmpNode, fr_hash_table_free_t freeNode)
Definition: hash.c:279
int fr_hash_table_num_elements(fr_hash_table_t *ht)
Definition: hash.c:598
int fr_hash_table_walk(fr_hash_table_t *ht, fr_hash_table_walk_t callback, void *ctx)
Definition: hash.c:609
int(* fr_hash_table_cmp_t)(void const *, void const *)
Definition: hash.h:43
int fr_hash_table_delete(fr_hash_table_t *ht, void const *data)
Definition: hash.c:546