libvalkey 4.0.0__tar.gz → 4.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. {libvalkey-4.0.0 → libvalkey-4.0.1}/MANIFEST.in +1 -0
  2. {libvalkey-4.0.0/libvalkey.egg-info → libvalkey-4.0.1}/PKG-INFO +2 -1
  3. libvalkey-4.0.1/libvalkey/version.py +1 -0
  4. {libvalkey-4.0.0 → libvalkey-4.0.1/libvalkey.egg-info}/PKG-INFO +2 -1
  5. {libvalkey-4.0.0 → libvalkey-4.0.1}/libvalkey.egg-info/SOURCES.txt +11 -0
  6. {libvalkey-4.0.0 → libvalkey-4.0.1}/setup.py +1 -0
  7. {libvalkey-4.0.0 → libvalkey-4.0.1}/src/reader.c +5 -5
  8. libvalkey-4.0.1/vendor/libvalkey/include/valkey/alloc.h +96 -0
  9. libvalkey-4.0.1/vendor/libvalkey/include/valkey/async.h +159 -0
  10. libvalkey-4.0.1/vendor/libvalkey/include/valkey/dict.h +125 -0
  11. libvalkey-4.0.1/vendor/libvalkey/include/valkey/net.h +57 -0
  12. libvalkey-4.0.1/vendor/libvalkey/include/valkey/read.h +129 -0
  13. libvalkey-4.0.1/vendor/libvalkey/include/valkey/sds.h +285 -0
  14. libvalkey-4.0.1/vendor/libvalkey/include/valkey/sockcompat.h +96 -0
  15. libvalkey-4.0.1/vendor/libvalkey/include/valkey/valkey.h +363 -0
  16. libvalkey-4.0.1/vendor/libvalkey/include/valkey/valkey_ssl.h +163 -0
  17. libvalkey-4.0.1/vendor/libvalkey/include/valkey/valkeycluster.h +345 -0
  18. libvalkey-4.0.1/vendor/libvalkey/include/valkey/valkeycluster_ssl.h +49 -0
  19. libvalkey-4.0.0/libvalkey/version.py +0 -1
  20. {libvalkey-4.0.0 → libvalkey-4.0.1}/LICENSE +0 -0
  21. {libvalkey-4.0.0 → libvalkey-4.0.1}/README.md +0 -0
  22. {libvalkey-4.0.0 → libvalkey-4.0.1}/libvalkey/__init__.py +0 -0
  23. {libvalkey-4.0.0 → libvalkey-4.0.1}/libvalkey/libvalkey.pyi +0 -0
  24. {libvalkey-4.0.0 → libvalkey-4.0.1}/libvalkey/py.typed +0 -0
  25. {libvalkey-4.0.0 → libvalkey-4.0.1}/libvalkey.egg-info/dependency_links.txt +0 -0
  26. {libvalkey-4.0.0 → libvalkey-4.0.1}/libvalkey.egg-info/top_level.txt +0 -0
  27. {libvalkey-4.0.0 → libvalkey-4.0.1}/setup.cfg +0 -0
  28. {libvalkey-4.0.0 → libvalkey-4.0.1}/src/libvalkey.c +0 -0
  29. {libvalkey-4.0.0 → libvalkey-4.0.1}/src/libvalkey.h +0 -0
  30. {libvalkey-4.0.0 → libvalkey-4.0.1}/src/pack.c +0 -0
  31. {libvalkey-4.0.0 → libvalkey-4.0.1}/src/pack.h +0 -0
  32. {libvalkey-4.0.0 → libvalkey-4.0.1}/src/reader.h +0 -0
  33. {libvalkey-4.0.0 → libvalkey-4.0.1}/tests/test_gc.py +0 -0
  34. {libvalkey-4.0.0 → libvalkey-4.0.1}/tests/test_pack.py +0 -0
  35. {libvalkey-4.0.0 → libvalkey-4.0.1}/tests/test_reader.py +0 -0
  36. {libvalkey-4.0.0 → libvalkey-4.0.1}/vendor/libvalkey/src/adlist.c +0 -0
  37. {libvalkey-4.0.0 → libvalkey-4.0.1}/vendor/libvalkey/src/adlist.h +0 -0
  38. {libvalkey-4.0.0 → libvalkey-4.0.1}/vendor/libvalkey/src/alloc.c +0 -0
  39. {libvalkey-4.0.0 → libvalkey-4.0.1}/vendor/libvalkey/src/async.c +0 -0
  40. {libvalkey-4.0.0 → libvalkey-4.0.1}/vendor/libvalkey/src/async_private.h +0 -0
  41. {libvalkey-4.0.0 → libvalkey-4.0.1}/vendor/libvalkey/src/cmddef.h +0 -0
  42. {libvalkey-4.0.0 → libvalkey-4.0.1}/vendor/libvalkey/src/command.c +0 -0
  43. {libvalkey-4.0.0 → libvalkey-4.0.1}/vendor/libvalkey/src/command.h +0 -0
  44. {libvalkey-4.0.0 → libvalkey-4.0.1}/vendor/libvalkey/src/crc16.c +0 -0
  45. {libvalkey-4.0.0 → libvalkey-4.0.1}/vendor/libvalkey/src/dict.c +0 -0
  46. {libvalkey-4.0.0 → libvalkey-4.0.1}/vendor/libvalkey/src/fmacros.h +0 -0
  47. {libvalkey-4.0.0 → libvalkey-4.0.1}/vendor/libvalkey/src/net.c +0 -0
  48. {libvalkey-4.0.0 → libvalkey-4.0.1}/vendor/libvalkey/src/read.c +0 -0
  49. {libvalkey-4.0.0 → libvalkey-4.0.1}/vendor/libvalkey/src/sds.c +0 -0
  50. {libvalkey-4.0.0 → libvalkey-4.0.1}/vendor/libvalkey/src/sdsalloc.h +0 -0
  51. {libvalkey-4.0.0 → libvalkey-4.0.1}/vendor/libvalkey/src/sockcompat.c +0 -0
  52. {libvalkey-4.0.0 → libvalkey-4.0.1}/vendor/libvalkey/src/ssl.c +0 -0
  53. {libvalkey-4.0.0 → libvalkey-4.0.1}/vendor/libvalkey/src/valkey.c +0 -0
  54. {libvalkey-4.0.0 → libvalkey-4.0.1}/vendor/libvalkey/src/valkey_private.h +0 -0
  55. {libvalkey-4.0.0 → libvalkey-4.0.1}/vendor/libvalkey/src/valkeycluster.c +0 -0
  56. {libvalkey-4.0.0 → libvalkey-4.0.1}/vendor/libvalkey/src/valkeycluster_ssl.c +0 -0
  57. {libvalkey-4.0.0 → libvalkey-4.0.1}/vendor/libvalkey/src/vkutil.c +0 -0
  58. {libvalkey-4.0.0 → libvalkey-4.0.1}/vendor/libvalkey/src/vkutil.h +0 -0
  59. {libvalkey-4.0.0 → libvalkey-4.0.1}/vendor/libvalkey/src/win32.h +0 -0
@@ -3,6 +3,7 @@ include MANIFEST.in
3
3
  include README.md
4
4
  include src/*.[ch]
5
5
  include vendor/libvalkey/COPYING
6
+ include vendor/libvalkey/include/valkey/*.h
6
7
  include vendor/libvalkey/src/*.[ch]
7
8
  graft tests
8
9
  global-exclude __pycache__
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: libvalkey
3
- Version: 4.0.0
3
+ Version: 4.0.1
4
4
  Summary: Python wrapper for libvalkey
5
5
  Home-page: https://github.com/valkey-io/libvalkey-py
6
6
  Author: libvalkey-py authors
@@ -22,6 +22,7 @@ Classifier: Programming Language :: Python :: 3.9
22
22
  Classifier: Programming Language :: Python :: 3.10
23
23
  Classifier: Programming Language :: Python :: 3.11
24
24
  Classifier: Programming Language :: Python :: 3.12
25
+ Classifier: Programming Language :: Python :: 3.13
25
26
  Classifier: Programming Language :: Python :: Implementation :: CPython
26
27
  Classifier: Topic :: Software Development
27
28
  Requires-Python: >=3.8
@@ -0,0 +1 @@
1
+ __version__ = "4.0.1"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: libvalkey
3
- Version: 4.0.0
3
+ Version: 4.0.1
4
4
  Summary: Python wrapper for libvalkey
5
5
  Home-page: https://github.com/valkey-io/libvalkey-py
6
6
  Author: libvalkey-py authors
@@ -22,6 +22,7 @@ Classifier: Programming Language :: Python :: 3.9
22
22
  Classifier: Programming Language :: Python :: 3.10
23
23
  Classifier: Programming Language :: Python :: 3.11
24
24
  Classifier: Programming Language :: Python :: 3.12
25
+ Classifier: Programming Language :: Python :: 3.13
25
26
  Classifier: Programming Language :: Python :: Implementation :: CPython
26
27
  Classifier: Topic :: Software Development
27
28
  Requires-Python: >=3.8
@@ -20,6 +20,17 @@ src/reader.h
20
20
  tests/test_gc.py
21
21
  tests/test_pack.py
22
22
  tests/test_reader.py
23
+ vendor/libvalkey/include/valkey/alloc.h
24
+ vendor/libvalkey/include/valkey/async.h
25
+ vendor/libvalkey/include/valkey/dict.h
26
+ vendor/libvalkey/include/valkey/net.h
27
+ vendor/libvalkey/include/valkey/read.h
28
+ vendor/libvalkey/include/valkey/sds.h
29
+ vendor/libvalkey/include/valkey/sockcompat.h
30
+ vendor/libvalkey/include/valkey/valkey.h
31
+ vendor/libvalkey/include/valkey/valkey_ssl.h
32
+ vendor/libvalkey/include/valkey/valkeycluster.h
33
+ vendor/libvalkey/include/valkey/valkeycluster_ssl.h
23
34
  vendor/libvalkey/src/adlist.c
24
35
  vendor/libvalkey/src/adlist.h
25
36
  vendor/libvalkey/src/alloc.c
@@ -83,6 +83,7 @@ setup(
83
83
  'Programming Language :: Python :: 3.10',
84
84
  'Programming Language :: Python :: 3.11',
85
85
  'Programming Language :: Python :: 3.12',
86
+ 'Programming Language :: Python :: 3.13',
86
87
  'Programming Language :: Python :: Implementation :: CPython',
87
88
  'Topic :: Software Development',
88
89
  ],
@@ -87,13 +87,13 @@ static void *tryParentize(const valkeyReadTask *task, PyObject *obj) {
87
87
  Py_DECREF(obj);
88
88
  return NULL;
89
89
  }
90
- if (PyDict_SetItem(parent, self->pendingObject, obj) < 0) {
91
- Py_DECREF(obj);
92
- Py_DECREF(self->pendingObject);
93
- self->pendingObject = NULL;
90
+ int x = PyDict_SetItem(parent, self->pendingObject, obj);
91
+ Py_DECREF(obj);
92
+ Py_DECREF(self->pendingObject);
93
+ self->pendingObject = NULL;
94
+ if (x < 0) {
94
95
  return NULL;
95
96
  }
96
- self->pendingObject = NULL;
97
97
  }
98
98
  break;
99
99
  case VALKEY_REPLY_SET:
@@ -0,0 +1,96 @@
1
+ /*
2
+ * Copyright (c) 2020, Michael Grunder <michael dot grunder at gmail dot com>
3
+ *
4
+ * All rights reserved.
5
+ *
6
+ * Redistribution and use in source and binary forms, with or without
7
+ * modification, are permitted provided that the following conditions are met:
8
+ *
9
+ * * Redistributions of source code must retain the above copyright notice,
10
+ * this list of conditions and the following disclaimer.
11
+ * * Redistributions in binary form must reproduce the above copyright
12
+ * notice, this list of conditions and the following disclaimer in the
13
+ * documentation and/or other materials provided with the distribution.
14
+ * * Neither the name of Redis nor the names of its contributors may be used
15
+ * to endorse or promote products derived from this software without
16
+ * specific prior written permission.
17
+ *
18
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28
+ * POSSIBILITY OF SUCH DAMAGE.
29
+ */
30
+
31
+ #ifndef VALKEY_ALLOC_H
32
+ #define VALKEY_ALLOC_H
33
+
34
+ #include <stddef.h> /* for size_t */
35
+ #include <stdint.h>
36
+
37
+ #ifdef __cplusplus
38
+ extern "C" {
39
+ #endif
40
+
41
+ /* Structure pointing to our actually configured allocators */
42
+ typedef struct valkeyAllocFuncs {
43
+ void *(*mallocFn)(size_t);
44
+ void *(*callocFn)(size_t,size_t);
45
+ void *(*reallocFn)(void*,size_t);
46
+ char *(*strdupFn)(const char*);
47
+ void (*freeFn)(void*);
48
+ } valkeyAllocFuncs;
49
+
50
+ valkeyAllocFuncs valkeySetAllocators(valkeyAllocFuncs *fns);
51
+ void valkeyResetAllocators(void);
52
+
53
+ #ifndef _WIN32
54
+
55
+ /* valkey' configured allocator function pointer struct */
56
+ extern valkeyAllocFuncs valkeyAllocFns;
57
+
58
+ static inline void *vk_malloc(size_t size) {
59
+ return valkeyAllocFns.mallocFn(size);
60
+ }
61
+
62
+ static inline void *vk_calloc(size_t nmemb, size_t size) {
63
+ /* Overflow check as the user can specify any arbitrary allocator */
64
+ if (SIZE_MAX / size < nmemb)
65
+ return NULL;
66
+
67
+ return valkeyAllocFns.callocFn(nmemb, size);
68
+ }
69
+
70
+ static inline void *vk_realloc(void *ptr, size_t size) {
71
+ return valkeyAllocFns.reallocFn(ptr, size);
72
+ }
73
+
74
+ static inline char *vk_strdup(const char *str) {
75
+ return valkeyAllocFns.strdupFn(str);
76
+ }
77
+
78
+ static inline void vk_free(void *ptr) {
79
+ valkeyAllocFns.freeFn(ptr);
80
+ }
81
+
82
+ #else
83
+
84
+ void *vk_malloc(size_t size);
85
+ void *vk_calloc(size_t nmemb, size_t size);
86
+ void *vk_realloc(void *ptr, size_t size);
87
+ char *vk_strdup(const char *str);
88
+ void vk_free(void *ptr);
89
+
90
+ #endif
91
+
92
+ #ifdef __cplusplus
93
+ }
94
+ #endif
95
+
96
+ #endif /* VALKEY_ALLOC_H */
@@ -0,0 +1,159 @@
1
+ /*
2
+ * Copyright (c) 2009-2011, Salvatore Sanfilippo <antirez at gmail dot com>
3
+ * Copyright (c) 2010-2011, Pieter Noordhuis <pcnoordhuis at gmail dot com>
4
+ *
5
+ * All rights reserved.
6
+ *
7
+ * Redistribution and use in source and binary forms, with or without
8
+ * modification, are permitted provided that the following conditions are met:
9
+ *
10
+ * * Redistributions of source code must retain the above copyright notice,
11
+ * this list of conditions and the following disclaimer.
12
+ * * Redistributions in binary form must reproduce the above copyright
13
+ * notice, this list of conditions and the following disclaimer in the
14
+ * documentation and/or other materials provided with the distribution.
15
+ * * Neither the name of Redis nor the names of its contributors may be used
16
+ * to endorse or promote products derived from this software without
17
+ * specific prior written permission.
18
+ *
19
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
+ * POSSIBILITY OF SUCH DAMAGE.
30
+ */
31
+
32
+ #ifndef VALKEY_ASYNC_H
33
+ #define VALKEY_ASYNC_H
34
+ #include "valkey.h"
35
+
36
+ #ifdef __cplusplus
37
+ extern "C" {
38
+ #endif
39
+
40
+ /* For the async cluster attach functions. */
41
+ #if defined(__GNUC__) || defined(__clang__)
42
+ #define VALKEY_UNUSED __attribute__((unused))
43
+ #else
44
+ #define VALKEY_UNUSED
45
+ #endif
46
+
47
+ struct valkeyAsyncContext; /* need forward declaration of valkeyAsyncContext */
48
+ struct dict; /* dictionary header is included in async.c */
49
+
50
+ /* Reply callback prototype and container */
51
+ typedef void (valkeyCallbackFn)(struct valkeyAsyncContext*, void*, void*);
52
+ typedef struct valkeyCallback {
53
+ struct valkeyCallback *next; /* simple singly linked list */
54
+ valkeyCallbackFn *fn;
55
+ int pending_subs;
56
+ int unsubscribe_sent;
57
+ void *privdata;
58
+ } valkeyCallback;
59
+
60
+ /* List of callbacks for either regular replies or pub/sub */
61
+ typedef struct valkeyCallbackList {
62
+ valkeyCallback *head, *tail;
63
+ } valkeyCallbackList;
64
+
65
+ /* Connection callback prototypes */
66
+ typedef void (valkeyDisconnectCallback)(const struct valkeyAsyncContext*, int status);
67
+ typedef void (valkeyConnectCallback)(const struct valkeyAsyncContext*, int status);
68
+ typedef void (valkeyConnectCallbackNC)(struct valkeyAsyncContext *, int status);
69
+ typedef void(valkeyTimerCallback)(void *timer, void *privdata);
70
+
71
+ /* Context for an async connection to Valkey */
72
+ typedef struct valkeyAsyncContext {
73
+ /* Hold the regular context, so it can be realloc'ed. */
74
+ valkeyContext c;
75
+
76
+ /* Setup error flags so they can be used directly. */
77
+ int err;
78
+ char *errstr;
79
+
80
+ /* Not used by libvalkey */
81
+ void *data;
82
+ void (*dataCleanup)(void *privdata);
83
+
84
+ /* Event library data and hooks */
85
+ struct {
86
+ void *data;
87
+
88
+ /* Hooks that are called when the library expects to start
89
+ * reading/writing. These functions should be idempotent. */
90
+ void (*addRead)(void *privdata);
91
+ void (*delRead)(void *privdata);
92
+ void (*addWrite)(void *privdata);
93
+ void (*delWrite)(void *privdata);
94
+ void (*cleanup)(void *privdata);
95
+ void (*scheduleTimer)(void *privdata, struct timeval tv);
96
+ } ev;
97
+
98
+ /* Called when either the connection is terminated due to an error or per
99
+ * user request. The status is set accordingly (VALKEY_OK, VALKEY_ERR). */
100
+ valkeyDisconnectCallback *onDisconnect;
101
+
102
+ /* Called when the first write event was received. */
103
+ valkeyConnectCallback *onConnect;
104
+ valkeyConnectCallbackNC *onConnectNC;
105
+
106
+ /* Regular command callbacks */
107
+ valkeyCallbackList replies;
108
+
109
+ /* Address used for connect() */
110
+ struct sockaddr *saddr;
111
+ size_t addrlen;
112
+
113
+ /* Subscription callbacks */
114
+ struct {
115
+ valkeyCallbackList replies;
116
+ struct dict *channels;
117
+ struct dict *patterns;
118
+ int pending_unsubs;
119
+ } sub;
120
+
121
+ /* Any configured RESP3 PUSH handler */
122
+ valkeyAsyncPushFn *push_cb;
123
+ } valkeyAsyncContext;
124
+
125
+ /* Functions that proxy to libvalkey */
126
+ valkeyAsyncContext *valkeyAsyncConnectWithOptions(const valkeyOptions *options);
127
+ valkeyAsyncContext *valkeyAsyncConnect(const char *ip, int port);
128
+ valkeyAsyncContext *valkeyAsyncConnectBind(const char *ip, int port, const char *source_addr);
129
+ valkeyAsyncContext *valkeyAsyncConnectBindWithReuse(const char *ip, int port,
130
+ const char *source_addr);
131
+ valkeyAsyncContext *valkeyAsyncConnectUnix(const char *path);
132
+ int valkeyAsyncSetConnectCallback(valkeyAsyncContext *ac, valkeyConnectCallback *fn);
133
+ int valkeyAsyncSetConnectCallbackNC(valkeyAsyncContext *ac, valkeyConnectCallbackNC *fn);
134
+ int valkeyAsyncSetDisconnectCallback(valkeyAsyncContext *ac, valkeyDisconnectCallback *fn);
135
+
136
+ valkeyAsyncPushFn *valkeyAsyncSetPushCallback(valkeyAsyncContext *ac, valkeyAsyncPushFn *fn);
137
+ int valkeyAsyncSetTimeout(valkeyAsyncContext *ac, struct timeval tv);
138
+ void valkeyAsyncDisconnect(valkeyAsyncContext *ac);
139
+ void valkeyAsyncFree(valkeyAsyncContext *ac);
140
+
141
+ /* Handle read/write events */
142
+ void valkeyAsyncHandleRead(valkeyAsyncContext *ac);
143
+ void valkeyAsyncHandleWrite(valkeyAsyncContext *ac);
144
+ void valkeyAsyncHandleTimeout(valkeyAsyncContext *ac);
145
+ void valkeyAsyncRead(valkeyAsyncContext *ac);
146
+ void valkeyAsyncWrite(valkeyAsyncContext *ac);
147
+
148
+ /* Command functions for an async context. Write the command to the
149
+ * output buffer and register the provided callback. */
150
+ int valkeyvAsyncCommand(valkeyAsyncContext *ac, valkeyCallbackFn *fn, void *privdata, const char *format, va_list ap);
151
+ int valkeyAsyncCommand(valkeyAsyncContext *ac, valkeyCallbackFn *fn, void *privdata, const char *format, ...);
152
+ int valkeyAsyncCommandArgv(valkeyAsyncContext *ac, valkeyCallbackFn *fn, void *privdata, int argc, const char **argv, const size_t *argvlen);
153
+ int valkeyAsyncFormattedCommand(valkeyAsyncContext *ac, valkeyCallbackFn *fn, void *privdata, const char *cmd, size_t len);
154
+
155
+ #ifdef __cplusplus
156
+ }
157
+ #endif
158
+
159
+ #endif
@@ -0,0 +1,125 @@
1
+ /* Hash table implementation.
2
+ *
3
+ * This file implements in memory hash tables with insert/del/replace/find/
4
+ * get-random-element operations. Hash tables will auto resize if needed
5
+ * tables of power of two in size are used, collisions are handled by
6
+ * chaining. See the source code for more information... :)
7
+ *
8
+ * Copyright (c) 2006-2010, Salvatore Sanfilippo <antirez at gmail dot com>
9
+ * All rights reserved.
10
+ *
11
+ * Redistribution and use in source and binary forms, with or without
12
+ * modification, are permitted provided that the following conditions are met:
13
+ *
14
+ * * Redistributions of source code must retain the above copyright notice,
15
+ * this list of conditions and the following disclaimer.
16
+ * * Redistributions in binary form must reproduce the above copyright
17
+ * notice, this list of conditions and the following disclaimer in the
18
+ * documentation and/or other materials provided with the distribution.
19
+ * * Neither the name of Redis nor the names of its contributors may be used
20
+ * to endorse or promote products derived from this software without
21
+ * specific prior written permission.
22
+ *
23
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
27
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33
+ * POSSIBILITY OF SUCH DAMAGE.
34
+ */
35
+
36
+ #ifndef __DICT_H
37
+ #define __DICT_H
38
+
39
+ #define DICT_OK 0
40
+ #define DICT_ERR 1
41
+
42
+ /* Unused arguments generate annoying warnings... */
43
+ #define DICT_NOTUSED(V) ((void) V)
44
+
45
+ typedef struct dictEntry {
46
+ void *key;
47
+ void *val;
48
+ struct dictEntry *next;
49
+ } dictEntry;
50
+
51
+ typedef struct dictType {
52
+ unsigned int (*hashFunction)(const void *key);
53
+ void *(*keyDup)(void *privdata, const void *key);
54
+ void *(*valDup)(void *privdata, const void *obj);
55
+ int (*keyCompare)(void *privdata, const void *key1, const void *key2);
56
+ void (*keyDestructor)(void *privdata, void *key);
57
+ void (*valDestructor)(void *privdata, void *obj);
58
+ } dictType;
59
+
60
+ typedef struct dict {
61
+ dictEntry **table;
62
+ dictType *type;
63
+ unsigned long size;
64
+ unsigned long sizemask;
65
+ unsigned long used;
66
+ void *privdata;
67
+ } dict;
68
+
69
+ typedef struct dictIterator {
70
+ dict *ht;
71
+ int index;
72
+ dictEntry *entry, *nextEntry;
73
+ } dictIterator;
74
+
75
+ /* This is the initial size of every hash table */
76
+ #define DICT_HT_INITIAL_SIZE 4
77
+
78
+ /* ------------------------------- Macros ------------------------------------*/
79
+ #define dictFreeEntryVal(ht, entry) \
80
+ if ((ht)->type->valDestructor) \
81
+ (ht)->type->valDestructor((ht)->privdata, (entry)->val)
82
+
83
+ #define dictSetHashVal(ht, entry, _val_) do { \
84
+ if ((ht)->type->valDup) \
85
+ entry->val = (ht)->type->valDup((ht)->privdata, _val_); \
86
+ else \
87
+ entry->val = (_val_); \
88
+ } while(0)
89
+
90
+ #define dictFreeEntryKey(ht, entry) \
91
+ if ((ht)->type->keyDestructor) \
92
+ (ht)->type->keyDestructor((ht)->privdata, (entry)->key)
93
+
94
+ #define dictSetHashKey(ht, entry, _key_) do { \
95
+ if ((ht)->type->keyDup) \
96
+ entry->key = (ht)->type->keyDup((ht)->privdata, _key_); \
97
+ else \
98
+ entry->key = (_key_); \
99
+ } while(0)
100
+
101
+ #define dictCompareHashKeys(ht, key1, key2) \
102
+ (((ht)->type->keyCompare) ? \
103
+ (ht)->type->keyCompare((ht)->privdata, key1, key2) : \
104
+ (key1) == (key2))
105
+
106
+ #define dictHashKey(ht, key) (ht)->type->hashFunction(key)
107
+
108
+ #define dictGetEntryKey(he) ((he)->key)
109
+ #define dictGetEntryVal(he) ((he)->val)
110
+ #define dictSlots(ht) ((ht)->size)
111
+ #define dictSize(ht) ((ht)->used)
112
+
113
+ /* API */
114
+ unsigned int dictGenHashFunction(const unsigned char *buf, int len);
115
+ dict *dictCreate(dictType *type, void *privDataPtr);
116
+ int dictExpand(dict *ht, unsigned long size);
117
+ int dictAdd(dict *ht, void *key, void *val);
118
+ int dictReplace(dict *ht, void *key, void *val);
119
+ int dictDelete(dict *ht, const void *key);
120
+ void dictRelease(dict *ht);
121
+ dictEntry * dictFind(dict *ht, const void *key);
122
+ void dictInitIterator(dictIterator *iter, dict *ht);
123
+ dictEntry *dictNext(dictIterator *iter);
124
+
125
+ #endif /* __DICT_H */
@@ -0,0 +1,57 @@
1
+ /* Extracted from anet.c to work properly with Hiredis error reporting.
2
+ *
3
+ * Copyright (c) 2009-2011, Salvatore Sanfilippo <antirez at gmail dot com>
4
+ * Copyright (c) 2010-2014, Pieter Noordhuis <pcnoordhuis at gmail dot com>
5
+ * Copyright (c) 2015, Matt Stancliff <matt at genges dot com>,
6
+ * Jan-Erik Rediger <janerik at fnordig dot com>
7
+ *
8
+ * All rights reserved.
9
+ *
10
+ * Redistribution and use in source and binary forms, with or without
11
+ * modification, are permitted provided that the following conditions are met:
12
+ *
13
+ * * Redistributions of source code must retain the above copyright notice,
14
+ * this list of conditions and the following disclaimer.
15
+ * * Redistributions in binary form must reproduce the above copyright
16
+ * notice, this list of conditions and the following disclaimer in the
17
+ * documentation and/or other materials provided with the distribution.
18
+ * * Neither the name of Redis nor the names of its contributors may be used
19
+ * to endorse or promote products derived from this software without
20
+ * specific prior written permission.
21
+ *
22
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32
+ * POSSIBILITY OF SUCH DAMAGE.
33
+ */
34
+
35
+ #ifndef VALKEY_NET_H
36
+ #define VALKEY_NET_H
37
+
38
+ #include "valkey.h"
39
+
40
+ void valkeyNetClose(valkeyContext *c);
41
+ ssize_t valkeyNetRead(valkeyContext *c, char *buf, size_t bufcap);
42
+ ssize_t valkeyNetWrite(valkeyContext *c);
43
+
44
+ int valkeyCheckSocketError(valkeyContext *c);
45
+ int valkeyContextSetTimeout(valkeyContext *c, const struct timeval tv);
46
+ int valkeyContextConnectTcp(valkeyContext *c, const char *addr, int port, const struct timeval *timeout);
47
+ int valkeyContextConnectBindTcp(valkeyContext *c, const char *addr, int port,
48
+ const struct timeval *timeout,
49
+ const char *source_addr);
50
+ int valkeyContextConnectUnix(valkeyContext *c, const char *path, const struct timeval *timeout);
51
+ int valkeyKeepAlive(valkeyContext *c, int interval);
52
+ int valkeyCheckConnectDone(valkeyContext *c, int *completed);
53
+
54
+ int valkeySetTcpNoDelay(valkeyContext *c);
55
+ int valkeyContextSetTcpUserTimeout(valkeyContext *c, unsigned int timeout);
56
+
57
+ #endif
@@ -0,0 +1,129 @@
1
+ /*
2
+ * Copyright (c) 2009-2011, Salvatore Sanfilippo <antirez at gmail dot com>
3
+ * Copyright (c) 2010-2011, Pieter Noordhuis <pcnoordhuis at gmail dot com>
4
+ *
5
+ * All rights reserved.
6
+ *
7
+ * Redistribution and use in source and binary forms, with or without
8
+ * modification, are permitted provided that the following conditions are met:
9
+ *
10
+ * * Redistributions of source code must retain the above copyright notice,
11
+ * this list of conditions and the following disclaimer.
12
+ * * Redistributions in binary form must reproduce the above copyright
13
+ * notice, this list of conditions and the following disclaimer in the
14
+ * documentation and/or other materials provided with the distribution.
15
+ * * Neither the name of Redis nor the names of its contributors may be used
16
+ * to endorse or promote products derived from this software without
17
+ * specific prior written permission.
18
+ *
19
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
+ * POSSIBILITY OF SUCH DAMAGE.
30
+ */
31
+
32
+
33
+ #ifndef VALKEY_READ_H
34
+ #define VALKEY_READ_H
35
+ #include <stdio.h> /* for size_t */
36
+
37
+ #define VALKEY_ERR -1
38
+ #define VALKEY_OK 0
39
+
40
+ /* When an error occurs, the err flag in a context is set to hold the type of
41
+ * error that occurred. VALKEY_ERR_IO means there was an I/O error and you
42
+ * should use the "errno" variable to find out what is wrong.
43
+ * For other values, the "errstr" field will hold a description. */
44
+ #define VALKEY_ERR_IO 1 /* Error in read or write */
45
+ #define VALKEY_ERR_EOF 3 /* End of file */
46
+ #define VALKEY_ERR_PROTOCOL 4 /* Protocol error */
47
+ #define VALKEY_ERR_OOM 5 /* Out of memory */
48
+ #define VALKEY_ERR_TIMEOUT 6 /* Timed out */
49
+ #define VALKEY_ERR_OTHER 2 /* Everything else... */
50
+
51
+ #define VALKEY_REPLY_STRING 1
52
+ #define VALKEY_REPLY_ARRAY 2
53
+ #define VALKEY_REPLY_INTEGER 3
54
+ #define VALKEY_REPLY_NIL 4
55
+ #define VALKEY_REPLY_STATUS 5
56
+ #define VALKEY_REPLY_ERROR 6
57
+ #define VALKEY_REPLY_DOUBLE 7
58
+ #define VALKEY_REPLY_BOOL 8
59
+ #define VALKEY_REPLY_MAP 9
60
+ #define VALKEY_REPLY_SET 10
61
+ #define VALKEY_REPLY_ATTR 11
62
+ #define VALKEY_REPLY_PUSH 12
63
+ #define VALKEY_REPLY_BIGNUM 13
64
+ #define VALKEY_REPLY_VERB 14
65
+
66
+ /* Default max unused reader buffer. */
67
+ #define VALKEY_READER_MAX_BUF (1024*16)
68
+
69
+ /* Default multi-bulk element limit */
70
+ #define VALKEY_READER_MAX_ARRAY_ELEMENTS ((1LL<<32) - 1)
71
+
72
+ #ifdef __cplusplus
73
+ extern "C" {
74
+ #endif
75
+
76
+ typedef struct valkeyReadTask {
77
+ int type;
78
+ long long elements; /* number of elements in multibulk container */
79
+ int idx; /* index in parent (array) object */
80
+ void *obj; /* holds user-generated value for a read task */
81
+ struct valkeyReadTask *parent; /* parent task */
82
+ void *privdata; /* user-settable arbitrary field */
83
+ } valkeyReadTask;
84
+
85
+ typedef struct valkeyReplyObjectFunctions {
86
+ void *(*createString)(const valkeyReadTask*, char*, size_t);
87
+ void *(*createArray)(const valkeyReadTask*, size_t);
88
+ void *(*createInteger)(const valkeyReadTask*, long long);
89
+ void *(*createDouble)(const valkeyReadTask*, double, char*, size_t);
90
+ void *(*createNil)(const valkeyReadTask*);
91
+ void *(*createBool)(const valkeyReadTask*, int);
92
+ void (*freeObject)(void*);
93
+ } valkeyReplyObjectFunctions;
94
+
95
+ typedef struct valkeyReader {
96
+ int err; /* Error flags, 0 when there is no error */
97
+ char errstr[128]; /* String representation of error when applicable */
98
+
99
+ char *buf; /* Read buffer */
100
+ size_t pos; /* Buffer cursor */
101
+ size_t len; /* Buffer length */
102
+ size_t maxbuf; /* Max length of unused buffer */
103
+ long long maxelements; /* Max multi-bulk elements */
104
+
105
+ valkeyReadTask **task;
106
+ int tasks;
107
+
108
+ int ridx; /* Index of current read task */
109
+ void *reply; /* Temporary reply pointer */
110
+
111
+ valkeyReplyObjectFunctions *fn;
112
+ void *privdata;
113
+ } valkeyReader;
114
+
115
+ /* Public API for the protocol parser. */
116
+ valkeyReader *valkeyReaderCreateWithFunctions(valkeyReplyObjectFunctions *fn);
117
+ void valkeyReaderFree(valkeyReader *r);
118
+ int valkeyReaderFeed(valkeyReader *r, const char *buf, size_t len);
119
+ int valkeyReaderGetReply(valkeyReader *r, void **reply);
120
+
121
+ #define valkeyReaderSetPrivdata(_r, _p) (int)(((valkeyReader*)(_r))->privdata = (_p))
122
+ #define valkeyReaderGetObject(_r) (((valkeyReader*)(_r))->reply)
123
+ #define valkeyReaderGetError(_r) (((valkeyReader*)(_r))->errstr)
124
+
125
+ #ifdef __cplusplus
126
+ }
127
+ #endif
128
+
129
+ #endif