use PrintAndLogEx() instead of PrintAndLog()

This commit is contained in:
Brian Pow 2018-02-21 20:06:41 +08:00
parent 6d6f5f422d
commit 7a9612036d

View file

@ -82,13 +82,13 @@ 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"); PrintAndLogEx(FAILED, "Couldn't open the scripts-directory");
return 1; return 1;
} }
for (uint16_t i = 0; i < n; i++) { for (uint16_t i = 0; i < n; i++) {
if (str_ends_with(namelist[i]->d_name, ".lua")) if (str_ends_with(namelist[i]->d_name, ".lua"))
PrintAndLog("%-21s", namelist[i]->d_name); PrintAndLogEx(NORMAL, "%-21s", namelist[i]->d_name);
free(namelist[i]); free(namelist[i]);
} }
free(namelist); free(namelist);
@ -136,7 +136,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); PrintAndLogEx(SUCCESS, "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);
@ -151,7 +151,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 (?!)"); PrintAndLogEx(FAILED, "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));
@ -162,7 +162,7 @@ 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"); PrintAndLogEx(NORMAL, "\n"); PrintAndLogEx(SUCCESS, "Finished\n");
return 0; return 0;
} }
@ -192,6 +192,6 @@ int CmdScript(const char *Cmd) {
* @return * @return
*/ */
int CmdHelp(const char * Cmd) { int CmdHelp(const char * Cmd) {
PrintAndLog("This is a feature to run Lua-scripts. You can place lua-scripts within the scripts/-folder. "); PrintAndLogEx(NORMAL, "This is a feature to run Lua-scripts. You can place lua-scripts within the scripts/-folder. ");
return 0; return 0;
} }