76 const char* base = strrchr(in,
'/');
82 const char* base_end = strrchr(base,
'.');
85 base_end = base + strlen(base);
88 const int length = base_end - base;
89 const int memsize =
sizeof(
char*) * ((length) + 1);
93 memset(*out, 0, memsize);
94 strncpy(*out, base, length);
95 (*out)[length] =
'\0';
106 TRACE_CALL(__func__);
113 PyRun_SimpleString(*ptr);
121 TRACE_CALL(__func__);
128 char* filename = NULL;
131 g_printerr(
"[%s:%d]: Can not extract filename from '%s'!\n", __FILE__, __LINE__, name);
135 PyObject* plugin_name = PyUnicode_DecodeFSDefault(filename);
140 g_printerr(
"[%s:%d]: Error converting plugin filename to PyUnicode!\n", __FILE__, __LINE__);
144 wchar_t* program_name = NULL;
145 Py_ssize_t len = PyUnicode_AsWideChar(plugin_name, program_name, 0);
149 g_printerr(
"[%s:%d]: Failed allocating %lu bytes!\n", __FILE__, __LINE__, (
sizeof(
wchar_t) * len));
157 g_printerr(
"[%s:%d]: Failed allocating %lu bytes!\n", __FILE__, __LINE__, (
sizeof(
wchar_t) * len));
161 PyUnicode_AsWideChar(plugin_name, program_name, len);
163 PySys_SetArgv(1, &program_name);
165 if (PyImport_Import(plugin_name))
171 g_print(
"[%s:%d]: Failed to load python plugin file: '%s'\n", __FILE__, __LINE__, name);
void remmina_plugin_python_module_init(void)
Initializes all globals and registers the 'remmina' module in the Python engine.
Contains the implementation of the Python module 'remmina', provided to interface with the applicatio...
void remmina_plugin_python_init(void)
Initializes the Python plugin loaders.
Declares the interface between the Python plugin implementation and Remmina covering the initializati...
void remmina_plugin_python_set_service(RemminaPluginService *service)
Sets the pointer to the plugin service of Remmina.
Contains functions and constants that are commonly used throughout the Python plugin implementation...
void * remmina_plugin_python_malloc(int bytes)
Allocates memory and checks for errors before returning.
gboolean remmina_plugin_python_load(RemminaPluginService *service, const char *name)
static int basename_no_ext(const char *in, char **out)
Extracts the filename without extension from a path.
static const char * python_init_commands[]
An null terminated array of commands that are executed after the initialization of the Python engine...