X-Git-Url: http://cvs.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/0a85b72549d294b127c3224610870be4f9382f9a..eb911aa8d6b2ddf5163fc75f06da416eb968bd9f:/client/cmdscript.c?ds=sidebyside diff --git a/client/cmdscript.c b/client/cmdscript.c index 8c1acf27..e9ec5871 100644 --- a/client/cmdscript.c +++ b/client/cmdscript.c @@ -25,7 +25,7 @@ #include "cmdscript.h" #include "cmdhfmf.h" #include "pm3_binlib.h" - +#include "pm3_bitlib.h" #include #include #include @@ -64,7 +64,7 @@ int str_ends_with(const char * str, const char * suffix) { */ int CmdHelp(const char * Cmd) { - PrintAndLog("This is a feature to run Lua-scripts. You can place lua-scripts within the scripts/-folder. "); + PrintAndLog("This is a feature to run Lua-scripts. You can place lua-scripts within the ´client/scripts/´ folder."); return 0; } @@ -83,8 +83,8 @@ int CmdList(const char *Cmd) { while ((ep = readdir (dp)) != NULL) { - if(ep->d_name != NULL && str_ends_with(ep->d_name, ".lua")) - PrintAndLog("%-16s %s", ep->d_name, "A script file"); + if(str_ends_with(ep->d_name, ".lua")) + PrintAndLog("%-21s %s", ep->d_name, "A script file"); } (void) closedir (dp); } @@ -98,10 +98,10 @@ int CmdList(const char *Cmd) * @param Cmd * @return */ -int CmdScript(const char *Cmd) -{ - CmdsParse(CommandTable, Cmd); - return 0; +int CmdScript(const char *Cmd) { + clearCommandBuffer(); + CmdsParse(CommandTable, Cmd); + return 0; } /** * Utility to check the ending of a string (used to check file suffix) @@ -133,6 +133,8 @@ int CmdRun(const char *Cmd) //Add the 'bin' library set_bin_library(lua_state); + //Add the 'bit' library + set_bit_library(lua_state); char script_name[128] = {0}; char arguments[256] = {0}; @@ -150,17 +152,13 @@ int CmdRun(const char *Cmd) char buf[256]; snprintf(buf, sizeof buf, "./scripts/%s%s", script_name, suffix); - printf("--- Executing: %s, args'%s'\n",buf,arguments); - - - + printf("--- Executing: %s, args'%s'\n", buf, arguments); // run the Lua script int error = luaL_loadfile(lua_state, buf); if(!error) { - lua_pushstring(lua_state, arguments); lua_setglobal(lua_state, "args");