chg: remark available in lua

This commit is contained in:
iceman1001 2019-10-17 22:28:49 +02:00
commit ed565d04f5
3 changed files with 20 additions and 1 deletions

View file

@ -38,7 +38,7 @@
static int CmdHelp(const char *Cmd); static int CmdHelp(const char *Cmd);
static int CmdRem(const char *Cmd) { int CmdRem(const char *Cmd) {
char buf[22] = {0}; char buf[22] = {0};
struct tm *ct, tm_buf; struct tm *ct, tm_buf;
time_t now = time(NULL); time_t now = time(NULL);

View file

@ -15,6 +15,7 @@
#include "cmdparser.h" // command_t #include "cmdparser.h" // command_t
int CommandReceived(char *Cmd); int CommandReceived(char *Cmd);
int CmdRem(const char *Cmd);
command_t *getTopLevelCommandTable(void); command_t *getTopLevelCommandTable(void);
#endif #endif

View file

@ -32,6 +32,7 @@
#include "crc16.h" #include "crc16.h"
#include "protocols.h" #include "protocols.h"
#include "fileutils.h" // searchfile #include "fileutils.h" // searchfile
#include "cmdlf.h" // lf_config
static int returnToLuaWithError(lua_State *L, const char *fmt, ...) { static int returnToLuaWithError(lua_State *L, const char *fmt, ...) {
char buffer[200]; char buffer[200];
@ -1056,6 +1057,22 @@ static int l_ndefparse(lua_State *L) {
return 1; 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) { static int l_searchfile(lua_State *L) {
//Check number of arguments //Check number of arguments
int n = lua_gettop(L); int n = lua_gettop(L);
@ -1141,6 +1158,7 @@ int set_pm3_libraries(lua_State *L) {
{"ndefparse", l_ndefparse}, {"ndefparse", l_ndefparse},
{"fast_push_mode", l_fast_push_mode}, {"fast_push_mode", l_fast_push_mode},
{"search_file", l_searchfile}, {"search_file", l_searchfile},
{"rem", l_remark},
{NULL, NULL} {NULL, NULL}
}; };