mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2026-06-05 04:12:09 +00:00
SWIG experiments
Squash of the following commits (a full rebase was too hard :( ) *ef309cfdfN - SWIG: create pm3.c (5 months ago) <Philippe Teuwen> *05ba6a73fN - swig pm3_device -> pm3 (5 months ago) <Philippe Teuwen> *d59630183N - swig: move pm3.i (5 months ago) <Philippe Teuwen> *6adcfad75N - Fix historic make & cmake (5 months ago) <Philippe Teuwen> *bcbef2edfN - Fix typo with script_embedded (5 months ago) <slurdge> *538ee4dabN - Better SWIG integration: autogen func & attributes (5 months ago) <slurdge> *756b62466N - SWIG: few helper scripts (5 months ago) <Philippe Teuwen> *47ba4acd0N - SWIG %extend (5 months ago) <Philippe Teuwen> *21841cb9dN - simplify scripts (5 months ago) <Philippe Teuwen> *78c4f7929N - Revert "SWIG experiments: introduce context" (5 months ago) <Philippe Teuwen> *1562b75fcN - SWIG experiments: introduce context (5 months ago) <Philippe Teuwen> *a503dfcd9N - SWIG experiments (5 months ago) <Philippe Teuwen>
This commit is contained in:
+15
-2
@@ -9,7 +9,6 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// 2020, added Python support (@iceman1001)
|
||||
|
||||
|
||||
#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
|
||||
@@ -274,7 +281,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) {
|
||||
@@ -355,6 +364,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