summaryrefslogtreecommitdiff
path: root/src/analysis/storage/serialize.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/analysis/storage/serialize.c')
-rw-r--r--src/analysis/storage/serialize.c119
1 files changed, 119 insertions, 0 deletions
diff --git a/src/analysis/storage/serialize.c b/src/analysis/storage/serialize.c
new file mode 100644
index 0000000..6ed1eab
--- /dev/null
+++ b/src/analysis/storage/serialize.c
@@ -0,0 +1,119 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * serialize.h - objets entreposables dans un cache
+ *
+ * Copyright (C) 2020 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * Chrysalide is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Chrysalide is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Chrysalide. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#include "serialize.h"
+
+
+#include "serialize-int.h"
+
+
+
+/* Procède à l'initialisation de l'interface de mise en cache. */
+static void g_serializable_object_default_init(GSerializableObjectInterface *);
+
+
+
+/* Détermine le type d'une interface pour la mise en cache d'objet. */
+G_DEFINE_INTERFACE(GSerializableObject, g_serializable_object, G_TYPE_OBJECT)
+
+
+/******************************************************************************
+* *
+* Paramètres : iface = interface GLib à initialiser. *
+* *
+* Description : Procède à l'initialisation de l'interface de mise en cache. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_serializable_object_default_init(GSerializableObjectInterface *iface)
+{
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : object = instruction d'assemblage à consulter. *
+* storage = conservateur de données à manipuler ou NULL. *
+* tpmem = mémoire des types d'objets à compléter. *
+* pbuf = zone tampon à remplir. *
+* *
+* Description : Charge un objet depuis une mémoire tampon. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool g_serializable_object_load(GSerializableObject *object, GObjectStorage *storage, GTypeMemory *tpmem, packed_buffer *pbuf)
+{
+ bool result; /* Bilan à retourner */
+ GSerializableObjectIface *iface; /* Interface utilisée */
+
+ iface = G_SERIALIZABLE_OBJECT_GET_IFACE(object);
+
+ result = iface->load(object, storage, tpmem, pbuf);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : object = instruction d'assemblage à consulter. *
+* storage = conservateur de données à manipuler ou NULL. *
+* tpmem = mémoire des types d'objets à compléter. *
+* pbuf = zone tampon à remplir. *
+* *
+* Description : Sauvegarde un objet dans une mémoire tampon. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool g_serializable_object_store(const GSerializableObject *object, GObjectStorage *storage, GTypeMemory *tpmem, packed_buffer *pbuf)
+{
+ bool result; /* Bilan à retourner */
+ GSerializableObjectIface *iface; /* Interface utilisée */
+
+ result = g_type_memory_store_object_gtype(tpmem, G_OBJECT(object), pbuf);
+
+ if (result)
+ {
+ iface = G_SERIALIZABLE_OBJECT_GET_IFACE(object);
+
+ result = iface->store(object, storage, tpmem, pbuf);
+
+ }
+
+ return result;
+
+}