]> arthur.barton.de Git - netatalk.git/blob - etc/afpd/hash.h
netatalk: fix a crash on Solaris when registering with mDNS
[netatalk.git] / etc / afpd / hash.h
1 /*
2  * Hash Table Data Type
3  * Copyright (C) 1997 Kaz Kylheku <kaz@ashi.footprints.net>
4  *
5  * Free Software License:
6  *
7  * All rights are reserved by the author, with the following exceptions:
8  * Permission is granted to freely reproduce and distribute this software,
9  * possibly in exchange for a fee, provided that this copyright notice appears
10  * intact. Permission is also granted to adapt this software to produce
11  * derivative works, as long as the modified versions carry this copyright
12  * notice and additional notices stating that the work has been modified.
13  * This source code may be translated into executable form and incorporated
14  * into proprietary software; there is no requirement for such software to
15  * contain a copyright notice related to this source.
16  *
17  * $Name:  $
18  */
19
20 #ifndef HASH_H
21 #define HASH_H
22
23 #include <limits.h>
24 #include <atalk/hash.h>
25
26 extern hash_t *hash_create(hashcount_t, hash_comp_t, hash_fun_t);
27 extern void hash_set_allocator(hash_t *, hnode_alloc_t, hnode_free_t, void *);
28 extern void hash_destroy(hash_t *);
29 extern void hash_free_nodes(hash_t *);
30 extern void hash_free(hash_t *);
31 extern hash_t *hash_init(hash_t *, hashcount_t, hash_comp_t,
32         hash_fun_t, hnode_t **, hashcount_t);
33 extern void hash_insert(hash_t *, hnode_t *, const void *);
34 extern hnode_t *hash_lookup(hash_t *, const void *);
35 extern hnode_t *hash_delete(hash_t *, hnode_t *);
36 extern int hash_alloc_insert(hash_t *, const void *, void *);
37 extern void hash_delete_free(hash_t *, hnode_t *);
38
39 extern void hnode_put(hnode_t *, void *);
40 extern void *hnode_get(hnode_t *);
41 extern const void *hnode_getkey(hnode_t *);
42 extern hashcount_t hash_count(hash_t *);
43 extern hashcount_t hash_size(hash_t *);
44
45 extern int hash_isfull(hash_t *);
46 extern int hash_isempty(hash_t *);
47
48 extern void hash_scan_begin(hscan_t *, hash_t *);
49 extern hnode_t *hash_scan_next(hscan_t *);
50 extern hnode_t *hash_scan_delete(hash_t *, hnode_t *);
51 extern void hash_scan_delfree(hash_t *, hnode_t *);
52
53 extern int hash_verify(hash_t *);
54
55 extern hnode_t *hnode_create(void *);
56 extern hnode_t *hnode_init(hnode_t *, void *);
57 extern void hnode_destroy(hnode_t *);
58
59 #if defined(HASH_IMPLEMENTATION) || !defined(KAZLIB_OPAQUE_DEBUG)
60 #ifdef KAZLIB_SIDEEFFECT_DEBUG
61 #define hash_isfull(H) (SFX_CHECK(H)->hash_nodecount == (H)->hash_maxcount)
62 #else
63 #define hash_isfull(H) ((H)->hash_nodecount == (H)->hash_maxcount)
64 #endif
65 #define hash_isempty(H) ((H)->hash_nodecount == 0)
66 #define hash_count(H) ((H)->hash_nodecount)
67 #define hash_size(H) ((H)->hash_nchains)
68 #define hnode_get(N) ((N)->hash_data)
69 #define hnode_getkey(N) ((N)->hash_key)
70 #define hnode_put(N, V) ((N)->hash_data = (V))
71 #endif
72
73 #endif