X-Git-Url: https://git.saurik.com/redis.git/blobdiff_plain/3b5e72d402345507856b00bb67a91942f4f1a49d..9703b1b3dc59aa76a314373fff748e26bdd0466f:/deps/hiredis/hiredis.h diff --git a/deps/hiredis/hiredis.h b/deps/hiredis/hiredis.h index 0a6a9a10..f4452091 100644 --- a/deps/hiredis/hiredis.h +++ b/deps/hiredis/hiredis.h @@ -1,5 +1,7 @@ /* * Copyright (c) 2009-2010, Salvatore Sanfilippo + * Copyright (c) 2010, Pieter Noordhuis + * * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -31,10 +33,11 @@ #define __HIREDIS_H #include /* for size_t */ #include /* for va_list */ +#include /* for struct timeval */ #define HIREDIS_MAJOR 0 #define HIREDIS_MINOR 9 -#define HIREDIS_PATCH 0 +#define HIREDIS_PATCH 2 #define REDIS_ERR -1 #define REDIS_OK 0 @@ -62,12 +65,26 @@ * should be terminated once all replies have been read. */ #define REDIS_DISCONNECTING 0x4 -#define REDIS_REPLY_ERROR 0 +/* Flag specific to the async API which means that the context should be clean + * up as soon as possible. */ +#define REDIS_FREEING 0x8 + +/* Flag that is set when an async callback is executed. */ +#define REDIS_IN_CALLBACK 0x10 + +/* Flag that is set when the async context has one or more subscriptions. */ +#define REDIS_SUBSCRIBED 0x20 + #define REDIS_REPLY_STRING 1 #define REDIS_REPLY_ARRAY 2 #define REDIS_REPLY_INTEGER 3 #define REDIS_REPLY_NIL 4 #define REDIS_REPLY_STATUS 5 +#define REDIS_REPLY_ERROR 6 + +#ifdef __cplusplus +extern "C" { +#endif /* This is the reply object returned by redisCommand() */ typedef struct redisReply { @@ -82,8 +99,10 @@ typedef struct redisReply { typedef struct redisReadTask { int type; int elements; /* number of elements in multibulk container */ - void *parent; /* optional pointer to parent object */ int idx; /* index in parent (array) object */ + void *obj; /* holds user-generated value for a read task */ + struct redisReadTask *parent; /* parent task */ + void *privdata; /* user-settable arbitrary field */ } redisReadTask; typedef struct redisReplyObjectFunctions { @@ -110,12 +129,13 @@ typedef struct redisContext { } redisContext; void freeReplyObject(void *reply); -void *redisReplyReaderCreate(); +void *redisReplyReaderCreate(void); int redisReplyReaderSetReplyObjectFunctions(void *reader, redisReplyObjectFunctions *fn); +int redisReplyReaderSetPrivdata(void *reader, void *privdata); void *redisReplyReaderGetObject(void *reader); char *redisReplyReaderGetError(void *reader); void redisReplyReaderFree(void *ptr); -void redisReplyReaderFeed(void *reader, char *buf, int len); +void redisReplyReaderFeed(void *reader, const char *buf, size_t len); int redisReplyReaderGetReply(void *reader, void **reply); /* Functions to format a command according to the protocol. */ @@ -124,9 +144,12 @@ int redisFormatCommand(char **target, const char *format, ...); int redisFormatCommandArgv(char **target, int argc, const char **argv, const size_t *argvlen); redisContext *redisConnect(const char *ip, int port); +redisContext *redisConnectWithTimeout(const char *ip, int port, struct timeval tv); redisContext *redisConnectNonBlock(const char *ip, int port); redisContext *redisConnectUnix(const char *path); +redisContext *redisConnectUnixWithTimeout(const char *path, struct timeval tv); redisContext *redisConnectUnixNonBlock(const char *path); +int redisSetTimeout(redisContext *c, struct timeval tv); int redisSetReplyObjectFunctions(redisContext *c, redisReplyObjectFunctions *fn); void redisFree(redisContext *c); int redisBufferRead(redisContext *c); @@ -154,4 +177,8 @@ void *redisvCommand(redisContext *c, const char *format, va_list ap); void *redisCommand(redisContext *c, const char *format, ...); void *redisCommandArgv(redisContext *c, int argc, const char **argv, const size_t *argvlen); +#ifdef __cplusplus +} +#endif + #endif