@@ -123,7 +123,7 @@ void KeyDBExecuteCallback(const v8::FunctionCallbackInfo<v8::Value>& args)
123
123
v8::String::Utf8Value fnName (isolate, vfnName);
124
124
125
125
std::vector<RedisModuleString*> vecstrs;
126
- for (size_t iarg = 1 ; iarg < args.Length (); ++iarg)
126
+ for (int iarg = 1 ; iarg < args.Length (); ++iarg)
127
127
{
128
128
v8::String::Utf8Value argument (isolate, args[iarg]);
129
129
vecstrs.push_back (RedisModule_CreateString (g_ctx, *argument, argument.length ()));
@@ -331,11 +331,11 @@ int evaljs_command(RedisModuleCtx *ctx, RedisModuleString **argv, int argc)
331
331
return REDISMODULE_OK;
332
332
}
333
333
334
- int run_startup_script (RedisModuleCtx *ctx, const char *rgchPath, size_t cchPath )
334
+ int run_startup_script (RedisModuleCtx *ctx, const char *szPath )
335
335
{
336
336
KeyDBContext ctxsav (ctx);
337
337
338
- std::ifstream file (rgchPath , std::ios::binary | std::ios::ate);
338
+ std::ifstream file (szPath , std::ios::binary | std::ios::ate);
339
339
std::streamsize size = file.tellg ();
340
340
if (size == -1 )
341
341
{
@@ -365,12 +365,19 @@ int run_startup_script(RedisModuleCtx *ctx, const char *rgchPath, size_t cchPath
365
365
return REDISMODULE_OK;
366
366
}
367
367
368
+ int ReplyWithCString (RedisModuleCtx *ctx, const char *sz)
369
+ {
370
+ return RedisModule_ReplyWithStringBuffer (ctx, sz, strlen (sz));
371
+ }
372
+
368
373
extern " C" int __attribute__ ((visibility(" default" ))) RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc)
369
374
{
370
- printf (" argc: %d\n " , argc);
371
375
if (RedisModule_Init (ctx," modjs" ,1 ,REDISMODULE_APIVER_1) == REDISMODULE_ERR)
372
376
return REDISMODULE_ERR;
373
377
378
+ if (RedisModule_ReplyWithCString == nullptr )
379
+ RedisModule_ReplyWithCString = ReplyWithCString;
380
+
374
381
if (RedisModule_CreateCommand (ctx," evaljs" , evaljs_command," write deny-oom random" ,0 ,0 ,0 ) == REDISMODULE_ERR)
375
382
return REDISMODULE_ERR;
376
383
@@ -389,7 +396,7 @@ extern "C" int __attribute__((visibility("default"))) RedisModule_OnLoad(RedisMo
389
396
path.remove_filename ();
390
397
path /= " bootstrap.js" ;
391
398
std::string strPath = path.string ();
392
- if (run_startup_script (ctx, strPath.data (), strPath. size ()) == REDISMODULE_ERR)
399
+ if (run_startup_script (ctx, strPath.c_str ()) == REDISMODULE_ERR)
393
400
{
394
401
RedisModule_Log (ctx, " warning" , " failed to run bootstrap.js, ensure this is located in the same location as the .so" );
395
402
return REDISMODULE_ERR;
@@ -408,7 +415,7 @@ extern "C" int __attribute__((visibility("default"))) RedisModule_OnLoad(RedisMo
408
415
size_t cchPath;
409
416
const char *rgchPath = RedisModule_StringPtrLen (argv[iarg], &cchPath);
410
417
411
- if (run_startup_script (ctx, rgchPath, cchPath ) == REDISMODULE_ERR)
418
+ if (run_startup_script (ctx, rgchPath) == REDISMODULE_ERR)
412
419
return REDISMODULE_ERR;
413
420
}
414
421
0 commit comments