-#define REDISMODULE_TYPE_METHOD_VERSION 1
-typedef struct RedisModuleTypeMethods {
- uint64_t version;
- RedisModuleTypeLoadFunc rdb_load;
- RedisModuleTypeSaveFunc rdb_save;
- RedisModuleTypeRewriteFunc aof_rewrite;
- RedisModuleTypeMemUsageFunc mem_usage;
- RedisModuleTypeDigestFunc digest;
- RedisModuleTypeFreeFunc free;
-} RedisModuleTypeMethods;
-
-#define REDISMODULE_GET_API(name) \
- RedisModule_GetApi("RedisModule_" #name, ((void **)&RedisModule_ ## name))
-
-#define REDISMODULE_API_FUNC(x) (*x)
-
-#if 1
-
-
-typedef struct redisObject {
- unsigned type:4;
- unsigned encoding:4;
- int refcount;
- void *ptr;
-} robj;
-/* This structure represents a module inside the system. */
-struct RedisModule {
- void *handle; /* Module dlopen() handle. */
- char *name; /* Module name. */
- int ver; /* Module version. We use just progressive integers. */
- int apiver; /* Module API version as requested during initialization.*/
- //list *types; /* Module data types. */
-};
-typedef struct RedisModule RedisModule;
-
-//static dict *modules; /* Hash table of modules. SDS -> RedisModule ptr.*/
-
-/* Entries in the context->amqueue array, representing objects to free
- * when the callback returns. */
-struct AutoMemEntry {
- void *ptr;
- int type;
-};
-
-/* AutMemEntry type field values. */
-#define REDISMODULE_AM_KEY 0
-#define REDISMODULE_AM_STRING 1
-#define REDISMODULE_AM_REPLY 2
-#define REDISMODULE_AM_FREED 3 /* Explicitly freed by user already. */
-
-/* The pool allocator block. Redis Modules can allocate memory via this special
- * allocator that will automatically release it all once the callback returns.
- * This means that it can only be used for ephemeral allocations. However
- * there are two advantages for modules to use this API:
- *
- * 1) The memory is automatically released when the callback returns.
- * 2) This allocator is faster for many small allocations since whole blocks
- * are allocated, and small pieces returned to the caller just advancing
- * the index of the allocation.
- *
- * Allocations are always rounded to the size of the void pointer in order
- * to always return aligned memory chunks. */
-
-#define REDISMODULE_POOL_ALLOC_MIN_SIZE (1024*8)
-#define REDISMODULE_POOL_ALLOC_ALIGN (sizeof(void*))
-
-typedef struct RedisModulePoolAllocBlock {
- uint32_t size;
- uint32_t used;
- struct RedisModulePoolAllocBlock *next;
- char memory[];
-} RedisModulePoolAllocBlock;
-
-/* This structure represents the context in which Redis modules operate.
- * Most APIs module can access, get a pointer to the context, so that the API
- * implementation can hold state across calls, or remember what to free after
- * the call and so forth.
- *
- * Note that not all the context structure is always filled with actual values
- * but only the fields needed in a given context. */
-
-struct RedisModuleBlockedClient;
-
-struct RedisModuleCtx {
- void *getapifuncptr; /* NOTE: Must be the first field. */
- struct RedisModule *module; /* Module reference. */
- //client *client; /* Client calling a command. */
- struct RedisModuleBlockedClient *blocked_client; /* Blocked client for
- thread safe context. */
- struct AutoMemEntry *amqueue; /* Auto memory queue of objects to free. */
- int amqueue_len; /* Number of slots in amqueue. */
- int amqueue_used; /* Number of used slots in amqueue. */
- int flags; /* REDISMODULE_CTX_... flags. */
- void **postponed_arrays; /* To set with RM_ReplySetArrayLength(). */
- int postponed_arrays_count; /* Number of entries in postponed_arrays. */
- void *blocked_privdata; /* Privdata set when unblocking a client. */
-
- /* Used if there is the REDISMODULE_CTX_KEYS_POS_REQUEST flag set. */
- int *keys_pos;
- int keys_count;
-
- struct RedisModulePoolAllocBlock *pa_head;
-};
-typedef struct RedisModuleCtx RedisModuleCtx;
-
-#define REDISMODULE_CTX_INIT {(void*)(unsigned long)&RM_GetApi, NULL, NULL, NULL, NULL, 0, 0, 0, NULL, 0, NULL, NULL, 0, NULL}
-#define REDISMODULE_CTX_MULTI_EMITTED (1<<0)
-#define REDISMODULE_CTX_AUTO_MEMORY (1<<1)
-#define REDISMODULE_CTX_KEYS_POS_REQUEST (1<<2)
-#define REDISMODULE_CTX_BLOCKED_REPLY (1<<3)
-#define REDISMODULE_CTX_BLOCKED_TIMEOUT (1<<4)
-#define REDISMODULE_CTX_THREAD_SAFE (1<<5)
-
-/* This represents a Redis key opened with RM_OpenKey(). */
-struct RedisModuleKey {
- RedisModuleCtx *ctx;
- //redisDb *db;
- robj *key; /* Key name object. */
- robj *value; /* Value object, or NULL if the key was not found. */
- void *iter; /* Iterator. */
- int mode; /* Opening mode. */
-
- /* Zset iterator. */
- uint32_t ztype; /* REDISMODULE_ZSET_RANGE_* */
- //zrangespec zrs; /* Score range. */
- //zlexrangespec zlrs; /* Lex range. */
- uint32_t zstart; /* Start pos for positional ranges. */
- uint32_t zend; /* End pos for positional ranges. */
- void *zcurrent; /* Zset iterator current node. */
- int zer; /* Zset iterator end reached flag
- (true if end was reached). */
-};
-typedef struct RedisModuleKey RedisModuleKey;
-
-/* RedisModuleKey 'ztype' values. */
-#define REDISMODULE_ZSET_RANGE_NONE 0 /* This must always be 0. */
-#define REDISMODULE_ZSET_RANGE_LEX 1
-#define REDISMODULE_ZSET_RANGE_SCORE 2
-#define REDISMODULE_ZSET_RANGE_POS 3
-
-/* Function pointer type of a function representing a command inside
- * a Redis module. */
-