Fix for bug #15450
[awesomized/libmemcached] / libhashkit / types.h
1
2 /* HashKit
3 * Copyright (C) 2009 Brian Aker
4 * All rights reserved.
5 *
6 * Use and distribution licensed under the BSD license. See
7 * the COPYING file in the parent directory for full text.
8 */
9
10 /**
11 * @file
12 * @brief HashKit Header
13 */
14
15 #ifndef HASHKIT_TYPES_H
16 #define HASHKIT_TYPES_H
17
18 #ifdef __cplusplus
19 extern "C" {
20 #endif
21
22 /**
23 * @addtogroup hashkit_types Types
24 * @ingroup hashkit
25 * @{
26 */
27
28 typedef enum {
29 HASHKIT_SUCCESS,
30 HASHKIT_FAILURE,
31 HASHKIT_MEMORY_ALLOCATION_FAILURE,
32 HASHKIT_MAXIMUM_RETURN /* Always add new error code before */
33 } hashkit_return_t;
34
35 /**
36 @todo hashkit_options_t is for future use, currently we do not define any user options.
37 */
38
39 typedef enum
40 {
41 HASHKIT_OPTION_MAX
42 } hashkit_options_t;
43
44 typedef struct
45 {
46 /* We use the following for internal book keeping. */
47 bool is_initialized:1;
48 bool is_allocated:1;
49 } hashkit_options_st;
50
51 typedef enum {
52 HASHKIT_HASH_DEFAULT= 0,
53 HASHKIT_HASH_MD5,
54 HASHKIT_HASH_CRC,
55 HASHKIT_HASH_FNV1_64,
56 HASHKIT_HASH_FNV1A_64,
57 HASHKIT_HASH_FNV1_32,
58 HASHKIT_HASH_FNV1A_32,
59 HASHKIT_HASH_HSIEH,
60 HASHKIT_HASH_MURMUR,
61 HASHKIT_HASH_JENKINS,
62 HASHKIT_HASH_MAX
63 } hashkit_hash_algorithm_t;
64
65 /**
66 * Hash distributions that are available to use.
67 */
68 typedef enum
69 {
70 HASHKIT_DISTRIBUTION_MODULA,
71 HASHKIT_DISTRIBUTION_RANDOM,
72 HASHKIT_DISTRIBUTION_KETAMA,
73 HASHKIT_DISTRIBUTION_MAX /* Always add new values before this. */
74 } hashkit_distribution_t;
75
76
77 typedef struct hashkit_st hashkit_st;
78 typedef struct hashkit_continuum_point_st hashkit_continuum_point_st;
79 typedef bool (hashkit_active_fn)(void *context);
80 typedef uint32_t (hashkit_fn)(const char *key, size_t key_length);
81 typedef size_t (hashkit_key_fn)(char *key, size_t key_length, uint32_t point_index, void *context);
82 typedef void (hashkit_sort_fn)(void *context, size_t count);
83 typedef uint32_t (hashkit_weight_fn)(void *context);
84
85 /** @} */
86
87
88 #ifdef __cplusplus
89 }
90 #endif
91
92 #endif /* HASHKIT_TYPES_H */