summaryrefslogtreecommitdiff
path: root/src/analysis
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2021-10-12 22:26:55 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2021-10-12 22:26:55 (GMT)
commitd405d93f41f9376c55ac8af7acde62eec80386ec (patch)
tree200fe3624d99061cca876493103bf6e981cf30a9 /src/analysis
parent2b3d86868d130ac82b403575d0b5521176e77827 (diff)
Reorganize the remaining code for binary contents.
Diffstat (limited to 'src/analysis')
-rw-r--r--src/analysis/contents/encapsulated.c364
-rw-r--r--src/analysis/contents/file.c64
-rw-r--r--src/analysis/contents/memory.c318
3 files changed, 438 insertions, 308 deletions
diff --git a/src/analysis/contents/encapsulated.c b/src/analysis/contents/encapsulated.c
index 7fb7e0c..dadc0a5 100644
--- a/src/analysis/contents/encapsulated.c
+++ b/src/analysis/contents/encapsulated.c
@@ -35,6 +35,9 @@
+/* -------------------------- ENSEMBLE DE DONNEES BINAIRES -------------------------- */
+
+
/* Contenu de issu d'un contenu plus global (instance) */
struct _GEncapsContent
{
@@ -75,11 +78,16 @@ static void g_encaps_content_dispose(GEncapsContent *);
/* Procède à la libération totale de la mémoire. */
static void g_encaps_content_finalize(GEncapsContent *);
-/* Charge un contenu depuis une mémoire tampon. */
-static bool g_encaps_content_load(GEncapsContent *, GObjectStorage *, packed_buffer_t *);
-/* Sauvegarde un contenu dans une mémoire tampon. */
-static bool g_encaps_content_store(const GEncapsContent *, GObjectStorage *, packed_buffer_t *);
+
+/* ---------------------- INTERACTIONS AVEC UN CONTENU BINAIRE ---------------------- */
+
+
+/* Associe un ensemble d'attributs au contenu binaire. */
+static void g_encaps_content_set_attributes(GEncapsContent *, GContentAttributes *);
+
+/* Fournit l'ensemble des attributs associés à un contenu. */
+static GContentAttributes *g_encaps_content_get_attributes(const GEncapsContent *);
/* Donne l'origine d'un contenu binaire. */
static GBinContent *g_encaps_content_get_root(GEncapsContent *);
@@ -131,10 +139,26 @@ static bool g_encaps_content_read_leb128(const GEncapsContent *, vmpa2t *, leb12
+/* -------------------- CONSERVATION ET RECHARGEMENT DES DONNEES -------------------- */
+
+
+/* Charge un contenu depuis une mémoire tampon. */
+static bool g_encaps_content_load(GEncapsContent *, GObjectStorage *, packed_buffer_t *);
+
+/* Sauvegarde un contenu dans une mémoire tampon. */
+static bool g_encaps_content_store(const GEncapsContent *, GObjectStorage *, packed_buffer_t *);
+
+
+
+/* ---------------------------------------------------------------------------------- */
+/* ENSEMBLE DE DONNEES BINAIRES */
+/* ---------------------------------------------------------------------------------- */
+
+
/* Indique le type défini par la GLib pour les contenus encapsulés. */
G_DEFINE_TYPE_WITH_CODE(GEncapsContent, g_encaps_content, G_TYPE_OBJECT,
- G_IMPLEMENT_INTERFACE(G_TYPE_SERIALIZABLE_OBJECT, g_encaps_content_serializable_init)
- G_IMPLEMENT_INTERFACE(G_TYPE_BIN_CONTENT, g_encaps_content_interface_init));
+ G_IMPLEMENT_INTERFACE(G_TYPE_BIN_CONTENT, g_encaps_content_interface_init)
+ G_IMPLEMENT_INTERFACE(G_TYPE_SERIALIZABLE_OBJECT, g_encaps_content_serializable_init));
/******************************************************************************
@@ -189,26 +213,6 @@ static void g_encaps_content_init(GEncapsContent *content)
* *
* Paramètres : iface = interface GLib à initialiser. *
* *
-* Description : Procède à l'initialisation de l'interface de sérialisation. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static void g_encaps_content_serializable_init(GSerializableObjectInterface *iface)
-{
- iface->load = (load_serializable_object_cb)g_encaps_content_load;
- iface->store = (store_serializable_object_cb)g_encaps_content_store;
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : iface = interface GLib à initialiser. *
-* *
* Description : Procède à l'initialisation de l'interface de lecture. *
* *
* Retour : - *
@@ -219,6 +223,9 @@ static void g_encaps_content_serializable_init(GSerializableObjectInterface *ifa
static void g_encaps_content_interface_init(GBinContentInterface *iface)
{
+ iface->set_attribs = (set_content_attributes)g_encaps_content_set_attributes;
+ iface->get_attribs = (get_content_attributes)g_encaps_content_get_attributes;
+
iface->get_root = (get_content_root_fc)g_encaps_content_get_root;
iface->describe = (describe_content_fc)g_encaps_content_describe;
@@ -248,6 +255,26 @@ static void g_encaps_content_interface_init(GBinContentInterface *iface)
/******************************************************************************
* *
+* Paramètres : iface = interface GLib à initialiser. *
+* *
+* Description : Procède à l'initialisation de l'interface de sérialisation. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_encaps_content_serializable_init(GSerializableObjectInterface *iface)
+{
+ iface->load = (load_serializable_object_cb)g_encaps_content_load;
+ iface->store = (store_serializable_object_cb)g_encaps_content_store;
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : content = instance d'objet GLib à traiter. *
* *
* Description : Supprime toutes les références externes. *
@@ -340,75 +367,47 @@ GBinContent *g_encaps_content_new(GBinContent *base, const char *path, GBinConte
/******************************************************************************
* *
-* Paramètres : content = élément GLib à constuire. *
-* storage = conservateur de données à manipuler ou NULL. *
-* pbuf = zone tampon à lire. *
+* Paramètres : content = contenu binaire à venir consulter. *
* *
-* Description : Charge un contenu depuis une mémoire tampon. *
+* Description : Indique la base d'un contenu binaire encapsulé. *
* *
-* Retour : Bilan de l'opération. *
+* Retour : Instance de contenu binaire ou NULL si aucune. *
* *
* Remarques : - *
* *
******************************************************************************/
-static bool g_encaps_content_load(GEncapsContent *content, GObjectStorage *storage, packed_buffer_t *pbuf)
+GBinContent *g_encaps_content_get_base(const GEncapsContent *content)
{
- bool result; /* Bilan à retourner */
- rle_string str; /* Chaîne à charger */
-
- content->base = G_BIN_CONTENT(g_object_storage_unpack_object(storage, "contents", pbuf));
- result = (content->base != NULL);
-
- setup_empty_rle_string(&str);
-
- if (result)
- result = unpack_rle_string(&str, pbuf);
-
- if (result)
- {
- result = (get_rle_string(&str) != NULL);
-
- if (result)
- content->path = strdup(get_rle_string(&str));
-
- exit_rle_string(&str);
-
- }
-
- if (result)
- {
- content->endpoint = G_BIN_CONTENT(g_object_storage_unpack_object(storage, "contents", pbuf));
- result = (content->endpoint != NULL);
- }
-
- if (result)
- result = unpack_rle_string(&str, pbuf);
-
- if (result)
- {
- result = (get_rle_string(&str) != NULL);
+ GBinContent *result; /* Contenu binaire à renvoyer */
- if (result)
- content->full_desc = strdup(get_rle_string(&str));
+ result = content->base;
- exit_rle_string(&str);
+ if (result != NULL)
+ g_object_ref(G_OBJECT(result));
- }
+ return result;
- if (result)
- result = unpack_rle_string(&str, pbuf);
+}
- if (result)
- {
- result = (get_rle_string(&str) != NULL);
- if (result)
- content->desc = strdup(get_rle_string(&str));
+/******************************************************************************
+* *
+* Paramètres : content = contenu binaire à venir consulter. *
+* *
+* Description : Fournit le chemin vers le contenu interne représenté. *
+* *
+* Retour : Chemin d'accès au contenu binaire. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
- exit_rle_string(&str);
+const char *g_encaps_content_get_path(const GEncapsContent *content)
+{
+ char *result; /* Chemin d'accès à retourner */
- }
+ result = content->path;
return result;
@@ -417,57 +416,73 @@ static bool g_encaps_content_load(GEncapsContent *content, GObjectStorage *stora
/******************************************************************************
* *
-* Paramètres : content = élément GLib à consulter. *
-* storage = conservateur de données à manipuler ou NULL. *
-* pbuf = zone tampon à remplir. *
+* Paramètres : content = contenu binaire à venir consulter. *
* *
-* Description : Sauvegarde un contenu dans une mémoire tampon. *
+* Description : Indique le contenu binaire embarqué dans une encapsulation. *
* *
-* Retour : Bilan de l'opération. *
+* Retour : Instance de contenu binaire ou NULL si aucune. *
* *
* Remarques : - *
* *
******************************************************************************/
-static bool g_encaps_content_store(const GEncapsContent *content, GObjectStorage *storage, packed_buffer_t *pbuf)
+GBinContent *g_encaps_content_get_endpoint(const GEncapsContent *content)
{
- bool result; /* Bilan à retourner */
- rle_string str; /* Chaîne à conserver */
+ GBinContent *result; /* Contenu binaire à renvoyer */
- result = g_object_storage_pack_object(storage, "contents", G_SERIALIZABLE_OBJECT(content->base), pbuf);
+ result = content->endpoint;
- if (result)
- {
- init_static_rle_string(&str, content->path);
+ if (result != NULL)
+ g_object_ref(G_OBJECT(result));
- result = pack_rle_string(&str, pbuf);
+ return result;
- exit_rle_string(&str);
+}
- }
- if (result)
- result = g_object_storage_pack_object(storage, "contents", G_SERIALIZABLE_OBJECT(content->endpoint), pbuf);
- if (result)
- {
- init_static_rle_string(&str, content->full_desc);
+/* ---------------------------------------------------------------------------------- */
+/* INTERACTIONS AVEC UN CONTENU BINAIRE */
+/* ---------------------------------------------------------------------------------- */
- result = pack_rle_string(&str, pbuf);
- exit_rle_string(&str);
+/******************************************************************************
+* *
+* Paramètres : content = contenu binaire à actualiser. *
+* attribs = jeu d'attributs à lier au contenu courant. *
+* *
+* Description : Associe un ensemble d'attributs au contenu binaire. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
- }
+static void g_encaps_content_set_attributes(GEncapsContent *content, GContentAttributes *attribs)
+{
+ g_binary_content_set_attributes(content->endpoint, attribs);
- if (result)
- {
- init_static_rle_string(&str, content->desc);
+}
- result = pack_rle_string(&str, pbuf);
- exit_rle_string(&str);
+/******************************************************************************
+* *
+* Paramètres : content = contenu binaire à consulter. *
+* *
+* Description : Fournit l'ensemble des attributs associés à un contenu. *
+* *
+* Retour : Jeu d'attributs liés au contenu courant. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
- }
+static GContentAttributes *g_encaps_content_get_attributes(const GEncapsContent *content)
+{
+ GContentAttributes *result; /* Instance à retourner */
+
+ result = g_binary_content_get_attributes(content->endpoint);
return result;
@@ -867,49 +882,83 @@ static bool g_encaps_content_read_leb128(const GEncapsContent *content, vmpa2t *
}
+
+/* ---------------------------------------------------------------------------------- */
+/* CONSERVATION ET RECHARGEMENT DES DONNEES */
+/* ---------------------------------------------------------------------------------- */
+
+
/******************************************************************************
* *
-* Paramètres : content = contenu binaire à venir consulter. *
+* Paramètres : content = élément GLib à constuire. *
+* storage = conservateur de données à manipuler ou NULL. *
+* pbuf = zone tampon à lire. *
* *
-* Description : Indique la base d'un contenu binaire encapsulé. *
+* Description : Charge un contenu depuis une mémoire tampon. *
* *
-* Retour : Instance de contenu binaire ou NULL si aucune. *
+* Retour : Bilan de l'opération. *
* *
* Remarques : - *
* *
******************************************************************************/
-GBinContent *g_encaps_content_get_base(const GEncapsContent *content)
+static bool g_encaps_content_load(GEncapsContent *content, GObjectStorage *storage, packed_buffer_t *pbuf)
{
- GBinContent *result; /* Contenu binaire à renvoyer */
+ bool result; /* Bilan à retourner */
+ rle_string str; /* Chaîne à charger */
- result = content->base;
+ content->base = G_BIN_CONTENT(g_object_storage_unpack_object(storage, "contents", pbuf));
+ result = (content->base != NULL);
- if (result != NULL)
- g_object_ref(G_OBJECT(result));
+ setup_empty_rle_string(&str);
- return result;
+ if (result)
+ result = unpack_rle_string(&str, pbuf);
-}
+ if (result)
+ {
+ result = (get_rle_string(&str) != NULL);
+ if (result)
+ content->path = strdup(get_rle_string(&str));
-/******************************************************************************
-* *
-* Paramètres : content = contenu binaire à venir consulter. *
-* *
-* Description : Fournit le chemin vers le contenu interne représenté. *
-* *
-* Retour : Chemin d'accès au contenu binaire. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
+ exit_rle_string(&str);
-const char *g_encaps_content_get_path(const GEncapsContent *content)
-{
- char *result; /* Chemin d'accès à retourner */
+ }
- result = content->path;
+ if (result)
+ {
+ content->endpoint = G_BIN_CONTENT(g_object_storage_unpack_object(storage, "contents", pbuf));
+ result = (content->endpoint != NULL);
+ }
+
+ if (result)
+ result = unpack_rle_string(&str, pbuf);
+
+ if (result)
+ {
+ result = (get_rle_string(&str) != NULL);
+
+ if (result)
+ content->full_desc = strdup(get_rle_string(&str));
+
+ exit_rle_string(&str);
+
+ }
+
+ if (result)
+ result = unpack_rle_string(&str, pbuf);
+
+ if (result)
+ {
+ result = (get_rle_string(&str) != NULL);
+
+ if (result)
+ content->desc = strdup(get_rle_string(&str));
+
+ exit_rle_string(&str);
+
+ }
return result;
@@ -918,24 +967,57 @@ const char *g_encaps_content_get_path(const GEncapsContent *content)
/******************************************************************************
* *
-* Paramètres : content = contenu binaire à venir consulter. *
+* Paramètres : content = élément GLib à consulter. *
+* storage = conservateur de données à manipuler ou NULL. *
+* pbuf = zone tampon à remplir. *
* *
-* Description : Indique le contenu binaire embarqué dans une encapsulation. *
+* Description : Sauvegarde un contenu dans une mémoire tampon. *
* *
-* Retour : Instance de contenu binaire ou NULL si aucune. *
+* Retour : Bilan de l'opération. *
* *
* Remarques : - *
* *
******************************************************************************/
-GBinContent *g_encaps_content_get_endpoint(const GEncapsContent *content)
+static bool g_encaps_content_store(const GEncapsContent *content, GObjectStorage *storage, packed_buffer_t *pbuf)
{
- GBinContent *result; /* Contenu binaire à renvoyer */
+ bool result; /* Bilan à retourner */
+ rle_string str; /* Chaîne à conserver */
- result = content->endpoint;
+ result = g_object_storage_pack_object(storage, "contents", G_SERIALIZABLE_OBJECT(content->base), pbuf);
- if (result != NULL)
- g_object_ref(G_OBJECT(result));
+ if (result)
+ {
+ init_static_rle_string(&str, content->path);
+
+ result = pack_rle_string(&str, pbuf);
+
+ exit_rle_string(&str);
+
+ }
+
+ if (result)
+ result = g_object_storage_pack_object(storage, "contents", G_SERIALIZABLE_OBJECT(content->endpoint), pbuf);
+
+ if (result)
+ {
+ init_static_rle_string(&str, content->full_desc);
+
+ result = pack_rle_string(&str, pbuf);
+
+ exit_rle_string(&str);
+
+ }
+
+ if (result)
+ {
+ init_static_rle_string(&str, content->desc);
+
+ result = pack_rle_string(&str, pbuf);
+
+ exit_rle_string(&str);
+
+ }
return result;
diff --git a/src/analysis/contents/file.c b/src/analysis/contents/file.c
index 78bd981..4f102d8 100644
--- a/src/analysis/contents/file.c
+++ b/src/analysis/contents/file.c
@@ -40,6 +40,9 @@
+/* -------------------------- ENSEMBLE DE DONNEES BINAIRES -------------------------- */
+
+
/* Contenu de données binaires issues d'un fichier (instance) */
struct _GFileContent
{
@@ -72,6 +75,10 @@ static void g_file_content_dispose(GFileContent *);
/* Procède à la libération totale de la mémoire. */
static void g_file_content_finalize(GFileContent *);
+
+/* -------------------- CONSERVATION ET RECHARGEMENT DES DONNEES -------------------- */
+
+
/* Charge un contenu depuis une mémoire tampon. */
static bool g_file_content_load(GFileContent *, GObjectStorage *, packed_buffer_t *);
@@ -80,6 +87,11 @@ static bool g_file_content_store(const GFileContent *, GObjectStorage *, packed_
+/* ---------------------------------------------------------------------------------- */
+/* ENSEMBLE DE DONNEES BINAIRES */
+/* ---------------------------------------------------------------------------------- */
+
+
/* Indique le type défini par la GLib pour les contenus de données. */
G_DEFINE_TYPE_WITH_CODE(GFileContent, g_file_content, G_TYPE_MEMORY_CONTENT,
G_IMPLEMENT_INTERFACE(G_TYPE_SERIALIZABLE_OBJECT, g_file_content_serializable_init));
@@ -261,6 +273,35 @@ GBinContent *g_file_content_new(const char *filename)
/******************************************************************************
* *
+* Paramètres : content = contenu binaire à venir consulter. *
+* *
+* Description : Fournit le nom de fichier associé au contenu binaire. *
+* *
+* Retour : Chemin d'accès au contenu binaire. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+const char *g_file_content_get_filename(const GFileContent *content)
+{
+ char *result; /* Chemin d'accès à retourner */
+
+ result = content->filename;
+
+ return result;
+
+}
+
+
+
+/* ---------------------------------------------------------------------------------- */
+/* CONSERVATION ET RECHARGEMENT DES DONNEES */
+/* ---------------------------------------------------------------------------------- */
+
+
+/******************************************************************************
+* *
* Paramètres : content = élément GLib à constuire. *
* storage = conservateur de données à manipuler ou NULL. *
* pbuf = zone tampon à lire. *
@@ -341,26 +382,3 @@ static bool g_file_content_store(const GFileContent *content, GObjectStorage *st
return result;
}
-
-
-/******************************************************************************
-* *
-* Paramètres : content = contenu binaire à venir consulter. *
-* *
-* Description : Fournit le nom de fichier associé au contenu binaire. *
-* *
-* Retour : Chemin d'accès au contenu binaire. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-const char *g_file_content_get_filename(const GFileContent *content)
-{
- char *result; /* Chemin d'accès à retourner */
-
- result = content->filename;
-
- return result;
-
-}
diff --git a/src/analysis/contents/memory.c b/src/analysis/contents/memory.c
index 50647f6..e28d31c 100644
--- a/src/analysis/contents/memory.c
+++ b/src/analysis/contents/memory.c
@@ -42,29 +42,31 @@
+/* -------------------------- ENSEMBLE DE DONNEES BINAIRES -------------------------- */
+
+
/* Initialise la classe des contenus de données en mémoire. */
static void g_memory_content_class_init(GMemoryContentClass *);
/* Initialise une instance de contenu de données en mémoire. */
static void g_memory_content_init(GMemoryContent *);
-/* Procède à l'initialisation de l'interface de sérialisation. */
-static void g_memory_content_serializable_init(GSerializableObjectInterface *);
-
/* Procède à l'initialisation de l'interface de lecture. */
static void g_memory_content_interface_init(GBinContentInterface *);
+/* Procède à l'initialisation de l'interface de sérialisation. */
+static void g_memory_content_serializable_init(GSerializableObjectInterface *);
+
/* Supprime toutes les références externes. */
static void g_memory_content_dispose(GMemoryContent *);
/* Procède à la libération totale de la mémoire. */
static void g_memory_content_finalize(GMemoryContent *);
-/* Charge un contenu depuis une mémoire tampon. */
-static bool g_memory_content_load(GMemoryContent *, GObjectStorage *, packed_buffer_t *);
-/* Sauvegarde un contenu dans une mémoire tampon. */
-static bool g_memory_content_store(const GMemoryContent *, GObjectStorage *, packed_buffer_t *);
+
+/* ---------------------- INTERACTIONS AVEC UN CONTENU BINAIRE ---------------------- */
+
/* Associe un ensemble d'attributs au contenu binaire. */
static void g_memory_content_set_attributes(GMemoryContent *, GContentAttributes *);
@@ -122,10 +124,26 @@ static bool g_memory_content_read_leb128(const GMemoryContent *, vmpa2t *, leb12
+/* -------------------- CONSERVATION ET RECHARGEMENT DES DONNEES -------------------- */
+
+
+/* Charge un contenu depuis une mémoire tampon. */
+static bool g_memory_content_load(GMemoryContent *, GObjectStorage *, packed_buffer_t *);
+
+/* Sauvegarde un contenu dans une mémoire tampon. */
+static bool g_memory_content_store(const GMemoryContent *, GObjectStorage *, packed_buffer_t *);
+
+
+
+/* ---------------------------------------------------------------------------------- */
+/* ENSEMBLE DE DONNEES BINAIRES */
+/* ---------------------------------------------------------------------------------- */
+
+
/* Indique le type défini par la GLib pour les contenus de données en mémoire. */
G_DEFINE_TYPE_WITH_CODE(GMemoryContent, g_memory_content, G_TYPE_OBJECT,
- G_IMPLEMENT_INTERFACE(G_TYPE_SERIALIZABLE_OBJECT, g_memory_content_serializable_init)
- G_IMPLEMENT_INTERFACE(G_TYPE_BIN_CONTENT, g_memory_content_interface_init));
+ G_IMPLEMENT_INTERFACE(G_TYPE_BIN_CONTENT, g_memory_content_interface_init)
+ G_IMPLEMENT_INTERFACE(G_TYPE_SERIALIZABLE_OBJECT, g_memory_content_serializable_init));
/******************************************************************************
@@ -187,26 +205,6 @@ static void g_memory_content_init(GMemoryContent *content)
* *
* Paramètres : iface = interface GLib à initialiser. *
* *
-* Description : Procède à l'initialisation de l'interface de sérialisation. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static void g_memory_content_serializable_init(GSerializableObjectInterface *iface)
-{
- iface->load = (load_serializable_object_cb)g_memory_content_load;
- iface->store = (store_serializable_object_cb)g_memory_content_store;
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : iface = interface GLib à initialiser. *
-* *
* Description : Procède à l'initialisation de l'interface de lecture. *
* *
* Retour : - *
@@ -249,6 +247,26 @@ static void g_memory_content_interface_init(GBinContentInterface *iface)
/******************************************************************************
* *
+* Paramètres : iface = interface GLib à initialiser. *
+* *
+* Description : Procède à l'initialisation de l'interface de sérialisation. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_memory_content_serializable_init(GSerializableObjectInterface *iface)
+{
+ iface->load = (load_serializable_object_cb)g_memory_content_load;
+ iface->store = (store_serializable_object_cb)g_memory_content_store;
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : content = instance d'objet GLib à traiter. *
* *
* Description : Supprime toutes les références externes. *
@@ -333,122 +351,10 @@ GBinContent *g_memory_content_new(const bin_t *data, phys_t size)
}
-/******************************************************************************
-* *
-* Paramètres : content = élément GLib à constuire. *
-* storage = conservateur de données à manipuler ou NULL. *
-* pbuf = zone tampon à lire. *
-* *
-* Description : Charge un contenu depuis une mémoire tampon. *
-* *
-* Retour : Bilan de l'opération. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static bool g_memory_content_load(GMemoryContent *content, GObjectStorage *storage, packed_buffer_t *pbuf)
-{
- bool result; /* Bilan à retourner */
- uleb128_t length; /* Quantité de données à suivre*/
- rle_string str; /* Chaîne à charger */
-
- result = unpack_uleb128(&length, pbuf);
-
- if (result)
- {
- content->data = malloc(length);
- result = (content->data != NULL);
- }
-
- if (result)
- {
- content->length = length;
- result = extract_packed_buffer(pbuf, content->data, length, false);
- }
-
- setup_empty_rle_string(&str);
-
- if (result)
- result = unpack_rle_string(&str, pbuf);
-
- if (result)
- {
- result = (get_rle_string(&str) != NULL);
-
- if (result)
- content->full_desc = strdup(get_rle_string(&str));
-
- exit_rle_string(&str);
-
- }
-
- if (result)
- result = unpack_rle_string(&str, pbuf);
-
- if (result)
- {
- result = (get_rle_string(&str) != NULL);
-
- if (result)
- content->desc = strdup(get_rle_string(&str));
-
- exit_rle_string(&str);
-
- }
-
- return result;
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : content = élément GLib à consulter. *
-* storage = conservateur de données à manipuler ou NULL. *
-* pbuf = zone tampon à remplir. *
-* *
-* Description : Sauvegarde un contenu dans une mémoire tampon. *
-* *
-* Retour : Bilan de l'opération. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static bool g_memory_content_store(const GMemoryContent *content, GObjectStorage *storage, packed_buffer_t *pbuf)
-{
- bool result; /* Bilan à retourner */
- rle_string str; /* Chaîne à conserver */
-
- result = pack_uleb128((uleb128_t []){ content->length }, pbuf);
-
- if (result)
- result = extend_packed_buffer(pbuf, content->data, content->length, false);
-
- if (result)
- {
- init_static_rle_string(&str, content->full_desc);
-
- result = pack_rle_string(&str, pbuf);
-
- exit_rle_string(&str);
-
- }
-
- if (result)
- {
- init_static_rle_string(&str, content->desc);
-
- result = pack_rle_string(&str, pbuf);
-
- exit_rle_string(&str);
- }
-
- return result;
-
-}
+/* ---------------------------------------------------------------------------------- */
+/* INTERACTIONS AVEC UN CONTENU BINAIRE */
+/* ---------------------------------------------------------------------------------- */
/******************************************************************************
@@ -979,3 +885,127 @@ static bool g_memory_content_read_leb128(const GMemoryContent *content, vmpa2t *
return result;
}
+
+
+
+/* ---------------------------------------------------------------------------------- */
+/* CONSERVATION ET RECHARGEMENT DES DONNEES */
+/* ---------------------------------------------------------------------------------- */
+
+
+/******************************************************************************
+* *
+* Paramètres : content = élément GLib à constuire. *
+* storage = conservateur de données à manipuler ou NULL. *
+* pbuf = zone tampon à lire. *
+* *
+* Description : Charge un contenu depuis une mémoire tampon. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static bool g_memory_content_load(GMemoryContent *content, GObjectStorage *storage, packed_buffer_t *pbuf)
+{
+ bool result; /* Bilan à retourner */
+ uleb128_t length; /* Quantité de données à suivre*/
+ rle_string str; /* Chaîne à charger */
+
+ result = unpack_uleb128(&length, pbuf);
+
+ if (result)
+ {
+ content->data = malloc(length);
+ result = (content->data != NULL);
+ }
+
+ if (result)
+ {
+ content->length = length;
+ result = extract_packed_buffer(pbuf, content->data, length, false);
+ }
+
+ setup_empty_rle_string(&str);
+
+ if (result)
+ result = unpack_rle_string(&str, pbuf);
+
+ if (result)
+ {
+ result = (get_rle_string(&str) != NULL);
+
+ if (result)
+ content->full_desc = strdup(get_rle_string(&str));
+
+ exit_rle_string(&str);
+
+ }
+
+ if (result)
+ result = unpack_rle_string(&str, pbuf);
+
+ if (result)
+ {
+ result = (get_rle_string(&str) != NULL);
+
+ if (result)
+ content->desc = strdup(get_rle_string(&str));
+
+ exit_rle_string(&str);
+
+ }
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : content = élément GLib à consulter. *
+* storage = conservateur de données à manipuler ou NULL. *
+* pbuf = zone tampon à remplir. *
+* *
+* Description : Sauvegarde un contenu dans une mémoire tampon. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static bool g_memory_content_store(const GMemoryContent *content, GObjectStorage *storage, packed_buffer_t *pbuf)
+{
+ bool result; /* Bilan à retourner */
+ rle_string str; /* Chaîne à conserver */
+
+ result = pack_uleb128((uleb128_t []){ content->length }, pbuf);
+
+ if (result)
+ result = extend_packed_buffer(pbuf, content->data, content->length, false);
+
+ if (result)
+ {
+ init_static_rle_string(&str, content->full_desc);
+
+ result = pack_rle_string(&str, pbuf);
+
+ exit_rle_string(&str);
+
+ }
+
+ if (result)
+ {
+ init_static_rle_string(&str, content->desc);
+
+ result = pack_rle_string(&str, pbuf);
+
+ exit_rle_string(&str);
+
+ }
+
+ return result;
+
+}