summaryrefslogtreecommitdiff
path: root/adapters
diff options
context:
space:
mode:
Diffstat (limited to 'adapters')
-rw-r--r--adapters/ae.h74
-rw-r--r--adapters/glib.h98
-rw-r--r--adapters/ivykis.h74
-rw-r--r--adapters/libev.h94
-rw-r--r--adapters/libevent.h106
-rw-r--r--adapters/libhv.h80
-rw-r--r--adapters/libsdevent.h104
-rw-r--r--adapters/libuv.h90
-rw-r--r--adapters/macosx.h110
-rw-r--r--adapters/poll.h102
-rw-r--r--adapters/qt.h64
-rw-r--r--adapters/redictmoduleapi.h122
12 files changed, 559 insertions, 559 deletions
diff --git a/adapters/ae.h b/adapters/ae.h
index 44db8ee..1edcd0e 100644
--- a/adapters/ae.h
+++ b/adapters/ae.h
@@ -9,45 +9,45 @@
*
*/
-#ifndef __HIREDIS_AE_H__
-#define __HIREDIS_AE_H__
+#ifndef __HIREDICT_AE_H__
+#define __HIREDICT_AE_H__
#include <sys/types.h>
#include <ae.h>
#include "../hiredict.h"
#include "../async.h"
-typedef struct redisAeEvents {
- redisAsyncContext *context;
+typedef struct redictAeEvents {
+ redictAsyncContext *context;
aeEventLoop *loop;
int fd;
int reading, writing;
-} redisAeEvents;
+} redictAeEvents;
-static void redisAeReadEvent(aeEventLoop *el, int fd, void *privdata, int mask) {
+static void redictAeReadEvent(aeEventLoop *el, int fd, void *privdata, int mask) {
((void)el); ((void)fd); ((void)mask);
- redisAeEvents *e = (redisAeEvents*)privdata;
- redisAsyncHandleRead(e->context);
+ redictAeEvents *e = (redictAeEvents*)privdata;
+ redictAsyncHandleRead(e->context);
}
-static void redisAeWriteEvent(aeEventLoop *el, int fd, void *privdata, int mask) {
+static void redictAeWriteEvent(aeEventLoop *el, int fd, void *privdata, int mask) {
((void)el); ((void)fd); ((void)mask);
- redisAeEvents *e = (redisAeEvents*)privdata;
- redisAsyncHandleWrite(e->context);
+ redictAeEvents *e = (redictAeEvents*)privdata;
+ redictAsyncHandleWrite(e->context);
}
-static void redisAeAddRead(void *privdata) {
- redisAeEvents *e = (redisAeEvents*)privdata;
+static void redictAeAddRead(void *privdata) {
+ redictAeEvents *e = (redictAeEvents*)privdata;
aeEventLoop *loop = e->loop;
if (!e->reading) {
e->reading = 1;
- aeCreateFileEvent(loop,e->fd,AE_READABLE,redisAeReadEvent,e);
+ aeCreateFileEvent(loop,e->fd,AE_READABLE,redictAeReadEvent,e);
}
}
-static void redisAeDelRead(void *privdata) {
- redisAeEvents *e = (redisAeEvents*)privdata;
+static void redictAeDelRead(void *privdata) {
+ redictAeEvents *e = (redictAeEvents*)privdata;
aeEventLoop *loop = e->loop;
if (e->reading) {
e->reading = 0;
@@ -55,17 +55,17 @@ static void redisAeDelRead(void *privdata) {
}
}
-static void redisAeAddWrite(void *privdata) {
- redisAeEvents *e = (redisAeEvents*)privdata;
+static void redictAeAddWrite(void *privdata) {
+ redictAeEvents *e = (redictAeEvents*)privdata;
aeEventLoop *loop = e->loop;
if (!e->writing) {
e->writing = 1;
- aeCreateFileEvent(loop,e->fd,AE_WRITABLE,redisAeWriteEvent,e);
+ aeCreateFileEvent(loop,e->fd,AE_WRITABLE,redictAeWriteEvent,e);
}
}
-static void redisAeDelWrite(void *privdata) {
- redisAeEvents *e = (redisAeEvents*)privdata;
+static void redictAeDelWrite(void *privdata) {
+ redictAeEvents *e = (redictAeEvents*)privdata;
aeEventLoop *loop = e->loop;
if (e->writing) {
e->writing = 0;
@@ -73,25 +73,25 @@ static void redisAeDelWrite(void *privdata) {
}
}
-static void redisAeCleanup(void *privdata) {
- redisAeEvents *e = (redisAeEvents*)privdata;
- redisAeDelRead(privdata);
- redisAeDelWrite(privdata);
+static void redictAeCleanup(void *privdata) {
+ redictAeEvents *e = (redictAeEvents*)privdata;
+ redictAeDelRead(privdata);
+ redictAeDelWrite(privdata);
hi_free(e);
}
-static int redisAeAttach(aeEventLoop *loop, redisAsyncContext *ac) {
- redisContext *c = &(ac->c);
- redisAeEvents *e;
+static int redictAeAttach(aeEventLoop *loop, redictAsyncContext *ac) {
+ redictContext *c = &(ac->c);
+ redictAeEvents *e;
/* Nothing should be attached when something is already attached */
if (ac->ev.data != NULL)
- return REDIS_ERR;
+ return REDICT_ERR;
/* Create container for context and r/w events */
- e = (redisAeEvents*)hi_malloc(sizeof(*e));
+ e = (redictAeEvents*)hi_malloc(sizeof(*e));
if (e == NULL)
- return REDIS_ERR;
+ return REDICT_ERR;
e->context = ac;
e->loop = loop;
@@ -99,13 +99,13 @@ static int redisAeAttach(aeEventLoop *loop, redisAsyncContext *ac) {
e->reading = e->writing = 0;
/* Register functions to start/stop listening for events */
- ac->ev.addRead = redisAeAddRead;
- ac->ev.delRead = redisAeDelRead;
- ac->ev.addWrite = redisAeAddWrite;
- ac->ev.delWrite = redisAeDelWrite;
- ac->ev.cleanup = redisAeCleanup;
+ ac->ev.addRead = redictAeAddRead;
+ ac->ev.delRead = redictAeDelRead;
+ ac->ev.addWrite = redictAeAddWrite;
+ ac->ev.delWrite = redictAeDelWrite;
+ ac->ev.cleanup = redictAeCleanup;
ac->ev.data = e;
- return REDIS_OK;
+ return REDICT_OK;
}
#endif
diff --git a/adapters/glib.h b/adapters/glib.h
index f3143ed..84490c8 100644
--- a/adapters/glib.h
+++ b/adapters/glib.h
@@ -9,8 +9,8 @@
*
*/
-#ifndef __HIREDIS_GLIB_H__
-#define __HIREDIS_GLIB_H__
+#ifndef __HIREDICT_GLIB_H__
+#define __HIREDICT_GLIB_H__
#include <glib.h>
@@ -20,55 +20,55 @@
typedef struct
{
GSource source;
- redisAsyncContext *ac;
+ redictAsyncContext *ac;
GPollFD poll_fd;
-} RedisSource;
+} RedictSource;
static void
-redis_source_add_read (gpointer data)
+redict_source_add_read (gpointer data)
{
- RedisSource *source = (RedisSource *)data;
+ RedictSource *source = (RedictSource *)data;
g_return_if_fail(source);
source->poll_fd.events |= G_IO_IN;
g_main_context_wakeup(g_source_get_context((GSource *)data));
}
static void
-redis_source_del_read (gpointer data)
+redict_source_del_read (gpointer data)
{
- RedisSource *source = (RedisSource *)data;
+ RedictSource *source = (RedictSource *)data;
g_return_if_fail(source);
source->poll_fd.events &= ~G_IO_IN;
g_main_context_wakeup(g_source_get_context((GSource *)data));
}
static void
-redis_source_add_write (gpointer data)
+redict_source_add_write (gpointer data)
{
- RedisSource *source = (RedisSource *)data;
+ RedictSource *source = (RedictSource *)data;
g_return_if_fail(source);
source->poll_fd.events |= G_IO_OUT;
g_main_context_wakeup(g_source_get_context((GSource *)data));
}
static void
-redis_source_del_write (gpointer data)
+redict_source_del_write (gpointer data)
{
- RedisSource *source = (RedisSource *)data;
+ RedictSource *source = (RedictSource *)data;
g_return_if_fail(source);
source->poll_fd.events &= ~G_IO_OUT;
g_main_context_wakeup(g_source_get_context((GSource *)data));
}
static void
-redis_source_cleanup (gpointer data)
+redict_source_cleanup (gpointer data)
{
- RedisSource *source = (RedisSource *)data;
+ RedictSource *source = (RedictSource *)data;
g_return_if_fail(source);
- redis_source_del_read(source);
- redis_source_del_write(source);
+ redict_source_del_read(source);
+ redict_source_del_write(source);
/*
* It is not our responsibility to remove ourself from the
* current main loop. However, we will remove the GPollFD.
@@ -80,36 +80,36 @@ redis_source_cleanup (gpointer data)
}
static gboolean
-redis_source_prepare (GSource *source,
+redict_source_prepare (GSource *source,
gint *timeout_)
{
- RedisSource *redis = (RedisSource *)source;
+ RedictSource *redict = (RedictSource *)source;
*timeout_ = -1;
- return !!(redis->poll_fd.events & redis->poll_fd.revents);
+ return !!(redict->poll_fd.events & redict->poll_fd.revents);
}
static gboolean
-redis_source_check (GSource *source)
+redict_source_check (GSource *source)
{
- RedisSource *redis = (RedisSource *)source;
- return !!(redis->poll_fd.events & redis->poll_fd.revents);
+ RedictSource *redict = (RedictSource *)source;
+ return !!(redict->poll_fd.events & redict->poll_fd.revents);
}
static gboolean
-redis_source_dispatch (GSource *source,
+redict_source_dispatch (GSource *source,
GSourceFunc callback,
gpointer user_data)
{
- RedisSource *redis = (RedisSource *)source;
+ RedictSource *redict = (RedictSource *)source;
- if ((redis->poll_fd.revents & G_IO_OUT)) {
- redisAsyncHandleWrite(redis->ac);
- redis->poll_fd.revents &= ~G_IO_OUT;
+ if ((redict->poll_fd.revents & G_IO_OUT)) {
+ redictAsyncHandleWrite(redict->ac);
+ redict->poll_fd.revents &= ~G_IO_OUT;
}
- if ((redis->poll_fd.revents & G_IO_IN)) {
- redisAsyncHandleRead(redis->ac);
- redis->poll_fd.revents &= ~G_IO_IN;
+ if ((redict->poll_fd.revents & G_IO_IN)) {
+ redictAsyncHandleRead(redict->ac);
+ redict->poll_fd.revents &= ~G_IO_IN;
}
if (callback) {
@@ -120,31 +120,31 @@ redis_source_dispatch (GSource *source,
}
static void
-redis_source_finalize (GSource *source)
+redict_source_finalize (GSource *source)
{
- RedisSource *redis = (RedisSource *)source;
+ RedictSource *redict = (RedictSource *)source;
- if (redis->poll_fd.fd >= 0) {
- g_source_remove_poll(source, &redis->poll_fd);
- redis->poll_fd.fd = -1;
+ if (redict->poll_fd.fd >= 0) {
+ g_source_remove_poll(source, &redict->poll_fd);
+ redict->poll_fd.fd = -1;
}
}
static GSource *
-redis_source_new (redisAsyncContext *ac)
+redict_source_new (redictAsyncContext *ac)
{
static GSourceFuncs source_funcs = {
- .prepare = redis_source_prepare,
- .check = redis_source_check,
- .dispatch = redis_source_dispatch,
- .finalize = redis_source_finalize,
+ .prepare = redict_source_prepare,
+ .check = redict_source_check,
+ .dispatch = redict_source_dispatch,
+ .finalize = redict_source_finalize,
};
- redisContext *c = &ac->c;
- RedisSource *source;
+ redictContext *c = &ac->c;
+ RedictSource *source;
g_return_val_if_fail(ac != NULL, NULL);
- source = (RedisSource *)g_source_new(&source_funcs, sizeof *source);
+ source = (RedictSource *)g_source_new(&source_funcs, sizeof *source);
if (source == NULL)
return NULL;
@@ -154,14 +154,14 @@ redis_source_new (redisAsyncContext *ac)
source->poll_fd.revents = 0;
g_source_add_poll((GSource *)source, &source->poll_fd);
- ac->ev.addRead = redis_source_add_read;
- ac->ev.delRead = redis_source_del_read;
- ac->ev.addWrite = redis_source_add_write;
- ac->ev.delWrite = redis_source_del_write;
- ac->ev.cleanup = redis_source_cleanup;
+ ac->ev.addRead = redict_source_add_read;
+ ac->ev.delRead = redict_source_del_read;
+ ac->ev.addWrite = redict_source_add_write;
+ ac->ev.delWrite = redict_source_del_write;
+ ac->ev.cleanup = redict_source_cleanup;
ac->ev.data = source;
return (GSource *)source;
}
-#endif /* __HIREDIS_GLIB_H__ */
+#endif /* __HIREDICT_GLIB_H__ */
diff --git a/adapters/ivykis.h b/adapters/ivykis.h
index 544723d..a8468d8 100644
--- a/adapters/ivykis.h
+++ b/adapters/ivykis.h
@@ -9,87 +9,87 @@
*
*/
-#ifndef __HIREDIS_IVYKIS_H__
-#define __HIREDIS_IVYKIS_H__
+#ifndef __HIREDICT_IVYKIS_H__
+#define __HIREDICT_IVYKIS_H__
#include <iv.h>
#include "../hiredict.h"
#include "../async.h"
-typedef struct redisIvykisEvents {
- redisAsyncContext *context;
+typedef struct redictIvykisEvents {
+ redictAsyncContext *context;
struct iv_fd fd;
-} redisIvykisEvents;
+} redictIvykisEvents;
-static void redisIvykisReadEvent(void *arg) {
- redisAsyncContext *context = (redisAsyncContext *)arg;
- redisAsyncHandleRead(context);
+static void redictIvykisReadEvent(void *arg) {
+ redictAsyncContext *context = (redictAsyncContext *)arg;
+ redictAsyncHandleRead(context);
}
-static void redisIvykisWriteEvent(void *arg) {
- redisAsyncContext *context = (redisAsyncContext *)arg;
- redisAsyncHandleWrite(context);
+static void redictIvykisWriteEvent(void *arg) {
+ redictAsyncContext *context = (redictAsyncContext *)arg;
+ redictAsyncHandleWrite(context);
}
-static void redisIvykisAddRead(void *privdata) {
- redisIvykisEvents *e = (redisIvykisEvents*)privdata;
- iv_fd_set_handler_in(&e->fd, redisIvykisReadEvent);
+static void redictIvykisAddRead(void *privdata) {
+ redictIvykisEvents *e = (redictIvykisEvents*)privdata;
+ iv_fd_set_handler_in(&e->fd, redictIvykisReadEvent);
}
-static void redisIvykisDelRead(void *privdata) {
- redisIvykisEvents *e = (redisIvykisEvents*)privdata;
+static void redictIvykisDelRead(void *privdata) {
+ redictIvykisEvents *e = (redictIvykisEvents*)privdata;
iv_fd_set_handler_in(&e->fd, NULL);
}
-static void redisIvykisAddWrite(void *privdata) {
- redisIvykisEvents *e = (redisIvykisEvents*)privdata;
- iv_fd_set_handler_out(&e->fd, redisIvykisWriteEvent);
+static void redictIvykisAddWrite(void *privdata) {
+ redictIvykisEvents *e = (redictIvykisEvents*)privdata;
+ iv_fd_set_handler_out(&e->fd, redictIvykisWriteEvent);
}
-static void redisIvykisDelWrite(void *privdata) {
- redisIvykisEvents *e = (redisIvykisEvents*)privdata;
+static void redictIvykisDelWrite(void *privdata) {
+ redictIvykisEvents *e = (redictIvykisEvents*)privdata;
iv_fd_set_handler_out(&e->fd, NULL);
}
-static void redisIvykisCleanup(void *privdata) {
- redisIvykisEvents *e = (redisIvykisEvents*)privdata;
+static void redictIvykisCleanup(void *privdata) {
+ redictIvykisEvents *e = (redictIvykisEvents*)privdata;
iv_fd_unregister(&e->fd);
hi_free(e);
}
-static int redisIvykisAttach(redisAsyncContext *ac) {
- redisContext *c = &(ac->c);
- redisIvykisEvents *e;
+static int redictIvykisAttach(redictAsyncContext *ac) {
+ redictContext *c = &(ac->c);
+ redictIvykisEvents *e;
/* Nothing should be attached when something is already attached */
if (ac->ev.data != NULL)
- return REDIS_ERR;
+ return REDICT_ERR;
/* Create container for context and r/w events */
- e = (redisIvykisEvents*)hi_malloc(sizeof(*e));
+ e = (redictIvykisEvents*)hi_malloc(sizeof(*e));
if (e == NULL)
- return REDIS_ERR;
+ return REDICT_ERR;
e->context = ac;
/* Register functions to start/stop listening for events */
- ac->ev.addRead = redisIvykisAddRead;
- ac->ev.delRead = redisIvykisDelRead;
- ac->ev.addWrite = redisIvykisAddWrite;
- ac->ev.delWrite = redisIvykisDelWrite;
- ac->ev.cleanup = redisIvykisCleanup;
+ ac->ev.addRead = redictIvykisAddRead;
+ ac->ev.delRead = redictIvykisDelRead;
+ ac->ev.addWrite = redictIvykisAddWrite;
+ ac->ev.delWrite = redictIvykisDelWrite;
+ ac->ev.cleanup = redictIvykisCleanup;
ac->ev.data = e;
/* Initialize and install read/write events */
IV_FD_INIT(&e->fd);
e->fd.fd = c->fd;
- e->fd.handler_in = redisIvykisReadEvent;
- e->fd.handler_out = redisIvykisWriteEvent;
+ e->fd.handler_in = redictIvykisReadEvent;
+ e->fd.handler_out = redictIvykisWriteEvent;
e->fd.handler_err = NULL;
e->fd.cookie = e->context;
iv_fd_register(&e->fd);
- return REDIS_OK;
+ return REDICT_OK;
}
#endif
diff --git a/adapters/libev.h b/adapters/libev.h
index 265e642..9aa841e 100644
--- a/adapters/libev.h
+++ b/adapters/libev.h
@@ -11,44 +11,44 @@
*
*/
-#ifndef __HIREDIS_LIBEV_H__
-#define __HIREDIS_LIBEV_H__
+#ifndef __HIREDICT_LIBEV_H__
+#define __HIREDICT_LIBEV_H__
#include <stdlib.h>
#include <sys/types.h>
#include <ev.h>
#include "../hiredict.h"
#include "../async.h"
-typedef struct redisLibevEvents {
- redisAsyncContext *context;
+typedef struct redictLibevEvents {
+ redictAsyncContext *context;
struct ev_loop *loop;
int reading, writing;
ev_io rev, wev;
ev_timer timer;
-} redisLibevEvents;
+} redictLibevEvents;
-static void redisLibevReadEvent(EV_P_ ev_io *watcher, int revents) {
+static void redictLibevReadEvent(EV_P_ ev_io *watcher, int revents) {
#if EV_MULTIPLICITY
((void)EV_A);
#endif
((void)revents);
- redisLibevEvents *e = (redisLibevEvents*)watcher->data;
- redisAsyncHandleRead(e->context);
+ redictLibevEvents *e = (redictLibevEvents*)watcher->data;
+ redictAsyncHandleRead(e->context);
}
-static void redisLibevWriteEvent(EV_P_ ev_io *watcher, int revents) {
+static void redictLibevWriteEvent(EV_P_ ev_io *watcher, int revents) {
#if EV_MULTIPLICITY
((void)EV_A);
#endif
((void)revents);
- redisLibevEvents *e = (redisLibevEvents*)watcher->data;
- redisAsyncHandleWrite(e->context);
+ redictLibevEvents *e = (redictLibevEvents*)watcher->data;
+ redictAsyncHandleWrite(e->context);
}
-static void redisLibevAddRead(void *privdata) {
- redisLibevEvents *e = (redisLibevEvents*)privdata;
+static void redictLibevAddRead(void *privdata) {
+ redictLibevEvents *e = (redictLibevEvents*)privdata;
#if EV_MULTIPLICITY
struct ev_loop *loop = e->loop;
#endif
@@ -58,8 +58,8 @@ static void redisLibevAddRead(void *privdata) {
}
}
-static void redisLibevDelRead(void *privdata) {
- redisLibevEvents *e = (redisLibevEvents*)privdata;
+static void redictLibevDelRead(void *privdata) {
+ redictLibevEvents *e = (redictLibevEvents*)privdata;
#if EV_MULTIPLICITY
struct ev_loop *loop = e->loop;
#endif
@@ -69,8 +69,8 @@ static void redisLibevDelRead(void *privdata) {
}
}
-static void redisLibevAddWrite(void *privdata) {
- redisLibevEvents *e = (redisLibevEvents*)privdata;
+static void redictLibevAddWrite(void *privdata) {
+ redictLibevEvents *e = (redictLibevEvents*)privdata;
#if EV_MULTIPLICITY
struct ev_loop *loop = e->loop;
#endif
@@ -80,8 +80,8 @@ static void redisLibevAddWrite(void *privdata) {
}
}
-static void redisLibevDelWrite(void *privdata) {
- redisLibevEvents *e = (redisLibevEvents*)privdata;
+static void redictLibevDelWrite(void *privdata) {
+ redictLibevEvents *e = (redictLibevEvents*)privdata;
#if EV_MULTIPLICITY
struct ev_loop *loop = e->loop;
#endif
@@ -91,39 +91,39 @@ static void redisLibevDelWrite(void *privdata) {
}
}
-static void redisLibevStopTimer(void *privdata) {
- redisLibevEvents *e = (redisLibevEvents*)privdata;
+static void redictLibevStopTimer(void *privdata) {
+ redictLibevEvents *e = (redictLibevEvents*)privdata;
#if EV_MULTIPLICITY
struct ev_loop *loop = e->loop;
#endif
ev_timer_stop(EV_A_ &e->timer);
}
-static void redisLibevCleanup(void *privdata) {
- redisLibevEvents *e = (redisLibevEvents*)privdata;
- redisLibevDelRead(privdata);
- redisLibevDelWrite(privdata);
- redisLibevStopTimer(privdata);
+static void redictLibevCleanup(void *privdata) {
+ redictLibevEvents *e = (redictLibevEvents*)privdata;
+ redictLibevDelRead(privdata);
+ redictLibevDelWrite(privdata);
+ redictLibevStopTimer(privdata);
hi_free(e);
}
-static void redisLibevTimeout(EV_P_ ev_timer *timer, int revents) {
+static void redictLibevTimeout(EV_P_ ev_timer *timer, int revents) {
#if EV_MULTIPLICITY
((void)EV_A);
#endif
((void)revents);
- redisLibevEvents *e = (redisLibevEvents*)timer->data;
- redisAsyncHandleTimeout(e->context);
+ redictLibevEvents *e = (redictLibevEvents*)timer->data;
+ redictAsyncHandleTimeout(e->context);
}
-static void redisLibevSetTimeout(void *privdata, struct timeval tv) {
- redisLibevEvents *e = (redisLibevEvents*)privdata;
+static void redictLibevSetTimeout(void *privdata, struct timeval tv) {
+ redictLibevEvents *e = (redictLibevEvents*)privdata;
#if EV_MULTIPLICITY
struct ev_loop *loop = e->loop;
#endif
if (!ev_is_active(&e->timer)) {
- ev_init(&e->timer, redisLibevTimeout);
+ ev_init(&e->timer, redictLibevTimeout);
e->timer.data = e;
}
@@ -131,18 +131,18 @@ static void redisLibevSetTimeout(void *privdata, struct timeval tv) {
ev_timer_again(EV_A_ &e->timer);
}
-static int redisLibevAttach(EV_P_ redisAsyncContext *ac) {
- redisContext *c = &(ac->c);
- redisLibevEvents *e;
+static int redictLibevAttach(EV_P_ redictAsyncContext *ac) {
+ redictContext *c = &(ac->c);
+ redictLibevEvents *e;
/* Nothing should be attached when something is already attached */
if (ac->ev.data != NULL)
- return REDIS_ERR;
+ return REDICT_ERR;
/* Create container for context and r/w events */
- e = (redisLibevEvents*)hi_calloc(1, sizeof(*e));
+ e = (redictLibevEvents*)hi_calloc(1, sizeof(*e));
if (e == NULL)
- return REDIS_ERR;
+ return REDICT_ERR;
e->context = ac;
#if EV_MULTIPLICITY
@@ -154,18 +154,18 @@ static int redisLibevAttach(EV_P_ redisAsyncContext *ac) {
e->wev.data = e;
/* Register functions to start/stop listening for events */
- ac->ev.addRead = redisLibevAddRead;
- ac->ev.delRead = redisLibevDelRead;
- ac->ev.addWrite = redisLibevAddWrite;
- ac->ev.delWrite = redisLibevDelWrite;
- ac->ev.cleanup = redisLibevCleanup;
- ac->ev.scheduleTimer = redisLibevSetTimeout;
+ ac->ev.addRead = redictLibevAddRead;
+ ac->ev.delRead = redictLibevDelRead;
+ ac->ev.addWrite = redictLibevAddWrite;
+ ac->ev.delWrite = redictLibevDelWrite;
+ ac->ev.cleanup = redictLibevCleanup;
+ ac->ev.scheduleTimer = redictLibevSetTimeout;
ac->ev.data = e;
/* Initialize read/write events */
- ev_io_init(&e->rev,redisLibevReadEvent,c->fd,EV_READ);
- ev_io_init(&e->wev,redisLibevWriteEvent,c->fd,EV_WRITE);
- return REDIS_OK;
+ ev_io_init(&e->rev,redictLibevReadEvent,c->fd,EV_READ);
+ ev_io_init(&e->wev,redictLibevWriteEvent,c->fd,EV_WRITE);
+ return REDICT_OK;
}
#endif
diff --git a/adapters/libevent.h b/adapters/libevent.h
index 936c37e..66ce6b6 100644
--- a/adapters/libevent.h
+++ b/adapters/libevent.h
@@ -9,59 +9,59 @@
*
*/
-#ifndef __HIREDIS_LIBEVENT_H__
-#define __HIREDIS_LIBEVENT_H__
+#ifndef __HIREDICT_LIBEVENT_H__
+#define __HIREDICT_LIBEVENT_H__
#include <event2/event.h>
#include "../hiredict.h"
#include "../async.h"
-#define REDIS_LIBEVENT_DELETED 0x01
-#define REDIS_LIBEVENT_ENTERED 0x02
+#define REDICT_LIBEVENT_DELETED 0x01
+#define REDICT_LIBEVENT_ENTERED 0x02
-typedef struct redisLibeventEvents {
- redisAsyncContext *context;
+typedef struct redictLibeventEvents {
+ redictAsyncContext *context;
struct event *ev;
struct event_base *base;
struct timeval tv;
short flags;
short state;
-} redisLibeventEvents;
+} redictLibeventEvents;
-static void redisLibeventDestroy(redisLibeventEvents *e) {
+static void redictLibeventDestroy(redictLibeventEvents *e) {
hi_free(e);
}
-static void redisLibeventHandler(evutil_socket_t fd, short event, void *arg) {
+static void redictLibeventHandler(evutil_socket_t fd, short event, void *arg) {
((void)fd);
- redisLibeventEvents *e = (redisLibeventEvents*)arg;
- e->state |= REDIS_LIBEVENT_ENTERED;
+ redictLibeventEvents *e = (redictLibeventEvents*)arg;
+ e->state |= REDICT_LIBEVENT_ENTERED;
- #define CHECK_DELETED() if (e->state & REDIS_LIBEVENT_DELETED) {\
- redisLibeventDestroy(e);\
+ #define CHECK_DELETED() if (e->state & REDICT_LIBEVENT_DELETED) {\
+ redictLibeventDestroy(e);\
return; \
}
- if ((event & EV_TIMEOUT) && (e->state & REDIS_LIBEVENT_DELETED) == 0) {
- redisAsyncHandleTimeout(e->context);
+ if ((event & EV_TIMEOUT) && (e->state & REDICT_LIBEVENT_DELETED) == 0) {
+ redictAsyncHandleTimeout(e->context);
CHECK_DELETED();
}
- if ((event & EV_READ) && e->context && (e->state & REDIS_LIBEVENT_DELETED) == 0) {
- redisAsyncHandleRead(e->context);
+ if ((event & EV_READ) && e->context && (e->state & REDICT_LIBEVENT_DELETED) == 0) {
+ redictAsyncHandleRead(e->context);
CHECK_DELETED();
}
- if ((event & EV_WRITE) && e->context && (e->state & REDIS_LIBEVENT_DELETED) == 0) {
- redisAsyncHandleWrite(e->context);
+ if ((event & EV_WRITE) && e->context && (e->state & REDICT_LIBEVENT_DELETED) == 0) {
+ redictAsyncHandleWrite(e->context);
CHECK_DELETED();
}
- e->state &= ~REDIS_LIBEVENT_ENTERED;
+ e->state &= ~REDICT_LIBEVENT_ENTERED;
#undef CHECK_DELETED
}
-static void redisLibeventUpdate(void *privdata, short flag, int isRemove) {
- redisLibeventEvents *e = (redisLibeventEvents *)privdata;
+static void redictLibeventUpdate(void *privdata, short flag, int isRemove) {
+ redictLibeventEvents *e = (redictLibeventEvents *)privdata;
const struct timeval *tv = e->tv.tv_sec || e->tv.tv_usec ? &e->tv : NULL;
if (isRemove) {
@@ -80,28 +80,28 @@ static void redisLibeventUpdate(void *privdata, short flag, int isRemove) {
event_del(e->ev);
event_assign(e->ev, e->base, e->context->c.fd, e->flags | EV_PERSIST,
- redisLibeventHandler, privdata);
+ redictLibeventHandler, privdata);
event_add(e->ev, tv);
}
-static void redisLibeventAddRead(void *privdata) {
- redisLibeventUpdate(privdata, EV_READ, 0);
+static void redictLibeventAddRead(void *privdata) {
+ redictLibeventUpdate(privdata, EV_READ, 0);
}
-static void redisLibeventDelRead(void *privdata) {
- redisLibeventUpdate(privdata, EV_READ, 1);
+static void redictLibeventDelRead(void *privdata) {
+ redictLibeventUpdate(privdata, EV_READ, 1);
}
-static void redisLibeventAddWrite(void *privdata) {
- redisLibeventUpdate(privdata, EV_WRITE, 0);
+static void redictLibeventAddWrite(void *privdata) {
+ redictLibeventUpdate(privdata, EV_WRITE, 0);
}
-static void redisLibeventDelWrite(void *privdata) {
- redisLibeventUpdate(privdata, EV_WRITE, 1);
+static void redictLibeventDelWrite(void *privdata) {
+ redictLibeventUpdate(privdata, EV_WRITE, 1);
}
-static void redisLibeventCleanup(void *privdata) {
- redisLibeventEvents *e = (redisLibeventEvents*)privdata;
+static void redictLibeventCleanup(void *privdata) {
+ redictLibeventEvents *e = (redictLibeventEvents*)privdata;
if (!e) {
return;
}
@@ -109,48 +109,48 @@ static void redisLibeventCleanup(void *privdata) {
event_free(e->ev);
e->ev = NULL;
- if (e->state & REDIS_LIBEVENT_ENTERED) {
- e->state |= REDIS_LIBEVENT_DELETED;
+ if (e->state & REDICT_LIBEVENT_ENTERED) {
+ e->state |= REDICT_LIBEVENT_DELETED;
} else {
- redisLibeventDestroy(e);
+ redictLibeventDestroy(e);
}
}
-static void redisLibeventSetTimeout(void *privdata, struct timeval tv) {
- redisLibeventEvents *e = (redisLibeventEvents *)privdata;
+static void redictLibeventSetTimeout(void *privdata, struct timeval tv) {
+ redictLibeventEvents *e = (redictLibeventEvents *)privdata;
short flags = e->flags;
e->flags = 0;
e->tv = tv;
- redisLibeventUpdate(e, flags, 0);
+ redictLibeventUpdate(e, flags, 0);
}
-static int redisLibeventAttach(redisAsyncContext *ac, struct event_base *base) {
- redisContext *c = &(ac->c);
- redisLibeventEvents *e;
+static int redictLibeventAttach(redictAsyncContext *ac, struct event_base *base) {
+ redictContext *c = &(ac->c);
+ redictLibeventEvents *e;
/* Nothing should be attached when something is already attached */
if (ac->ev.data != NULL)
- return REDIS_ERR;
+ return REDICT_ERR;
/* Create container for context and r/w events */
- e = (redisLibeventEvents*)hi_calloc(1, sizeof(*e));
+ e = (redictLibeventEvents*)hi_calloc(1, sizeof(*e));
if (e == NULL)
- return REDIS_ERR;
+ return REDICT_ERR;
e->context = ac;
/* Register functions to start/stop listening for events */
- ac->ev.addRead = redisLibeventAddRead;
- ac->ev.delRead = redisLibeventDelRead;
- ac->ev.addWrite = redisLibeventAddWrite;
- ac->ev.delWrite = redisLibeventDelWrite;
- ac->ev.cleanup = redisLibeventCleanup;
- ac->ev.scheduleTimer = redisLibeventSetTimeout;
+ ac->ev.addRead = redictLibeventAddRead;
+ ac->ev.delRead = redictLibeventDelRead;
+ ac->ev.addWrite = redictLibeventAddWrite;
+ ac->ev.delWrite = redictLibeventDelWrite;
+ ac->ev.cleanup = redictLibeventCleanup;
+ ac->ev.scheduleTimer = redictLibeventSetTimeout;
ac->ev.data = e;
/* Initialize and install read/write events */
- e->ev = event_new(base, c->fd, EV_READ | EV_WRITE, redisLibeventHandler, e);
+ e->ev = event_new(base, c->fd, EV_READ | EV_WRITE, redictLibeventHandler, e);
e->base = base;
- return REDIS_OK;
+ return REDICT_OK;
}
#endif
diff --git a/adapters/libhv.h b/adapters/libhv.h
index 4955bb4..2d6fd77 100644
--- a/adapters/libhv.h
+++ b/adapters/libhv.h
@@ -9,52 +9,52 @@
*
*/
-#ifndef __HIREDIS_LIBHV_H__
-#define __HIREDIS_LIBHV_H__
+#ifndef __HIREDICT_LIBHV_H__
+#define __HIREDICT_LIBHV_H__
#include <hv/hloop.h>
#include "../hiredict.h"
#include "../async.h"
-typedef struct redisLibhvEvents {
+typedef struct redictLibhvEvents {
hio_t *io;
htimer_t *timer;
-} redisLibhvEvents;
+} redictLibhvEvents;
-static void redisLibhvHandleEvents(hio_t* io) {
- redisAsyncContext* context = (redisAsyncContext*)hevent_userdata(io);
+static void redictLibhvHandleEvents(hio_t* io) {
+ redictAsyncContext* context = (redictAsyncContext*)hevent_userdata(io);
int events = hio_events(io);
int revents = hio_revents(io);
if (context && (events & HV_READ) && (revents & HV_READ)) {
- redisAsyncHandleRead(context);
+ redictAsyncHandleRead(context);
}
if (context && (events & HV_WRITE) && (revents & HV_WRITE)) {
- redisAsyncHandleWrite(context);
+ redictAsyncHandleWrite(context);
}
}
-static void redisLibhvAddRead(void *privdata) {
- redisLibhvEvents* events = (redisLibhvEvents*)privdata;
- hio_add(events->io, redisLibhvHandleEvents, HV_READ);
+static void redictLibhvAddRead(void *privdata) {
+ redictLibhvEvents* events = (redictLibhvEvents*)privdata;
+ hio_add(events->io, redictLibhvHandleEvents, HV_READ);
}
-static void redisLibhvDelRead(void *privdata) {
- redisLibhvEvents* events = (redisLibhvEvents*)privdata;
+static void redictLibhvDelRead(void *privdata) {
+ redictLibhvEvents* events = (redictLibhvEvents*)privdata;
hio_del(events->io, HV_READ);
}
-static void redisLibhvAddWrite(void *privdata) {
- redisLibhvEvents* events = (redisLibhvEvents*)privdata;
- hio_add(events->io, redisLibhvHandleEvents, HV_WRITE);
+static void redictLibhvAddWrite(void *privdata) {
+ redictLibhvEvents* events = (redictLibhvEvents*)privdata;
+ hio_add(events->io, redictLibhvHandleEvents, HV_WRITE);
}
-static void redisLibhvDelWrite(void *privdata) {
- redisLibhvEvents* events = (redisLibhvEvents*)privdata;
+static void redictLibhvDelWrite(void *privdata) {
+ redictLibhvEvents* events = (redictLibhvEvents*)privdata;
hio_del(events->io, HV_WRITE);
}
-static void redisLibhvCleanup(void *privdata) {
- redisLibhvEvents* events = (redisLibhvEvents*)privdata;
+static void redictLibhvCleanup(void *privdata) {
+ redictLibhvEvents* events = (redictLibhvEvents*)privdata;
if (events->timer)
htimer_del(events->timer);
@@ -65,17 +65,17 @@ static void redisLibhvCleanup(void *privdata) {
hi_free(events);
}
-static void redisLibhvTimeout(htimer_t* timer) {
+static void redictLibhvTimeout(htimer_t* timer) {
hio_t* io = (hio_t*)hevent_userdata(timer);
- redisAsyncHandleTimeout((redisAsyncContext*)hevent_userdata(io));
+ redictAsyncHandleTimeout((redictAsyncContext*)hevent_userdata(io));
}
-static void redisLibhvSetTimeout(void *privdata, struct timeval tv) {
- redisLibhvEvents* events;
+static void redictLibhvSetTimeout(void *privdata, struct timeval tv) {
+ redictLibhvEvents* events;
uint32_t millis;
hloop_t* loop;
- events = (redisLibhvEvents*)privdata;
+ events = (redictLibhvEvents*)privdata;
millis = tv.tv_sec * 1000 + tv.tv_usec / 1000;
if (millis == 0) {
@@ -87,7 +87,7 @@ static void redisLibhvSetTimeout(void *privdata, struct timeval tv) {
} else if (events->timer == NULL) {
/* Add new timer */
loop = hevent_loop(events->io);
- events->timer = htimer_add(loop, redisLibhvTimeout, millis, 1);
+ events->timer = htimer_add(loop, redictLibhvTimeout, millis, 1);
hevent_set_userdata(events->timer, events->io);
} else {
/* Update existing timer */
@@ -95,25 +95,25 @@ static void redisLibhvSetTimeout(void *privdata, struct timeval tv) {
}
}
-static int redisLibhvAttach(redisAsyncContext* ac, hloop_t* loop) {
- redisContext *c = &(ac->c);
- redisLibhvEvents *events;
+static int redictLibhvAttach(redictAsyncContext* ac, hloop_t* loop) {
+ redictContext *c = &(ac->c);
+ redictLibhvEvents *events;
hio_t* io = NULL;
if (ac->ev.data != NULL) {
- return REDIS_ERR;
+ return REDICT_ERR;
}
/* Create container struct to keep track of our io and any timer */
- events = (redisLibhvEvents*)hi_malloc(sizeof(*events));
+ events = (redictLibhvEvents*)hi_malloc(sizeof(*events));
if (events == NULL) {
- return REDIS_ERR;
+ return REDICT_ERR;
}
io = hio_get(loop, c->fd);
if (io == NULL) {
hi_free(events);
- return REDIS_ERR;
+ return REDICT_ERR;
}
hevent_set_userdata(io, ac);
@@ -121,14 +121,14 @@ static int redisLibhvAttach(redisAsyncContext* ac, hloop_t* loop) {
events->io = io;
events->timer = NULL;
- ac->ev.addRead = redisLibhvAddRead;
- ac->ev.delRead = redisLibhvDelRead;
- ac->ev.addWrite = redisLibhvAddWrite;
- ac->ev.delWrite = redisLibhvDelWrite;
- ac->ev.cleanup = redisLibhvCleanup;
- ac->ev.scheduleTimer = redisLibhvSetTimeout;
+ ac->ev.addRead = redictLibhvAddRead;
+ ac->ev.delRead = redictLibhvDelRead;
+ ac->ev.addWrite = redictLibhvAddWrite;
+ ac->ev.delWrite = redictLibhvDelWrite;
+ ac->ev.cleanup = redictLibhvCleanup;
+ ac->ev.scheduleTimer = redictLibhvSetTimeout;
ac->ev.data = events;
- return REDIS_OK;
+ return REDICT_OK;
}
#endif
diff --git a/adapters/libsdevent.h b/adapters/libsdevent.h
index dc4249a..103d69e 100644
--- a/adapters/libsdevent.h
+++ b/adapters/libsdevent.h
@@ -9,26 +9,26 @@
*
*/
-#ifndef HIREDIS_LIBSDEVENT_H
-#define HIREDIS_LIBSDEVENT_H
+#ifndef HIREDICT_LIBSDEVENT_H
+#define HIREDICT_LIBSDEVENT_H
#include <systemd/sd-event.h>
#include "../hiredict.h"
#include "../async.h"
-#define REDIS_LIBSDEVENT_DELETED 0x01
-#define REDIS_LIBSDEVENT_ENTERED 0x02
+#define REDICT_LIBSDEVENT_DELETED 0x01
+#define REDICT_LIBSDEVENT_ENTERED 0x02
-typedef struct redisLibsdeventEvents {
- redisAsyncContext *context;
+typedef struct redictLibsdeventEvents {
+ redictAsyncContext *context;
struct sd_event *event;
struct sd_event_source *fdSource;
struct sd_event_source *timerSource;
int fd;
short flags;
short state;
-} redisLibsdeventEvents;
+} redictLibsdeventEvents;
-static void redisLibsdeventDestroy(redisLibsdeventEvents *e) {
+static void redictLibsdeventDestroy(redictLibsdeventEvents *e) {
if (e->fdSource) {
e->fdSource = sd_event_source_disable_unref(e->fdSource);
}
@@ -39,43 +39,43 @@ static void redisLibsdeventDestroy(redisLibsdeventEvents *e) {
hi_free(e);
}
-static int redisLibsdeventTimeoutHandler(sd_event_source *s, uint64_t usec, void *userdata) {
+static int redictLibsdeventTimeoutHandler(sd_event_source *s, uint64_t usec, void *userdata) {
((void)s);
((void)usec);
- redisLibsdeventEvents *e = (redisLibsdeventEvents*)userdata;
- redisAsyncHandleTimeout(e->context);
+ redictLibsdeventEvents *e = (redictLibsdeventEvents*)userdata;
+ redictAsyncHandleTimeout(e->context);
return 0;
}
-static int redisLibsdeventHandler(sd_event_source *s, int fd, uint32_t event, void *userdata) {
+static int redictLibsdeventHandler(sd_event_source *s, int fd, uint32_t event, void *userdata) {
((void)s);
((void)fd);
- redisLibsdeventEvents *e = (redisLibsdeventEvents*)userdata;
- e->state |= REDIS_LIBSDEVENT_ENTERED;
+ redictLibsdeventEvents *e = (redictLibsdeventEvents*)userdata;
+ e->state |= REDICT_LIBSDEVENT_ENTERED;
-#define CHECK_DELETED() if (e->state & REDIS_LIBSDEVENT_DELETED) {\
- redisLibsdeventDestroy(e);\
+#define CHECK_DELETED() if (e->state & REDICT_LIBSDEVENT_DELETED) {\
+ redictLibsdeventDestroy(e);\
return 0; \
}
- if ((event & EPOLLIN) && e->context && (e->state & REDIS_LIBSDEVENT_DELETED) == 0) {
- redisAsyncHandleRead(e->context);
+ if ((event & EPOLLIN) && e->context && (e->state & REDICT_LIBSDEVENT_DELETED) == 0) {
+ redictAsyncHandleRead(e->context);
CHECK_DELETED();
}
- if ((event & EPOLLOUT) && e->context && (e->state & REDIS_LIBSDEVENT_DELETED) == 0) {
- redisAsyncHandleWrite(e->context);
+ if ((event & EPOLLOUT) && e->context && (e->state & REDICT_LIBSDEVENT_DELETED) == 0) {
+ redictAsyncHandleWrite(e->context);
CHECK_DELETED();
}
- e->state &= ~REDIS_LIBSDEVENT_ENTERED;
+ e->state &= ~REDICT_LIBSDEVENT_ENTERED;
#undef CHECK_DELETED
return 0;
}
-static void redisLibsdeventAddRead(void *userdata) {
- redisLibsdeventEvents *e = (redisLibsdeventEvents*)userdata;
+static void redictLibsdeventAddRead(void *userdata) {
+ redictLibsdeventEvents *e = (redictLibsdeventEvents*)userdata;
if (e->flags & EPOLLIN) {
return;
@@ -86,12 +86,12 @@ static void redisLibsdeventAddRead(void *userdata) {
if (e->flags & EPOLLOUT) {
sd_event_source_set_io_events(e->fdSource, e->flags);
} else {
- sd_event_add_io(e->event, &e->fdSource, e->fd, e->flags, redisLibsdeventHandler, e);
+ sd_event_add_io(e->event, &e->fdSource, e->fd, e->flags, redictLibsdeventHandler, e);
}
}
-static void redisLibsdeventDelRead(void *userdata) {
- redisLibsdeventEvents *e = (redisLibsdeventEvents*)userdata;
+static void redictLibsdeventDelRead(void *userdata) {
+ redictLibsdeventEvents *e = (redictLibsdeventEvents*)userdata;
e->flags &= ~EPOLLIN;
@@ -102,8 +102,8 @@ static void redisLibsdeventDelRead(void *userdata) {
}
}
-static void redisLibsdeventAddWrite(void *userdata) {
- redisLibsdeventEvents *e = (redisLibsdeventEvents*)userdata;
+static void redictLibsdeventAddWrite(void *userdata) {
+ redictLibsdeventEvents *e = (redictLibsdeventEvents*)userdata;
if (e->flags & EPOLLOUT) {
return;
@@ -114,12 +114,12 @@ static void redisLibsdeventAddWrite(void *userdata) {
if (e->flags & EPOLLIN) {
sd_event_source_set_io_events(e->fdSource, e->flags);
} else {
- sd_event_add_io(e->event, &e->fdSource, e->fd, e->flags, redisLibsdeventHandler, e);
+ sd_event_add_io(e->event, &e->fdSource, e->fd, e->flags, redictLibsdeventHandler, e);
}
}
-static void redisLibsdeventDelWrite(void *userdata) {
- redisLibsdeventEvents *e = (redisLibsdeventEvents*)userdata;
+static void redictLibsdeventDelWrite(void *userdata) {
+ redictLibsdeventEvents *e = (redictLibsdeventEvents*)userdata;
e->flags &= ~EPOLLOUT;
@@ -130,43 +130,43 @@ static void redisLibsdeventDelWrite(void *userdata) {
}
}
-static void redisLibsdeventCleanup(void *userdata) {
- redisLibsdeventEvents *e = (redisLibsdeventEvents*)userdata;
+static void redictLibsdeventCleanup(void *userdata) {
+ redictLibsdeventEvents *e = (redictLibsdeventEvents*)userdata;
if (!e) {
return;
}
- if (e->state & REDIS_LIBSDEVENT_ENTERED) {
- e->state |= REDIS_LIBSDEVENT_DELETED;
+ if (e->state & REDICT_LIBSDEVENT_ENTERED) {
+ e->state |= REDICT_LIBSDEVENT_DELETED;
} else {
- redisLibsdeventDestroy(e);
+ redictLibsdeventDestroy(e);
}
}
-static void redisLibsdeventSetTimeout(void *userdata, struct timeval tv) {
- redisLibsdeventEvents *e = (redisLibsdeventEvents *)userdata;
+static void redictLibsdeventSetTimeout(void *userdata, struct timeval tv) {
+ redictLibsdeventEvents *e = (redictLibsdeventEvents *)userdata;
uint64_t usec = tv.tv_sec * 1000000 + tv.tv_usec;
if (!e->timerSource) {
- sd_event_add_time_relative(e->event, &e->timerSource, CLOCK_MONOTONIC, usec, 1, redisLibsdeventTimeoutHandler, e);
+ sd_event_add_time_relative(e->event, &e->timerSource, CLOCK_MONOTONIC, usec, 1, redictLibsdeventTimeoutHandler, e);
} else {
sd_event_source_set_time_relative(e->timerSource, usec);
}
}
-static int redisLibsdeventAttach(redisAsyncContext *ac, struct sd_event *event) {
- redisContext *c = &(ac->c);
- redisLibsdeventEvents *e;
+static int redictLibsdeventAttach(redictAsyncContext *ac, struct sd_event *event) {
+ redictContext *c = &(ac->c);
+ redictLibsdeventEvents *e;
/* Nothing should be attached when something is already attached */
if (ac->ev.data != NULL)
- return REDIS_ERR;
+ return REDICT_ERR;
/* Create container for context and r/w events */
- e = (redisLibsdeventEvents*)hi_calloc(1, sizeof(*e));
+ e = (redictLibsdeventEvents*)hi_calloc(1, sizeof(*e));
if (e == NULL)
- return REDIS_ERR;
+ return REDICT_ERR;
/* Initialize and increase event refcount */
e->context = ac;
@@ -175,14 +175,14 @@ static int redisLibsdeventAttach(redisAsyncContext *ac, struct sd_event *event)
sd_event_ref(event);
/* Register functions to start/stop listening for events */
- ac->ev.addRead = redisLibsdeventAddRead;
- ac->ev.delRead = redisLibsdeventDelRead;
- ac->ev.addWrite = redisLibsdeventAddWrite;
- ac->ev.delWrite = redisLibsdeventDelWrite;
- ac->ev.cleanup = redisLibsdeventCleanup;
- ac->ev.scheduleTimer = redisLibsdeventSetTimeout;
+ ac->ev.addRead = redictLibsdeventAddRead;
+ ac->ev.delRead = redictLibsdeventDelRead;
+ ac->ev.addWrite = redictLibsdeventAddWrite;
+ ac->ev.delWrite = redictLibsdeventDelWrite;
+ ac->ev.cleanup = redictLibsdeventCleanup;
+ ac->ev.scheduleTimer = redictLibsdeventSetTimeout;
ac->ev.data = e;
- return REDIS_OK;
+ return REDICT_OK;
}
#endif
diff --git a/adapters/libuv.h b/adapters/libuv.h
index 317d5e1..e91b872 100644
--- a/adapters/libuv.h
+++ b/adapters/libuv.h
@@ -9,37 +9,37 @@
*
*/
-#ifndef __HIREDIS_LIBUV_H__
-#define __HIREDIS_LIBUV_H__
+#ifndef __HIREDICT_LIBUV_H__
+#define __HIREDICT_LIBUV_H__
#include <stdlib.h>
#include <uv.h>
#include "../hiredict.h"
#include "../async.h"
#include <string.h>
-typedef struct redisLibuvEvents {
- redisAsyncContext* context;
+typedef struct redictLibuvEvents {
+ redictAsyncContext* context;
uv_poll_t handle;
uv_timer_t timer;
int events;
-} redisLibuvEvents;
+} redictLibuvEvents;
-static void redisLibuvPoll(uv_poll_t* handle, int status, int events) {
- redisLibuvEvents* p = (redisLibuvEvents*)handle->data;
+static void redictLibuvPoll(uv_poll_t* handle, int status, int events) {
+ redictLibuvEvents* p = (redictLibuvEvents*)handle->data;
int ev = (status ? p->events : events);
if (p->context != NULL && (ev & UV_READABLE)) {
- redisAsyncHandleRead(p->context);
+ redictAsyncHandleRead(p->context);
}
if (p->context != NULL && (ev & UV_WRITABLE)) {
- redisAsyncHandleWrite(p->context);
+ redictAsyncHandleWrite(p->context);
}
}
-static void redisLibuvAddRead(void *privdata) {
- redisLibuvEvents* p = (redisLibuvEvents*)privdata;
+static void redictLibuvAddRead(void *privdata) {
+ redictLibuvEvents* p = (redictLibuvEvents*)privdata;
if (p->events & UV_READABLE) {
return;
@@ -47,25 +47,25 @@ static void redisLibuvAddRead(void *privdata) {
p->events |= UV_READABLE;
- uv_poll_start(&p->handle, p->events, redisLibuvPoll);
+ uv_poll_start(&p->handle, p->events, redictLibuvPoll);
}
-static void redisLibuvDelRead(void *privdata) {
- redisLibuvEvents* p = (redisLibuvEvents*)privdata;
+static void redictLibuvDelRead(void *privdata) {
+ redictLibuvEvents* p = (redictLibuvEvents*)privdata;
p->events &= ~UV_READABLE;
if (p->events) {
- uv_poll_start(&p->handle, p->events, redisLibuvPoll);
+ uv_poll_start(&p->handle, p->events, redictLibuvPoll);
} else {
uv_poll_stop(&p->handle);
}
}
-static void redisLibuvAddWrite(void *privdata) {
- redisLibuvEvents* p = (redisLibuvEvents*)privdata;
+static void redictLibuvAddWrite(void *privdata) {
+ redictLibuvEvents* p = (redictLibuvEvents*)privdata;
if (p->events & UV_WRITABLE) {
return;
@@ -73,24 +73,24 @@ static void redisLibuvAddWrite(void *privdata) {
p->events |= UV_WRITABLE;
- uv_poll_start(&p->handle, p->events, redisLibuvPoll);
+ uv_poll_start(&p->handle, p->events, redictLibuvPoll);
}
-static void redisLibuvDelWrite(void *privdata) {
- redisLibuvEvents* p = (redisLibuvEvents*)privdata;
+static void redictLibuvDelWrite(void *privdata) {
+ redictLibuvEvents* p = (redictLibuvEvents*)privdata;
p->events &= ~UV_WRITABLE;
if (p->events) {
- uv_poll_start(&p->handle, p->events, redisLibuvPoll);
+ uv_poll_start(&p->handle, p->events, redictLibuvPoll);
} else {
uv_poll_stop(&p->handle);
}
}
static void on_timer_close(uv_handle_t *handle) {
- redisLibuvEvents* p = (redisLibuvEvents*)handle->data;
+ redictLibuvEvents* p = (redictLibuvEvents*)handle->data;
p->timer.data = NULL;
if (!p->handle.data) {
// both timer and handle are closed
@@ -100,7 +100,7 @@ static void on_timer_close(uv_handle_t *handle) {
}
static void on_handle_close(uv_handle_t *handle) {
- redisLibuvEvents* p = (redisLibuvEvents*)handle->data;
+ redictLibuvEvents* p = (redictLibuvEvents*)handle->data;
p->handle.data = NULL;
if (!p->timer.data) {
// timer never started, or timer already destroyed
@@ -113,17 +113,17 @@ static void on_handle_close(uv_handle_t *handle) {
// see: https://github.com/libuv/libuv/blob/v0.11.23/include/uv.h
#if (UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR < 11) || \
(UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR == 11 && UV_VERSION_PATCH < 23)
-static void redisLibuvTimeout(uv_timer_t *timer, int status) {
+static void redictLibuvTimeout(uv_timer_t *timer, int status) {
(void)status; // unused
#else
-static void redisLibuvTimeout(uv_timer_t *timer) {
+static void redictLibuvTimeout(uv_timer_t *timer) {
#endif
- redisLibuvEvents *e = (redisLibuvEvents*)timer->data;
- redisAsyncHandleTimeout(e->context);
+ redictLibuvEvents *e = (redictLibuvEvents*)timer->data;
+ redictAsyncHandleTimeout(e->context);
}
-static void redisLibuvSetTimeout(void *privdata, struct timeval tv) {
- redisLibuvEvents* p = (redisLibuvEvents*)privdata;
+static void redictLibuvSetTimeout(void *privdata, struct timeval tv) {
+ redictLibuvEvents* p = (redictLibuvEvents*)privdata;
uint64_t millsec = tv.tv_sec * 1000 + tv.tv_usec / 1000.0;
if (!p->timer.data) {
@@ -135,11 +135,11 @@ static void redisLibuvSetTimeout(void *privdata, struct timeval tv) {
}
// updates the timeout if the timer has already started
// or start the timer
- uv_timer_start(&p->timer, redisLibuvTimeout, millsec, 0);
+ uv_timer_start(&p->timer, redictLibuvTimeout, millsec, 0);
}
-static void redisLibuvCleanup(void *privdata) {
- redisLibuvEvents* p = (redisLibuvEvents*)privdata;
+static void redictLibuvCleanup(void *privdata) {
+ redictLibuvEvents* p = (redictLibuvEvents*)privdata;
p->context = NULL; // indicate that context might no longer exist
if (p->timer.data) {
@@ -149,35 +149,35 @@ static void redisLibuvCleanup(void *privdata) {
}
-static int redisLibuvAttach(redisAsyncContext* ac, uv_loop_t* loop) {
- redisContext *c = &(ac->c);
+static int redictLibuvAttach(redictAsyncContext* ac, uv_loop_t* loop) {
+ redictContext *c = &(ac->c);
if (ac->ev.data != NULL) {
- return REDIS_ERR;
+ return REDICT_ERR;
}
- ac->ev.addRead = redisLibuvAddRead;
- ac->ev.delRead = redisLibuvDelRead;
- ac->ev.addWrite = redisLibuvAddWrite;
- ac->ev.delWrite = redisLibuvDelWrite;
- ac->ev.cleanup = redisLibuvCleanup;
- ac->ev.scheduleTimer = redisLibuvSetTimeout;
+ ac->ev.addRead = redictLibuvAddRead;
+ ac->ev.delRead = redictLibuvDelRead;
+ ac->ev.addWrite = redictLibuvAddWrite;
+ ac->ev.delWrite = redictLibuvDelWrite;
+ ac->ev.cleanup = redictLibuvCleanup;
+ ac->ev.scheduleTimer = redictLibuvSetTimeout;
- redisLibuvEvents* p = (redisLibuvEvents*)hi_malloc(sizeof(*p));
+ redictLibuvEvents* p = (redictLibuvEvents*)hi_malloc(sizeof(*p));
if (p == NULL)
- return REDIS_ERR;
+ return REDICT_ERR;
memset(p, 0, sizeof(*p));
if (uv_poll_init_socket(loop, &p->handle, c->fd) != 0) {
hi_free(p);
- return REDIS_ERR;
+ return REDICT_ERR;
}
ac->ev.data = p;
p->handle.data = p;
p->context = ac;
- return REDIS_OK;
+ return REDICT_OK;
}
#endif
diff --git a/adapters/macosx.h b/adapters/macosx.h
index 7ae5e5a..670ca62 100644
--- a/adapters/macosx.h
+++ b/adapters/macosx.h
@@ -9,8 +9,8 @@
*
*/
-#ifndef __HIREDIS_MACOSX_H__
-#define __HIREDIS_MACOSX_H__
+#ifndef __HIREDICT_MACOSX_H__
+#define __HIREDICT_MACOSX_H__
#include <CoreFoundation/CoreFoundation.h>
@@ -18,61 +18,61 @@
#include "../async.h"
typedef struct {
- redisAsyncContext *context;
+ redictAsyncContext *context;
CFSocketRef socketRef;
CFRunLoopSourceRef sourceRef;
-} RedisRunLoop;
+} RedictRunLoop;
-static int freeRedisRunLoop(RedisRunLoop* redisRunLoop) {
- if( redisRunLoop != NULL ) {
- if( redisRunLoop->sourceRef != NULL ) {
- CFRunLoopSourceInvalidate(redisRunLoop->sourceRef);
- CFRelease(redisRunLoop->sourceRef);
+static int freeRedictRunLoop(RedictRunLoop* redictRunLoop) {
+ if( redictRunLoop != NULL ) {
+ if( redictRunLoop->sourceRef != NULL ) {
+ CFRunLoopSourceInvalidate(redictRunLoop->sourceRef);
+ CFRelease(redictRunLoop->sourceRef);
}
- if( redisRunLoop->socketRef != NULL ) {
- CFSocketInvalidate(redisRunLoop->socketRef);
- CFRelease(redisRunLoop->socketRef);
+ if( redictRunLoop->socketRef != NULL ) {
+ CFSocketInvalidate(redictRunLoop->socketRef);
+ CFRelease(redictRunLoop->socketRef);
}
- hi_free(redisRunLoop);
+ hi_free(redictRunLoop);
}
- return REDIS_ERR;
+ return REDICT_ERR;
}
-static void redisMacOSAddRead(void *privdata) {
- RedisRunLoop *redisRunLoop = (RedisRunLoop*)privdata;
- CFSocketEnableCallBacks(redisRunLoop->socketRef, kCFSocketReadCallBack);
+static void redictMacOSAddRead(void *privdata) {
+ RedictRunLoop *redictRunLoop = (RedictRunLoop*)privdata;
+ CFSocketEnableCallBacks(redictRunLoop->socketRef, kCFSocketReadCallBack);
}
-static void redisMacOSDelRead(void *privdata) {
- RedisRunLoop *redisRunLoop = (RedisRunLoop*)privdata;
- CFSocketDisableCallBacks(redisRunLoop->socketRef, kCFSocketReadCallBack);
+static void redictMacOSDelRead(void *privdata) {
+ RedictRunLoop *redictRunLoop = (RedictRunLoop*)privdata;
+ CFSocketDisableCallBacks(redictRunLoop->socketRef, kCFSocketReadCallBack);
}
-static void redisMacOSAddWrite(void *privdata) {
- RedisRunLoop *redisRunLoop = (RedisRunLoop*)privdata;
- CFSocketEnableCallBacks(redisRunLoop->socketRef, kCFSocketWriteCallBack);
+static void redictMacOSAddWrite(void *privdata) {
+ RedictRunLoop *redictRunLoop = (RedictRunLoop*)privdata;
+ CFSocketEnableCallBacks(redictRunLoop->socketRef, kCFSocketWriteCallBack);
}
-static void redisMacOSDelWrite(void *privdata) {
- RedisRunLoop *redisRunLoop = (RedisRunLoop*)privdata;
- CFSocketDisableCallBacks(redisRunLoop->socketRef, kCFSocketWriteCallBack);
+static void redictMacOSDelWrite(void *privdata) {
+ RedictRunLoop *redictRunLoop = (RedictRunLoop*)privdata;
+ CFSocketDisableCallBacks(redictRunLoop->socketRef, kCFSocketWriteCallBack);
}
-static void redisMacOSCleanup(void *privdata) {
- RedisRunLoop *redisRunLoop = (RedisRunLoop*)privdata;
- freeRedisRunLoop(redisRunLoop);
+static void redictMacOSCleanup(void *privdata) {
+ RedictRunLoop *redictRunLoop = (RedictRunLoop*)privdata;
+ freeRedictRunLoop(redictRunLoop);
}
-static void redisMacOSAsyncCallback(CFSocketRef __unused s, CFSocketCallBackType callbackType, CFDataRef __unused address, const void __unused *data, void *info) {
- redisAsyncContext* context = (redisAsyncContext*) info;
+static void redictMacOSAsyncCallback(CFSocketRef __unused s, CFSocketCallBackType callbackType, CFDataRef __unused address, const void __unused *data, void *info) {
+ redictAsyncContext* context = (redictAsyncContext*) info;
switch (callbackType) {
case kCFSocketReadCallBack:
- redisAsyncHandleRead(context);
+ redictAsyncHandleRead(context);
break;
case kCFSocketWriteCallBack:
- redisAsyncHandleWrite(context);
+ redictAsyncHandleWrite(context);
break;
default:
@@ -80,41 +80,41 @@ static void redisMacOSAsyncCallback(CFSocketRef __unused s, CFSocketCallBackType
}
}
-static int redisMacOSAttach(redisAsyncContext *redisAsyncCtx, CFRunLoopRef runLoop) {
- redisContext *redisCtx = &(redisAsyncCtx->c);
+static int redictMacOSAttach(redictAsyncContext *redictAsyncCtx, CFRunLoopRef runLoop) {
+ redictContext *redictCtx = &(redictAsyncCtx->c);
/* Nothing should be attached when something is already attached */
- if( redisAsyncCtx->ev.data != NULL ) return REDIS_ERR;
+ if( redictAsyncCtx->ev.data != NULL ) return REDICT_ERR;
- RedisRunLoop* redisRunLoop = (RedisRunLoop*) hi_calloc(1, sizeof(RedisRunLoop));
- if (redisRunLoop == NULL)
- return REDIS_ERR;
+ RedictRunLoop* redictRunLoop = (RedictRunLoop*) hi_calloc(1, sizeof(RedictRunLoop));
+ if (redictRunLoop == NULL)
+ return REDICT_ERR;
- /* Setup redis stuff */
- redisRunLoop->context = redisAsyncCtx;
+ /* Setup redict stuff */
+ redictRunLoop->context = redictAsyncCtx;
- redisAsyncCtx->ev.addRead = redisMacOSAddRead;
- redisAsyncCtx->ev.delRead = redisMacOSDelRead;
- redisAsyncCtx->ev.addWrite = redisMacOSAddWrite;
- redisAsyncCtx->ev.delWrite = redisMacOSDelWrite;
- redisAsyncCtx->ev.cleanup = redisMacOSCleanup;
- redisAsyncCtx->ev.data = redisRunLoop;
+ redictAsyncCtx->ev.addRead = redictMacOSAddRead;
+ redictAsyncCtx->ev.delRead = redictMacOSDelRead;
+ redictAsyncCtx->ev.addWrite = redictMacOSAddWrite;
+ redictAsyncCtx->ev.delWrite = redictMacOSDelWrite;
+ redictAsyncCtx->ev.cleanup = redictMacOSCleanup;
+ redictAsyncCtx->ev.data = redictRunLoop;
/* Initialize and install read/write events */
- CFSocketContext socketCtx = { 0, redisAsyncCtx, NULL, NULL, NULL };
+ CFSocketContext socketCtx = { 0, redictAsyncCtx, NULL, NULL, NULL };
- redisRunLoop->socketRef = CFSocketCreateWithNative(NULL, redisCtx->fd,
+ redictRunLoop->socketRef = CFSocketCreateWithNative(NULL, redictCtx->fd,
kCFSocketReadCallBack | kCFSocketWriteCallBack,
- redisMacOSAsyncCallback,
+ redictMacOSAsyncCallback,
&socketCtx);
- if( !redisRunLoop->socketRef ) return freeRedisRunLoop(redisRunLoop);
+ if( !redictRunLoop->socketRef ) return freeRedictRunLoop(redictRunLoop);
- redisRunLoop->sourceRef = CFSocketCreateRunLoopSource(NULL, redisRunLoop->socketRef, 0);
- if( !redisRunLoop->sourceRef ) return freeRedisRunLoop(redisRunLoop);
+ redictRunLoop->sourceRef = CFSocketCreateRunLoopSource(NULL, redictRunLoop->socketRef, 0);
+ if( !redictRunLoop->sourceRef ) return freeRedictRunLoop(redictRunLoop);
- CFRunLoopAddSource(runLoop, redisRunLoop->sourceRef, kCFRunLoopDefaultMode);
+ CFRunLoopAddSource(runLoop, redictRunLoop->sourceRef, kCFRunLoopDefaultMode);
- return REDIS_OK;
+ return REDICT_OK;
}
#endif
diff --git a/adapters/poll.h b/adapters/poll.h
index 23b3eba..adc0aab 100644
--- a/adapters/poll.h
+++ b/adapters/poll.h
@@ -9,43 +9,43 @@
*
*/
-#ifndef HIREDIS_POLL_H
-#define HIREDIS_POLL_H
+#ifndef HIREDICT_POLL_H
+#define HIREDICT_POLL_H
#include "../async.h"
#include "../sockcompat.h"
#include <string.h> // for memset
#include <errno.h>
-/* Values to return from redisPollTick */
-#define REDIS_POLL_HANDLED_READ 1
-#define REDIS_POLL_HANDLED_WRITE 2
-#define REDIS_POLL_HANDLED_TIMEOUT 4
+/* Values to return from redictPollTick */
+#define REDICT_POLL_HANDLED_READ 1
+#define REDICT_POLL_HANDLED_WRITE 2
+#define REDICT_POLL_HANDLED_TIMEOUT 4
/* An adapter to allow manual polling of the async context by checking the state
* of the underlying file descriptor. Useful in cases where there is no formal
* IO event loop but regular ticking can be used, such as in game engines. */
-typedef struct redisPollEvents {
- redisAsyncContext *context;
- redisFD fd;
+typedef struct redictPollEvents {
+ redictAsyncContext *context;
+ redictFD fd;
char reading, writing;
char in_tick;
char deleted;
double deadline;
-} redisPollEvents;
+} redictPollEvents;
-static double redisPollTimevalToDouble(struct timeval *tv) {
+static double redictPollTimevalToDouble(struct timeval *tv) {
if (tv == NULL)
return 0.0;
return tv->tv_sec + tv->tv_usec / 1000000.00;
}
-static double redisPollGetNow(void) {
+static double redictPollGetNow(void) {
#ifndef _MSC_VER
struct timeval tv;
gettimeofday(&tv,NULL);
- return redisPollTimevalToDouble(&tv);
+ return redictPollTimevalToDouble(&tv);
#else
FILETIME ft;
ULARGE_INTEGER li;
@@ -59,14 +59,14 @@ static double redisPollGetNow(void) {
/* Poll for io, handling any pending callbacks. The timeout argument can be
* positive to wait for a maximum given time for IO, zero to poll, or negative
* to wait forever */
-static int redisPollTick(redisAsyncContext *ac, double timeout) {
+static int redictPollTick(redictAsyncContext *ac, double timeout) {
int reading, writing;
struct pollfd pfd;
int handled;
int ns;
int itimeout;
- redisPollEvents *e = (redisPollEvents*)ac->ev.data;
+ redictPollEvents *e = (redictPollEvents*)ac->ev.data;
if (!e)
return 0;
@@ -101,29 +101,29 @@ static int redisPollTick(redisAsyncContext *ac, double timeout) {
e->in_tick = 1;
if (ns) {
if (reading && (pfd.revents & POLLIN)) {
- redisAsyncHandleRead(ac);
- handled |= REDIS_POLL_HANDLED_READ;
+ redictAsyncHandleRead(ac);
+ handled |= REDICT_POLL_HANDLED_READ;
}
/* on Windows, connection failure is indicated with the Exception fdset.
* handle it the same as writable. */
if (writing && (pfd.revents & (POLLOUT | POLLERR))) {
/* context Read callback may have caused context to be deleted, e.g.
- by doing an redisAsyncDisconnect() */
+ by doing an redictAsyncDisconnect() */
if (!e->deleted) {
- redisAsyncHandleWrite(ac);
- handled |= REDIS_POLL_HANDLED_WRITE;
+ redictAsyncHandleWrite(ac);
+ handled |= REDICT_POLL_HANDLED_WRITE;
}
}
}
/* perform timeouts */
if (!e->deleted && e->deadline != 0.0) {
- double now = redisPollGetNow();
+ double now = redictPollGetNow();
if (now >= e->deadline) {
/* deadline has passed. disable timeout and perform callback */
e->deadline = 0.0;
- redisAsyncHandleTimeout(ac);
- handled |= REDIS_POLL_HANDLED_TIMEOUT;
+ redictAsyncHandleTimeout(ac);
+ handled |= REDICT_POLL_HANDLED_TIMEOUT;
}
}
@@ -136,28 +136,28 @@ static int redisPollTick(redisAsyncContext *ac, double timeout) {
return handled;
}
-static void redisPollAddRead(void *data) {
- redisPollEvents *e = (redisPollEvents*)data;
+static void redictPollAddRead(void *data) {
+ redictPollEvents *e = (redictPollEvents*)data;
e->reading = 1;
}
-static void redisPollDelRead(void *data) {
- redisPollEvents *e = (redisPollEvents*)data;
+static void redictPollDelRead(void *data) {
+ redictPollEvents *e = (redictPollEvents*)data;
e->reading = 0;
}
-static void redisPollAddWrite(void *data) {
- redisPollEvents *e = (redisPollEvents*)data;
+static void redictPollAddWrite(void *data) {
+ redictPollEvents *e = (redictPollEvents*)data;
e->writing = 1;
}
-static void redisPollDelWrite(void *data) {
- redisPollEvents *e = (redisPollEvents*)data;
+static void redictPollDelWrite(void *data) {
+ redictPollEvents *e = (redictPollEvents*)data;
e->writing = 0;
}
-static void redisPollCleanup(void *data) {
- redisPollEvents *e = (redisPollEvents*)data;
+static void redictPollCleanup(void *data) {
+ redictPollEvents *e = (redictPollEvents*)data;
/* if we are currently processing a tick, postpone deletion */
if (e->in_tick)
@@ -166,25 +166,25 @@ static void redisPollCleanup(void *data) {
hi_free(e);
}
-static void redisPollScheduleTimer(void *data, struct timeval tv)
+static void redictPollScheduleTimer(void *data, struct timeval tv)
{
- redisPollEvents *e = (redisPollEvents*)data;
- double now = redisPollGetNow();
- e->deadline = now + redisPollTimevalToDouble(&tv);
+ redictPollEvents *e = (redictPollEvents*)data;
+ double now = redictPollGetNow();
+ e->deadline = now + redictPollTimevalToDouble(&tv);
}
-static int redisPollAttach(redisAsyncContext *ac) {
- redisContext *c = &(ac->c);
- redisPollEvents *e;
+static int redictPollAttach(redictAsyncContext *ac) {
+ redictContext *c = &(ac->c);
+ redictPollEvents *e;
/* Nothing should be attached when something is already attached */
if (ac->ev.data != NULL)
- return REDIS_ERR;
+ return REDICT_ERR;
/* Create container for context and r/w events */
- e = (redisPollEvents*)hi_malloc(sizeof(*e));
+ e = (redictPollEvents*)hi_malloc(sizeof(*e));
if (e == NULL)
- return REDIS_ERR;
+ return REDICT_ERR;
memset(e, 0, sizeof(*e));
e->context = ac;
@@ -194,14 +194,14 @@ static int redisPollAttach(redisAsyncContext *ac) {
e->deadline = 0.0;
/* Register functions to start/stop listening for events */
- ac->ev.addRead = redisPollAddRead;
- ac->ev.delRead = redisPollDelRead;
- ac->ev.addWrite = redisPollAddWrite;
- ac->ev.delWrite = redisPollDelWrite;
- ac->ev.scheduleTimer = redisPollScheduleTimer;
- ac->ev.cleanup = redisPollCleanup;
+ ac->ev.addRead = redictPollAddRead;
+ ac->ev.delRead = redictPollDelRead;
+ ac->ev.addWrite = redictPollAddWrite;
+ ac->ev.delWrite = redictPollDelWrite;
+ ac->ev.scheduleTimer = redictPollScheduleTimer;
+ ac->ev.cleanup = redictPollCleanup;
ac->ev.data = e;
- return REDIS_OK;
+ return REDICT_OK;
}
-#endif /* HIREDIS_POLL_H */
+#endif /* HIREDICT_POLL_H */
diff --git a/adapters/qt.h b/adapters/qt.h
index a75cf31..de8d191 100644
--- a/adapters/qt.h
+++ b/adapters/qt.h
@@ -9,73 +9,73 @@
*
*/
-#ifndef __HIREDIS_QT_H__
-#define __HIREDIS_QT_H__
+#ifndef __HIREDICT_QT_H__
+#define __HIREDICT_QT_H__
#include <QSocketNotifier>
#include "../async.h"
-static void RedisQtAddRead(void *);
-static void RedisQtDelRead(void *);
-static void RedisQtAddWrite(void *);
-static void RedisQtDelWrite(void *);
-static void RedisQtCleanup(void *);
+static void RedictQtAddRead(void *);
+static void RedictQtDelRead(void *);
+static void RedictQtAddWrite(void *);
+static void RedictQtDelWrite(void *);
+static void RedictQtCleanup(void *);
-class RedisQtAdapter : public QObject {
+class RedictQtAdapter : public QObject {
Q_OBJECT
friend
- void RedisQtAddRead(void * adapter) {
- RedisQtAdapter * a = static_cast<RedisQtAdapter *>(adapter);
+ void RedictQtAddRead(void * adapter) {
+ RedictQtAdapter * a = static_cast<RedictQtAdapter *>(adapter);
a->addRead();
}
friend
- void RedisQtDelRead(void * adapter) {
- RedisQtAdapter * a = static_cast<RedisQtAdapter *>(adapter);
+ void RedictQtDelRead(void * adapter) {
+ RedictQtAdapter * a = static_cast<RedictQtAdapter *>(adapter);
a->delRead();
}
friend
- void RedisQtAddWrite(void * adapter) {
- RedisQtAdapter * a = static_cast<RedisQtAdapter *>(adapter);
+ void RedictQtAddWrite(void * adapter) {
+ RedictQtAdapter * a = static_cast<RedictQtAdapter *>(adapter);
a->addWrite();
}
friend
- void RedisQtDelWrite(void * adapter) {
- RedisQtAdapter * a = static_cast<RedisQtAdapter *>(adapter);
+ void RedictQtDelWrite(void * adapter) {
+ RedictQtAdapter * a = static_cast<RedictQtAdapter *>(adapter);
a->delWrite();
}
friend
- void RedisQtCleanup(void * adapter) {
- RedisQtAdapter * a = static_cast<RedisQtAdapter *>(adapter);
+ void RedictQtCleanup(void * adapter) {
+ RedictQtAdapter * a = static_cast<RedictQtAdapter *>(adapter);
a->cleanup();
}
public:
- RedisQtAdapter(QObject * parent = 0)
+ RedictQtAdapter(QObject * parent = 0)
: QObject(parent), m_ctx(0), m_read(0), m_write(0) { }
- ~RedisQtAdapter() {
+ ~RedictQtAdapter() {
if (m_ctx != 0) {
m_ctx->ev.data = NULL;
}
}
- int setContext(redisAsyncContext * ac) {
+ int setContext(redictAsyncContext * ac) {
if (ac->ev.data != NULL) {
- return REDIS_ERR;
+ return REDICT_ERR;
}
m_ctx = ac;
m_ctx->ev.data = this;
- m_ctx->ev.addRead = RedisQtAddRead;
- m_ctx->ev.delRead = RedisQtDelRead;
- m_ctx->ev.addWrite = RedisQtAddWrite;
- m_ctx->ev.delWrite = RedisQtDelWrite;
- m_ctx->ev.cleanup = RedisQtCleanup;
- return REDIS_OK;
+ m_ctx->ev.addRead = RedictQtAddRead;
+ m_ctx->ev.delRead = RedictQtDelRead;
+ m_ctx->ev.addWrite = RedictQtAddWrite;
+ m_ctx->ev.delWrite = RedictQtDelWrite;
+ m_ctx->ev.cleanup = RedictQtCleanup;
+ return REDICT_OK;
}
private:
@@ -109,13 +109,13 @@ class RedisQtAdapter : public QObject {
}
private slots:
- void read() { redisAsyncHandleRead(m_ctx); }
- void write() { redisAsyncHandleWrite(m_ctx); }
+ void read() { redictAsyncHandleRead(m_ctx); }
+ void write() { redictAsyncHandleWrite(m_ctx); }
private:
- redisAsyncContext * m_ctx;
+ redictAsyncContext * m_ctx;
QSocketNotifier * m_read;
QSocketNotifier * m_write;
};
-#endif /* !__HIREDIS_QT_H__ */
+#endif /* !__HIREDICT_QT_H__ */
diff --git a/adapters/redictmoduleapi.h b/adapters/redictmoduleapi.h
index 1a134f5..0238ba1 100644
--- a/adapters/redictmoduleapi.h
+++ b/adapters/redictmoduleapi.h
@@ -9,8 +9,8 @@
*
*/
-#ifndef __HIREDIS_REDISMODULEAPI_H__
-#define __HIREDIS_REDISMODULEAPI_H__
+#ifndef __HIREDICT_REDICTMODULEAPI_H__
+#define __HIREDICT_REDICTMODULEAPI_H__
#include "redictmodule.h"
@@ -19,120 +19,120 @@
#include <sys/types.h>
-typedef struct redisModuleEvents {
- redisAsyncContext *context;
- RedisModuleCtx *module_ctx;
+typedef struct redictModuleEvents {
+ redictAsyncContext *context;
+ RedictModuleCtx *module_ctx;
int fd;
int reading, writing;
int timer_active;
- RedisModuleTimerID timer_id;
-} redisModuleEvents;
+ RedictModuleTimerID timer_id;
+} redictModuleEvents;
-static inline void redisModuleReadEvent(int fd, void *privdata, int mask) {
+static inline void redictModuleReadEvent(int fd, void *privdata, int mask) {
(void) fd;
(void) mask;
- redisModuleEvents *e = (redisModuleEvents*)privdata;
- redisAsyncHandleRead(e->context);
+ redictModuleEvents *e = (redictModuleEvents*)privdata;
+ redictAsyncHandleRead(e->context);
}
-static inline void redisModuleWriteEvent(int fd, void *privdata, int mask) {
+static inline void redictModuleWriteEvent(int fd, void *privdata, int mask) {
(void) fd;
(void) mask;
- redisModuleEvents *e = (redisModuleEvents*)privdata;
- redisAsyncHandleWrite(e->context);
+ redictModuleEvents *e = (redictModuleEvents*)privdata;
+ redictAsyncHandleWrite(e->context);
}
-static inline void redisModuleAddRead(void *privdata) {
- redisModuleEvents *e = (redisModuleEvents*)privdata;
+static inline void redictModuleAddRead(void *privdata) {
+ redictModuleEvents *e = (redictModuleEvents*)privdata;
if (!e->reading) {
e->reading = 1;
- RedisModule_EventLoopAdd(e->fd, REDISMODULE_EVENTLOOP_READABLE, redisModuleReadEvent, e);
+ RedictModule_EventLoopAdd(e->fd, REDICTMODULE_EVENTLOOP_READABLE, redictModuleReadEvent, e);
}
}
-static inline void redisModuleDelRead(void *privdata) {
- redisModuleEvents *e = (redisModuleEvents*)privdata;
+static inline void redictModuleDelRead(void *privdata) {
+ redictModuleEvents *e = (redictModuleEvents*)privdata;
if (e->reading) {
e->reading = 0;
- RedisModule_EventLoopDel(e->fd, REDISMODULE_EVENTLOOP_READABLE);
+ RedictModule_EventLoopDel(e->fd, REDICTMODULE_EVENTLOOP_READABLE);
}
}
-static inline void redisModuleAddWrite(void *privdata) {
- redisModuleEvents *e = (redisModuleEvents*)privdata;
+static inline void redictModuleAddWrite(void *privdata) {
+ redictModuleEvents *e = (redictModuleEvents*)privdata;
if (!e->writing) {
e->writing = 1;
- RedisModule_EventLoopAdd(e->fd, REDISMODULE_EVENTLOOP_WRITABLE, redisModuleWriteEvent, e);
+ RedictModule_EventLoopAdd(e->fd, REDICTMODULE_EVENTLOOP_WRITABLE, redictModuleWriteEvent, e);
}
}
-static inline void redisModuleDelWrite(void *privdata) {
- redisModuleEvents *e = (redisModuleEvents*)privdata;
+static inline void redictModuleDelWrite(void *privdata) {
+ redictModuleEvents *e = (redictModuleEvents*)privdata;
if (e->writing) {
e->writing = 0;
- RedisModule_EventLoopDel(e->fd, REDISMODULE_EVENTLOOP_WRITABLE);
+ RedictModule_EventLoopDel(e->fd, REDICTMODULE_EVENTLOOP_WRITABLE);
}
}
-static inline void redisModuleStopTimer(void *privdata) {
- redisModuleEvents *e = (redisModuleEvents*)privdata;
+static inline void redictModuleStopTimer(void *privdata) {
+ redictModuleEvents *e = (redictModuleEvents*)privdata;
if (e->timer_active) {
- RedisModule_StopTimer(e->module_ctx, e->timer_id, NULL);
+ RedictModule_StopTimer(e->module_ctx, e->timer_id, NULL);
}
e->timer_active = 0;
}
-static inline void redisModuleCleanup(void *privdata) {
- redisModuleEvents *e = (redisModuleEvents*)privdata;
- redisModuleDelRead(privdata);
- redisModuleDelWrite(privdata);
- redisModuleStopTimer(privdata);
+static inline void redictModuleCleanup(void *privdata) {
+ redictModuleEvents *e = (redictModuleEvents*)privdata;
+ redictModuleDelRead(privdata);
+ redictModuleDelWrite(privdata);
+ redictModuleStopTimer(privdata);
hi_free(e);
}
-static inline void redisModuleTimeout(RedisModuleCtx *ctx, void *privdata) {
+static inline void redictModuleTimeout(RedictModuleCtx *ctx, void *privdata) {
(void) ctx;
- redisModuleEvents *e = (redisModuleEvents*)privdata;
+ redictModuleEvents *e = (redictModuleEvents*)privdata;
e->timer_active = 0;
- redisAsyncHandleTimeout(e->context);
+ redictAsyncHandleTimeout(e->context);
}
-static inline void redisModuleSetTimeout(void *privdata, struct timeval tv) {
- redisModuleEvents* e = (redisModuleEvents*)privdata;
+static inline void redictModuleSetTimeout(void *privdata, struct timeval tv) {
+ redictModuleEvents* e = (redictModuleEvents*)privdata;
- redisModuleStopTimer(privdata);
+ redictModuleStopTimer(privdata);
mstime_t millis = tv.tv_sec * 1000 + tv.tv_usec / 1000.0;
- e->timer_id = RedisModule_CreateTimer(e->module_ctx, millis, redisModuleTimeout, e);
+ e->timer_id = RedictModule_CreateTimer(e->module_ctx, millis, redictModuleTimeout, e);
e->timer_active = 1;
}
-/* Check if Redis version is compatible with the adapter. */
-static inline int redisModuleCompatibilityCheck(void) {
- if (!RedisModule_EventLoopAdd ||
- !RedisModule_EventLoopDel ||
- !RedisModule_CreateTimer ||
- !RedisModule_StopTimer) {
- return REDIS_ERR;
+/* Check if Redict is compatible with the adapter. */
+static inline int redictModuleCompatibilityCheck(void) {
+ if (!RedictModule_EventLoopAdd ||
+ !RedictModule_EventLoopDel ||
+ !RedictModule_CreateTimer ||
+ !RedictModule_StopTimer) {
+ return REDICT_ERR;
}
- return REDIS_OK;
+ return REDICT_OK;
}
-static inline int redisModuleAttach(redisAsyncContext *ac, RedisModuleCtx *module_ctx) {
- redisContext *c = &(ac->c);
- redisModuleEvents *e;
+static inline int redictModuleAttach(redictAsyncContext *ac, RedictModuleCtx *module_ctx) {
+ redictContext *c = &(ac->c);
+ redictModuleEvents *e;
/* Nothing should be attached when something is already attached */
if (ac->ev.data != NULL)
- return REDIS_ERR;
+ return REDICT_ERR;
/* Create container for context and r/w events */
- e = (redisModuleEvents*)hi_malloc(sizeof(*e));
+ e = (redictModuleEvents*)hi_malloc(sizeof(*e));
if (e == NULL)
- return REDIS_ERR;
+ return REDICT_ERR;
e->context = ac;
e->module_ctx = module_ctx;
@@ -141,15 +141,15 @@ static inline int redisModuleAttach(redisAsyncContext *ac, RedisModuleCtx *modul
e->timer_active = 0;
/* Register functions to start/stop listening for events */
- ac->ev.addRead = redisModuleAddRead;
- ac->ev.delRead = redisModuleDelRead;
- ac->ev.addWrite = redisModuleAddWrite;
- ac->ev.delWrite = redisModuleDelWrite;
- ac->ev.cleanup = redisModuleCleanup;
- ac->ev.scheduleTimer = redisModuleSetTimeout;
+ ac->ev.addRead = redictModuleAddRead;
+ ac->ev.delRead = redictModuleDelRead;
+ ac->ev.addWrite = redictModuleAddWrite;
+ ac->ev.delWrite = redictModuleDelWrite;
+ ac->ev.cleanup = redictModuleCleanup;
+ ac->ev.scheduleTimer = redictModuleSetTimeout;
ac->ev.data = e;
- return REDIS_OK;
+ return REDICT_OK;
}
#endif