summaryrefslogtreecommitdiff
path: root/plugins/pychrysalide/analysis/binary.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2019-09-08 07:47:41 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2019-09-08 07:47:41 (GMT)
commitfbb80d00d8ac456451963d52af24fcccbbc1d751 (patch)
tree232d2f63378bf30db17c33c399cedc28fc13d4f9 /plugins/pychrysalide/analysis/binary.c
parent1a85f36e0505d75a51ab7b7f2c5078da7ef6bd98 (diff)
Updated the database protocol for bookmarks.
Diffstat (limited to 'plugins/pychrysalide/analysis/binary.c')
-rw-r--r--plugins/pychrysalide/analysis/binary.c58
1 files changed, 58 insertions, 0 deletions
diff --git a/plugins/pychrysalide/analysis/binary.c b/plugins/pychrysalide/analysis/binary.c
index e137f87..98b20dc 100644
--- a/plugins/pychrysalide/analysis/binary.c
+++ b/plugins/pychrysalide/analysis/binary.c
@@ -38,12 +38,16 @@
#include "../access.h"
#include "../helpers.h"
#include "../format/executable.h"
+#include "db/item.h"
/* Crée un nouvel objet Python de type 'LoadedBinary'. */
static PyObject *py_loaded_binary_new(PyTypeObject *, PyObject *, PyObject *);
+/* Demande l'intégration d'une modification dans une collection. */
+static PyObject *py_loaded_binary_add_to_collection(PyObject *, PyObject *);
+
/* Fournit le nom associé à l'élément binaire. */
static PyObject *py_loaded_binary_get_name(PyObject *, void *);
@@ -96,6 +100,59 @@ static PyObject *py_loaded_binary_new(PyTypeObject *type, PyObject *args, PyObje
/******************************************************************************
* *
+* Paramètres : self = objet représentant un binaire chargé. *
+* args = arguments fournis pour l'opération. *
+* *
+* Description : Demande l'intégration d'une modification dans une collection.*
+* *
+* Retour : Bilan partiel de l'opération demandée. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static PyObject *py_loaded_binary_add_to_collection(PyObject *self, PyObject *args)
+{
+ PyObject *result; /* Bilan à retourner */
+ GDbItem *item; /* Elément à intégrer */
+ int ret; /* Bilan de lecture des args. */
+ GLoadedBinary *binary; /* Binaire en cours d'analyse */
+ bool status; /* Bilan de l'opération */
+
+#define LOADED_BINARY_ADD_TO_COLLECTION_METHOD PYTHON_METHOD_DEF \
+( \
+ add_to_collection, "$self, item, /", \
+ METH_VARARGS, py_loaded_binary, \
+ "Ask a server to include the given item into the update database." \
+ "\n" \
+ "The server type (internal or remote) depends on the collection type" \
+ " linked to the item and the user configuration." \
+ "\n" \
+ "The item has to be a subclass of pychrysalide.analysis.db.DbItem." \
+ "\n" \
+ "The method returns True if the item has been successfully forwarded" \
+ " to a server, False otherwise." \
+)
+
+ ret = PyArg_ParseTuple(args, "O&", convert_to_db_item, &item);
+ if (!ret) return NULL;
+
+ binary = G_LOADED_BINARY(pygobject_get(self));
+
+ g_object_ref(G_OBJECT(item));
+
+ status = g_loaded_binary_add_to_collection(binary, item);
+
+ result = status ? Py_True : Py_False;
+ Py_INCREF(result);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : self = objet Python concerné par l'appel. *
* closure = non utilisé ici. *
* *
@@ -246,6 +303,7 @@ static PyObject *py_loaded_binary_get_disassembled_cache(PyObject *self, void *c
PyTypeObject *get_python_loaded_binary_type(void)
{
static PyMethodDef py_loaded_binary_methods[] = {
+ LOADED_BINARY_ADD_TO_COLLECTION_METHOD,
{ NULL }
};