summaryrefslogtreecommitdiff
path: root/plugins/pychrysalide/analysis/project.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2018-12-12 02:37:58 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2018-12-12 02:37:58 (GMT)
commitcdfc8c13fdd78c4af6e0ad120a8369e5fcb2e78d (patch)
tree02e84c98d3ebb264f5f96b0b984faef91138f41a /plugins/pychrysalide/analysis/project.c
parent9d74efa39abcbe68b102ceff79c8d61766387f53 (diff)
Implemented the Python bindings to load unknown binaries.
Diffstat (limited to 'plugins/pychrysalide/analysis/project.c')
-rw-r--r--plugins/pychrysalide/analysis/project.c98
1 files changed, 92 insertions, 6 deletions
diff --git a/plugins/pychrysalide/analysis/project.c b/plugins/pychrysalide/analysis/project.c
index 62ce43b..06a67b6 100644
--- a/plugins/pychrysalide/analysis/project.c
+++ b/plugins/pychrysalide/analysis/project.c
@@ -25,13 +25,14 @@
#include "project.h"
-#include <assert.h>
+#include <malloc.h>
#include <pygobject.h>
#include <analysis/project.h>
+#include "content.h"
#include "loaded.h"
#include "../access.h"
#include "../helpers.h"
@@ -44,9 +45,15 @@ static PyObject *py_study_project_new(PyTypeObject *, PyObject *, PyObject *);
/* Procède à l'enregistrement d'un projet donné. */
static PyObject *py_study_project_save(PyObject *, PyObject *);
+/* Assure l'intégration de contenus binaires dans un projet. */
+static PyObject *py_study_project_discover_binary_content(PyObject *, PyObject *);
+
/* Attache un contenu donné à un projet donné. */
static PyObject *py_study_project_attach_content(PyObject *, PyObject *);
+/* Fournit l'ensemble des contenus associés à un projet. */
+static PyObject *py_study_project_get_contents(PyObject *, void *);
+
/******************************************************************************
@@ -112,7 +119,6 @@ static PyObject *py_study_project_save(PyObject *self, PyObject *args)
bool status; /* Bilan de l'opération */
project = G_STUDY_PROJECT(pygobject_get(self));
- assert(project != NULL);
ret = PyArg_ParseTuple(args, "s", &filename);
if (!ret) return NULL;
@@ -132,6 +138,37 @@ static PyObject *py_study_project_save(PyObject *self, PyObject *args)
* Paramètres : self = projet d'étude à manipuler. *
* args = arguments accompagnant l'appel. *
* *
+* Description : Assure l'intégration de contenus binaires dans un projet. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static PyObject *py_study_project_discover_binary_content(PyObject *self, PyObject *args)
+{
+ GStudyProject *project; /* Version GLib du format */
+ int ret; /* Bilan de lecture des args. */
+ GBinContent *content; /* Instance de contenu binaire */
+
+ project = G_STUDY_PROJECT(pygobject_get(self));
+
+ ret = PyArg_ParseTuple(args, "O&", convert_to_binary_content, &content);
+ if (!ret) return NULL;
+
+ g_study_project_discover_binary_content(project, content);
+
+ Py_RETURN_NONE;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : self = projet d'étude à manipuler. *
+* args = arguments accompagnant l'appel. *
+* *
* Description : Attache un contenu donné à un projet donné. *
* *
* Retour : - *
@@ -142,17 +179,16 @@ static PyObject *py_study_project_save(PyObject *self, PyObject *args)
static PyObject *py_study_project_attach_content(PyObject *self, PyObject *args)
{
- GStudyProject *project; /* Version GLib du format */
PyObject *content_obj; /* Objet pour le contenu */
int ret; /* Bilan de lecture des args. */
GLoadedContent *content; /* Instance GLib correspondante*/
-
- project = G_STUDY_PROJECT(pygobject_get(self));
- assert(project != NULL);
+ GStudyProject *project; /* Version GLib du format */
ret = PyArg_ParseTuple(args, "O!", get_python_loaded_content_type(), &content_obj);
if (!ret) return NULL;
+ project = G_STUDY_PROJECT(pygobject_get(self));
+
content = G_LOADED_CONTENT(pygobject_get(content_obj));
g_study_project_attach_content(project, content);
@@ -164,6 +200,46 @@ static PyObject *py_study_project_attach_content(PyObject *self, PyObject *args)
/******************************************************************************
* *
+* Paramètres : self = objet Python concerné par l'appel. *
+* closure = non utilisé ici. *
+* *
+* Description : Fournit l'ensemble des contenus associés à un projet. *
+* *
+* Retour : Liste de contenus chargés. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static PyObject *py_study_project_get_contents(PyObject *self, void *closure)
+{
+ PyObject *result; /* Trouvailles à retourner */
+ GStudyProject *project; /* Version GLib du format */
+ size_t count; /* Nombre de contenus présents */
+ GLoadedContent **contents; /* Liste de contenus chargés */
+ size_t i; /* Boucle de parcours */
+
+ project = G_STUDY_PROJECT(pygobject_get(self));
+
+ contents = g_study_project_get_contents(project, &count);
+
+ result = PyTuple_New(count);
+
+ for (i = 0; i < count; i++)
+ {
+ PyTuple_SetItem(result, i, pygobject_new(G_OBJECT(contents[i])));
+
+ g_object_unref(G_OBJECT(contents[i]));
+
+ }
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : - *
* *
* Description : Fournit un accès à une définition de type à diffuser. *
@@ -183,6 +259,11 @@ PyTypeObject *get_python_study_project_type(void)
"save($self, filename, /)\n--\n\nSave the project into a given file."
},
{
+ "discover", py_study_project_discover_binary_content,
+ METH_VARARGS,
+ "discover($self, content, /)\n--\n\nExplore a new binary content for the project."
+ },
+ {
"attach", py_study_project_attach_content,
METH_VARARGS,
"attach($self, loaded, /)\n--\n\nAdd a loaded content to the project."
@@ -191,6 +272,11 @@ PyTypeObject *get_python_study_project_type(void)
};
static PyGetSetDef py_study_project_getseters[] = {
+ {
+ "contents", py_study_project_get_contents, NULL,
+ "List of all loaded contents for the project.", NULL
+ },
+
{ NULL }
};