summaryrefslogtreecommitdiff
path: root/plugins/pychrysalide/core
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2018-01-16 19:02:56 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2018-01-16 19:02:56 (GMT)
commit9da8f8b37e3edebc917b4e223dd2447cd7cbc818 (patch)
tree3f330b13e7ca2a0a163882be3043ca9571f25211 /plugins/pychrysalide/core
parenteb9b7fd76451db5c9f07a800c0394480e4b88c9c (diff)
Changed the Python bindings source directory and updated code.
Diffstat (limited to 'plugins/pychrysalide/core')
-rw-r--r--plugins/pychrysalide/core/Makefile.am17
-rw-r--r--plugins/pychrysalide/core/formats.c190
-rw-r--r--plugins/pychrysalide/core/formats.h42
-rw-r--r--plugins/pychrysalide/core/logs.c278
-rw-r--r--plugins/pychrysalide/core/logs.h42
-rw-r--r--plugins/pychrysalide/core/module.c97
-rw-r--r--plugins/pychrysalide/core/module.h39
-rw-r--r--plugins/pychrysalide/core/params.c179
-rw-r--r--plugins/pychrysalide/core/params.h42
9 files changed, 926 insertions, 0 deletions
diff --git a/plugins/pychrysalide/core/Makefile.am b/plugins/pychrysalide/core/Makefile.am
new file mode 100644
index 0000000..71abfa4
--- /dev/null
+++ b/plugins/pychrysalide/core/Makefile.am
@@ -0,0 +1,17 @@
+
+noinst_LTLIBRARIES = libpychrysacore.la
+
+libpychrysacore_la_SOURCES = \
+ formats.h formats.c \
+ logs.h logs.c \
+ module.h module.c \
+ params.h params.c
+
+
+libpychrysacore_la_LDFLAGS =
+
+
+AM_CPPFLAGS = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS) $(LIBPYTHON_CFLAGS) $(LIBPYGOBJECT_CFLAGS) \
+ -I../../../src
+
+AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS)
diff --git a/plugins/pychrysalide/core/formats.c b/plugins/pychrysalide/core/formats.c
new file mode 100644
index 0000000..621277a
--- /dev/null
+++ b/plugins/pychrysalide/core/formats.c
@@ -0,0 +1,190 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * formats.c - équivalent Python du fichier "core/formats.c"
+ *
+ * Copyright (C) 2015-2017 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * Chrysalide is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Chrysalide is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+
+#include "formats.h"
+
+
+#include <pygobject.h>
+
+
+#include <core/formats.h>
+
+
+#include "../helpers.h"
+
+
+
+/* Fournit le nom humain du format binaire visé. */
+static PyObject *py_formats_get_binary_format_name(PyObject *, PyObject *);
+
+/* Définit les constantes pour les paramètres. */
+static bool py_formats_define_constants(PyTypeObject *);
+
+
+
+/******************************************************************************
+* *
+* Paramètres : self = NULL car méthode statique. *
+* args = non utilisé ici. *
+* *
+* Description : Fournit le nom humain du format binaire visé. *
+* *
+* Retour : Désignation humaine trouvée ou None. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static PyObject *py_formats_get_binary_format_name(PyObject *self, PyObject *args)
+{
+ PyObject *result; /* Désignation à retourner */
+ const char *key; /* Nom court du format */
+ int ret; /* Bilan de lecture des args. */
+ const char *name; /* Désignation humaine */
+
+ ret = PyArg_ParseTuple(args, "s", &key);
+ if (!ret) return NULL;
+
+ name = get_binary_format_name(key);
+
+ if (name != NULL)
+ result = PyUnicode_FromString(name);
+
+ else
+ {
+ result = Py_None;
+ Py_INCREF(result);
+ }
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : - *
+* *
+* Description : Fournit un accès à une définition de type à diffuser. *
+* *
+* Retour : Définition d'objet pour Python. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+PyTypeObject *get_python_formats_type(void)
+{
+ static PyMethodDef py_formats_methods[] = {
+
+ { "get_binary_format_name", py_formats_get_binary_format_name,
+ METH_VARARGS | METH_STATIC,
+ "get_binary_format_name(key, /)\n--\n\nGive access to the main configuration of Chrysalide."
+ },
+ { NULL }
+
+ };
+
+ static PyTypeObject py_formats_type = {
+
+ PyVarObject_HEAD_INIT(NULL, 0)
+
+ .tp_name = "pychrysalide.core.formats",
+ .tp_basicsize = sizeof(PyObject),
+
+ .tp_flags = Py_TPFLAGS_DEFAULT,
+
+ .tp_doc = "Python object for parameters",
+
+ .tp_methods = py_formats_methods
+
+ };
+
+ return &py_formats_type;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : obj_type = type dont le dictionnaire est à compléter. *
+* *
+* Description : Définit les constantes pour les paramètres. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static bool py_formats_define_constants(PyTypeObject *obj_type)
+{
+ bool result; /* Bilan à retourner */
+
+ result = true;
+
+ result &= PyDict_AddIntMacro(obj_type, FMS_MATCHED);
+ result &= PyDict_AddIntMacro(obj_type, FMS_FORWARDED);
+ result &= PyDict_AddIntMacro(obj_type, FMS_UNKNOWN);
+
+ result &= PyDict_AddIntMacro(obj_type, FMS_COUNT);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : module = module dont la définition est à compléter. *
+* *
+* Description : Prend en charge l'objet 'pychrysalide.core.formats'. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool register_python_formats(PyObject *module)
+{
+ PyTypeObject *py_formats_type; /* Type Python pour 'formats' */
+ int ret; /* Bilan d'un appel */
+
+ py_formats_type = get_python_formats_type();
+
+ py_formats_type->tp_new = PyType_GenericNew;
+
+ if (PyType_Ready(py_formats_type) != 0)
+ return false;
+
+ if (!py_formats_define_constants(py_formats_type))
+ return false;
+
+ Py_INCREF(py_formats_type);
+ ret = PyModule_AddObject(module, "formats", (PyObject *)py_formats_type);
+
+ return (ret == 0);
+
+}
diff --git a/plugins/pychrysalide/core/formats.h b/plugins/pychrysalide/core/formats.h
new file mode 100644
index 0000000..ca12c3e
--- /dev/null
+++ b/plugins/pychrysalide/core/formats.h
@@ -0,0 +1,42 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * formats.h - prototypes pour l'équivalent Python du fichier "core/formats.h"
+ *
+ * Copyright (C) 2015-2017 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * Chrysalide is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Chrysalide is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+
+#ifndef _PLUGINS_PYCHRYSALIDE_CORE_FORMATS_H
+#define _PLUGINS_PYCHRYSALIDE_CORE_FORMATS_H
+
+
+#include <Python.h>
+#include <stdbool.h>
+
+
+
+/* Fournit un accès à une définition de type à diffuser. */
+PyTypeObject *get_python_formats_type(void);
+
+/* Prend en charge l'objet 'pychrysalide.core.formats'. */
+bool register_python_formats(PyObject *);
+
+
+
+#endif /* _PLUGINS_PYCHRYSALIDE_CORE_FORMATS_H */
diff --git a/plugins/pychrysalide/core/logs.c b/plugins/pychrysalide/core/logs.c
new file mode 100644
index 0000000..8a922c1
--- /dev/null
+++ b/plugins/pychrysalide/core/logs.c
@@ -0,0 +1,278 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * logs.c - équivalent Python du fichier "gui/panels/logs.c"
+ *
+ * Copyright (C) 2017 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * Chrysalide is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Chrysalide is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+
+#include "logs.h"
+
+
+#include <pygobject.h>
+
+
+#include <core/logs.h>
+
+
+#include "../helpers.h"
+
+
+
+/* Fournit la verbosité des messages système. */
+static PyObject *py_logs_get_verbosity(PyObject *, PyObject *);
+
+/* Définit la verbosité des messages système. */
+static PyObject *py_logs_set_verbosity(PyObject *, PyObject *);
+
+/* Affiche un message dans le journal des messages système. */
+static PyObject *py_logs_log_message(PyObject *, PyObject *);
+
+/* Définit les constantes pour les types de message. */
+static bool define_python_log_constants(PyTypeObject *);
+
+
+
+/******************************************************************************
+* *
+* Paramètres : self = classe assurant le lien avec l'éditeur de messages. *
+* args = arguments fournis à l'appel. *
+* *
+* Description : Fournit la verbosité des messages système. *
+* *
+* Retour : Plus faible niveau des types de message affichés. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static PyObject *py_logs_get_verbosity(PyObject *self, PyObject *args)
+{
+ PyObject *result; /* Conversion à retourner */
+ LogMessageType verbosity; /* Niveau de filtre de message */
+
+ verbosity = get_log_verbosity();
+
+ result = PyLong_FromUnsignedLong(verbosity);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : self = classe assurant le lien avec l'éditeur de messages. *
+* args = arguments fournis à l'appel. *
+* *
+* Description : Définit la verbosité des messages système. *
+* *
+* Retour : Rien en équivalent Python. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static PyObject *py_logs_set_verbosity(PyObject *self, PyObject *args)
+{
+ PyObject *result; /* Bilan à retourner */
+ unsigned long verbosity; /* Niveau de filtre de message */
+
+ if (!PyArg_ParseTuple(args, "k", &verbosity))
+ return NULL;
+
+ set_log_verbosity(verbosity);
+
+ result = Py_None;
+ Py_INCREF(result);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : self = classe assurant le lien avec l'éditeur de messages. *
+* args = arguments fournis à l'appel. *
+* *
+* Description : Affiche un message dans le journal des messages système. *
+* *
+* Retour : Rien en équivalent Python. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static PyObject *py_logs_log_message(PyObject *self, PyObject *args)
+{
+ PyObject *result; /* Bilan à retourner */
+ unsigned long type; /* Espèce du message */
+ const char *msg; /* Contenu du message */
+
+ if (!PyArg_ParseTuple(args, "ks", &type, &msg))
+ return NULL;
+
+ switch (type)
+ {
+ case LMT_INFO:
+ case LMT_PROCESS:
+ case LMT_WARNING:
+ case LMT_ERROR:
+ case LMT_BAD_BINARY:
+ log_simple_message(type, msg);
+ result = Py_None;
+ Py_INCREF(result);
+ break;
+
+ default:
+ PyErr_SetString(PyExc_ValueError,
+ _("Invalid type of message"));
+ result = NULL;
+ break;
+
+ }
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : - *
+* *
+* Description : Fournit un accès à une définition de type à diffuser. *
+* *
+* Retour : Définition d'objet pour Python. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+PyTypeObject *get_python_logs_type(void)
+{
+ static PyMethodDef py_logs_methods[] = {
+ {
+ "get_verbosity", (PyCFunction)py_logs_get_verbosity,
+ METH_NOARGS | METH_STATIC,
+ "get_verbosity(, /)\n--\n\nGet the log verbosity."
+ },
+ {
+ "set_verbosity", (PyCFunction)py_logs_set_verbosity,
+ METH_VARARGS | METH_STATIC,
+ "set_verbosity(, /)\n--\n\nSet the log verbosity."
+ },
+ {
+ "log_message", (PyCFunction)py_logs_log_message,
+ METH_VARARGS | METH_STATIC,
+ "log_message(type, msg, /)\n--\n\nDisplay a message in the log window, if any."
+ },
+ { NULL }
+
+ };
+
+ static PyGetSetDef py_logs_getseters[] = {
+ { NULL }
+ };
+
+ static PyTypeObject py_logs_type = {
+
+ PyVarObject_HEAD_INIT(NULL, 0)
+
+ .tp_name = "pychrysalide.core.logs",
+ .tp_basicsize = sizeof(PyObject) + 80,
+
+ .tp_flags = Py_TPFLAGS_DEFAULT,
+
+ .tp_doc = "Python object for logs",
+
+ .tp_methods = py_logs_methods,
+ .tp_getset = py_logs_getseters
+
+ };
+
+ return &py_logs_type;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : obj_type = type dont le dictionnaire est à compléter. *
+* *
+* Description : Définit les constantes pour les types de message. *
+* *
+* Retour : true en cas de succès de l'opération, false sinon. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static bool define_python_log_constants(PyTypeObject *obj_type)
+{
+ bool result; /* Bilan à retourner */
+
+ result = true;
+
+ result &= PyDict_AddIntMacro(obj_type, LMT_INFO);
+ result &= PyDict_AddIntMacro(obj_type, LMT_PROCESS);
+ result &= PyDict_AddIntMacro(obj_type, LMT_WARNING);
+ result &= PyDict_AddIntMacro(obj_type, LMT_ERROR);
+ result &= PyDict_AddIntMacro(obj_type, LMT_BAD_BINARY);
+ result &= PyDict_AddIntMacro(obj_type, LMT_COUNT);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : module = module dont la définition est à compléter. *
+* *
+* Description : Prend en charge l'objet 'pychrysalide.gui.panels.LogPanel'. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool register_python_logs(PyObject *module)
+{
+ PyTypeObject *py_logs_type; /* Type Python pour 'logs' */
+ int ret; /* Bilan d'un appel */
+
+ py_logs_type = get_python_logs_type();
+
+ py_logs_type->tp_new = PyType_GenericNew;
+
+ if (PyType_Ready(py_logs_type) != 0)
+ return false;
+
+ if (!define_python_log_constants(py_logs_type))
+ return false;
+
+ Py_INCREF(py_logs_type);
+ ret = PyModule_AddObject(module, "logs", (PyObject *)py_logs_type);
+
+ return (ret == 0);
+
+}
diff --git a/plugins/pychrysalide/core/logs.h b/plugins/pychrysalide/core/logs.h
new file mode 100644
index 0000000..a43d9ca
--- /dev/null
+++ b/plugins/pychrysalide/core/logs.h
@@ -0,0 +1,42 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * logs.h - prototypes pour l'équivalent Python du fichier "core/logs.h"
+ *
+ * Copyright (C) 2017 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * Chrysalide is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Chrysalide is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+
+#ifndef _PLUGINS_PYCHRYSALIDE_CORE_LOGS_H
+#define _PLUGINS_PYCHRYSALIDE_CORE_LOGS_H
+
+
+#include <Python.h>
+#include <stdbool.h>
+
+
+
+/* Fournit un accès à une définition de type à diffuser. */
+PyTypeObject *get_python_logs_type(void);
+
+/* Prend en charge l'objet 'pychrysalide.core.logs'. */
+bool register_python_logs(PyObject *);
+
+
+
+#endif /* _PLUGINS_PYCHRYSALIDE_CORE_LOGS_H */
diff --git a/plugins/pychrysalide/core/module.c b/plugins/pychrysalide/core/module.c
new file mode 100644
index 0000000..ff7f828
--- /dev/null
+++ b/plugins/pychrysalide/core/module.c
@@ -0,0 +1,97 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * module.c - intégration du répertoire core en tant que module
+ *
+ * Copyright (C) 2014-2017 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * Chrysalide is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Chrysalide is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+
+#include "module.h"
+
+
+#include <assert.h>
+
+
+#include "formats.h"
+#include "logs.h"
+#include "params.h"
+#include "../access.h"
+
+
+
+/******************************************************************************
+* *
+* Paramètres : module = module dont la définition est à compléter. *
+* *
+* Description : Ajoute le module 'core' au module Python. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool add_core_module_to_python_module(PyObject *super)
+{
+ bool result; /* Bilan à retourner */
+ PyObject *module; /* Sous-module mis en place */
+ int ret; /* Bilan d'un appel */
+
+ static PyModuleDef py_chrysalide_core_module = {
+
+ .m_base = PyModuleDef_HEAD_INIT,
+
+ .m_name = "pychrysalide.core",
+ .m_doc = "Python module for Chrysalide.core",
+
+ .m_size = -1,
+
+ };
+
+ result = false;
+
+ module = PyModule_Create(&py_chrysalide_core_module);
+ if (module == NULL) return false;
+
+ ret = PyState_AddModule(super, &py_chrysalide_core_module);
+ if (ret != 0) goto loading_failed;
+
+ ret = _PyImport_FixupBuiltin(module, "pychrysalide.core");
+ if (ret != 0) goto loading_failed;
+
+ Py_INCREF(module);
+ ret = PyModule_AddObject(super, "core", module);
+ if (ret != 0) goto loading_failed;
+
+ result = true;
+
+ result &= register_python_formats(module);
+ result &= register_python_logs(module);
+ result &= register_python_params(module);
+
+ if (result)
+ register_access_to_python_module("pychrysalide.core", module);
+
+ loading_failed:
+
+ assert(result);
+
+ return result;
+
+}
diff --git a/plugins/pychrysalide/core/module.h b/plugins/pychrysalide/core/module.h
new file mode 100644
index 0000000..8581425
--- /dev/null
+++ b/plugins/pychrysalide/core/module.h
@@ -0,0 +1,39 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * module.h - prototypes pour l'intégration du répertoire core en tant que module
+ *
+ * Copyright (C) 2014-2017 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * Chrysalide is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Chrysalide is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+
+#ifndef _PLUGINS_PYCHRYSALIDE_CORE_MODULE_H
+#define _PLUGINS_PYCHRYSALIDE_CORE_MODULE_H
+
+
+#include <Python.h>
+#include <stdbool.h>
+
+
+
+/* Ajoute le module 'core' au module Python. */
+bool add_core_module_to_python_module(PyObject *);
+
+
+
+#endif /* _PLUGINS_PYCHRYSALIDE_CORE_MODULE_H */
diff --git a/plugins/pychrysalide/core/params.c b/plugins/pychrysalide/core/params.c
new file mode 100644
index 0000000..df71a88
--- /dev/null
+++ b/plugins/pychrysalide/core/params.c
@@ -0,0 +1,179 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * params.c - équivalent Python du fichier "core/params.c"
+ *
+ * Copyright (C) 2014-2017 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * Chrysalide is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Chrysalide is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+
+#include "params.h"
+
+
+#include <pygobject.h>
+
+
+#include <core/params.h>
+
+
+#include "../helpers.h"
+
+
+
+/* Fournit la version du programme global. */
+static PyObject *py_params_get_main_configuration(PyObject *, PyObject *);
+
+/* Définit les constantes pour les paramètres. */
+static bool py_params_define_constants(PyTypeObject *);
+
+
+
+/******************************************************************************
+* *
+* Paramètres : self = NULL car méthode statique. *
+* args = non utilisé ici. *
+* *
+* Description : Fournit la version du programme global. *
+* *
+* Retour : Numéro de révision. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static PyObject *py_params_get_main_configuration(PyObject *self, PyObject *args)
+{
+ PyObject *result; /* Instance GLib à retourner */
+ GGenConfig *config; /* Configuration à convertir */
+
+ config = get_main_configuration();
+
+ result = pygobject_new(G_OBJECT(config));
+ Py_XINCREF(result);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : - *
+* *
+* Description : Fournit un accès à une définition de type à diffuser. *
+* *
+* Retour : Définition d'objet pour Python. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+PyTypeObject *get_python_params_type(void)
+{
+ static PyMethodDef py_params_methods[] = {
+
+ { "get_main_configuration", py_params_get_main_configuration,
+ METH_NOARGS | METH_STATIC,
+ "Give access to the main configuration of Chrysalide."
+ },
+ { NULL }
+
+ };
+
+ static PyTypeObject py_params_type = {
+
+ PyVarObject_HEAD_INIT(NULL, 0)
+
+ .tp_name = "pychrysalide.core.params",
+ .tp_basicsize = sizeof(PyObject),
+
+ .tp_flags = Py_TPFLAGS_DEFAULT,
+
+ .tp_doc = "Python object for parameters",
+
+ .tp_methods = py_params_methods
+
+ };
+
+ return &py_params_type;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : obj_type = type dont le dictionnaire est à compléter. *
+* *
+* Description : Définit les constantes pour les paramètres. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static bool py_params_define_constants(PyTypeObject *obj_type)
+{
+ bool result; /* Bilan à retourner */
+
+ result = true;
+
+ result &= PyDict_AddStringMacro(obj_type, MPK_LAST_PROJECT);
+ result &= PyDict_AddStringMacro(obj_type, MPK_ELLIPSIS_HEADER);
+ result &= PyDict_AddStringMacro(obj_type, MPK_ELLIPSIS_TAB);
+ result &= PyDict_AddStringMacro(obj_type, MPK_KEYBINDINGS_EDIT);
+ result &= PyDict_AddStringMacro(obj_type, MPK_AUTO_SAVE);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : module = module dont la définition est à compléter. *
+* *
+* Description : Prend en charge l'objet 'pychrysalide.core.params'. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool register_python_params(PyObject *module)
+{
+ PyTypeObject *py_params_type; /* Type Python pour 'params' */
+ int ret; /* Bilan d'un appel */
+
+ py_params_type = get_python_params_type();
+
+ py_params_type->tp_new = PyType_GenericNew;
+
+ if (PyType_Ready(py_params_type) != 0)
+ return false;
+
+ if (!py_params_define_constants(py_params_type))
+ return false;
+
+ Py_INCREF(py_params_type);
+ ret = PyModule_AddObject(module, "params", (PyObject *)py_params_type);
+
+ return (ret == 0);
+
+}
diff --git a/plugins/pychrysalide/core/params.h b/plugins/pychrysalide/core/params.h
new file mode 100644
index 0000000..e7297b3
--- /dev/null
+++ b/plugins/pychrysalide/core/params.h
@@ -0,0 +1,42 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * params.h - prototypes pour l'équivalent Python du fichier "core/params.h"
+ *
+ * Copyright (C) 2014-2017 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * Chrysalide is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Chrysalide is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+
+#ifndef _PLUGINS_PYCHRYSALIDE_CORE_PARAMS_H
+#define _PLUGINS_PYCHRYSALIDE_CORE_PARAMS_H
+
+
+#include <Python.h>
+#include <stdbool.h>
+
+
+
+/* Fournit un accès à une définition de type à diffuser. */
+PyTypeObject *get_python_params_type(void);
+
+/* Prend en charge l'objet 'pychrysalide.core.params'. */
+bool register_python_params(PyObject *);
+
+
+
+#endif /* _PLUGINS_PYCHRYSALIDE_CORE_PARAMS_H */