summaryrefslogtreecommitdiff
path: root/src/analysis/contents/encapsulated.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/analysis/contents/encapsulated.c')
-rw-r--r--src/analysis/contents/encapsulated.c168
1 files changed, 168 insertions, 0 deletions
diff --git a/src/analysis/contents/encapsulated.c b/src/analysis/contents/encapsulated.c
index 59b0c9e..fa31aa4 100644
--- a/src/analysis/contents/encapsulated.c
+++ b/src/analysis/contents/encapsulated.c
@@ -29,6 +29,8 @@
#include "../content-int.h"
+#include "../db/misc/rlestr.h"
+#include "../storage/serialize-int.h"
#include "../../common/extstr.h"
@@ -61,6 +63,9 @@ static void g_encaps_content_class_init(GEncapsContentClass *);
/* Initialise une instance de contenu de données encapsulé. */
static void g_encaps_content_init(GEncapsContent *);
+/* Procède à l'initialisation de l'interface de sérialisation. */
+static void g_encaps_content_serializable_init(GSerializableObjectInterface *);
+
/* Procède à l'initialisation de l'interface de lecture. */
static void g_encaps_content_interface_init(GBinContentInterface *);
@@ -70,6 +75,12 @@ 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 *);
+
/* Donne l'origine d'un contenu binaire. */
static GBinContent *g_encaps_content_get_root(GEncapsContent *);
@@ -125,6 +136,7 @@ static bool g_encaps_content_read_leb128(const GEncapsContent *, vmpa2t *, leb12
/* 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));
@@ -180,6 +192,26 @@ 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 : - *
@@ -382,6 +414,142 @@ GBinContent *g_encaps_content_new_from_xml(xmlXPathContextPtr context, const cha
/******************************************************************************
* *
+* 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_encaps_content_load(GEncapsContent *content, GObjectStorage *storage, packed_buffer_t *pbuf)
+{
+ 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);
+
+ 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_encaps_content_store(const GEncapsContent *content, GObjectStorage *storage, packed_buffer_t *pbuf)
+{
+ bool result; /* Bilan à retourner */
+ rle_string str; /* Chaîne à conserver */
+
+ result = g_object_storage_pack_object(storage, "contents", G_SERIALIZABLE_OBJECT(content->base), pbuf);
+
+ 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;
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : content = contenu binaire à consulter. *
* *
* Description : Donne l'origine d'un contenu binaire. *