summaryrefslogtreecommitdiff
path: root/plugins/pychrysalide/analysis/content.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2019-07-01 19:22:17 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2019-07-01 19:22:17 (GMT)
commitbfd453d597d23b5c782aa8d40eb744d2ab56838e (patch)
treeb285ada70fcb80b367542ec876716b2aa33ebc5c /plugins/pychrysalide/analysis/content.c
parent2f1a1323b4b6c5d4ff84a6d4d335e0cf56c5c8fa (diff)
Introduced attributes for loaded contents.
Diffstat (limited to 'plugins/pychrysalide/analysis/content.c')
-rw-r--r--plugins/pychrysalide/analysis/content.c82
1 files changed, 82 insertions, 0 deletions
diff --git a/plugins/pychrysalide/analysis/content.c b/plugins/pychrysalide/analysis/content.c
index f332167..5f8694a 100644
--- a/plugins/pychrysalide/analysis/content.c
+++ b/plugins/pychrysalide/analysis/content.c
@@ -36,6 +36,7 @@
#include <common/endianness.h>
+#include "cattribs.h"
#include "../access.h"
#include "../helpers.h"
#include "../arch/vmpa.h"
@@ -60,6 +61,12 @@ static PyObject *py_binary_content_read_u32(PyObject *, PyObject *);
/* Lit un nombre non signé sur huit octets. */
static PyObject *py_binary_content_read_u64(PyObject *, PyObject *);
+/* Associe un ensemble d'attributs au contenu binaire. */
+static int py_binary_content_set_attributes(PyObject *, PyObject *, void *);
+
+/* Fournit l'ensemble des attributs associés à un contenu. */
+static PyObject *py_binary_content_get_attributes(PyObject *, void *);
+
/* Fournit une empreinte unique (SHA256) pour les données. */
static PyObject *py_binary_content_get_checksum(PyObject *, void *);
@@ -348,6 +355,80 @@ static PyObject *py_binary_content_read_u64(PyObject *self, PyObject *args)
/******************************************************************************
* *
* Paramètres : self = contenu binaire à manipuler. *
+* value = jeu d'attributs à lier au contenu courant. *
+* closure = adresse non utilisée ici. *
+* *
+* Description : Associe un ensemble d'attributs au contenu binaire. *
+* *
+* Retour : Jeu d'attributs liés au contenu courant. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static int py_binary_content_set_attributes(PyObject *self, PyObject *value, void *closure)
+{
+ int result; /* Bilan à renvoyer */
+ GBinContent *content; /* Version GLib du format */
+ GContentAttributes *attribs; /* Version native des attributs*/
+
+ content = G_BIN_CONTENT(pygobject_get(self));
+
+ if (!convert_to_content_attributes(value, &attribs))
+ result = -1;
+
+ else
+ {
+ g_binary_content_set_attributes(content, attribs);
+ result = 0;
+ }
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : self = contenu binaire à manipuler. *
+* closure = adresse non utilisée ici. *
+* *
+* Description : Fournit l'ensemble des attributs associés à un contenu. *
+* *
+* Retour : Jeu d'attributs liés au contenu courant. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static PyObject *py_binary_content_get_attributes(PyObject *self, void *closure)
+{
+ PyObject *result; /* Instance à retourner */
+ GBinContent *content; /* Version GLib du format */
+ GContentAttributes *attribs; /* Attributs à transmettre */
+
+#define BINARY_CONTENT_ATTRIBUTES_ATTRIB PYTHON_GETSET_DEF_FULL \
+( \
+ attributes, py_binary_content, \
+ "Provide or define the attributes linked to the binary content." \
+)
+
+ content = G_BIN_CONTENT(pygobject_get(self));
+
+ attribs = g_binary_content_get_attributes(content);
+
+ result = pygobject_new(G_OBJECT(attribs));
+
+ g_object_unref(attribs);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : self = contenu binaire à manipuler. *
* closure = adresse non utilisée ici. *
* *
* Description : Fournit une empreinte unique (SHA256) pour les données. *
@@ -552,6 +633,7 @@ PyTypeObject *get_python_binary_content_type(void)
};
static PyGetSetDef py_binary_content_getseters[] = {
+ BINARY_CONTENT_ATTRIBUTES_ATTRIB,
{
"checksum", py_binary_content_get_checksum, NULL,
"Compute a SHA256 hash as chechsum of handled data.", NULL