mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 05:43:48 -07:00
adapt to optional python, Thanks @doegox!
This commit is contained in:
parent
0e57a1c6cd
commit
f852bf41c3
1 changed files with 10 additions and 5 deletions
|
@ -13,9 +13,11 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#define PY_SSIZE_T_CLEAN
|
#ifdef DHAVE_PYTHON
|
||||||
|
//#define PY_SSIZE_T_CLEAN
|
||||||
#include <Python.h>
|
#include <Python.h>
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#include "cmdparser.h" // command_t
|
#include "cmdparser.h" // command_t
|
||||||
|
@ -79,8 +81,10 @@ static int CmdScriptRun(const char *Cmd) {
|
||||||
pm3_scriptfile_t ext = PM3_LUA;
|
pm3_scriptfile_t ext = PM3_LUA;
|
||||||
if (str_endswith(preferredName, ".cmd"))
|
if (str_endswith(preferredName, ".cmd"))
|
||||||
ext = PM3_CMD;
|
ext = PM3_CMD;
|
||||||
|
#ifdef DHAVE_PYTHON
|
||||||
if (str_endswith(preferredName, ".py"))
|
if (str_endswith(preferredName, ".py"))
|
||||||
ext = PM3_PY;
|
ext = PM3_PY;
|
||||||
|
#endif
|
||||||
|
|
||||||
char *script_path = NULL;
|
char *script_path = NULL;
|
||||||
if ((ext == PM3_LUA) && (searchFile(&script_path, LUA_SCRIPTS_SUBDIR, preferredName, ".lua", true) == PM3_SUCCESS)) {
|
if ((ext == PM3_LUA) && (searchFile(&script_path, LUA_SCRIPTS_SUBDIR, preferredName, ".lua", true) == PM3_SUCCESS)) {
|
||||||
|
@ -151,8 +155,7 @@ static int CmdScriptRun(const char *Cmd) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
For apt (Ubuntu, Debian...):
|
For apt (Ubuntu, Debian...):
|
||||||
sudo apt-get install python3-dev # for python3.x installs
|
sudo apt-get install python3-dev # for python3.x installs
|
||||||
|
|
||||||
|
@ -177,6 +180,7 @@ static int CmdScriptRun(const char *Cmd) {
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifdef DHAVE_PYTHON
|
||||||
if ((ext == PM3_PY) && (searchFile(&script_path, PYTHON_SCRIPTS_SUBDIR, preferredName, ".py", true) == PM3_SUCCESS)) {
|
if ((ext == PM3_PY) && (searchFile(&script_path, PYTHON_SCRIPTS_SUBDIR, preferredName, ".py", true) == PM3_SUCCESS)) {
|
||||||
|
|
||||||
PrintAndLogEx(SUCCESS, "executing python s " _YELLOW_("%s"), script_path);
|
PrintAndLogEx(SUCCESS, "executing python s " _YELLOW_("%s"), script_path);
|
||||||
|
@ -215,6 +219,7 @@ static int CmdScriptRun(const char *Cmd) {
|
||||||
PrintAndLogEx(SUCCESS, "\nfinished " _YELLOW_("%s"), preferredName);
|
PrintAndLogEx(SUCCESS, "\nfinished " _YELLOW_("%s"), preferredName);
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// file not found, let's search again to display the error messages
|
// file not found, let's search again to display the error messages
|
||||||
int ret = PM3_EUNDEF;
|
int ret = PM3_EUNDEF;
|
||||||
|
@ -223,10 +228,10 @@ static int CmdScriptRun(const char *Cmd) {
|
||||||
|
|
||||||
if (ext == PM3_CMD)
|
if (ext == PM3_CMD)
|
||||||
ret = searchFile(&script_path, CMD_SCRIPTS_SUBDIR, preferredName, ".cmd", false);
|
ret = searchFile(&script_path, CMD_SCRIPTS_SUBDIR, preferredName, ".cmd", false);
|
||||||
|
#ifdef DHAVE_PYTHON
|
||||||
if (ext == PM3_PY)
|
if (ext == PM3_PY)
|
||||||
ret = searchFile(&script_path, PYTHON_SCRIPTS_SUBDIR, preferredName, ".py", false);
|
ret = searchFile(&script_path, PYTHON_SCRIPTS_SUBDIR, preferredName, ".py", false);
|
||||||
|
#endif
|
||||||
free(script_path);
|
free(script_path);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue