summaryrefslogtreecommitdiff
path: root/plugins/pyoida/pyoida.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/pyoida/pyoida.c')
-rw-r--r--plugins/pyoida/pyoida.c118
1 files changed, 102 insertions, 16 deletions
diff --git a/plugins/pyoida/pyoida.c b/plugins/pyoida/pyoida.c
index 4a79bfd..be75b7c 100644
--- a/plugins/pyoida/pyoida.c
+++ b/plugins/pyoida/pyoida.c
@@ -24,6 +24,10 @@
#include "pyoida.h"
+#include <config.h>
+#include <dirent.h>
+
+
#include <Python.h>
@@ -69,6 +73,7 @@ static PyMethodDef SpamMethods[] = {
+static PyObject *__mod;
/******************************************************************************
@@ -85,17 +90,37 @@ static PyMethodDef SpamMethods[] = {
bool init_plugin(GObject *ref)
{
+ char *paths; /* Emplacements de greffons */
+ char *path; /* Chemin à fouiller */
+ char *save; /* Sauvegarde pour ré-entrance */
+ DIR *dir; /* Répertoire à parcourir */
+ struct dirent entry; /* Elément trouvé */
+ struct dirent *next; /* Prochain élément fourni */
+ int ret; /* Bilan d'un appel système */
+ char *filename; /* Chemin d'accès reconstruit */
+
+
+
+
GPluginModule *plugin;
- int ret;
+
+
printf("Init pyoida\n");
_ref = ref;
- add_to_env_var("PYTHONPATH", "/home/ocb/prog/openida/plugins/python", ";");
+
+ /* Définition des zones d'influence */
+
+ add_to_env_var("PYTHONPATH", PLUGINS_DIR G_DIR_SEPARATOR_S "python", ";");
+
+ paths = get_env_var("PYTHONPATH");
+
+ /* Intialisations Python */
- return false;
+ //return false;
Py_Initialize();
@@ -104,33 +129,92 @@ bool init_plugin(GObject *ref)
+ /* Chargement des greffons */
- plugin = g_python_plugin_new("lnxsyscalls/lnxsyscalls");
- add_plugin_to_main_list(plugin);
+ printf("Paths :: '%s'\n", paths);
+ for (path = strtok_r(paths, ";", &save);
+ path != NULL;
+ path = strtok_r(NULL, ";", &save))
+ {
+ dir = opendir(path);
+ if (dir == NULL)
+ {
+ perror("opendir");
+ continue;
+ }
+ printf("CHEMIN :: '%s'\n", path);
-#if 0
+ for (ret = readdir_r(dir, &entry, &next);
+ ret == 0 && next != NULL;
+ ret = readdir_r(dir, &entry, &next))
+ {
+ if (entry.d_name[0] == '.') continue;
-#if 0
- //main2("/home/ocb/prog/openida/plugins/pyoida/lnxsyscalls/lnxsyscalls.py", "get_instance");
- main2("lnxsyscalls", "get_instance");
-#else
- //main2("/home/ocb/prog/openida/plugins/pyoida/lnxsyscalls/lnxsyscalls.py", "get_instance");
- main2("lnxsyscalls/lnxsyscalls", "get_instance");
-#endif
+ filename = strdup(entry.d_name);
+ filename = stradd(filename, ".");
+ filename = stradd(filename, "__init__");
-#endif
+ printf(" - entry :: '%s'\n", filename);
- //Py_Finalize();
- //exit(-1);
+ plugin = g_python_plugin_new(entry.d_name, filename);
+
+ if (plugin == NULL)
+ printf("No suitable Python plugin found in '%s'\n", filename); /* FIXME : LOG(...) */
+ else
+ {
+ printf("ok pour %s\n", filename);
+ add_plugin_to_main_list(plugin);
+ }
+
+ free(filename);
+
+ }
+
+ closedir(dir);
+
+ break; /* FIXME */
+
+ }
+
+ //Py_Finalize();
return true;
}
+/******************************************************************************
+* *
+* Paramètres : plugin = greffon à consulter. *
+* *
+* Description : Indique les opérations offertes par un greffon donné. *
+* *
+* Retour : Action(s) offerte(s) par le greffon. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+PluginAction get_plugin_action(const GPluginModule *plugin)
+{
+ PluginAction result; /* Combinaison à retourner */
+
+ result = PGA_NONE;
+
+
+
+
+ return result;
+
+}
+
+
+
+
+
#if PY_VERSION_HEX >= 0x03000000
/* Python 3.x code */
@@ -169,6 +253,8 @@ initpyoida(void)
printf("Passage 2\n");
module = Py_InitModule("pyoida", SpamMethods);
+ __mod = module;
+
//add_analysis_roptions_to_python_module(module);
add_analysis_module_to_python_module(module);
add_arch_module_to_python_module(module);