diff options
author | aunsane <aunsane@gmail.com> | 2017-09-29 00:23:53 +0300 |
---|---|---|
committer | aunsane <aunsane@gmail.com> | 2017-09-29 00:39:19 +0300 |
commit | 5709b0dfa9523055ec423e48d411f098ba6882eb (patch) | |
tree | f53ed90f801c143e5588543726b61987a8ca9fcb /plugins/CmdLine/src/mimcmd_handlers.cpp | |
parent | 8d706b4ef942e01814f0a9db519aa32505b9abed (diff) |
CmdLine: MirLua support
version bump
Diffstat (limited to 'plugins/CmdLine/src/mimcmd_handlers.cpp')
-rw-r--r-- | plugins/CmdLine/src/mimcmd_handlers.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
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);
|