mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2026-04-14 09:55:41 +00:00
SWIG experiments
This commit is contained in:
@@ -9,7 +9,6 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// 2020, added Python support (@iceman100)
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -32,7 +31,15 @@
|
||||
#include "ui.h"
|
||||
#include "fileutils.h"
|
||||
|
||||
#ifdef HAVE_LUA_SWIG
|
||||
extern int luaopen_pm3(lua_State* L);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PYTHON
|
||||
#ifdef HAVE_PYTHON_SWIG
|
||||
extern PyObject* PyInit__pm3(void);
|
||||
#endif // HAVE_PYTHON_SWIG
|
||||
|
||||
// Partly ripped from PyRun_SimpleFileExFlags
|
||||
// but does not terminate client on sys.exit
|
||||
// and print exit code only if != 0
|
||||
@@ -272,7 +279,9 @@ static int CmdScriptRun(const char *Cmd) {
|
||||
|
||||
//Add the 'bit' library
|
||||
set_bit_library(lua_state);
|
||||
|
||||
#ifdef HAVE_LUA_SWIG
|
||||
luaL_requiref(lua_state, "pm3", luaopen_pm3, 1);
|
||||
#endif
|
||||
error = luaL_loadfile(lua_state, script_path);
|
||||
free(script_path);
|
||||
if (!error) {
|
||||
@@ -353,6 +362,10 @@ static int CmdScriptRun(const char *Cmd) {
|
||||
|
||||
// optional but recommended
|
||||
Py_SetProgramName(program);
|
||||
#ifdef HAVE_PYTHON_SWIG
|
||||
// hook Proxmark3 API
|
||||
PyImport_AppendInittab("_pm3", PyInit__pm3);
|
||||
#endif
|
||||
Py_Initialize();
|
||||
|
||||
//int argc, char ** argv
|
||||
|
||||
Reference in New Issue
Block a user