f4155eacb8a716adf07ebac68a4b61d6105a1e86
[m6w6/libmemcached] / include / libhashkit-1.0 / hashkit.h
1 /*
2 +--------------------------------------------------------------------+
3 | libmemcached - C/C++ Client Library for memcached |
4 +--------------------------------------------------------------------+
5 | Redistribution and use in source and binary forms, with or without |
6 | modification, are permitted under the terms of the BSD license. |
7 | You should have received a copy of the license in a bundled file |
8 | named LICENSE; in case you did not receive a copy you can review |
9 | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
10 +--------------------------------------------------------------------+
11 | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
12 | Copyright (c) 2020 Michael Wallner <mike@php.net> |
13 +--------------------------------------------------------------------+
14 */
15
16 #pragma once
17
18 #if !defined(__cplusplus)
19 # include <stdbool.h>
20 #endif
21 #include <inttypes.h>
22 #include <sys/types.h>
23
24 #include <libhashkit-1.0/visibility.h>
25 #include <libhashkit-1.0/configure.h>
26 #include <libhashkit-1.0/types.h>
27 #include <libhashkit-1.0/has.h>
28 #include <libhashkit-1.0/algorithm.h>
29 #include <libhashkit-1.0/behavior.h>
30 #include <libhashkit-1.0/digest.h>
31 #include <libhashkit-1.0/function.h>
32 #include <libhashkit-1.0/str_algorithm.h>
33 #include <libhashkit-1.0/strerror.h>
34 #include <libhashkit-1.0/string.h>
35
36 struct hashkit_st {
37 struct hashkit_function_st {
38 hashkit_hash_fn function;
39 void *context;
40 } base_hash, distribution_hash;
41
42 struct {
43 bool is_base_same_distributed : 1;
44 } flags;
45
46 struct {
47 bool is_allocated : 1;
48 } options;
49
50 void *_key;
51 };
52
53 #ifdef __cplusplus
54 extern "C" {
55 #endif
56
57 HASHKIT_API
58 hashkit_st *hashkit_create(hashkit_st *hash);
59
60 HASHKIT_API
61 hashkit_st *hashkit_clone(hashkit_st *destination, const hashkit_st *ptr);
62
63 HASHKIT_API
64 bool hashkit_compare(const hashkit_st *first, const hashkit_st *second);
65
66 HASHKIT_API
67 void hashkit_free(hashkit_st *hash);
68
69 HASHKIT_API
70 hashkit_string_st *hashkit_encrypt(hashkit_st *, const char *source, size_t source_length);
71
72 HASHKIT_API
73 hashkit_string_st *hashkit_decrypt(hashkit_st *, const char *source, size_t source_length);
74
75 HASHKIT_API
76 bool hashkit_key(hashkit_st *, const char *key, const size_t key_length);
77
78 #ifdef __cplusplus
79 } // extern "C"
80 #endif