From 5709b0dfa9523055ec423e48d411f098ba6882eb Mon Sep 17 00:00:00 2001 From: aunsane Date: Fri, 29 Sep 2017 00:23:53 +0300 Subject: CmdLine: MirLua support version bump --- plugins/CmdLine/src/mimcmd_handlers.cpp | 38 +++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'plugins/CmdLine/src/mimcmd_handlers.cpp') diff --git a/plugins/CmdLine/src/mimcmd_handlers.cpp b/plugins/CmdLine/src/mimcmd_handlers.cpp index 05c1bbed22..ca84413487 100644 --- a/plugins/CmdLine/src/mimcmd_handlers.cpp +++ b/plugins/CmdLine/src/mimcmd_handlers.cpp @@ -1610,6 +1610,40 @@ void HandleIgnoreCommand(PCommand command, TArgument *argv, int argc, PReply rep else HandleWrongParametersCount(command, reply); } +void HandleLuaCommand(PCommand command, TArgument *argv, int argc, PReply reply) +{ + if (argc <= 3) { + HandleWrongParametersCount(command, reply); + return; + } + + if (_stricmp(argv[2], "call") == 0) { + wchar_t *result = argc == 4 + ? lua_call(NULL, _A2T(argv[3])) + : lua_call(_A2T(argv[3]), _A2T(argv[4])); + mir_strcpy(reply->message, _T2A(result)); + mir_free(result); + reply->code = MIMRES_SUCCESS; + return; + } + + if (_stricmp(argv[2], "exec") == 0) { + ptrW result(lua_exec(_A2T(argv[3]))); + mir_strcpy(reply->message, _T2A(result)); + reply->code = MIMRES_SUCCESS; + return; + } + + if (_stricmp(argv[2], "eval") == 0) { + ptrW result(lua_eval(_A2T(argv[3]))); + mir_strcpy(reply->message, _T2A(result)); + reply->code = MIMRES_SUCCESS; + return; + } + + HandleUnknownParameter(command, argv[2], reply); +} + void HandleCommand(PCommand command, TArgument *argv, int argc, PReply reply) { switch (command->ID) { @@ -1681,6 +1715,10 @@ void HandleCommand(PCommand command, TArgument *argv, int argc, PReply reply) HandleIgnoreCommand(command, argv, argc, reply); return; + case MIMCMD_LUA: + HandleLuaCommand(command, argv, argc, reply); + return; + default: reply->code = MIMRES_NOTFOUND; mir_snprintf(reply->message, Translate("Command '%s' is not currently supported."), command->command); -- cgit v1.2.3