mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-31 10:26:21 +00:00
Add function to get plugin name
This commit is contained in:
@@ -33,6 +33,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <Python.h>
|
#include <Python.h>
|
||||||
|
#include <frameobject.h>
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
|
||||||
@@ -41,6 +42,9 @@
|
|||||||
#include "plugins/python_plugins.h"
|
#include "plugins/python_plugins.h"
|
||||||
#include "plugins/callbacks.h"
|
#include "plugins/callbacks.h"
|
||||||
#include "plugins/autocompleters.h"
|
#include "plugins/autocompleters.h"
|
||||||
|
#include "log.h"
|
||||||
|
|
||||||
|
static char* _python_plugin_name(void);
|
||||||
|
|
||||||
static PyObject*
|
static PyObject*
|
||||||
python_api_cons_alert(PyObject *self, PyObject *args)
|
python_api_cons_alert(PyObject *self, PyObject *args)
|
||||||
@@ -157,6 +161,9 @@ python_api_register_command(PyObject *self, PyObject *args)
|
|||||||
}
|
}
|
||||||
c_examples[len] = NULL;
|
c_examples[len] = NULL;
|
||||||
|
|
||||||
|
char *plugin_name = _python_plugin_name();
|
||||||
|
log_debug("FILENAME : %s", plugin_name);
|
||||||
|
|
||||||
allow_python_threads();
|
allow_python_threads();
|
||||||
api_register_command(command_name, min_args, max_args, c_synopsis,
|
api_register_command(command_name, min_args, max_args, c_synopsis,
|
||||||
description, c_arguments, c_examples, p_callback, python_command_callback);
|
description, c_arguments, c_examples, p_callback, python_command_callback);
|
||||||
@@ -790,3 +797,16 @@ python_api_init(void)
|
|||||||
{
|
{
|
||||||
Py_InitModule("prof", apiMethods);
|
Py_InitModule("prof", apiMethods);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char*
|
||||||
|
_python_plugin_name(void)
|
||||||
|
{
|
||||||
|
PyThreadState *ts = PyThreadState_Get();
|
||||||
|
PyFrameObject *frame = ts->frame;
|
||||||
|
char const* filename = PyString_AsString(frame->f_code->co_filename);
|
||||||
|
gchar **split = g_strsplit(filename, "/", 0);
|
||||||
|
char *plugin_name = strdup(split[g_strv_length(split)-1]);
|
||||||
|
g_strfreev(split);
|
||||||
|
|
||||||
|
return plugin_name;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user