summaryrefslogtreecommitdiff
path: root/hiredis.h
diff options
context:
space:
mode:
authorPieter Noordhuis <pcnoordhuis@gmail.com>2010-09-20 22:04:35 +0200
committerPieter Noordhuis <pcnoordhuis@gmail.com>2010-09-20 22:04:35 +0200
commitb1bedf5c6df6290249850f73912d9fc566782b64 (patch)
tree9ec026db44587e9a6ba2f6babbb48ce7b46476be /hiredis.h
parent0a6e3b38e71de07226f88b5edd4147405d4b7bef (diff)
Use a set of function pointers for building the reply
Allows libraries to wrap the reply parsing code and build the reply in a streaming fashion. Reply objects can immediately be initialized to the required type without having to convert an intermediary format.
Diffstat (limited to 'hiredis.h')
-rw-r--r--hiredis.h14
1 files changed, 11 insertions, 3 deletions
diff --git a/hiredis.h b/hiredis.h
index 1f30b79..c354935 100644
--- a/hiredis.h
+++ b/hiredis.h
@@ -49,17 +49,25 @@ typedef struct redisReply {
struct redisReply **element; /* elements vector for REDIS_REPLY_ARRAY */
} redisReply;
-
typedef struct redisReadTask {
int type;
void *parent; /* optional pointer to parent object */
int idx; /* index in parent (array) object */
} redisReadTask;
+typedef struct redisReplyObjectFunctions {
+ void *(*createString)(redisReadTask*, char*, size_t);
+ void *(*createArray)(redisReadTask*, int);
+ void *(*createInteger)(redisReadTask*, long long);
+ void *(*createNil)(redisReadTask*);
+ void (*freeObject)(void*);
+} redisReplyFunctions;
+
redisReply *redisConnect(int *fd, const char *ip, int port);
-void freeReplyObject(redisReply *r);
+void freeReplyObject(void *reply);
redisReply *redisCommand(int fd, const char *format, ...);
-void *redisCreateReplyReader();
+void *redisCreateReplyReader(redisReplyFunctions *fn);
+void *redisGetReplyObjectFromReplyReader(void *reader);
void redisFreeReplyReader(void *ptr);
int redisIsReplyReaderEmpty(void *ptr);
void *redisFeedReplyReader(void *reader, char *buf, int len);