mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 05:43:48 -07:00
redirect LUA print to Proxmark PrintAndLogEx
This commit is contained in:
parent
2089edbba9
commit
ff5f565619
1 changed files with 21 additions and 7 deletions
|
@ -1129,9 +1129,7 @@ static int l_remark(lua_State *L) {
|
|||
}
|
||||
|
||||
size_t size;
|
||||
// data
|
||||
const char *s = luaL_checklstring(L, 1, &size);
|
||||
|
||||
int res = CmdRem(s);
|
||||
lua_pushinteger(L, res);
|
||||
return 1;
|
||||
|
@ -1199,6 +1197,19 @@ static int l_cwd(lua_State *L) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
// ref: https://github.com/RfidResearchGroup/proxmark3/issues/891
|
||||
// redirect LUA's print to Proxmark3 PrintAndLogEx
|
||||
static int l_printandlogex(lua_State* L) {
|
||||
|
||||
int n = lua_gettop(L);
|
||||
for (int i = 1; i <= n; i++) {
|
||||
if (lua_isstring(L, i)) {
|
||||
PrintAndLogEx(NORMAL, "%s", lua_tostring(L, i));
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Sets the lua path to include "./lualibs/?.lua", in order for a script to be
|
||||
* able to do "require('foobar')" if foobar.lua is within lualibs folder.
|
||||
|
@ -1272,7 +1283,7 @@ int set_pm3_libraries(lua_State *L) {
|
|||
// this is 'pm3' table
|
||||
lua_newtable(L);
|
||||
|
||||
//Put the function into the hash table.
|
||||
// put the function into the hash table.
|
||||
for (int i = 0; libs[i].name; i++) {
|
||||
lua_pushcfunction(L, libs[i].func);
|
||||
lua_setfield(L, -2, libs[i].name);//set the name, pop stack
|
||||
|
@ -1280,10 +1291,13 @@ int set_pm3_libraries(lua_State *L) {
|
|||
// Name of 'core'
|
||||
lua_setfield(L, -2, "core");
|
||||
|
||||
//-- remove the global environment table from the stack
|
||||
// remove the global environment table from the stack
|
||||
lua_pop(L, 1);
|
||||
|
||||
//--add to the LUA_PATH (package.path in lua)
|
||||
// print redirect here
|
||||
lua_register(L, "print", l_printandlogex);
|
||||
|
||||
// add to the LUA_PATH (package.path in lua)
|
||||
// so we can load scripts from various places:
|
||||
const char *exec_path = get_my_executable_directory();
|
||||
if (exec_path != NULL) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue