summaryrefslogtreecommitdiff
path: root/src/format/known.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/format/known.c')
-rw-r--r--src/format/known.c181
1 files changed, 180 insertions, 1 deletions
diff --git a/src/format/known.c b/src/format/known.c
index 6865d0d..7512ae1 100644
--- a/src/format/known.c
+++ b/src/format/known.c
@@ -28,16 +28,23 @@
#include "known-int.h"
+#include "../analysis/storage/serialize-int.h"
#include "../plugins/pglist.h"
+/* ---------------------- DEFINITION DE LA BASE DE TOUT FORMAT ---------------------- */
+
+
/* Initialise la classe des formats binaires génériques. */
static void g_known_format_class_init(GKnownFormatClass *);
/* Initialise une instance de format binaire générique. */
static void g_known_format_init(GKnownFormat *);
+/* Procède à l'initialisation de l'interface de sérialisation. */
+static void g_known_format_serializable_init(GSerializableObjectInterface *);
+
/* Supprime toutes les références externes. */
static void g_known_format_dispose(GKnownFormat *);
@@ -46,8 +53,31 @@ static void g_known_format_finalize(GKnownFormat *);
+/* -------------------- CONSERVATION ET RECHARGEMENT DES DONNEES -------------------- */
+
+
+/* Charge un format depuis une mémoire tampon. */
+static bool _g_known_format_load(GKnownFormat *, GObjectStorage *, packed_buffer_t *);
+
+/* Charge un format depuis une mémoire tampon. */
+static bool g_known_format_load(GKnownFormat *, GObjectStorage *, packed_buffer_t *);
+
+/* Sauvegarde un format dans une mémoire tampon. */
+static bool _g_known_format_store(GKnownFormat *, GObjectStorage *, packed_buffer_t *);
+
+/* Sauvegarde un format dans une mémoire tampon. */
+static bool g_known_format_store(GKnownFormat *, GObjectStorage *, packed_buffer_t *);
+
+
+
+/* ---------------------------------------------------------------------------------- */
+/* DEFINITION DE LA BASE DE TOUT FORMAT */
+/* ---------------------------------------------------------------------------------- */
+
+
/* Indique le type défini pour un format binaire générique. */
-G_DEFINE_TYPE(GKnownFormat, g_known_format, G_TYPE_OBJECT);
+G_DEFINE_TYPE_WITH_CODE(GKnownFormat, g_known_format, G_TYPE_OBJECT,
+ G_IMPLEMENT_INTERFACE(G_TYPE_SERIALIZABLE_OBJECT, g_known_format_serializable_init));
/******************************************************************************
@@ -71,6 +101,9 @@ static void g_known_format_class_init(GKnownFormatClass *klass)
object->dispose = (GObjectFinalizeFunc/* ! */)g_known_format_dispose;
object->finalize = (GObjectFinalizeFunc)g_known_format_finalize;
+ klass->load = (load_known_fc)_g_known_format_load;
+ klass->store = (store_known_fc)_g_known_format_store;
+
}
@@ -95,6 +128,26 @@ static void g_known_format_init(GKnownFormat *format)
/******************************************************************************
* *
+* Paramètres : iface = interface GLib à initialiser. *
+* *
+* Description : Procède à l'initialisation de l'interface de sérialisation. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_known_format_serializable_init(GSerializableObjectInterface *iface)
+{
+ iface->load = (load_serializable_object_cb)g_known_format_load;
+ iface->store = (store_serializable_object_cb)g_known_format_store;
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : format = instance d'objet GLib à traiter. *
* *
* Description : Supprime toutes les références externes. *
@@ -289,3 +342,129 @@ void g_known_format_complete_analysis(GKnownFormat *format, wgroup_id_t gid, Gtk
handle_known_format_analysis(PGA_FORMAT_POST_ANALYSIS_ENDED, format, gid, status);
}
+
+
+
+/* ---------------------------------------------------------------------------------- */
+/* CONSERVATION ET RECHARGEMENT DES DONNEES */
+/* ---------------------------------------------------------------------------------- */
+
+
+/******************************************************************************
+* *
+* Paramètres : operand = élément GLib à constuire. *
+* storage = conservateur de données à manipuler ou NULL. *
+* pbuf = zone tampon à lire. *
+* *
+* Description : Charge un format depuis une mémoire tampon. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static bool _g_known_format_load(GKnownFormat *format, GObjectStorage *storage, packed_buffer_t *pbuf)
+{
+ bool result; /* Bilan à retourner */
+ GBinContent *content; /* Contenu binaire rechargé */
+
+ content = G_BIN_CONTENT(g_object_storage_unpack_object(storage, "contents", pbuf));
+ result = (content != NULL);
+
+ if (result)
+ {
+ g_known_format_set_content(format, content);
+
+ g_object_unref(G_OBJECT(content));
+
+ }
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : operand = élément GLib à constuire. *
+* storage = conservateur de données à manipuler ou NULL. *
+* pbuf = zone tampon à lire. *
+* *
+* Description : Charge un format depuis une mémoire tampon. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static bool g_known_format_load(GKnownFormat *format, GObjectStorage *storage, packed_buffer_t *pbuf)
+{
+ bool result; /* Bilan à retourner */
+ GKnownFormatClass *class; /* Classe à activer */
+
+ class = G_KNOWN_FORMAT_GET_CLASS(format);
+
+ result = class->load(format, storage, pbuf);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : operand = élément GLib à consulter. *
+* storage = conservateur de données à manipuler ou NULL. *
+* pbuf = zone tampon à remplir. *
+* *
+* Description : Sauvegarde un format dans une mémoire tampon. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static bool _g_known_format_store(GKnownFormat *format, GObjectStorage *storage, packed_buffer_t *pbuf)
+{
+ bool result; /* Bilan à retourner */
+
+ if (format->content == NULL)
+ result = false;
+
+ else
+ result = g_object_storage_pack_object(storage, "contents", G_SERIALIZABLE_OBJECT(format->content), pbuf);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : operand = élément GLib à consulter. *
+* storage = conservateur de données à manipuler ou NULL. *
+* pbuf = zone tampon à remplir. *
+* *
+* Description : Sauvegarde un format dans une mémoire tampon. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static bool g_known_format_store(GKnownFormat *format, GObjectStorage *storage, packed_buffer_t *pbuf)
+{
+ bool result; /* Bilan à retourner */
+ GKnownFormatClass *class; /* Classe à activer */
+
+ class = G_KNOWN_FORMAT_GET_CLASS(format);
+
+ result = class->store(format, storage, pbuf);
+
+ return result;
+
+}