mirror of
https://github.com/Proxmark/proxmark3.git
synced 2025-07-11 15:56:09 -07:00
Make LUA scripting work even if proxmark3 is called from arbitrary working directory
- add @gpakosz whereami library (https://github.com/gpakosz/whereami) in order to ... - determine and set absolute paths for LUA scripts and LUA libraries
This commit is contained in:
parent
4c16ae80f0
commit
4197a3f6ff
8 changed files with 782 additions and 8 deletions
|
@ -30,7 +30,6 @@
|
|||
#include <lualib.h>
|
||||
#include <lauxlib.h>
|
||||
|
||||
|
||||
static int CmdHelp(const char *Cmd);
|
||||
static int CmdList(const char *Cmd);
|
||||
static int CmdRun(const char *Cmd);
|
||||
|
@ -77,7 +76,10 @@ int CmdList(const char *Cmd)
|
|||
{
|
||||
DIR *dp;
|
||||
struct dirent *ep;
|
||||
dp = opendir ("./scripts/");
|
||||
char script_directory_path[strlen(get_my_executable_directory()) + strlen(LUA_SCRIPTS_DIRECTORY) + 1];
|
||||
strcpy(script_directory_path, get_my_executable_directory());
|
||||
strcat(script_directory_path, LUA_SCRIPTS_DIRECTORY);
|
||||
dp = opendir(script_directory_path);
|
||||
|
||||
if (dp != NULL)
|
||||
{
|
||||
|
@ -149,17 +151,19 @@ int CmdRun(const char *Cmd)
|
|||
suffix = ".lua";
|
||||
}
|
||||
|
||||
char buf[256];
|
||||
snprintf(buf, sizeof buf, "./scripts/%s%s", script_name, suffix);
|
||||
|
||||
printf("--- Executing: %s, args'%s'\n",buf,arguments);
|
||||
char script_path[strlen(get_my_executable_directory()) + strlen(LUA_SCRIPTS_DIRECTORY) + strlen(script_name) + strlen(suffix) + 1];
|
||||
strcpy(script_path, get_my_executable_directory());
|
||||
strcat(script_path, LUA_SCRIPTS_DIRECTORY);
|
||||
strcat(script_path, script_name);
|
||||
strcat(script_path, suffix);
|
||||
|
||||
printf("--- Executing: %s%s, args '%s'\n", script_name, suffix, arguments);
|
||||
|
||||
|
||||
|
||||
// run the Lua script
|
||||
|
||||
int error = luaL_loadfile(lua_state, buf);
|
||||
int error = luaL_loadfile(lua_state, script_path);
|
||||
if(!error)
|
||||
{
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue