summaryrefslogtreecommitdiff
path: root/src/arch/sharing
diff options
context:
space:
mode:
Diffstat (limited to 'src/arch/sharing')
-rw-r--r--src/arch/sharing/Makefile.am16
-rw-r--r--src/arch/sharing/container-int.h51
-rw-r--r--src/arch/sharing/container.c93
-rw-r--r--src/arch/sharing/container.h59
-rw-r--r--src/arch/sharing/instance-int.h83
-rw-r--r--src/arch/sharing/instance.c273
-rw-r--r--src/arch/sharing/instance.h77
-rw-r--r--src/arch/sharing/manager.c431
-rw-r--r--src/arch/sharing/manager.h81
9 files changed, 0 insertions, 1164 deletions
diff --git a/src/arch/sharing/Makefile.am b/src/arch/sharing/Makefile.am
deleted file mode 100644
index 48c6636..0000000
--- a/src/arch/sharing/Makefile.am
+++ /dev/null
@@ -1,16 +0,0 @@
-
-noinst_LTLIBRARIES = libarchsharing.la
-
-libarchsharing_la_SOURCES = \
- container-int.h \
- container.h container.c \
- instance-int.h \
- instance.h instance.c \
- manager.h manager.c
-
-libarchdalvik_la_CFLAGS = $(AM_CFLAGS)
-
-
-AM_CPPFLAGS = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS)
-
-AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS)
diff --git a/src/arch/sharing/container-int.h b/src/arch/sharing/container-int.h
deleted file mode 100644
index bc67bf6..0000000
--- a/src/arch/sharing/container-int.h
+++ /dev/null
@@ -1,51 +0,0 @@
-
-/* Chrysalide - Outil d'analyse de fichiers binaires
- * container-int.h - définitions internes propres aux intégrateurs de contenu
- *
- * Copyright (C) 2016-2017 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
- */
-
-
-#ifndef _ARCH_SHARING_CONTAINER_INT_H
-#define _ARCH_SHARING_CONTAINER_INT_H
-
-
-#include "container.h"
-
-
-
-/* Assure la mise à jour du contenu d'un intégrateur. */
-typedef bool (* replace_shared_fc) (GShareContainer *, GSharedInstance *, GSharedInstance *);
-
-
-/* Règles de partage d'une instance GObject (interface) */
-struct _GShareContainerIface
-{
- GTypeInterface base_iface; /* A laisser en premier */
-
- replace_shared_fc replace; /* Mise à jour du conteneur */
-
-};
-
-
-/* Redéfinition */
-typedef GShareContainerIface GShareContainerInterface;
-
-
-
-#endif /* _ARCH_SHARING_CONTAINER_INT_H */
diff --git a/src/arch/sharing/container.c b/src/arch/sharing/container.c
deleted file mode 100644
index 5ff62b7..0000000
--- a/src/arch/sharing/container.c
+++ /dev/null
@@ -1,93 +0,0 @@
-
-/* Chrysalide - Outil d'analyse de fichiers binaires
- * content.c - intégration de données partagées
- *
- * Copyright (C) 2016-2017 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
- */
-
-
-#include "container.h"
-
-
-#include <assert.h>
-
-
-#include "container-int.h"
-
-
-
-/* Procède à l'initialisation de l'interface d'intégration. */
-static void g_share_container_default_init(GShareContainerInterface *);
-
-
-
-/* Détermine le type d'une interface pour l'intégration de contenu partagé. */
-G_DEFINE_INTERFACE(GShareContainer, g_share_container, G_TYPE_OBJECT)
-
-
-/******************************************************************************
-* *
-* Paramètres : iface = interface GLib à initialiser. *
-* *
-* Description : Procède à l'initialisation de l'interface d'intégration. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static void g_share_container_default_init(GShareContainerInterface *iface)
-{
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : instance = intégrateur à éventuellement manipuler. *
-* old = ancien contenu à remplacer si besoin est. *
-* new = nouveau contenu, potentiellement original. *
-* *
-* Description : Assure la mise à jour du contenu d'un intégrateur. *
-* *
-* Retour : Bilan de l'opération. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-bool g_share_container_replace(GShareContainer *container, GSharedInstance *old, GSharedInstance *new)
-{
- bool result; /* Bilan à retourner */
- GShareContainerIface *iface; /* Interface utilisée */
-
- if (old != new)
- {
- iface = G_SHARE_CONTAINER_GET_IFACE(container);
-
- result = iface->replace(container, old, new);
-
- }
-
- else
- result = false;
-
- return result;
-
-}
diff --git a/src/arch/sharing/container.h b/src/arch/sharing/container.h
deleted file mode 100644
index 3312f9d..0000000
--- a/src/arch/sharing/container.h
+++ /dev/null
@@ -1,59 +0,0 @@
-
-/* Chrysalide - Outil d'analyse de fichiers binaires
- * content.h - prototypes pour l'intégration de données partagées
- *
- * Copyright (C) 2016-2017 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
- */
-
-
-#ifndef _ARCH_SHARING_CONTAINER_H
-#define _ARCH_SHARING_CONTAINER_H
-
-
-#include <stdbool.h>
-#include <glib-object.h>
-
-
-#include "instance.h"
-
-
-
-#define G_TYPE_SHARE_CONTAINER (g_share_container_get_type())
-#define G_SHARE_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), G_TYPE_SHARE_CONTAINER, GShareContainer))
-#define G_SHARE_CONTAINER_CLASS(vtable) (G_TYPE_CHECK_CLASS_CAST((vtable), G_TYPE_SHARE_CONTAINER, GShareContainerIface))
-#define GTK_IS_SHARE_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), G_TYPE_SHARE_CONTAINER))
-#define GTK_IS_SHARE_CONTAINER_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE((vtable), G_TYPE_SHARE_CONTAINER))
-#define G_SHARE_CONTAINER_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE((inst), G_TYPE_SHARE_CONTAINER, GShareContainerIface))
-
-
-/* Intégrateur de contenu partagé (coquille vide) */
-typedef struct _GShareContainer GShareContainer;
-
-/* Intégrateur de contenu partagé (interface) */
-typedef struct _GShareContainerIface GShareContainerIface;
-
-
-/* Détermine le type d'une interface pour l'intégration de contenu partagé. */
-GType g_share_container_get_type(void) G_GNUC_CONST;
-
-/* Assure la mise à jour du contenu d'un intégrateur. */
-bool g_share_container_replace(GShareContainer *, GSharedInstance *, GSharedInstance *);
-
-
-
-#endif /* _ARCH_SHARING_CONTAINER_H */
diff --git a/src/arch/sharing/instance-int.h b/src/arch/sharing/instance-int.h
deleted file mode 100644
index cf5a56d..0000000
--- a/src/arch/sharing/instance-int.h
+++ /dev/null
@@ -1,83 +0,0 @@
-
-/* Chrysalide - Outil d'analyse de fichiers binaires
- * instance-int.h - définitions internes propres aux instances partagées
- *
- * Copyright (C) 2016-2017 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
- */
-
-
-#ifndef _ARCH_SHARING_INSTANCE_INT_H
-#define _ARCH_SHARING_INSTANCE_INT_H
-
-
-#include "instance.h"
-#include "manager.h"
-
-
-
-/* Fournit le gestionnaire de partages attribué à un type. */
-typedef GShareManager * (* get_share_manager_fc) (const GSharedInstance *);
-
-/* Initialise un nouvel objet partagé avec des informations. */
-typedef bool (* apply_shared_template_fc) (GSharedInstance *, const GSharedInstance *);
-
-/* Procède à l'initialisation de l'interface de partage. */
-typedef void (* define_shared_template_fc) (const GSharedInstance *, GSharedInstance *);
-
-/* Initialise un nouvel objet partagé avec des informations. */
-typedef bool (* free_shared_template_fc) (const GSharedInstance *, GSharedInstance *);
-
-/* Fournit la valeur du compteur de partage. */
-typedef unsigned int (* get_shared_ref_fc) (const GSharedInstance *);
-
-/* Incrémente le compteur de partage. */
-typedef void (* inc_shared_ref_fc) (GSharedInstance *);
-
-/* Décrémente le compteur de partage. */
-typedef void (* dec_shared_ref_fc) (GSharedInstance *);
-
-/* Procède à l'initialisation de l'interface de partage. */
-typedef int (* compare_shared_fc) (const GSharedInstance * const *, const GSharedInstance * const *);
-
-
-/* Règles de partage d'une instance GObject (interface) */
-struct _GSharedInstanceIface
-{
- GTypeInterface base_iface; /* A laisser en premier */
-
- get_share_manager_fc get_manager; /* Accès au gestionnaire */
-
- apply_shared_template_fc apply_template;/* Intialisation d'instance */
- define_shared_template_fc define_template; /* Copie minimale de détails*/
- free_shared_template_fc free_template; /* Libération d'un patron */
-
- get_shared_ref_fc get_ref; /* Obtention du compteur */
- inc_shared_ref_fc inc_ref; /* Incrémentation du compteur */
- dec_shared_ref_fc dec_ref; /* Décrémentation du compteur */
-
- compare_shared_fc compare; /* Comparaison des détails */
-
-};
-
-
-/* Redéfinition */
-typedef GSharedInstanceIface GSharedInstanceInterface;
-
-
-
-#endif /* _ARCH_SHARING_INSTANCE_INT_H */
diff --git a/src/arch/sharing/instance.c b/src/arch/sharing/instance.c
deleted file mode 100644
index 05081bb..0000000
--- a/src/arch/sharing/instance.c
+++ /dev/null
@@ -1,273 +0,0 @@
-
-/* Chrysalide - Outil d'analyse de fichiers binaires
- * instance.c - partage de données d'architecture quelconques
- *
- * Copyright (C) 2016-2017 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
- */
-
-
-#include "instance.h"
-
-
-#include <assert.h>
-
-
-#include "instance-int.h"
-
-
-
-/* Procède à l'initialisation de l'interface de partage. */
-static void g_shared_instance_default_init(GSharedInstanceInterface *);
-
-
-
-/* Détermine le type d'une interface pour le partage d'instance. */
-G_DEFINE_INTERFACE(GSharedInstance, g_shared_instance, G_TYPE_OBJECT)
-
-
-/******************************************************************************
-* *
-* Paramètres : iface = interface GLib à initialiser. *
-* *
-* Description : Procède à l'initialisation de l'interface de partage. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static void g_shared_instance_default_init(GSharedInstanceInterface *iface)
-{
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : instance = objet partagé à initialiser. *
-* template = informations à retrouver intégralement. *
-* *
-* Description : Initialise un nouvel objet partagé avec des informations. *
-* *
-* Retour : Bilan de l'opération. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-bool g_shared_instance_apply_template(GSharedInstance *instance, const GSharedInstance *template)
-{
- bool result; /* Bilan à retourner */
- GSharedInstanceIface *iface; /* Interface utilisée */
-
- iface = G_SHARED_INSTANCE_GET_IFACE(instance);
-
- /**
- * Le compteur de références des objets GLib doit être incrémenté ici,
- * à la différence d'une opération de copie minimaliste.
- */
-
- result = iface->apply_template(instance, template);
-
- return result;
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : instance = objet partagé à consulter. *
-* template = informations à retrouver intégralement. *
-* *
-* Description : Réalise une copie minimale d'un contenu partagé. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-void g_shared_instance_define_template(const GSharedInstance *instance, GSharedInstance *template)
-{
- GSharedInstanceIface *iface; /* Interface utilisée */
-
- iface = G_SHARED_INSTANCE_GET_IFACE(instance);
-
- /**
- * Le compteur de références des objets GLib ne doit pas être incrémenté ici.
- * Ce genre de traitement est réservé à la phase d'initialisation.
- */
-
- iface->define_template(instance, template);
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : instance = objet partagé à modifier. *
-* *
-* Description : Incrémente le compteur de références d'un élément partagé. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-void g_shared_instance_ref(GSharedInstance *instance)
-{
- GSharedInstanceIface *iface; /* Interface utilisée */
- GShareManager *manager; /* Gestionnaire associé */
-
- iface = G_SHARED_INSTANCE_GET_IFACE(instance);
-
- manager = iface->get_manager(instance);
-
- g_share_manager_get(manager, instance);
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : instance = objet partagé à modifier. *
-* *
-* Description : Décrémente le compteur de références d'un élément partagé. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-void g_shared_instance_unref(GSharedInstance *instance)
-{
- GSharedInstanceIface *iface; /* Interface utilisée */
- GShareManager *manager; /* Gestionnaire associé */
-
- iface = G_SHARED_INSTANCE_GET_IFACE(instance);
-
- manager = iface->get_manager(instance);
-
- g_share_manager_put(manager, instance);
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : instance = objet partagé à consulter. *
-* *
-* Description : Fournit la valeur du compteur de partage. *
-* *
-* Retour : Nombre de partages courant. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-unsigned int g_shared_instance_get_references(const GSharedInstance *instance)
-{
- GSharedInstanceIface *iface; /* Interface utilisée */
-
- iface = G_SHARED_INSTANCE_GET_IFACE(instance);
-
- return iface->get_ref(instance);
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : instance = objet partagé à modifier. *
-* *
-* Description : Incrémente le compteur de partage. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-void g_shared_instance_inc_references(GSharedInstance *instance)
-{
- GSharedInstanceIface *iface; /* Interface utilisée */
-
- iface = G_SHARED_INSTANCE_GET_IFACE(instance);
-
- iface->inc_ref(instance);
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : instance = objet partagé à modifier. *
-* *
-* Description : Décrémente le compteur de partage. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-void g_shared_instance_dec_references(GSharedInstance *instance)
-{
- GSharedInstanceIface *iface; /* Interface utilisée */
-
- iface = G_SHARED_INSTANCE_GET_IFACE(instance);
-
- iface->dec_ref(instance);
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : a = premier objet partagé à consulter. *
-* b = second objet partagé à consulter. *
-* *
-* Description : Compare de façon accélérée un object partagé avec un autre. *
-* *
-* Retour : Bilan de la comparaison. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-int g_shared_instance_compare(const GSharedInstance * const *a, const GSharedInstance * const *b)
-{
- int result; /* Bilan à faire remonter */
- GSharedInstanceIface *iface; /* Interface utilisée */
-
- /**
- * Comme les insertions dans les tableaux triés à l'aide de qinsert()
- * font passer la clef en premier argument et que celle ci n'est pas un
- * objet valide, on inverse les arguments, puis on inverse le résultat obtenu.
- */
-
- iface = G_SHARED_INSTANCE_GET_IFACE(*b);
-
- result = iface->compare(b, a) * -1;
-
- return result;
-
-}
diff --git a/src/arch/sharing/instance.h b/src/arch/sharing/instance.h
deleted file mode 100644
index d9653ff..0000000
--- a/src/arch/sharing/instance.h
+++ /dev/null
@@ -1,77 +0,0 @@
-
-/* Chrysalide - Outil d'analyse de fichiers binaires
- * instance.h - prototypes pour le partage de données d'architecture quelconques
- *
- * Copyright (C) 2016-2017 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
- */
-
-
-#ifndef _ARCH_SHARING_INSTANCE_H
-#define _ARCH_SHARING_INSTANCE_H
-
-
-#include <stdbool.h>
-#include <glib-object.h>
-
-
-
-#define G_TYPE_SHARED_INSTANCE (g_shared_instance_get_type())
-#define G_SHARED_INSTANCE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), G_TYPE_SHARED_INSTANCE, GSharedInstance))
-#define G_SHARED_INSTANCE_CLASS(vtable) (G_TYPE_CHECK_CLASS_CAST((vtable), G_TYPE_SHARED_INSTANCE, GSharedInstanceIface))
-#define GTK_IS_SHARED_INSTANCE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), G_TYPE_SHARED_INSTANCE))
-#define GTK_IS_SHARED_INSTANCE_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE((vtable), G_TYPE_SHARED_INSTANCE))
-#define G_SHARED_INSTANCE_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE((inst), G_TYPE_SHARED_INSTANCE, GSharedInstanceIface))
-
-
-/* Règles de partage d'une instance GObject (coquille vide) */
-typedef struct _GSharedInstance GSharedInstance;
-
-/* Règles de partage d'une instance GObject (interface) */
-typedef struct _GSharedInstanceIface GSharedInstanceIface;
-
-
-/* Détermine le type d'une interface pour le partage d'instance. */
-GType g_shared_instance_get_type(void) G_GNUC_CONST;
-
-/* Initialise un nouvel objet partagé avec des informations. */
-bool g_shared_instance_apply_template(GSharedInstance *, const GSharedInstance *);
-
-/* Réalise une copie minimale d'un contenu partagé. */
-void g_shared_instance_define_template(const GSharedInstance *, GSharedInstance *);
-
-/* Incrémente le compteur de références d'un élément partagé. */
-void g_shared_instance_ref(GSharedInstance *);
-
-/* Décrémente le compteur de références d'un élément partagé. */
-void g_shared_instance_unref(GSharedInstance *);
-
-/* Fournit la valeur du compteur de partage. */
-unsigned int g_shared_instance_get_references(const GSharedInstance *);
-
-/* Incrémente le compteur de partage. */
-void g_shared_instance_inc_references(GSharedInstance *);
-
-/* Décrémente le compteur de partage. */
-void g_shared_instance_dec_references(GSharedInstance *);
-
-/* Compare de façon accélérée un object partagé avec un autre. */
-int g_shared_instance_compare(const GSharedInstance * const *, const GSharedInstance * const *);
-
-
-
-#endif /* _ARCH_SHARING_INSTANCE_H */
diff --git a/src/arch/sharing/manager.c b/src/arch/sharing/manager.c
deleted file mode 100644
index 379c342..0000000
--- a/src/arch/sharing/manager.c
+++ /dev/null
@@ -1,431 +0,0 @@
-
-/* Chrysalide - Outil d'analyse de fichiers binaires
- * manager.c - collecte et gestion des instances partagées
- *
- * Copyright (C) 2016-2017 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
- */
-
-
-#include "manager.h"
-
-
-#include <assert.h>
-#include <malloc.h>
-#ifdef DEBUG_DUMP_STATS
-# include <stdio.h>
-#endif
-#include <string.h>
-
-
-#include "../../common/sort.h"
-
-
-
-/* Gestionnaire d'instances de type identique partagées (instance) */
-struct _GShareManager
-{
- GObject parent; /* A laisser en premier */
-
- GSharedInstance **instances; /* Instances partagées */
- size_t count; /* Quantité de ces instances */
- GMutex access; /* Accès à la table */
-
- GType managed; /* Type d'instances gérées */
-
-};
-
-/* Gestionnaire d'instances de type identique partagées (classe) */
-struct _GShareManagerClass
-{
- GObjectClass parent; /* A laisser en premier */
-
-};
-
-
-/* Procède à l'initialisation d'une classe de suivi de largeurs. */
-static void g_share_manager_class_init(GShareManagerClass *);
-
-/* Procède à l'initialisation d'un suivi de largeurs de lignes. */
-static void g_share_manager_init(GShareManager *);
-
-/* Supprime toutes les références externes. */
-static void g_share_manager_dispose(GShareManager *);
-
-/* Procède à la libération totale de la mémoire. */
-static void g_share_manager_finalize(GShareManager *);
-
-/* Note une augmentation des utilisations d'un élément partagé. */
-static void _g_share_manager_get(GShareManager *, GSharedInstance *);
-
-
-
-/* Détermine le type du gestionnaire d'instances partagées. */
-G_DEFINE_TYPE(GShareManager, g_share_manager, G_TYPE_OBJECT);
-
-
-/******************************************************************************
-* *
-* Paramètres : class = classe de composant GTK à initialiser. *
-* *
-* Description : Procède à l'initialisation d'une classe de suivi de largeurs.*
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static void g_share_manager_class_init(GShareManagerClass *class)
-{
- GObjectClass *object; /* Autre version de la classe */
-
- object = G_OBJECT_CLASS(class);
-
- object->dispose = (GObjectFinalizeFunc/* ! */)g_share_manager_dispose;
- object->finalize = (GObjectFinalizeFunc)g_share_manager_finalize;
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : manager = composant GLib à initialiser. *
-* *
-* Description : Procède à l'initialisation d'un suivi de largeurs de lignes. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static void g_share_manager_init(GShareManager *manager)
-{
- manager->instances = NULL;
- manager->count = 0;
-
- g_mutex_init(&manager->access);
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : manager = instance d'objet GLib à traiter. *
-* *
-* Description : Supprime toutes les références externes. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static void g_share_manager_dispose(GShareManager *manager)
-{
- size_t i; /* Boucle de parcours */
-
- for (i = 0; i < manager->count; i++)
- g_object_unref(G_OBJECT(manager->instances[i]));
-
- g_mutex_clear(&manager->access);
-
- G_OBJECT_CLASS(g_share_manager_parent_class)->dispose(G_OBJECT(manager));
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : manager = instance d'objet GLib à traiter. *
-* *
-* Description : Procède à la libération totale de la mémoire. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static void g_share_manager_finalize(GShareManager *manager)
-{
- if (manager->instances != NULL)
- free(manager->instances);
-
- G_OBJECT_CLASS(g_share_manager_parent_class)->finalize(G_OBJECT(manager));
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : type = type d'instances encadrées ici. *
-* *
-* Description : Crée un nouveau gestionnaire d'instances partagées. *
-* *
-* Retour : Composant GLib créé. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-GShareManager *g_share_manager_new(GType type)
-{
- GShareManager *result; /* Gestionnaire à renvoyer */
-
- result = g_object_new(G_TYPE_SHARE_MANAGER, NULL);
-
- result->managed = type;
-
- return result;
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : manager = gestionnaire d'instance à consulter. *
-* template = informations à retrouver intégralement. *
-* *
-* Description : Retrouve ou crée une instance partagée. *
-* *
-* Retour : Instance existante déjà partagée ou nouvellement créée. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-GSharedInstance *g_share_manager_build(GShareManager *manager, GSharedInstance *template)
-{
- GSharedInstance *result; /* Trouvaille à retourner */
- size_t index; /* Indice d'une instance idéale*/
- bool found; /* Existence de cette instance */
- bool status; /* Conclusion d'initialisation */
-
- g_mutex_lock(&manager->access);
-
- found = bsearch_index(&template, manager->instances, manager->count, sizeof(GSharedInstance *),
- (__compar_fn_t)g_shared_instance_compare, &index);
-
- if (!found)
- {
- result = g_object_new(manager->managed, NULL);
-
- status = g_shared_instance_apply_template(result, template);
-
- if (!status)
- {
- g_object_unref(result);
- result = NULL;
- }
-
- else
- {
- g_shared_instance_inc_references(result);
-
- manager->instances = _qinsert(manager->instances, &manager->count,
- sizeof(GSharedInstance *), &result, index);
-
- }
-
- }
-
- else
- result = manager->instances[index];
-
- _g_share_manager_get(manager, result);
-
- g_mutex_unlock(&manager->access);
-
- return result;
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : manager = gestionnaire d'instance à consulter. *
-* old = ancienne instance partagée à faire évoluer. *
-* template = informations à retrouver intégralement. *
-* container = propriétaire de l'ancienne version à contacter. *
-* *
-* Description : Met à jour une instance partagée. *
-* *
-* Retour : Instance existante déjà partagée ou nouvellement créée. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-GSharedInstance *g_share_manager_update(GShareManager *manager, GSharedInstance *old, GSharedInstance *template, GShareContainer *container)
-{
- GSharedInstance *result; /* Nouvelle instance à renvoyer*/
- bool replaced; /* Remplacement effectué ? */
-
- result = g_share_manager_build(manager, template);
-
- if (container != NULL)
- replaced = g_share_container_replace(container, old, result);
- else
- replaced = true;
-
- if (replaced)
- g_share_manager_put(manager, old);
-
- else
- {
- g_share_manager_put(manager, result);
- result = old;
- }
-
- return result;
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : manager = gestionnaire d'instance à consulter. *
-* instance = élément partagé à manipuler. *
-* *
-* Description : Note une augmentation des utilisations d'un élément partagé. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static void _g_share_manager_get(GShareManager *manager, GSharedInstance *instance)
-{
-#ifndef NDEBUG
- bool found; /* Existence de cette instance */
-#endif
-
-#ifndef NDEBUG
-
- found = bsearch_index(&instance, manager->instances, manager->count, sizeof(GSharedInstance *),
- (__compar_fn_t)g_shared_instance_compare, (size_t []) { 0 });
-
- assert(found);
-
-#endif
-
- g_object_ref(G_OBJECT(instance));
- g_shared_instance_inc_references(instance);
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : manager = gestionnaire d'instance à consulter. *
-* instance = élément partagé à manipuler. *
-* *
-* Description : Note une augmentation des utilisations d'un élément partagé. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-void g_share_manager_get(GShareManager *manager, GSharedInstance *instance)
-{
- g_mutex_lock(&manager->access);
-
- _g_share_manager_get(manager, instance);
-
- g_mutex_unlock(&manager->access);
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : manager = gestionnaire d'instance à consulter. *
-* shared = instance partagée à libérer. *
-* *
-* Description : Abandonne un usage d'une instance partagée. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-void g_share_manager_put(GShareManager *manager, GSharedInstance *shared)
-{
- g_mutex_lock(&manager->access);
-
- g_shared_instance_dec_references(shared);
-
- if (g_shared_instance_get_references(shared) == 1)
- {
- manager->instances = qdelete(manager->instances, &manager->count,
- sizeof(GSharedInstance *),
- (__compar_fn_t)g_shared_instance_compare,
- &shared);
-
- g_object_unref(G_OBJECT(shared));
-
- }
-
- g_mutex_unlock(&manager->access);
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : manager = gestionnaire d'instance à consulter. *
-* *
-* Description : Imprime des statistiques d'utilisation du gestionnaire. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-#ifdef DEBUG_DUMP_STATS
-void g_share_manager_dump_stats(GShareManager *manager)
-{
- unsigned int counter; /* Quantité nécessaire */
- size_t i; /* Boucle de parcours */
- GTypeQuery query; /* Informations sur un type */
-
- counter = 0;
-
- g_mutex_lock(&manager->access);
-
- for (i = 0; i < manager->count; i++)
- counter += g_shared_instance_get_references(manager->instances[i]);
-
- g_mutex_unlock(&manager->access);
-
- g_type_query(manager->managed, &query);
-
- printf("%s: current = %zu / %zu - needed = %u / %u (size=%u, saved=%zu)\n",
- query.type_name,
- manager->count, manager->count * query.instance_size,
- counter, counter * query.instance_size,
- query.instance_size,
- (counter - manager->count) * query.instance_size);
-
-}
-#endif
diff --git a/src/arch/sharing/manager.h b/src/arch/sharing/manager.h
deleted file mode 100644
index c24fcc6..0000000
--- a/src/arch/sharing/manager.h
+++ /dev/null
@@ -1,81 +0,0 @@
-
-/* Chrysalide - Outil d'analyse de fichiers binaires
- * manager.h - prototypes pour la collecte et la gestion des instances partagées
- *
- * Copyright (C) 2016-2017 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
- */
-
-
-#ifndef _ARCH_SHARING_MANAGER_H
-#define _ARCH_SHARING_MANAGER_H
-
-
-#include <glib-object.h>
-#include <stdbool.h>
-
-
-#include "container.h"
-#include "instance.h"
-
-
-
-/* Compare une instance avec des informations similaires. */
-typedef gboolean (* compare_with_info_fc) (const GSharedInstance *, const void *);
-
-
-#define G_TYPE_SHARE_MANAGER (g_share_manager_get_type())
-#define G_SHARE_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), G_TYPE_SHARE_MANAGER, GShareManager))
-#define G_SHARE_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_SHARE_MANAGER, GShareManagerClass))
-#define G_IS_SHARE_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), G_TYPE_SHARE_MANAGER))
-#define G_IS_SHARE_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_SHARE_MANAGER))
-#define G_SHARE_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_SHARE_MANAGER, GShareManagerClass))
-
-
-/* Gestionnaire d'instances de type identique partagées (instance) */
-typedef struct _GShareManager GShareManager;
-
-/* Gestionnaire d'instances de type identique partagées (classe) */
-typedef struct _GShareManagerClass GShareManagerClass;
-
-
-/* Détermine le type du gestionnaire d'instances partagées. */
-GType g_share_manager_get_type(void);
-
-/* Crée un nouveau gestionnaire d'instances partagées. */
-GShareManager *g_share_manager_new(GType);
-
-/* Retrouve ou crée une instance partagée. */
-GSharedInstance *g_share_manager_build(GShareManager *, GSharedInstance *);
-
-/* Met à jour une instance partagée. */
-GSharedInstance *g_share_manager_update(GShareManager *, GSharedInstance *, GSharedInstance *, GShareContainer *);
-
-/* Note une augmentation des utilisations d'un élément partagé. */
-void g_share_manager_get(GShareManager *, GSharedInstance *);
-
-/* Abandonne un usage d'une instance partagée. */
-void g_share_manager_put(GShareManager *, GSharedInstance *);
-
-/* Imprime des statistiques d'utilisation du gestionnaire. */
-#ifdef DEBUG_DUMP_STATS
-void g_share_manager_dump_stats(GShareManager *);
-#endif
-
-
-
-#endif /* _ARCH_SHARING_MANAGER_H */