Rename defines HIREDIS_* to REDIS_*
This commit is contained in:
parent
bb668e1b94
commit
e6fb160b44
22
hiredis.c
22
hiredis.c
@ -572,13 +572,13 @@ static int redisContextConnect(redisContext *c, const char *ip, int port) {
|
|||||||
|
|
||||||
if (c->fd == ANET_ERR) {
|
if (c->fd == ANET_ERR) {
|
||||||
c->error = c->fn->createError(err,strlen(err));
|
c->error = c->fn->createError(err,strlen(err));
|
||||||
return HIREDIS_ERR;
|
return REDIS_ERR;
|
||||||
}
|
}
|
||||||
if (anetTcpNoDelay(err,c->fd) == ANET_ERR) {
|
if (anetTcpNoDelay(err,c->fd) == ANET_ERR) {
|
||||||
c->error = c->fn->createError(err,strlen(err));
|
c->error = c->fn->createError(err,strlen(err));
|
||||||
return HIREDIS_ERR;
|
return REDIS_ERR;
|
||||||
}
|
}
|
||||||
return HIREDIS_OK;
|
return REDIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static redisContext *redisContextInit(redisReplyFunctions *fn) {
|
static redisContext *redisContextInit(redisReplyFunctions *fn) {
|
||||||
@ -625,16 +625,16 @@ int redisBufferRead(redisContext *c) {
|
|||||||
/* Set error in context */
|
/* Set error in context */
|
||||||
c->error = formatError(c->fn,
|
c->error = formatError(c->fn,
|
||||||
"Error reading from socket: %s", strerror(errno));
|
"Error reading from socket: %s", strerror(errno));
|
||||||
return HIREDIS_ERR;
|
return REDIS_ERR;
|
||||||
}
|
}
|
||||||
} else if (nread == 0) {
|
} else if (nread == 0) {
|
||||||
c->error = formatError(c->fn,
|
c->error = formatError(c->fn,
|
||||||
"Server closed the connection");
|
"Server closed the connection");
|
||||||
return HIREDIS_ERR;
|
return REDIS_ERR;
|
||||||
} else {
|
} else {
|
||||||
redisReplyReaderFeed(c->reader,buf,nread);
|
redisReplyReaderFeed(c->reader,buf,nread);
|
||||||
}
|
}
|
||||||
return HIREDIS_OK;
|
return REDIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void redisPopCallback(redisContext *c) {
|
static void redisPopCallback(redisContext *c) {
|
||||||
@ -659,7 +659,7 @@ int redisProcessCallbacks(redisContext *c) {
|
|||||||
cb.fn(c,reply,cb.privdata);
|
cb.fn(c,reply,cb.privdata);
|
||||||
redisPopCallback(c);
|
redisPopCallback(c);
|
||||||
}
|
}
|
||||||
return HIREDIS_OK;
|
return REDIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Use this function to try and write the entire output buffer to the
|
/* Use this function to try and write the entire output buffer to the
|
||||||
@ -673,7 +673,7 @@ int redisBufferWrite(redisContext *c, int *done) {
|
|||||||
/* Set error in context */
|
/* Set error in context */
|
||||||
c->error = formatError(c->fn,
|
c->error = formatError(c->fn,
|
||||||
"Error writing to socket: %s", strerror(errno));
|
"Error writing to socket: %s", strerror(errno));
|
||||||
return HIREDIS_ERR;
|
return REDIS_ERR;
|
||||||
}
|
}
|
||||||
} else if (nwritten > 0) {
|
} else if (nwritten > 0) {
|
||||||
if (nwritten == (signed)sdslen(c->obuf)) {
|
if (nwritten == (signed)sdslen(c->obuf)) {
|
||||||
@ -684,7 +684,7 @@ int redisBufferWrite(redisContext *c, int *done) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (done != NULL) *done = (sdslen(c->obuf) == 0);
|
if (done != NULL) *done = (sdslen(c->obuf) == 0);
|
||||||
return HIREDIS_OK;
|
return REDIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void* redisCommandWrite(redisContext *c, redisCallback *cb, char *str, size_t len) {
|
static void* redisCommandWrite(redisContext *c, redisCallback *cb, char *str, size_t len) {
|
||||||
@ -695,12 +695,12 @@ static void* redisCommandWrite(redisContext *c, redisCallback *cb, char *str, si
|
|||||||
/* Read reply immediately when the context is blocking. */
|
/* Read reply immediately when the context is blocking. */
|
||||||
if (c->flags & HIREDIS_BLOCK) {
|
if (c->flags & HIREDIS_BLOCK) {
|
||||||
do { /* Write until done. */
|
do { /* Write until done. */
|
||||||
if (redisBufferWrite(c,&wdone) == HIREDIS_ERR)
|
if (redisBufferWrite(c,&wdone) == REDIS_ERR)
|
||||||
return c->error;
|
return c->error;
|
||||||
} while (!wdone);
|
} while (!wdone);
|
||||||
|
|
||||||
do { /* Read until there is a reply. */
|
do { /* Read until there is a reply. */
|
||||||
if (redisBufferRead(c) == HIREDIS_ERR)
|
if (redisBufferRead(c) == REDIS_ERR)
|
||||||
return c->error;
|
return c->error;
|
||||||
reply = redisGetReply(c);
|
reply = redisGetReply(c);
|
||||||
} while (reply == NULL);
|
} while (reply == NULL);
|
||||||
|
@ -30,8 +30,8 @@
|
|||||||
#ifndef __HIREDIS_H
|
#ifndef __HIREDIS_H
|
||||||
#define __HIREDIS_H
|
#define __HIREDIS_H
|
||||||
|
|
||||||
#define HIREDIS_ERR -1
|
#define REDIS_ERR -1
|
||||||
#define HIREDIS_OK 0
|
#define REDIS_OK 0
|
||||||
|
|
||||||
/* Connection type can be blocking or non-blocking and is set in the
|
/* Connection type can be blocking or non-blocking and is set in the
|
||||||
* least significant bit of the flags field in redisContext. */
|
* least significant bit of the flags field in redisContext. */
|
||||||
|
Loading…
Reference in New Issue
Block a user