From ed565d04f5cce3bdc323085027a8cb4170fc9996 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Thu, 17 Oct 2019 22:28:49 +0200 Subject: [PATCH] chg: remark available in lua --- client/cmdmain.c | 2 +- client/cmdmain.h | 1 + client/scripting.c | 18 ++++++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/client/cmdmain.c b/client/cmdmain.c index 7a04960f0..5a2c91904 100644 --- a/client/cmdmain.c +++ b/client/cmdmain.c @@ -38,7 +38,7 @@ static int CmdHelp(const char *Cmd); -static int CmdRem(const char *Cmd) { +int CmdRem(const char *Cmd) { char buf[22] = {0}; struct tm *ct, tm_buf; time_t now = time(NULL); diff --git a/client/cmdmain.h b/client/cmdmain.h index 8b440143e..68984efab 100644 --- a/client/cmdmain.h +++ b/client/cmdmain.h @@ -15,6 +15,7 @@ #include "cmdparser.h" // command_t int CommandReceived(char *Cmd); +int CmdRem(const char *Cmd); command_t *getTopLevelCommandTable(void); #endif diff --git a/client/scripting.c b/client/scripting.c index e5c3990fb..43bcbd9c7 100644 --- a/client/scripting.c +++ b/client/scripting.c @@ -32,6 +32,7 @@ #include "crc16.h" #include "protocols.h" #include "fileutils.h" // searchfile +#include "cmdlf.h" // lf_config static int returnToLuaWithError(lua_State *L, const char *fmt, ...) { char buffer[200]; @@ -1056,6 +1057,22 @@ static int l_ndefparse(lua_State *L) { return 1; } +static int l_remark(lua_State *L) { + //Check number of arguments + int n = lua_gettop(L); + if (n != 1) { + return returnToLuaWithError(L, "Only one string allowed"); + } + + size_t size; + // data + const char *s = luaL_checklstring(L, 1, &size); + + int res = CmdRem(s); + lua_pushinteger(L, res); + return 1; +} + static int l_searchfile(lua_State *L) { //Check number of arguments int n = lua_gettop(L); @@ -1141,6 +1158,7 @@ int set_pm3_libraries(lua_State *L) { {"ndefparse", l_ndefparse}, {"fast_push_mode", l_fast_push_mode}, {"search_file", l_searchfile}, + {"rem", l_remark}, {NULL, NULL} };