chg: textual

This commit is contained in:
iceman1001 2018-01-01 18:54:01 +01:00
parent f92a6ddf7d
commit d9089e74b4

View file

@ -82,7 +82,7 @@ int CmdScriptList(const char *Cmd) {
n = scandir(script_directory_path, &namelist, NULL, alphasort); n = scandir(script_directory_path, &namelist, NULL, alphasort);
if (n == -1) { if (n == -1) {
PrintAndLog ("Couldn't open the scripts-directory"); PrintAndLog ("[-] Couldn't open the scripts-directory");
return 1; return 1;
} }
@ -127,9 +127,7 @@ int CmdScriptRun(const char *Cmd) {
char *suffix = ""; char *suffix = "";
if (!endsWith(script_name,".lua")) if (!endsWith(script_name,".lua"))
{
suffix = ".lua"; suffix = ".lua";
}
char script_path[strlen(get_my_executable_directory()) + strlen(LUA_SCRIPTS_DIRECTORY) + strlen(script_name) + strlen(suffix) + 1]; 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()); strcpy(script_path, get_my_executable_directory());
@ -137,7 +135,7 @@ int CmdScriptRun(const char *Cmd) {
strcat(script_path, script_name); strcat(script_path, script_name);
strcat(script_path, suffix); strcat(script_path, suffix);
printf("--- Executing: %s%s, args '%s'\n", script_name, suffix, arguments); printf("[+] Executing: %s%s, args '%s'\n", script_name, suffix, arguments);
// run the Lua script // run the Lua script
int error = luaL_loadfile(lua_state, script_path); int error = luaL_loadfile(lua_state, script_path);
@ -152,7 +150,7 @@ int CmdScriptRun(const char *Cmd) {
{ {
// the top of the stack should be the error string // the top of the stack should be the error string
if (!lua_isstring(lua_state, lua_gettop(lua_state))) if (!lua_isstring(lua_state, lua_gettop(lua_state)))
printf( "Error - but no error (?!)"); printf("[-] Error - but no error (?!)");
// get the top of the stack as the error and pop it off // get the top of the stack as the error and pop it off
const char * str = lua_tostring(lua_state, lua_gettop(lua_state)); const char * str = lua_tostring(lua_state, lua_gettop(lua_state));
@ -163,11 +161,10 @@ int CmdScriptRun(const char *Cmd) {
//luaL_dofile(lua_state, buf); //luaL_dofile(lua_state, buf);
// close the Lua state // close the Lua state
lua_close(lua_state); lua_close(lua_state);
printf("\n-----Finished\n"); printf("\n[+] Finished\n");
return 0; return 0;
} }
static command_t CommandTable[] = { static command_t CommandTable[] = {
{"help", CmdHelp, 1, "This help"}, {"help", CmdHelp, 1, "This help"},
{"list", CmdScriptList, 1, "List available scripts"}, {"list", CmdScriptList, 1, "List available scripts"},