summaryrefslogtreecommitdiff
path: root/plugins/pychrysa/pychrysa.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2015-07-17 16:36:21 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2015-07-17 16:36:21 (GMT)
commit24d3836fcf8d443eb654b981f65478cd9923b8f1 (patch)
tree7672a28b864127e8958c3c6cce751dcf646d2fbe /plugins/pychrysa/pychrysa.c
parenta61f089babe336b012da31a494b0f7470b6e1a9a (diff)
Updated the Python bindings.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@552 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'plugins/pychrysa/pychrysa.c')
-rw-r--r--plugins/pychrysa/pychrysa.c214
1 files changed, 47 insertions, 167 deletions
diff --git a/plugins/pychrysa/pychrysa.c b/plugins/pychrysa/pychrysa.c
index 00856f3..367895d 100644
--- a/plugins/pychrysa/pychrysa.c
+++ b/plugins/pychrysa/pychrysa.c
@@ -24,6 +24,8 @@
#include "pychrysa.h"
+
+
#if 0
#include <dirent.h>
@@ -57,32 +59,6 @@
-static PyMethodDef SpamMethods[] = {
- {NULL, NULL, 0, NULL} /* Sentinel */
-};
-
-
-
-
-
-/******************************************************************************
-* *
-* Paramètres : - *
-* *
-* Description : Précise le nom associé au greffon. *
-* *
-* Retour : Nom à libérer de la mémoire. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-char *get_plugin_name(void)
-{
- return strdup("PyChrysalide");
-
-}
-
/******************************************************************************
* *
@@ -193,146 +169,8 @@ bool init_plugin(GPluginModule *plugin, GObject *ref)
}
-/******************************************************************************
-* *
-* Paramètres : plugin = instance représentant le greffon en déchargement. *
-* *
-* Description : Libère le greffon permettant l'usage de Python. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-void exit_plugin(GPluginModule *plugin)
-{
- /* FIXME */
- //Py_Finalize();
-}
-
-
-/******************************************************************************
-* *
-* 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
-
-/******************************************************************************
-* *
-* Paramètres : - *
-* *
-* Description : Point d'entrée pour l'initialisation de Python. *
-* *
-* Retour : ? *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-PyMODINIT_FUNC initpychrysa/*PyInit_pychrysa*/(void)
-{
- PyObject *module;
-
- //init_pygobject();
- //init_pygtk();
-
- pychrysalide_init_quirks();
-
- module = Py_InitModule("pychrysalide", SpamMethods);
-
- //add_analysis_roptions_to_python_module(module);
- add_analysis_module_to_python_module(module);
- add_arch_module_to_python_module(module);
- add_debug_module_to_python_module(module);
- add_format_module_to_python_module(module);
- add_glibext_module_to_python_module(module);
- add_gtkext_module_to_python_module(module);
- add_gui_module_to_python_module(module);
-
- add_plugin_to_python_module(module);
-
-
- /*
-
-
-
- static struct PyModuleDef spammodule = {
- PyModuleDef_HEAD_INIT,
- "pychrysalide",
- "pychrysalide_doc",
- -1,
- SpamMethods
- };
-
- PyModule_Create(&spammodule);
-
- */
-
-}
-
-#else
-
-/******************************************************************************
-* *
-* Paramètres : - *
-* *
-* Description : Point d'entrée pour l'initialisation de Python. *
-* *
-* Retour : ? *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-PyMODINIT_FUNC initpychrysa(void)
-{
- PyObject *module;
-
- init_pygobject();
- //init_pygtk();
-
- pychrysalide_init_quirks();
-
- module = Py_InitModule("pychrysalide", SpamMethods);
-
- //add_analysis_roptions_to_python_module(module);
- add_analysis_module_to_python_module(module);
- add_arch_module_to_python_module(module);
- add_debug_module_to_python_module(module);
- add_format_module_to_python_module(module);
- add_glibext_module_to_python_module(module);
- add_gtkext_module_to_python_module(module);
- add_gui_module_to_python_module(module);
-
- add_plugin_to_python_module(module);
-
-}
-
-#endif
@@ -356,8 +194,12 @@ PyMODINIT_FUNC initpychrysa(void)
#include "analysis/module.h"
#include "arch/module.h"
+#include "common/module.h"
#include "core/module.h"
+#include "format/module.h"
#include "glibext/module.h"
+#include "gtkext/module.h"
+#include "gui/module.h"
@@ -537,6 +379,20 @@ static bool is_current_abi_suitable(void)
* Remarques : - *
* *
******************************************************************************/
+#include <gtkext/support.h> // REMME
+#include <glibext/delayed.h>
+
+#define PYCHRYSALIDE_DOC \
+ "PyChrysalide is a module containing Chrysalide's features and designed for Python users.\n" \
+ "\n" \
+ "The whole API is defined in a single library named 'pychrysalide.so' and can be used in two ways:\n" \
+ "* either from the Chrysalide's GUI, by registering hooks or GLib signals.\n" \
+ "* or from a shell command line, by setting PYTHONPATH to point to the directory containing the library.\n" \
+ "\n" \
+ "In both cases, it is a good start point to have a look at already existing plugins to quickly learn " \
+ "how the API works.\n" \
+ "\n" \
+ "These plugins are located in the 'plugins/python' directory."
PyMODINIT_FUNC PyInit_pychrysalide(void)
{
@@ -548,11 +404,11 @@ PyMODINIT_FUNC PyInit_pychrysalide(void)
{ "version", py_chrysalide_version,
METH_NOARGS,
- "Provide the revision number of Chrysalide."
+ "version(/)\n--\n\nProvide the revision number of Chrysalide."
},
{ "mod_version", py_chrysalide_mod_version,
METH_NOARGS,
- "Provide the revision number of Chrysalide module for Python."
+ "mod_version(/)\n--\n\nProvide the revision number of Chrysalide module for Python."
},
{ NULL }
@@ -563,7 +419,7 @@ PyMODINIT_FUNC PyInit_pychrysalide(void)
.m_base = PyModuleDef_HEAD_INIT,
.m_name = "pychrysalide",
- .m_doc = "Python module for Chrysalide",
+ .m_doc = PYCHRYSALIDE_DOC,
.m_size = -1,
@@ -576,6 +432,26 @@ PyMODINIT_FUNC PyInit_pychrysalide(void)
//init_all_processors();
//init_all_formats();
+ do
+ {
+ int argc = 0;
+ //char *argv[] = { NULL };
+
+ /* Initialisation de GTK */
+ g_set_prgname("Chrysalide");
+ setlocale (LC_ALL, "");
+ gtk_init(&argc, NULL/*&argv-*/);
+
+ } while (0);
+
+ add_pixmap_directory(PACKAGE_DATA_DIR);
+ add_pixmap_directory(PACKAGE_SOURCE_DIR G_DIR_SEPARATOR_S "pixmaps");
+
+ init_work_queue(NULL/* !! */);
+
+
+ ////////////////////////
+
if (!is_current_abi_suitable())
return NULL;
@@ -606,8 +482,12 @@ PyMODINIT_FUNC PyInit_pychrysalide(void)
status &= add_analysis_module_to_python_module(result);
status &= add_arch_module_to_python_module(result);
+ status &= add_common_module_to_python_module(result);
status &= add_core_module_to_python_module(result);
+ status &= add_format_module_to_python_module(result);
status &= add_glibext_module_to_python_module(result);
+ status &= add_gtkext_module_to_python_module(result);
+ status &= add_gui_module_to_python_module(result);
if (!status)
{