Updates to libhashkit.
[awesomized/libmemcached] / libhashkit / hashkit.h
1 /* HashKit
2 * Copyright (C) 2009 Brian Aker
3 * All rights reserved.
4 *
5 * Use and distribution licensed under the BSD license. See
6 * the COPYING file in the parent directory for full text.
7 */
8
9 #ifndef HASHKIT_H
10 #define HASHKIT_H
11
12 #if !defined(__cplusplus)
13 # include <stdbool.h>
14 #endif
15 #include <inttypes.h>
16 #include <sys/types.h>
17 #include <libhashkit/visibility.h>
18 #include <libhashkit/types.h>
19 #include <libhashkit/algorithm.h>
20 #include <libhashkit/behavior.h>
21 #include <libhashkit/strerror.h>
22
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26
27 struct hashkit_st
28 {
29 struct {
30 hashkit_hash_algorithm_t type;
31 hashkit_hash_fn function;
32 void *context;
33 } base_hash;
34
35 struct {
36 bool is_allocated:1;
37 } options;
38 };
39
40 HASHKIT_API
41 hashkit_st *hashkit_create(hashkit_st *hash);
42
43 HASHKIT_API
44 hashkit_st *hashkit_clone(hashkit_st *destination, const hashkit_st *ptr);
45
46 HASHKIT_API
47 void hashkit_free(hashkit_st *hash);
48
49 HASHKIT_API
50 uint32_t hashkit_generate_value(const hashkit_st *self, const char *key, size_t key_length);
51
52 HASHKIT_API
53 uint32_t libhashkit_generate_value(const char *key, size_t key_length, hashkit_hash_algorithm_t hash_algorithm);
54
55 #define hashkit_is_allocated(__object) ((__object)->options.is_allocated)
56 #define hashkit_is_initialized(__object) ((__object)->options.is_initialized)
57
58 /** @} */
59
60 #ifdef __cplusplus
61 }
62 #endif
63
64 #endif /* HASHKIT_H */