[
  {
    "path": "README.md",
    "content": "# RedisModules ExecuteCommand for Windows\n可在Windows下执行系统命令的Redis模块 。   \n可在Linux下执行系统命令的Redis模块在 ![这里](https://github.com/puckiestyle/RedisModules-ExecuteCommand)\n\n## 快速开始\n已经有编译好了的模块`exp.dll`，你也可以自行修改、编译，以下是可参考的的步骤：  \n1.  用vs2017打开exp.sln文件。\n2.  修改exp.c源文件。\n2.  编译生成模块`exp.dll`  。\n4.  在Redis中加载`exp.dll`，并使用模块的命令  。\n\n## 模块命令  \n该模块有一个命令`e`，可以执行系统命令。\n在redis-cli命令行下，执行如下命令：\n\n```\n127.0.0.1:6379> module load exp.dll\n127.0.0.1:6379> exp.e whoami\n127.0.0.1:6379> exp.e net user\n```\n\n![62556355199](pic/1625563551991.png)  \n\n## 反馈\nMail：h.vi@qq.com   \n或者 [issue](https://github.com/0671/RedisModules-ExecuteCommand-for-Windows/issues/new)、PR  \n\n## Stargazers over time\n\n[![Stargazers over time](https://starchart.cc/0671/RedisModules-ExecuteCommand-for-Windows.svg)](https://github.com/0671/RedisModules-ExecuteCommand-for-Windows)\n"
  },
  {
    "path": "exp/exp.c",
    "content": "﻿#define _CRT_SECURE_NO_WARNINGS\n#include <string.h>\n#include <stdlib.h>\n#include \"win32_port.h\"\n#include \"redismodule.h\"\n#ifdef _WIN32\n#define strncasecmp(s1, s2, len) _strnicmp(s1, s2, len)\n#define strcasecmp(s1, s2) _stricmp(s1, s2)\n#endif\n\n\n\nchar * join(char*s1, char*s2) {\n\tchar *result = malloc(strlen(s1) + strlen(s2) + 1 + 1);\n\tif (result == NULL) exit(1);\n\tstrcpy(result, s1);\n\tstrcat(result, \" \");\n\tstrcat(result, s2);\n\treturn result;\n}\n\n\nint DoCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) {\n\n\tchar *_cmd;\n\tsize_t _cmd_len;\n\tsize_t size = 1024; //µ¥Î»\n\tchar *all_cmd = \"\";\n\tif (argc >= 2)\n\t{\n\t\tfor (size_t i = 1; i < argc; i++)\n\t\t{\n\t\t\t_cmd = RedisModule_StringPtrLen(argv[i], &_cmd_len);\n\t\t\tall_cmd = join(all_cmd, _cmd);\n\t\t}\n\n\t\tFILE *fp = _popen(all_cmd, \"r\");\n\t\tchar *buf, *output;\n\t\tbuf = (char *)malloc(size);\n\t\toutput = \"{\";\n\n\t\twhile (fgets(buf, sizeof(buf), fp) != 0) {\n\t\t\toutput = join(output, buf);\n\t\t}\n\t\toutput = join(output, \"}\");\n\t\tRedisModuleString *ret = RedisModule_CreateString(ctx, output, strlen(output));\n\t\tRedisModule_ReplyWithString(ctx, ret);\n\t\t_pclose(fp);\n\t}\n\treturn REDISMODULE_OK;\n}\n\n#ifdef _WIN32\n__declspec(dllexport)\n#endif\nint RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) {\n\t// Register the module\n\tif (RedisModule_Init(ctx, \"exp\", 1, REDISMODULE_APIVER_1) ==\n\t\tREDISMODULE_ERR)\n\t\treturn REDISMODULE_ERR;\n\n\tif (RedisModule_CreateCommand(ctx, \"exp.e\", DoCommand, \"readonly\", 1, 1, 1) ==\n\t\tREDISMODULE_ERR)\n\t\treturn REDISMODULE_ERR;\n\n\treturn REDISMODULE_OK;\n}"
  },
  {
    "path": "exp/exp.vcxproj",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project DefaultTargets=\"Build\" ToolsVersion=\"15.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n  <ItemGroup Label=\"ProjectConfigurations\">\n    <ProjectConfiguration Include=\"Debug|Win32\">\n      <Configuration>Debug</Configuration>\n      <Platform>Win32</Platform>\n    </ProjectConfiguration>\n    <ProjectConfiguration Include=\"Release|Win32\">\n      <Configuration>Release</Configuration>\n      <Platform>Win32</Platform>\n    </ProjectConfiguration>\n    <ProjectConfiguration Include=\"Debug|x64\">\n      <Configuration>Debug</Configuration>\n      <Platform>x64</Platform>\n    </ProjectConfiguration>\n    <ProjectConfiguration Include=\"Release|x64\">\n      <Configuration>Release</Configuration>\n      <Platform>x64</Platform>\n    </ProjectConfiguration>\n  </ItemGroup>\n  <PropertyGroup Label=\"Globals\">\n    <VCProjectVersion>15.0</VCProjectVersion>\n    <ProjectGuid>{D9081C23-553E-47EA-80C8-FE534EF58EAB}</ProjectGuid>\n    <Keyword>Win32Proj</Keyword>\n    <RootNamespace>exp</RootNamespace>\n    <WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>\n  </PropertyGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\" Label=\"Configuration\">\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\n    <UseDebugLibraries>true</UseDebugLibraries>\n    <PlatformToolset>v141</PlatformToolset>\n    <CharacterSet>Unicode</CharacterSet>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\" Label=\"Configuration\">\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\n    <UseDebugLibraries>false</UseDebugLibraries>\n    <PlatformToolset>v141</PlatformToolset>\n    <WholeProgramOptimization>true</WholeProgramOptimization>\n    <CharacterSet>Unicode</CharacterSet>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\" Label=\"Configuration\">\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\n    <UseDebugLibraries>true</UseDebugLibraries>\n    <PlatformToolset>v141</PlatformToolset>\n    <CharacterSet>Unicode</CharacterSet>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\" Label=\"Configuration\">\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\n    <UseDebugLibraries>false</UseDebugLibraries>\n    <PlatformToolset>v141</PlatformToolset>\n    <WholeProgramOptimization>true</WholeProgramOptimization>\n    <CharacterSet>Unicode</CharacterSet>\n    <SpectreMitigation>false</SpectreMitigation>\n  </PropertyGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />\n  <ImportGroup Label=\"ExtensionSettings\">\n  </ImportGroup>\n  <ImportGroup Label=\"Shared\">\n  </ImportGroup>\n  <ImportGroup Label=\"PropertySheets\" Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\n  </ImportGroup>\n  <ImportGroup Label=\"PropertySheets\" Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\n  </ImportGroup>\n  <ImportGroup Label=\"PropertySheets\" Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\n  </ImportGroup>\n  <ImportGroup Label=\"PropertySheets\" Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\n  </ImportGroup>\n  <PropertyGroup Label=\"UserMacros\" />\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">\n    <LinkIncremental>true</LinkIncremental>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\n    <LinkIncremental>true</LinkIncremental>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">\n    <LinkIncremental>false</LinkIncremental>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\n    <LinkIncremental>false</LinkIncremental>\n  </PropertyGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">\n    <ClCompile>\n      <PrecompiledHeader>Use</PrecompiledHeader>\n      <WarningLevel>Level3</WarningLevel>\n      <Optimization>Disabled</Optimization>\n      <SDLCheck>true</SDLCheck>\n      <PreprocessorDefinitions>WIN32;_DEBUG;EXP_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n      <ConformanceMode>true</ConformanceMode>\n    </ClCompile>\n    <Link>\n      <SubSystem>Windows</SubSystem>\n      <GenerateDebugInformation>true</GenerateDebugInformation>\n    </Link>\n  </ItemDefinitionGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\n    <ClCompile>\n      <PrecompiledHeader>Use</PrecompiledHeader>\n      <WarningLevel>Level3</WarningLevel>\n      <Optimization>Disabled</Optimization>\n      <SDLCheck>true</SDLCheck>\n      <PreprocessorDefinitions>_DEBUG;EXP_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n      <ConformanceMode>true</ConformanceMode>\n    </ClCompile>\n    <Link>\n      <SubSystem>Windows</SubSystem>\n      <GenerateDebugInformation>true</GenerateDebugInformation>\n    </Link>\n  </ItemDefinitionGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">\n    <ClCompile>\n      <PrecompiledHeader>Use</PrecompiledHeader>\n      <WarningLevel>Level3</WarningLevel>\n      <Optimization>MaxSpeed</Optimization>\n      <FunctionLevelLinking>true</FunctionLevelLinking>\n      <IntrinsicFunctions>true</IntrinsicFunctions>\n      <SDLCheck>true</SDLCheck>\n      <PreprocessorDefinitions>WIN32;NDEBUG;EXP_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n      <ConformanceMode>true</ConformanceMode>\n    </ClCompile>\n    <Link>\n      <SubSystem>Windows</SubSystem>\n      <EnableCOMDATFolding>true</EnableCOMDATFolding>\n      <OptimizeReferences>true</OptimizeReferences>\n      <GenerateDebugInformation>true</GenerateDebugInformation>\n    </Link>\n  </ItemDefinitionGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\n    <ClCompile>\n      <PrecompiledHeader>NotUsing</PrecompiledHeader>\n      <WarningLevel>Level3</WarningLevel>\n      <Optimization>MaxSpeed</Optimization>\n      <FunctionLevelLinking>true</FunctionLevelLinking>\n      <IntrinsicFunctions>true</IntrinsicFunctions>\n      <SDLCheck>true</SDLCheck>\n      <PreprocessorDefinitions>NDEBUG;EXP_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n      <ConformanceMode>true</ConformanceMode>\n    </ClCompile>\n    <Link>\n      <SubSystem>Windows</SubSystem>\n      <EnableCOMDATFolding>true</EnableCOMDATFolding>\n      <OptimizeReferences>true</OptimizeReferences>\n      <GenerateDebugInformation>true</GenerateDebugInformation>\n    </Link>\n  </ItemDefinitionGroup>\n  <ItemGroup>\n    <ClCompile Include=\"exp.c\" />\n  </ItemGroup>\n  <ItemGroup>\n    <ClInclude Include=\"redismodule.h\" />\n    <ClInclude Include=\"win32_port.h\" />\n  </ItemGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\" />\n  <ImportGroup Label=\"ExtensionTargets\">\n  </ImportGroup>\n</Project>"
  },
  {
    "path": "exp/exp.vcxproj.filters",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n  <ItemGroup>\n    <Filter Include=\"源文件\">\n      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>\n      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>\n    </Filter>\n    <Filter Include=\"头文件\">\n      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>\n      <Extensions>h;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions>\n    </Filter>\n    <Filter Include=\"资源文件\">\n      <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>\n      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>\n    </Filter>\n  </ItemGroup>\n  <ItemGroup>\n    <ClInclude Include=\"win32_port.h\">\n      <Filter>头文件</Filter>\n    </ClInclude>\n    <ClInclude Include=\"redismodule.h\">\n      <Filter>头文件</Filter>\n    </ClInclude>\n  </ItemGroup>\n  <ItemGroup>\n    <ClCompile Include=\"exp.c\">\n      <Filter>源文件</Filter>\n    </ClCompile>\n  </ItemGroup>\n</Project>"
  },
  {
    "path": "exp/exp.vcxproj.user",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project ToolsVersion=\"15.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n  <PropertyGroup />\n</Project>"
  },
  {
    "path": "exp/redismodule.h",
    "content": "#ifndef REDISMODULE_H\n#define REDISMODULE_H\n\n#include <sys/types.h>\n#include <stdint.h>\n#include <stdio.h>\n\n#include \"win32_port.h\"\n\n/* ---------------- Defines common between core and modules --------------- */\n\n/* Error status return values. */\n#define REDISMODULE_OK 0\n#define REDISMODULE_ERR 1\n\n/* API versions. */\n#define REDISMODULE_APIVER_1 1\n\n/* API flags and constants */\n#define REDISMODULE_READ (1<<0)\n#define REDISMODULE_WRITE (1<<1)\n\n#define REDISMODULE_LIST_HEAD 0\n#define REDISMODULE_LIST_TAIL 1\n\n/* Key types. */\n#define REDISMODULE_KEYTYPE_EMPTY 0\n#define REDISMODULE_KEYTYPE_STRING 1\n#define REDISMODULE_KEYTYPE_LIST 2\n#define REDISMODULE_KEYTYPE_HASH 3\n#define REDISMODULE_KEYTYPE_SET 4\n#define REDISMODULE_KEYTYPE_ZSET 5\n#define REDISMODULE_KEYTYPE_MODULE 6\n\n/* Reply types. */\n#define REDISMODULE_REPLY_UNKNOWN -1\n#define REDISMODULE_REPLY_STRING 0\n#define REDISMODULE_REPLY_ERROR 1\n#define REDISMODULE_REPLY_INTEGER 2\n#define REDISMODULE_REPLY_ARRAY 3\n#define REDISMODULE_REPLY_NULL 4\n\n/* Postponed array length. */\n#define REDISMODULE_POSTPONED_ARRAY_LEN -1\n\n/* Expire */\n#define REDISMODULE_NO_EXPIRE -1\n\n/* Sorted set API flags. */\n#define REDISMODULE_ZADD_XX      (1<<0)\n#define REDISMODULE_ZADD_NX      (1<<1)\n#define REDISMODULE_ZADD_ADDED   (1<<2)\n#define REDISMODULE_ZADD_UPDATED (1<<3)\n#define REDISMODULE_ZADD_NOP     (1<<4)\n\n/* Hash API flags. */\n#define REDISMODULE_HASH_NONE       0\n#define REDISMODULE_HASH_NX         (1<<0)\n#define REDISMODULE_HASH_XX         (1<<1)\n#define REDISMODULE_HASH_CFIELDS    (1<<2)\n#define REDISMODULE_HASH_EXISTS     (1<<3)\n\n/* A special pointer that we can use between the core and the module to signal\n * field deletion, and that is impossible to be a valid pointer. */\n#define REDISMODULE_HASH_DELETE ((RedisModuleString*)(PORT_LONG)1)\n\n /* Error messages. */\n#define REDISMODULE_ERRORMSG_WRONGTYPE \"WRONGTYPE Operation against a key holding the wrong kind of value\"\n\n#define REDISMODULE_POSITIVE_INFINITE (1.0/0.0)\n#define REDISMODULE_NEGATIVE_INFINITE (-1.0/0.0)\n\n#define REDISMODULE_NOT_USED(V) ((void) V)\n\n/* ------------------------- End of common defines ------------------------ */\n\n#ifndef REDISMODULE_CORE\n\ntypedef PORT_LONGLONG mstime_t;\n\n/* Incomplete structures for compiler checks but opaque access. */\ntypedef struct RedisModuleCtx RedisModuleCtx;\ntypedef struct RedisModuleKey RedisModuleKey;\ntypedef struct RedisModuleString RedisModuleString;\ntypedef struct RedisModuleCallReply RedisModuleCallReply;\ntypedef struct RedisModuleIO RedisModuleIO;\ntypedef struct RedisModuleType RedisModuleType;\ntypedef struct RedisModuleDigest RedisModuleDigest;\ntypedef struct RedisModuleBlockedClient RedisModuleBlockedClient;\n\ntypedef int(*RedisModuleCmdFunc) (RedisModuleCtx *ctx, RedisModuleString **argv, int argc);\n\ntypedef void *(*RedisModuleTypeLoadFunc)(RedisModuleIO *rdb, int encver);\ntypedef void(*RedisModuleTypeSaveFunc)(RedisModuleIO *rdb, void *value);\ntypedef void(*RedisModuleTypeRewriteFunc)(RedisModuleIO *aof, RedisModuleString *key, void *value);\ntypedef size_t(*RedisModuleTypeMemUsageFunc)(const void *value);\ntypedef void(*RedisModuleTypeDigestFunc)(RedisModuleDigest *digest, void *value);\ntypedef void(*RedisModuleTypeFreeFunc)(void *value);\n\n#define REDISMODULE_TYPE_METHOD_VERSION 1\ntypedef struct RedisModuleTypeMethods {\n\tuint64_t version;\n\tRedisModuleTypeLoadFunc rdb_load;\n\tRedisModuleTypeSaveFunc rdb_save;\n\tRedisModuleTypeRewriteFunc aof_rewrite;\n\tRedisModuleTypeMemUsageFunc mem_usage;\n\tRedisModuleTypeDigestFunc digest;\n\tRedisModuleTypeFreeFunc free;\n} RedisModuleTypeMethods;\n\n#define REDISMODULE_GET_API(name) \\\n    RedisModule_GetApi(\"RedisModule_\" #name, ((void **)&RedisModule_ ## name))\n\n#define REDISMODULE_API_FUNC(x) (*x)\n\n\nvoid *REDISMODULE_API_FUNC(RedisModule_Alloc)(size_t bytes);\nvoid *REDISMODULE_API_FUNC(RedisModule_Realloc)(void *ptr, size_t bytes);\nvoid REDISMODULE_API_FUNC(RedisModule_Free)(void *ptr);\nvoid *REDISMODULE_API_FUNC(RedisModule_Calloc)(size_t nmemb, size_t size);\nchar *REDISMODULE_API_FUNC(RedisModule_Strdup)(const char *str);\nint REDISMODULE_API_FUNC(RedisModule_GetApi)(const char *, void *);\nint REDISMODULE_API_FUNC(RedisModule_CreateCommand)(RedisModuleCtx *ctx, const char *name, RedisModuleCmdFunc cmdfunc, const char *strflags, int firstkey, int lastkey, int keystep);\nint REDISMODULE_API_FUNC(RedisModule_SetModuleAttribs)(RedisModuleCtx *ctx, const char *name, int ver, int apiver);\nint REDISMODULE_API_FUNC(RedisModule_WrongArity)(RedisModuleCtx *ctx);\nint REDISMODULE_API_FUNC(RedisModule_ReplyWithLongLong)(RedisModuleCtx *ctx, PORT_LONGLONG ll);\nint REDISMODULE_API_FUNC(RedisModule_GetSelectedDb)(RedisModuleCtx *ctx);\nint REDISMODULE_API_FUNC(RedisModule_SelectDb)(RedisModuleCtx *ctx, int newid);\nvoid *REDISMODULE_API_FUNC(RedisModule_OpenKey)(RedisModuleCtx *ctx, RedisModuleString *keyname, int mode);\nvoid REDISMODULE_API_FUNC(RedisModule_CloseKey)(RedisModuleKey *kp);\nint REDISMODULE_API_FUNC(RedisModule_KeyType)(RedisModuleKey *kp);\nsize_t REDISMODULE_API_FUNC(RedisModule_ValueLength)(RedisModuleKey *kp);\nint REDISMODULE_API_FUNC(RedisModule_ListPush)(RedisModuleKey *kp, int where, RedisModuleString *ele);\nRedisModuleString *REDISMODULE_API_FUNC(RedisModule_ListPop)(RedisModuleKey *key, int where);\nRedisModuleCallReply *REDISMODULE_API_FUNC(RedisModule_Call)(RedisModuleCtx *ctx, const char *cmdname, const char *fmt, ...);\nconst char *REDISMODULE_API_FUNC(RedisModule_CallReplyProto)(RedisModuleCallReply *reply, size_t *len);\nvoid REDISMODULE_API_FUNC(RedisModule_FreeCallReply)(RedisModuleCallReply *reply);\nint REDISMODULE_API_FUNC(RedisModule_CallReplyType)(RedisModuleCallReply *reply);\nPORT_LONGLONG REDISMODULE_API_FUNC(RedisModule_CallReplyInteger)(RedisModuleCallReply *reply);\nsize_t REDISMODULE_API_FUNC(RedisModule_CallReplyLength)(RedisModuleCallReply *reply);\nRedisModuleCallReply *REDISMODULE_API_FUNC(RedisModule_CallReplyArrayElement)(RedisModuleCallReply *reply, size_t idx);\nRedisModuleString *REDISMODULE_API_FUNC(RedisModule_CreateString)(RedisModuleCtx *ctx, const char *ptr, size_t len);\nRedisModuleString *REDISMODULE_API_FUNC(RedisModule_CreateStringFromLongLong)(RedisModuleCtx *ctx, PORT_LONGLONG ll);\nRedisModuleString *REDISMODULE_API_FUNC(RedisModule_CreateStringFromString)(RedisModuleCtx *ctx, const RedisModuleString *str);\nRedisModuleString *REDISMODULE_API_FUNC(RedisModule_CreateStringPrintf)(RedisModuleCtx *ctx, const char *fmt, ...);\nvoid REDISMODULE_API_FUNC(RedisModule_FreeString)(RedisModuleCtx *ctx, RedisModuleString *str);\nconst char *REDISMODULE_API_FUNC(RedisModule_StringPtrLen)(const RedisModuleString *str, size_t *len);\nint REDISMODULE_API_FUNC(RedisModule_ReplyWithError)(RedisModuleCtx *ctx, const char *err);\nint REDISMODULE_API_FUNC(RedisModule_ReplyWithSimpleString)(RedisModuleCtx *ctx, const char *msg);\nint REDISMODULE_API_FUNC(RedisModule_ReplyWithArray)(RedisModuleCtx *ctx, PORT_LONG len);\nvoid REDISMODULE_API_FUNC(RedisModule_ReplySetArrayLength)(RedisModuleCtx *ctx, PORT_LONG len);\nint REDISMODULE_API_FUNC(RedisModule_ReplyWithStringBuffer)(RedisModuleCtx *ctx, const char *buf, size_t len);\nint REDISMODULE_API_FUNC(RedisModule_ReplyWithString)(RedisModuleCtx *ctx, RedisModuleString *str);\nint REDISMODULE_API_FUNC(RedisModule_ReplyWithNull)(RedisModuleCtx *ctx);\nint REDISMODULE_API_FUNC(RedisModule_ReplyWithDouble)(RedisModuleCtx *ctx, PORT_LONGDOUBLE d);\nint REDISMODULE_API_FUNC(RedisModule_ReplyWithCallReply)(RedisModuleCtx *ctx, RedisModuleCallReply *reply);\nint REDISMODULE_API_FUNC(RedisModule_StringToLongLong)(const RedisModuleString *str, PORT_LONGLONG *ll);\nint REDISMODULE_API_FUNC(RedisModule_StringToDouble)(const RedisModuleString *str, PORT_LONGDOUBLE *d);\nvoid REDISMODULE_API_FUNC(RedisModule_AutoMemory)(RedisModuleCtx *ctx);\nint REDISMODULE_API_FUNC(RedisModule_Replicate)(RedisModuleCtx *ctx, const char *cmdname, const char *fmt, ...);\nint REDISMODULE_API_FUNC(RedisModule_ReplicateVerbatim)(RedisModuleCtx *ctx);\nconst char *REDISMODULE_API_FUNC(RedisModule_CallReplyStringPtr)(RedisModuleCallReply *reply, size_t *len);\nRedisModuleString *REDISMODULE_API_FUNC(RedisModule_CreateStringFromCallReply)(RedisModuleCallReply *reply);\nint REDISMODULE_API_FUNC(RedisModule_DeleteKey)(RedisModuleKey *key);\nint REDISMODULE_API_FUNC(RedisModule_StringSet)(RedisModuleKey *key, RedisModuleString *str);\nchar *REDISMODULE_API_FUNC(RedisModule_StringDMA)(RedisModuleKey *key, size_t *len, int mode);\nint REDISMODULE_API_FUNC(RedisModule_StringTruncate)(RedisModuleKey *key, size_t newlen);\nmstime_t REDISMODULE_API_FUNC(RedisModule_GetExpire)(RedisModuleKey *key);\nint REDISMODULE_API_FUNC(RedisModule_SetExpire)(RedisModuleKey *key, mstime_t expire);\nint REDISMODULE_API_FUNC(RedisModule_ZsetAdd)(RedisModuleKey *key, PORT_LONGDOUBLE score, RedisModuleString *ele, int *flagsptr);\nint REDISMODULE_API_FUNC(RedisModule_ZsetIncrby)(RedisModuleKey *key, PORT_LONGDOUBLE score, RedisModuleString *ele, int *flagsptr, PORT_LONGDOUBLE *newscore);\nint REDISMODULE_API_FUNC(RedisModule_ZsetScore)(RedisModuleKey *key, RedisModuleString *ele, PORT_LONGDOUBLE *score);\nint REDISMODULE_API_FUNC(RedisModule_ZsetRem)(RedisModuleKey *key, RedisModuleString *ele, int *deleted);\nvoid REDISMODULE_API_FUNC(RedisModule_ZsetRangeStop)(RedisModuleKey *key);\nint REDISMODULE_API_FUNC(RedisModule_ZsetFirstInScoreRange)(RedisModuleKey *key, PORT_LONGDOUBLE min, PORT_LONGDOUBLE max, int minex, int maxex);\nint REDISMODULE_API_FUNC(RedisModule_ZsetLastInScoreRange)(RedisModuleKey *key, PORT_LONGDOUBLE min, PORT_LONGDOUBLE max, int minex, int maxex);\nint REDISMODULE_API_FUNC(RedisModule_ZsetFirstInLexRange)(RedisModuleKey *key, RedisModuleString *min, RedisModuleString *max);\nint REDISMODULE_API_FUNC(RedisModule_ZsetLastInLexRange)(RedisModuleKey *key, RedisModuleString *min, RedisModuleString *max);\nRedisModuleString *REDISMODULE_API_FUNC(RedisModule_ZsetRangeCurrentElement)(RedisModuleKey *key, PORT_LONGDOUBLE *score);\nint REDISMODULE_API_FUNC(RedisModule_ZsetRangeNext)(RedisModuleKey *key);\nint REDISMODULE_API_FUNC(RedisModule_ZsetRangePrev)(RedisModuleKey *key);\nint REDISMODULE_API_FUNC(RedisModule_ZsetRangeEndReached)(RedisModuleKey *key);\nint REDISMODULE_API_FUNC(RedisModule_HashSet)(RedisModuleKey *key, int flags, ...);\nint REDISMODULE_API_FUNC(RedisModule_HashGet)(RedisModuleKey *key, int flags, ...);\nint REDISMODULE_API_FUNC(RedisModule_IsKeysPositionRequest)(RedisModuleCtx *ctx);\nvoid REDISMODULE_API_FUNC(RedisModule_KeyAtPos)(RedisModuleCtx *ctx, int pos);\nPORT_ULONGLONG REDISMODULE_API_FUNC(RedisModule_GetClientId)(RedisModuleCtx *ctx);\nvoid *REDISMODULE_API_FUNC(RedisModule_PoolAlloc)(RedisModuleCtx *ctx, size_t bytes);\nRedisModuleType *REDISMODULE_API_FUNC(RedisModule_CreateDataType)(RedisModuleCtx *ctx, const char *name, int encver, RedisModuleTypeMethods *typemethods);\nint REDISMODULE_API_FUNC(RedisModule_ModuleTypeSetValue)(RedisModuleKey *key, RedisModuleType *mt, void *value);\nRedisModuleType *REDISMODULE_API_FUNC(RedisModule_ModuleTypeGetType)(RedisModuleKey *key);\nvoid *REDISMODULE_API_FUNC(RedisModule_ModuleTypeGetValue)(RedisModuleKey *key);\nvoid REDISMODULE_API_FUNC(RedisModule_SaveUnsigned)(RedisModuleIO *io, uint64_t value);\nuint64_t REDISMODULE_API_FUNC(RedisModule_LoadUnsigned)(RedisModuleIO *io);\nvoid REDISMODULE_API_FUNC(RedisModule_SaveSigned)(RedisModuleIO *io, int64_t value);\nint64_t REDISMODULE_API_FUNC(RedisModule_LoadSigned)(RedisModuleIO *io);\nvoid REDISMODULE_API_FUNC(RedisModule_EmitAOF)(RedisModuleIO *io, const char *cmdname, const char *fmt, ...);\nvoid REDISMODULE_API_FUNC(RedisModule_SaveString)(RedisModuleIO *io, RedisModuleString *s);\nvoid REDISMODULE_API_FUNC(RedisModule_SaveStringBuffer)(RedisModuleIO *io, const char *str, size_t len);\nRedisModuleString *REDISMODULE_API_FUNC(RedisModule_LoadString)(RedisModuleIO *io);\nchar *REDISMODULE_API_FUNC(RedisModule_LoadStringBuffer)(RedisModuleIO *io, size_t *lenptr);\nvoid REDISMODULE_API_FUNC(RedisModule_SaveDouble)(RedisModuleIO *io, PORT_LONGDOUBLE value);\nPORT_LONGDOUBLE REDISMODULE_API_FUNC(RedisModule_LoadDouble)(RedisModuleIO *io);\nvoid REDISMODULE_API_FUNC(RedisModule_SaveFloat)(RedisModuleIO *io, float value);\nfloat REDISMODULE_API_FUNC(RedisModule_LoadFloat)(RedisModuleIO *io);\nvoid REDISMODULE_API_FUNC(RedisModule_Log)(RedisModuleCtx *ctx, const char *level, const char *fmt, ...);\nvoid REDISMODULE_API_FUNC(RedisModule_LogIOError)(RedisModuleIO *io, const char *levelstr, const char *fmt, ...);\nint REDISMODULE_API_FUNC(RedisModule_StringAppendBuffer)(RedisModuleCtx *ctx, RedisModuleString *str, const char *buf, size_t len);\nvoid REDISMODULE_API_FUNC(RedisModule_RetainString)(RedisModuleCtx *ctx, RedisModuleString *str);\nint REDISMODULE_API_FUNC(RedisModule_StringCompare)(RedisModuleString *a, RedisModuleString *b);\nRedisModuleCtx *REDISMODULE_API_FUNC(RedisModule_GetContextFromIO)(RedisModuleIO *io);\nRedisModuleBlockedClient *REDISMODULE_API_FUNC(RedisModule_BlockClient)(RedisModuleCtx *ctx, RedisModuleCmdFunc reply_callback, RedisModuleCmdFunc timeout_callback, void(*free_privdata)(void*), PORT_LONGLONG timeout_ms);\nint REDISMODULE_API_FUNC(RedisModule_UnblockClient)(RedisModuleBlockedClient *bc, void *privdata);\nint REDISMODULE_API_FUNC(RedisModule_IsBlockedReplyRequest)(RedisModuleCtx *ctx);\nint REDISMODULE_API_FUNC(RedisModule_IsBlockedTimeoutRequest)(RedisModuleCtx *ctx);\nvoid *REDISMODULE_API_FUNC(RedisModule_GetBlockedClientPrivateData)(RedisModuleCtx *ctx);\nint REDISMODULE_API_FUNC(RedisModule_AbortBlock)(RedisModuleBlockedClient *bc);\nPORT_LONGLONG REDISMODULE_API_FUNC(RedisModule_Milliseconds)(void);\n\n/* This is included inline inside each Redis module. */\nstatic int RedisModule_Init(RedisModuleCtx *ctx, const char *name, int ver, int apiver)\n#ifndef _WIN32\n__attribute__((unused));\n#else\n;\n#endif\nstatic int RedisModule_Init(RedisModuleCtx *ctx, const char *name, int ver, int apiver) {\n\tvoid *getapifuncptr = ((void**)ctx)[0];\n\tRedisModule_GetApi = (int(*)(const char *, void *)) (PORT_ULONG)getapifuncptr;\n\tREDISMODULE_GET_API(Alloc);\n\tREDISMODULE_GET_API(Calloc);\n\tREDISMODULE_GET_API(Free);\n\tREDISMODULE_GET_API(Realloc);\n\tREDISMODULE_GET_API(Strdup);\n\tREDISMODULE_GET_API(CreateCommand);\n\tREDISMODULE_GET_API(SetModuleAttribs);\n\tREDISMODULE_GET_API(WrongArity);\n\tREDISMODULE_GET_API(ReplyWithLongLong);\n\tREDISMODULE_GET_API(ReplyWithError);\n\tREDISMODULE_GET_API(ReplyWithSimpleString);\n\tREDISMODULE_GET_API(ReplyWithArray);\n\tREDISMODULE_GET_API(ReplySetArrayLength);\n\tREDISMODULE_GET_API(ReplyWithStringBuffer);\n\tREDISMODULE_GET_API(ReplyWithString);\n\tREDISMODULE_GET_API(ReplyWithNull);\n\tREDISMODULE_GET_API(ReplyWithCallReply);\n\tREDISMODULE_GET_API(ReplyWithDouble);\n\tREDISMODULE_GET_API(ReplySetArrayLength);\n\tREDISMODULE_GET_API(GetSelectedDb);\n\tREDISMODULE_GET_API(SelectDb);\n\tREDISMODULE_GET_API(OpenKey);\n\tREDISMODULE_GET_API(CloseKey);\n\tREDISMODULE_GET_API(KeyType);\n\tREDISMODULE_GET_API(ValueLength);\n\tREDISMODULE_GET_API(ListPush);\n\tREDISMODULE_GET_API(ListPop);\n\tREDISMODULE_GET_API(StringToLongLong);\n\tREDISMODULE_GET_API(StringToDouble);\n\tREDISMODULE_GET_API(Call);\n\tREDISMODULE_GET_API(CallReplyProto);\n\tREDISMODULE_GET_API(FreeCallReply);\n\tREDISMODULE_GET_API(CallReplyInteger);\n\tREDISMODULE_GET_API(CallReplyType);\n\tREDISMODULE_GET_API(CallReplyLength);\n\tREDISMODULE_GET_API(CallReplyArrayElement);\n\tREDISMODULE_GET_API(CallReplyStringPtr);\n\tREDISMODULE_GET_API(CreateStringFromCallReply);\n\tREDISMODULE_GET_API(CreateString);\n\tREDISMODULE_GET_API(CreateStringFromLongLong);\n\tREDISMODULE_GET_API(CreateStringFromString);\n\tREDISMODULE_GET_API(CreateStringPrintf);\n\tREDISMODULE_GET_API(FreeString);\n\tREDISMODULE_GET_API(StringPtrLen);\n\tREDISMODULE_GET_API(AutoMemory);\n\tREDISMODULE_GET_API(Replicate);\n\tREDISMODULE_GET_API(ReplicateVerbatim);\n\tREDISMODULE_GET_API(DeleteKey);\n\tREDISMODULE_GET_API(StringSet);\n\tREDISMODULE_GET_API(StringDMA);\n\tREDISMODULE_GET_API(StringTruncate);\n\tREDISMODULE_GET_API(GetExpire);\n\tREDISMODULE_GET_API(SetExpire);\n\tREDISMODULE_GET_API(ZsetAdd);\n\tREDISMODULE_GET_API(ZsetIncrby);\n\tREDISMODULE_GET_API(ZsetScore);\n\tREDISMODULE_GET_API(ZsetRem);\n\tREDISMODULE_GET_API(ZsetRangeStop);\n\tREDISMODULE_GET_API(ZsetFirstInScoreRange);\n\tREDISMODULE_GET_API(ZsetLastInScoreRange);\n\tREDISMODULE_GET_API(ZsetFirstInLexRange);\n\tREDISMODULE_GET_API(ZsetLastInLexRange);\n\tREDISMODULE_GET_API(ZsetRangeCurrentElement);\n\tREDISMODULE_GET_API(ZsetRangeNext);\n\tREDISMODULE_GET_API(ZsetRangePrev);\n\tREDISMODULE_GET_API(ZsetRangeEndReached);\n\tREDISMODULE_GET_API(HashSet);\n\tREDISMODULE_GET_API(HashGet);\n\tREDISMODULE_GET_API(IsKeysPositionRequest);\n\tREDISMODULE_GET_API(KeyAtPos);\n\tREDISMODULE_GET_API(GetClientId);\n\tREDISMODULE_GET_API(PoolAlloc);\n\tREDISMODULE_GET_API(CreateDataType);\n\tREDISMODULE_GET_API(ModuleTypeSetValue);\n\tREDISMODULE_GET_API(ModuleTypeGetType);\n\tREDISMODULE_GET_API(ModuleTypeGetValue);\n\tREDISMODULE_GET_API(SaveUnsigned);\n\tREDISMODULE_GET_API(LoadUnsigned);\n\tREDISMODULE_GET_API(SaveSigned);\n\tREDISMODULE_GET_API(LoadSigned);\n\tREDISMODULE_GET_API(SaveString);\n\tREDISMODULE_GET_API(SaveStringBuffer);\n\tREDISMODULE_GET_API(LoadString);\n\tREDISMODULE_GET_API(LoadStringBuffer);\n\tREDISMODULE_GET_API(SaveDouble);\n\tREDISMODULE_GET_API(LoadDouble);\n\tREDISMODULE_GET_API(SaveFloat);\n\tREDISMODULE_GET_API(LoadFloat);\n\tREDISMODULE_GET_API(EmitAOF);\n\tREDISMODULE_GET_API(Log);\n\tREDISMODULE_GET_API(LogIOError);\n\tREDISMODULE_GET_API(StringAppendBuffer);\n\tREDISMODULE_GET_API(RetainString);\n\tREDISMODULE_GET_API(StringCompare);\n\tREDISMODULE_GET_API(GetContextFromIO);\n\tREDISMODULE_GET_API(BlockClient);\n\tREDISMODULE_GET_API(UnblockClient);\n\tREDISMODULE_GET_API(IsBlockedReplyRequest);\n\tREDISMODULE_GET_API(IsBlockedTimeoutRequest);\n\tREDISMODULE_GET_API(GetBlockedClientPrivateData);\n\tREDISMODULE_GET_API(AbortBlock);\n\tREDISMODULE_GET_API(Milliseconds);\n\n\tRedisModule_SetModuleAttribs(ctx, name, ver, apiver);\n\treturn REDISMODULE_OK;\n}\n\n#else\n\n/* Things only defined for the modules core, not exported to modules\n * including this file. */\n#define RedisModuleString robj\n\n#endif /* REDISMODULE_CORE */\n#endif /* REDISMOUDLE_H */"
  },
  {
    "path": "exp/win32_port.h",
    "content": "/*\n * Unification of type definitions with the ones used in Redis for Windows.\n * Based on:\n * - https://github.com/tporadowski/redis/blob/win-4.0.2/src/Win32_Interop/win32_types_hiredis.h\n * - https://github.com/tporadowski/redis/blob/win-4.0.2/src/Win32_Interop/Win32_Portability.h\n */\n#ifndef WIN32_PORT_H\n#define WIN32_PORT_H\n\n#ifdef _WIN32\n\ntypedef __int64 PORT_LONGLONG;\ntypedef unsigned __int64 PORT_ULONGLONG;\ntypedef double PORT_LONGDOUBLE;\n\n#define IF_WIN32(x, y) x\n#define WIN32_ONLY(x) x\n#define POSIX_ONLY(x)\n#define inline __inline\n\n#ifdef _WIN64\ntypedef __int64 ssize_t;\ntypedef __int64 PORT_LONG;\ntypedef unsigned __int64 PORT_ULONG;\n#else\ntypedef long ssize_t;\ntypedef long PORT_LONG;\ntypedef unsigned long PORT_ULONG;\n#endif\n\n#ifdef _WIN64\n#define PORT_LONG_MAX _I64_MAX\n#define PORT_LONG_MIN _I64_MIN\n#define PORT_ULONG_MAX _UI64_MAX\n#else\n#define PORT_LONG_MAX LONG_MAX\n#define PORT_LONG_MIN LONG_MIN\n#define PORT_ULONG_MAX ULONG_MAX\n#endif\n\n#else //not(_WIN32)\n\ntypedef long long PORT_LONGLONG;\ntypedef unsigned long long PORT_ULONGLONG;\ntypedef double PORT_LONGDOUBLE;\ntypedef long PORT_LONG;\ntypedef unsigned long PORT_ULONG;\n\n#define IF_WIN32(x, y) y\n#define WIN32_ONLY(x)\n#define POSIX_ONLY(x) x\n\n#endif\n\n#endif"
  },
  {
    "path": "exp.sln",
    "content": "﻿\nMicrosoft Visual Studio Solution File, Format Version 12.00\n# Visual Studio 15\nVisualStudioVersion = 15.0.28307.489\nMinimumVisualStudioVersion = 10.0.40219.1\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"exp\", \"exp\\exp.vcxproj\", \"{D9081C23-553E-47EA-80C8-FE534EF58EAB}\"\nEndProject\nGlobal\n\tGlobalSection(SolutionConfigurationPlatforms) = preSolution\n\t\tDebug|x64 = Debug|x64\n\t\tDebug|x86 = Debug|x86\n\t\tRelease|x64 = Release|x64\n\t\tRelease|x86 = Release|x86\n\tEndGlobalSection\n\tGlobalSection(ProjectConfigurationPlatforms) = postSolution\n\t\t{D9081C23-553E-47EA-80C8-FE534EF58EAB}.Debug|x64.ActiveCfg = Debug|x64\n\t\t{D9081C23-553E-47EA-80C8-FE534EF58EAB}.Debug|x64.Build.0 = Debug|x64\n\t\t{D9081C23-553E-47EA-80C8-FE534EF58EAB}.Debug|x86.ActiveCfg = Debug|Win32\n\t\t{D9081C23-553E-47EA-80C8-FE534EF58EAB}.Debug|x86.Build.0 = Debug|Win32\n\t\t{D9081C23-553E-47EA-80C8-FE534EF58EAB}.Release|x64.ActiveCfg = Release|x64\n\t\t{D9081C23-553E-47EA-80C8-FE534EF58EAB}.Release|x64.Build.0 = Release|x64\n\t\t{D9081C23-553E-47EA-80C8-FE534EF58EAB}.Release|x86.ActiveCfg = Release|Win32\n\t\t{D9081C23-553E-47EA-80C8-FE534EF58EAB}.Release|x86.Build.0 = Release|Win32\n\tEndGlobalSection\n\tGlobalSection(SolutionProperties) = preSolution\n\t\tHideSolutionNode = FALSE\n\tEndGlobalSection\n\tGlobalSection(ExtensibilityGlobals) = postSolution\n\t\tSolutionGuid = {D3DED947-B683-4C24-9AFB-2CC3B9BF1B49}\n\tEndGlobalSection\nEndGlobal\n"
  }
]