summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2018-01-13 00:35:33 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2018-01-13 00:35:33 (GMT)
commita6975c1d754a1ba5bfb9e23f0b26692c746e6f9c (patch)
tree7ec962129ebbce6cd210b449443afc91ced72719 /plugins
parent5adcf950f1f928c7127f2d694b52addf54cc04ca (diff)
Handled the logs from the GUI, the command line and the Python bindings.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/dex/loading.c2
-rw-r--r--plugins/elf/format.c2
-rw-r--r--plugins/elf/loading.c2
-rw-r--r--plugins/elf/symbols.c2
-rw-r--r--plugins/pychrysa/arch/vmpa.c12
-rw-r--r--plugins/pychrysa/core/Makefile.am1
-rw-r--r--plugins/pychrysa/core/formats.c2
-rw-r--r--plugins/pychrysa/core/logs.c (renamed from plugins/pychrysa/gui/panels/log.c)200
-rw-r--r--plugins/pychrysa/core/logs.h (renamed from plugins/pychrysa/gui/panels/log.h)16
-rw-r--r--plugins/pychrysa/core/module.c2
-rw-r--r--plugins/pychrysa/gui/panels/Makefile.am1
-rw-r--r--plugins/pychrysa/gui/panels/module.c2
12 files changed, 155 insertions, 89 deletions
diff --git a/plugins/dex/loading.c b/plugins/dex/loading.c
index c00d0c5..7a1abf2 100644
--- a/plugins/dex/loading.c
+++ b/plugins/dex/loading.c
@@ -25,8 +25,8 @@
#include <i18n.h>
+#include <core/logs.h>
#include <glibext/delayed-int.h>
-#include <gui/panels/log.h>
#include "pool.h"
diff --git a/plugins/elf/format.c b/plugins/elf/format.c
index c12460a..a5c8c92 100644
--- a/plugins/elf/format.c
+++ b/plugins/elf/format.c
@@ -31,7 +31,7 @@
#include <i18n.h>
-#include <gui/panels/log.h>
+#include <core/logs.h>
#include <plugins/pglist.h>
diff --git a/plugins/elf/loading.c b/plugins/elf/loading.c
index 168c9c6..377eb14 100644
--- a/plugins/elf/loading.c
+++ b/plugins/elf/loading.c
@@ -25,8 +25,8 @@
#include <i18n.h>
+#include <core/logs.h>
#include <glibext/delayed-int.h>
-#include <gui/panels/log.h>
#include "elf-int.h"
diff --git a/plugins/elf/symbols.c b/plugins/elf/symbols.c
index b5dc2b8..7bf68f5 100644
--- a/plugins/elf/symbols.c
+++ b/plugins/elf/symbols.c
@@ -33,9 +33,9 @@
#include <arch/raw.h>
#include <common/extstr.h>
#include <core/global.h>
+#include <core/logs.h>
#include <core/params.h>
#include <format/mangling/demangler.h>
-#include <gui/panels/log.h>
#include "dynamic.h"
diff --git a/plugins/pychrysa/arch/vmpa.c b/plugins/pychrysa/arch/vmpa.c
index aaaede8..413d67b 100644
--- a/plugins/pychrysa/arch/vmpa.c
+++ b/plugins/pychrysa/arch/vmpa.c
@@ -521,18 +521,6 @@ static PyObject *py_vmpa_nb_add(PyObject *o1, PyObject *o2)
-void log_simple_message(/*LogMessageType*/ int type, const char *msg)
-{
-
-}
-
-
-void log_variadic_message(/*LogMessageType*/ int type, const char *fmt, ...)
-{
-
-
-}
-
void change_editor_items_current_view_content(void/*GtkDisplayPanel*/ *view)
{
diff --git a/plugins/pychrysa/core/Makefile.am b/plugins/pychrysa/core/Makefile.am
index 129b5af..71abfa4 100644
--- a/plugins/pychrysa/core/Makefile.am
+++ b/plugins/pychrysa/core/Makefile.am
@@ -3,6 +3,7 @@ noinst_LTLIBRARIES = libpychrysacore.la
libpychrysacore_la_SOURCES = \
formats.h formats.c \
+ logs.h logs.c \
module.h module.c \
params.h params.c
diff --git a/plugins/pychrysa/core/formats.c b/plugins/pychrysa/core/formats.c
index 8d6bd4f..621277a 100644
--- a/plugins/pychrysa/core/formats.c
+++ b/plugins/pychrysa/core/formats.c
@@ -117,7 +117,7 @@ PyTypeObject *get_python_formats_type(void)
.tp_doc = "Python object for parameters",
- .tp_methods = py_formats_methods
+ .tp_methods = py_formats_methods
};
diff --git a/plugins/pychrysa/gui/panels/log.c b/plugins/pychrysa/core/logs.c
index 686749f..8a922c1 100644
--- a/plugins/pychrysa/gui/panels/log.c
+++ b/plugins/pychrysa/core/logs.c
@@ -1,8 +1,8 @@
/* Chrysalide - Outil d'analyse de fichiers binaires
- * log.c - équivalent Python du fichier "gui/panels/log.c"
+ * logs.c - équivalent Python du fichier "gui/panels/logs.c"
*
- * Copyright (C) 2013-2017 Cyrille Bagard
+ * Copyright (C) 2017 Cyrille Bagard
*
* This file is part of Chrysalide.
*
@@ -22,22 +22,27 @@
*/
-#include "log.h"
+#include "logs.h"
#include <pygobject.h>
-#include <gui/panels/log.h>
+#include <core/logs.h>
-#include "panel.h"
-#include "../../helpers.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_log_panel_log_message(PyObject *, PyObject *);
+static PyObject *py_logs_log_message(PyObject *, PyObject *);
/* Définit les constantes pour les types de message. */
static bool define_python_log_constants(PyTypeObject *);
@@ -49,7 +54,34 @@ 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 : Affiche un message dans le journal des messages système. *
+* 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. *
* *
@@ -57,34 +89,18 @@ static bool define_python_log_constants(PyTypeObject *);
* *
******************************************************************************/
-static PyObject *py_log_panel_log_message(PyObject *self, PyObject *args)
+static PyObject *py_logs_set_verbosity(PyObject *self, PyObject *args)
{
PyObject *result; /* Bilan à retourner */
- LogMessageType type; /* Espèce du message */
- const char *msg; /* Contenu du message */
+ unsigned long verbosity; /* Niveau de filtre de message */
- if (!PyArg_ParseTuple(args, "ls", &type, &msg))
+ if (!PyArg_ParseTuple(args, "k", &verbosity))
return NULL;
- switch (type)
- {
- case LMT_INFO:
- case LMT_BAD_BINARY:
- case LMT_PROCESS:
- case LMT_ERROR:
- case LMT_WARNING:
- log_simple_message(type, msg);
- result = Py_None;
- Py_INCREF(result);
- break;
-
- default:
- PyErr_SetString(PyExc_ValueError,
- _("Invalid type of message"));
- result = NULL;
- break;
+ set_log_verbosity(verbosity);
- }
+ result = Py_None;
+ Py_INCREF(result);
return result;
@@ -93,27 +109,45 @@ static PyObject *py_log_panel_log_message(PyObject *self, PyObject *args)
/******************************************************************************
* *
-* Paramètres : obj_type = type dont le dictionnaire est à compléter. *
+* Paramètres : self = classe assurant le lien avec l'éditeur de messages. *
+* args = arguments fournis à l'appel. *
* *
-* Description : Définit les constantes pour les types de message. *
+* Description : Affiche un message dans le journal des messages système. *
* *
-* Retour : true en cas de succès de l'opération, false sinon. *
+* Retour : Rien en équivalent Python. *
* *
* Remarques : - *
* *
******************************************************************************/
-static bool define_python_log_constants(PyTypeObject *obj_type)
+static PyObject *py_logs_log_message(PyObject *self, PyObject *args)
{
- bool result; /* Bilan à retourner */
+ PyObject *result; /* Bilan à retourner */
+ unsigned long type; /* Espèce du message */
+ const char *msg; /* Contenu du message */
- result = true;
+ if (!PyArg_ParseTuple(args, "ks", &type, &msg))
+ return NULL;
- result &= PyDict_AddIntMacro(obj_type, LMT_INFO);
- result &= PyDict_AddIntMacro(obj_type, LMT_BAD_BINARY);
- result &= PyDict_AddIntMacro(obj_type, LMT_PROCESS);
- result &= PyDict_AddIntMacro(obj_type, LMT_ERROR);
- result &= PyDict_AddIntMacro(obj_type, LMT_WARNING);
+ 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;
@@ -132,38 +166,79 @@ static bool define_python_log_constants(PyTypeObject *obj_type)
* *
******************************************************************************/
-PyTypeObject *get_python_log_panel_type(void)
+PyTypeObject *get_python_logs_type(void)
{
- static PyMethodDef py_log_panel_methods[] = {
+ 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_log_panel_log_message,
+ "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_log_panel_getseters[] = {
+ static PyGetSetDef py_logs_getseters[] = {
{ NULL }
};
- static PyTypeObject py_log_panel_type = {
+ static PyTypeObject py_logs_type = {
PyVarObject_HEAD_INIT(NULL, 0)
- .tp_name = "pychrysalide.gui.panels.LogPanel",
- .tp_basicsize = sizeof(PyGObject),
+ .tp_name = "pychrysalide.core.logs",
+ .tp_basicsize = sizeof(PyObject) + 80,
- .tp_flags = Py_TPFLAGS_DEFAULT,
+ .tp_flags = Py_TPFLAGS_DEFAULT,
- .tp_doc = "PyChrysalide log panel",
+ .tp_doc = "Python object for logs",
- .tp_methods = py_log_panel_methods,
- .tp_getset = py_log_panel_getseters
+ .tp_methods = py_logs_methods,
+ .tp_getset = py_logs_getseters
};
- return &py_log_panel_type;
+ 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;
}
@@ -180,21 +255,24 @@ PyTypeObject *get_python_log_panel_type(void)
* *
******************************************************************************/
-bool register_python_log_panel(PyObject *module)
+bool register_python_logs(PyObject *module)
{
- PyTypeObject *py_log_panel_type; /* Type Python 'LoadedBinary' */
- PyObject *dict; /* Dictionnaire du module */
+ PyTypeObject *py_logs_type; /* Type Python pour 'logs' */
+ int ret; /* Bilan d'un appel */
- py_log_panel_type = get_python_log_panel_type();
+ py_logs_type = get_python_logs_type();
- dict = PyModule_GetDict(module);
+ py_logs_type->tp_new = PyType_GenericNew;
- if (!register_class_for_pygobject(dict, G_TYPE_LOG_PANEL, py_log_panel_type, get_python_panel_item_type()))
+ if (PyType_Ready(py_logs_type) != 0)
return false;
- if (!define_python_log_constants(py_log_panel_type))
+ if (!define_python_log_constants(py_logs_type))
return false;
- return true;
+ Py_INCREF(py_logs_type);
+ ret = PyModule_AddObject(module, "logs", (PyObject *)py_logs_type);
+
+ return (ret == 0);
}
diff --git a/plugins/pychrysa/gui/panels/log.h b/plugins/pychrysa/core/logs.h
index 49da96c..f1c7faf 100644
--- a/plugins/pychrysa/gui/panels/log.h
+++ b/plugins/pychrysa/core/logs.h
@@ -1,8 +1,8 @@
/* Chrysalide - Outil d'analyse de fichiers binaires
- * log.h - prototypes pour l'équivalent Python du fichier "gui/panels/log.h"
+ * logs.h - prototypes pour l'équivalent Python du fichier "core/logs.h"
*
- * Copyright (C) 2013-2017 Cyrille Bagard
+ * Copyright (C) 2017 Cyrille Bagard
*
* This file is part of Chrysalide.
*
@@ -22,8 +22,8 @@
*/
-#ifndef _PLUGINS_PYCHRYSA_GUI_PANELS_LOG_H
-#define _PLUGINS_PYCHRYSA_GUI_PANELS_LOG_H
+#ifndef _PLUGINS_PYCHRYSA_CORE_LOGS_H
+#define _PLUGINS_PYCHRYSA_CORE_LOGS_H
#include <Python.h>
@@ -32,11 +32,11 @@
/* Fournit un accès à une définition de type à diffuser. */
-PyTypeObject *get_python_log_panel_type(void);
+PyTypeObject *get_python_logs_type(void);
-/* Prend en charge l'objet 'pychrysalide.gui.panels.LogPanel'. */
-bool register_python_log_panel(PyObject *);
+/* Prend en charge l'objet 'pychrysalide.core.logs'. */
+bool register_python_logs(PyObject *);
-#endif /* _PLUGINS_PYCHRYSA_GUI_PANELS_LOG_H */
+#endif /* _PLUGINS_PYCHRYSA_CORE_LOGS_H */
diff --git a/plugins/pychrysa/core/module.c b/plugins/pychrysa/core/module.c
index 6c44197..ff7f828 100644
--- a/plugins/pychrysa/core/module.c
+++ b/plugins/pychrysa/core/module.c
@@ -29,6 +29,7 @@
#include "formats.h"
+#include "logs.h"
#include "params.h"
#include "../access.h"
@@ -81,6 +82,7 @@ bool add_core_module_to_python_module(PyObject *super)
result = true;
result &= register_python_formats(module);
+ result &= register_python_logs(module);
result &= register_python_params(module);
if (result)
diff --git a/plugins/pychrysa/gui/panels/Makefile.am b/plugins/pychrysa/gui/panels/Makefile.am
index 12e79ab..99e4c3f 100644
--- a/plugins/pychrysa/gui/panels/Makefile.am
+++ b/plugins/pychrysa/gui/panels/Makefile.am
@@ -2,7 +2,6 @@
noinst_LTLIBRARIES = libpychrysaguipanels.la
libpychrysaguipanels_la_SOURCES = \
- log.h log.c \
module.h module.c \
panel.h panel.c
diff --git a/plugins/pychrysa/gui/panels/module.c b/plugins/pychrysa/gui/panels/module.c
index d5040e3..21b487e 100644
--- a/plugins/pychrysa/gui/panels/module.c
+++ b/plugins/pychrysa/gui/panels/module.c
@@ -28,7 +28,6 @@
#include <assert.h>
-#include "log.h"
#include "panel.h"
#include "../../access.h"
@@ -81,7 +80,6 @@ bool add_gui_panels_module_to_python_module(PyObject *super)
result = true;
result &= register_python_panel_item(module);
- result &= register_python_log_panel(module);
if (result)
register_access_to_python_module("pychrysalide.gui.panels", module);