summaryrefslogtreecommitdiff
path: root/hiredis.h
diff options
context:
space:
mode:
authorPieter Noordhuis <pcnoordhuis@gmail.com>2010-10-18 12:37:33 +0200
committerPieter Noordhuis <pcnoordhuis@gmail.com>2010-10-18 12:37:33 +0200
commit61ba85ce57a340449f9fe1fa6d2796d7afe2c1a3 (patch)
treeb17313c5dbbebdc840a0ceb659e3b905263ec44d /hiredis.h
parent7496458c68d41d946df52fcaf6833ab49cd07b4a (diff)
Move context callbacks into struct and make privdata const
Diffstat (limited to 'hiredis.h')
-rw-r--r--hiredis.h26
1 files changed, 15 insertions, 11 deletions
diff --git a/hiredis.h b/hiredis.h
index 39a0cd6..75419f5 100644
--- a/hiredis.h
+++ b/hiredis.h
@@ -77,10 +77,17 @@ typedef struct redisReplyObjectFunctions {
struct redisContext; /* need forward declaration of redisContext */
/* Callbacks triggered on non-reply events. */
-typedef void (redisContextCallback)(struct redisContext*, void*);
+typedef void (redisContextCallbackFn)(struct redisContext*, const void*);
/* Reply callback prototype and container */
-typedef void redisCallbackFn(struct redisContext*, redisReply*, const void*);
+typedef void (redisCallbackFn)(struct redisContext*, redisReply*, const void*);
+
+/* Callback containers */
+typedef struct redisContextCallback {
+ redisContextCallbackFn *fn;
+ const void *privdata;
+} redisContextCallback;
+
typedef struct redisCallback {
redisCallbackFn *fn;
const void *privdata;
@@ -98,12 +105,9 @@ typedef struct redisContext {
void *reader;
/* Non-reply callbacks */
- redisContextCallback *cbDisconnect;
- void *privdataDisconnect;
- redisContextCallback *cbCommand;
- void *privdataCommand;
- redisContextCallback *cbFree;
- void *privdataFree;
+ redisContextCallback cbDisconnect;
+ redisContextCallback cbCommand;
+ redisContextCallback cbFree;
/* Reply callbacks */
redisCallback *callbacks;
@@ -131,16 +135,16 @@ int redisProcessCallbacks(redisContext *c);
/* The disconnect callback is called *immediately* when redisDisconnect()
* is called. It is called only once for every redisContext (since hiredis
* currently does not support reconnecting an existing context). */
-void redisSetDisconnectCallback(redisContext *c, redisContextCallback *fn, void *privdata);
+void redisSetDisconnectCallback(redisContext *c, redisContextCallbackFn *fn, const void *privdata);
/* The command callback is called every time redisCommand() is called in a
* non-blocking context. It is called *after* the formatted command has been
* appended to the write buffer. */
-void redisSetCommandCallback(redisContext *c, redisContextCallback *fn, void *privdata);
+void redisSetCommandCallback(redisContext *c, redisContextCallbackFn *fn, const void *privdata);
/* The free callback is called *before* all allocations are free'd. Use it to
* release resources that depend/use the redisContext that is being free'd. */
-void redisSetFreeCallback(redisContext *c, redisContextCallback *fn, void *privdata);
+void redisSetFreeCallback(redisContext *c, redisContextCallbackFn *fn, const void *privdata);
/* Issue a command to Redis. In a blocking context, it returns the reply. When
* an error occurs, it returns NULL and you should read redisContext->error