diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/analysis/binary.c | 67 | ||||
-rw-r--r-- | src/analysis/loaded-int.h | 17 | ||||
-rw-r--r-- | src/analysis/loaded.c | 173 | ||||
-rw-r--r-- | src/analysis/loaded.h | 22 |
4 files changed, 165 insertions, 114 deletions
diff --git a/src/analysis/binary.c b/src/analysis/binary.c index 2b23eff..ddd2e30 100644 --- a/src/analysis/binary.c +++ b/src/analysis/binary.c @@ -63,7 +63,7 @@ /* Description de fichier binaire (instance) */ struct _GLoadedBinary { - GObject parent; /* A laisser en premier */ + GLoadedContent parent; /* A laisser en premier */ bool use_remote; /* Enregistrements distants ? */ char *remote_host; /* Nom du serveur distant */ @@ -91,7 +91,7 @@ struct _GLoadedBinary /* Description de fichier binaire (classe) */ struct _GLoadedBinaryClass { - GObjectClass parent; /* A laisser en premier */ + GLoadedContentClass parent; /* A laisser en premier */ }; @@ -102,9 +102,6 @@ static void g_loaded_binary_class_init(GLoadedBinaryClass *); /* Initialise une description de fichier binaire. */ static void g_loaded_binary_init(GLoadedBinary *); -/* Procède à l'initialisation de l'interface de contenu chargé. */ -static void g_loaded_binary_interface_init(GLoadedContentInterface *); - /* Supprime toutes les références externes. */ static void g_loaded_binary_dispose(GLoadedBinary *); @@ -197,9 +194,7 @@ static GDisplayOptions *g_loaded_binary_get_display_options(const GLoadedBinary /* Indique le type défini pour une description de fichier binaire. */ -G_DEFINE_TYPE_WITH_CODE(GLoadedBinary, g_loaded_binary, G_TYPE_OBJECT, - G_IMPLEMENT_INTERFACE(G_TYPE_LOADED_CONTENT, g_loaded_binary_interface_init) - G_IMPLEMENT_INTERFACE(G_TYPE_NAMED_WIDGET, g_loaded_content_named_interface_init)); +G_DEFINE_TYPE(GLoadedBinary, g_loaded_binary, G_TYPE_LOADED_CONTENT); /****************************************************************************** @@ -217,12 +212,33 @@ G_DEFINE_TYPE_WITH_CODE(GLoadedBinary, g_loaded_binary, G_TYPE_OBJECT, static void g_loaded_binary_class_init(GLoadedBinaryClass *klass) { GObjectClass *object; /* Autre version de la classe */ + GLoadedContentClass *loaded; /* Forme parente de la classe */ object = G_OBJECT_CLASS(klass); object->dispose = (GObjectFinalizeFunc/* ! */)g_loaded_binary_dispose; object->finalize = (GObjectFinalizeFunc)g_loaded_binary_finalize; + loaded = G_LOADED_CONTENT_CLASS(klass); + + loaded->restore = (restore_content_fc)g_loaded_binary_restore; + loaded->save = (save_content_fc)g_loaded_binary_save; + + loaded->get_content = (get_content_fc)g_loaded_binary_get_content; + loaded->get_format_name = (get_format_name_fc)g_loaded_binary_get_format_name; + + loaded->analyze = (analyze_loaded_fc)g_loaded_binary_analyze; + + loaded->describe = (describe_loaded_fc)g_loaded_binary_describe; + + loaded->count_views = (count_loaded_views_fc)g_loaded_binary_count_views; + loaded->get_view_name = (get_loaded_view_name_fc)g_loaded_binary_get_view_name; + loaded->build_def_view = (build_loaded_def_view_fc)g_loaded_binary_build_default_view; + loaded->build_view = (build_loaded_view_fc)g_loaded_binary_build_view; + loaded->get_view_index = (get_loaded_view_index_fc)g_loaded_binary_get_view_index; + + loaded->get_options = (get_loaded_options_fc)g_loaded_binary_get_display_options; + } @@ -270,41 +286,6 @@ static void g_loaded_binary_init(GLoadedBinary *binary) /****************************************************************************** * * -* Paramètres : iface = interface GLib à initialiser. * -* * -* Description : Procède à l'initialisation de l'interface de contenu chargé. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_loaded_binary_interface_init(GLoadedContentInterface *iface) -{ - iface->restore = (restore_content_fc)g_loaded_binary_restore; - iface->save = (save_content_fc)g_loaded_binary_save; - - iface->get_content = (get_content_fc)g_loaded_binary_get_content; - iface->get_format_name = (get_format_name_fc)g_loaded_binary_get_format_name; - - iface->analyze = (analyze_loaded_fc)g_loaded_binary_analyze; - - iface->describe = (describe_loaded_fc)g_loaded_binary_describe; - - iface->count_views = (count_loaded_views_fc)g_loaded_binary_count_views; - iface->get_view_name = (get_loaded_view_name_fc)g_loaded_binary_get_view_name; - iface->build_def_view = (build_loaded_def_view_fc)g_loaded_binary_build_default_view; - iface->build_view = (build_loaded_view_fc)g_loaded_binary_build_view; - iface->get_view_index = (get_loaded_view_index_fc)g_loaded_binary_get_view_index; - - iface->get_options = (get_loaded_options_fc)g_loaded_binary_get_display_options; - -} - - -/****************************************************************************** -* * * Paramètres : binary = instance d'objet GLib à traiter. * * * * Description : Supprime toutes les références externes. * diff --git a/src/analysis/loaded-int.h b/src/analysis/loaded-int.h index 0476af5..cd47a6a 100644 --- a/src/analysis/loaded-int.h +++ b/src/analysis/loaded-int.h @@ -67,10 +67,17 @@ typedef unsigned int (* get_loaded_view_index_fc) (GLoadedContent *, GtkWidget * typedef GDisplayOptions * (* get_loaded_options_fc) (const GLoadedContent *, unsigned int); -/* Accès à un contenu binaire quelconque (interface) */ -struct _GLoadedContentIface +/* Accès à un contenu binaire quelconque (instance) */ +struct _GLoadedContent { - GTypeInterface base_iface; /* A laisser en premier */ + GObject parent; /* A laisser en premier */ + +}; + +/* Accès à un contenu binaire quelconque (classe) */ +struct _GLoadedContentClass +{ + GObjectClass parent; /* A laisser en premier */ /* Méthodes virtuelles */ @@ -99,9 +106,5 @@ struct _GLoadedContentIface }; -/* Redéfinition */ -typedef GLoadedContentIface GLoadedContentInterface; - - #endif /* _ANALYSIS_LOADED_INT_H */ diff --git a/src/analysis/loaded.c b/src/analysis/loaded.c index 10ab05e..3a497f9 100644 --- a/src/analysis/loaded.c +++ b/src/analysis/loaded.c @@ -39,11 +39,6 @@ -/* Analyse de contenu chargé (instance) */ -typedef struct _GLoadedAnalysis GLoadedAnalysis; - - - /* ---------------------- GESTION SOUS FORME DE CONTENU CHARGE ---------------------- */ @@ -59,8 +54,20 @@ typedef struct _analysis_data_t } analysis_data_t; -/* Procède à l'initialisation de l'interface de contenu chargé. */ -static void g_loaded_content_default_init(GLoadedContentInterface *); +/* Initialise la classe des contenus chargés. */ +static void g_loaded_content_class_init(GLoadedContentClass *); + +/* Initialise un contenu chargé. */ +static void g_loaded_content_init(GLoadedContent *); + +/* Procède à l'initialisation de l'interface de composant nommé. */ +static void g_loaded_content_named_init(GNamedWidgetIface *); + +/* Supprime toutes les références externes. */ +static void g_loaded_content_dispose(GLoadedContent *); + +/* Procède à la libération totale de la mémoire. */ +static void g_loaded_content_finalize(GLoadedContent *); /* Crée une structure pour accompagner une tâche d'analyse. */ static analysis_data_t *create_analysis_data(GLoadedContent *, bool, bool); @@ -82,14 +89,15 @@ static void on_loaded_content_analysis_completed(GSeqWork *, analysis_data_t *); /* Détermine le type d'une interface pour l'intégration de contenu chargé. */ -G_DEFINE_INTERFACE(GLoadedContent, g_loaded_content, G_TYPE_OBJECT); +G_DEFINE_TYPE_WITH_CODE(GLoadedContent, g_loaded_content, G_TYPE_OBJECT, + G_IMPLEMENT_INTERFACE(G_TYPE_NAMED_WIDGET, g_loaded_content_named_init)); /****************************************************************************** * * -* Paramètres : iface = interface GLib à initialiser. * +* Paramètres : klass = classe à initialiser. * * * -* Description : Procède à l'initialisation de l'interface de contenu chargé. * +* Description : Initialise la classe des contenus chargés. * * * * Retour : - * * * @@ -97,12 +105,19 @@ G_DEFINE_INTERFACE(GLoadedContent, g_loaded_content, G_TYPE_OBJECT); * * ******************************************************************************/ -static void g_loaded_content_default_init(GLoadedContentInterface *iface) +static void g_loaded_content_class_init(GLoadedContentClass *klass) { + GObjectClass *object; /* Autre version de la classe */ + + object = G_OBJECT_CLASS(klass); + + object->dispose = (GObjectFinalizeFunc/* ! */)g_loaded_content_dispose; + object->finalize = (GObjectFinalizeFunc)g_loaded_content_finalize; + g_signal_new("analyzed", G_TYPE_LOADED_CONTENT, G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET(GLoadedContentIface, analyzed), + G_STRUCT_OFFSET(GLoadedContentClass, analyzed), NULL, NULL, g_cclosure_marshal_VOID__BOOLEAN, G_TYPE_NONE, 1, G_TYPE_BOOLEAN); @@ -112,6 +127,24 @@ static void g_loaded_content_default_init(GLoadedContentInterface *iface) /****************************************************************************** * * +* Paramètres : content = instance à initialiser. * +* * +* Description : Initialise un contenu chargé. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_loaded_content_init(GLoadedContent *content) +{ + +} + + +/****************************************************************************** +* * * Paramètres : iface = interface GLib à initialiser. * * * * Description : Procède à l'initialisation de l'interface de composant nommé.* @@ -122,7 +155,7 @@ static void g_loaded_content_default_init(GLoadedContentInterface *iface) * * ******************************************************************************/ -void g_loaded_content_named_interface_init(GNamedWidgetIface *iface) +static void g_loaded_content_named_init(GNamedWidgetIface *iface) { iface->get_name = (get_named_widget_name_fc)g_loaded_content_describe; iface->get_widget = (get_named_widget_widget_fc)g_loaded_content_build_default_view; @@ -132,6 +165,44 @@ void g_loaded_content_named_interface_init(GNamedWidgetIface *iface) /****************************************************************************** * * +* Paramètres : content = instance d'objet GLib à traiter. * +* * +* Description : Supprime toutes les références externes. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_loaded_content_dispose(GLoadedContent *content) +{ + G_OBJECT_CLASS(g_loaded_content_parent_class)->dispose(G_OBJECT(content)); + +} + + +/****************************************************************************** +* * +* Paramètres : content = instance d'objet GLib à traiter. * +* * +* Description : Procède à la libération totale de la mémoire. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_loaded_content_finalize(GLoadedContent *content) +{ + G_OBJECT_CLASS(g_loaded_content_parent_class)->finalize(G_OBJECT(content)); + +} + + +/****************************************************************************** +* * * Paramètres : content = élément chargé à traiter. * * xdoc = structure XML en cours d'édition. * * context = contexte à utiliser pour les recherches. * @@ -148,12 +219,12 @@ void g_loaded_content_named_interface_init(GNamedWidgetIface *iface) bool g_loaded_content_restore(GLoadedContent *content, xmlDocPtr xdoc, xmlXPathContextPtr context, const char *path) { bool result; /* Bilan à faire remonter */ - GLoadedContentIface *iface; /* Interface utilisée */ + GLoadedContentClass *class; /* Classe de l'instance */ - iface = G_LOADED_CONTENT_GET_IFACE(content); + class = G_LOADED_CONTENT_GET_CLASS(content); - if (iface->restore != NULL) - result = iface->restore(content, xdoc, context, path); + if (class->restore != NULL) + result = class->restore(content, xdoc, context, path); else result = true; @@ -181,12 +252,12 @@ bool g_loaded_content_restore(GLoadedContent *content, xmlDocPtr xdoc, xmlXPathC bool g_loaded_content_save(GLoadedContent *content, xmlDocPtr xdoc, xmlXPathContextPtr context, const char *path) { bool result; /* Bilan à faire remonter */ - GLoadedContentIface *iface; /* Interface utilisée */ + GLoadedContentClass *class; /* Classe de l'instance */ - iface = G_LOADED_CONTENT_GET_IFACE(content); + class = G_LOADED_CONTENT_GET_CLASS(content); - if (iface->save != NULL) - result = iface->save(content, xdoc, context, path); + if (class->save != NULL) + result = class->save(content, xdoc, context, path); else result = true; @@ -211,11 +282,11 @@ bool g_loaded_content_save(GLoadedContent *content, xmlDocPtr xdoc, xmlXPathCont GBinContent *g_loaded_content_get_content(const GLoadedContent *content) { GBinContent *result; /* Contenu interne à renvoyer */ - GLoadedContentIface *iface; /* Interface utilisée */ + GLoadedContentClass *class; /* Classe de l'instance */ - iface = G_LOADED_CONTENT_GET_IFACE(content); + class = G_LOADED_CONTENT_GET_CLASS(content); - result = iface->get_content(content); + result = class->get_content(content); return result; @@ -237,11 +308,11 @@ GBinContent *g_loaded_content_get_content(const GLoadedContent *content) char *g_loaded_content_get_format_name(const GLoadedContent *content) { char *result; /* Contenu interne à renvoyer */ - GLoadedContentIface *iface; /* Interface utilisée */ + GLoadedContentClass *class; /* Classe de l'instance */ - iface = G_LOADED_CONTENT_GET_IFACE(content); + class = G_LOADED_CONTENT_GET_CLASS(content); - result = iface->get_format_name(content); + result = class->get_format_name(content); return result; @@ -298,17 +369,17 @@ static analysis_data_t *create_analysis_data(GLoadedContent *content, bool conne static bool process_analysis_with_data(analysis_data_t *data, size_t i, GtkStatusStack *status, activity_id_t id) { - GLoadedContentIface *iface; /* Interface utilisée */ + GLoadedContentClass *class; /* Classe de l'instance */ GWorkQueue *queue; /* Gestionnaire de différés */ wgroup_id_t gid; /* Identifiant pour les tâches */ - iface = G_LOADED_CONTENT_GET_IFACE(data->content); + class = G_LOADED_CONTENT_GET_CLASS(data->content); queue = get_work_queue(); gid = g_work_queue_define_work_group(queue); - data->success = iface->analyze(data->content, data->connect, data->cache, gid, status); + data->success = class->analyze(data->content, data->connect, data->cache, gid, status); if (data->success) handle_loaded_content(PGA_CONTENT_ANALYZED, data->content, gid, status); @@ -460,11 +531,11 @@ bool g_loaded_content_analyze_and_wait(GLoadedContent *content, bool connect, bo char *g_loaded_content_describe(const GLoadedContent *content, bool full) { char *result; /* Description à retourner */ - GLoadedContentIface *iface; /* Interface utilisée */ + GLoadedContentClass *class; /* Classe de l'instance */ - iface = G_LOADED_CONTENT_GET_IFACE(content); + class = G_LOADED_CONTENT_GET_CLASS(content); - result = iface->describe(content, full); + result = class->describe(content, full); return result; @@ -520,11 +591,11 @@ char **g_loaded_content_detect_obfuscators(const GLoadedContent *content, bool v unsigned int g_loaded_content_count_views(const GLoadedContent *content) { unsigned int result; /* Quantité de vues à renvoyer */ - GLoadedContentIface *iface; /* Interface utilisée */ + GLoadedContentClass *class; /* Classe de l'instance */ - iface = G_LOADED_CONTENT_GET_IFACE(content); + class = G_LOADED_CONTENT_GET_CLASS(content); - result = iface->count_views(content); + result = class->count_views(content); return result; @@ -547,13 +618,13 @@ unsigned int g_loaded_content_count_views(const GLoadedContent *content) char *g_loaded_content_get_view_name(const GLoadedContent *content, unsigned int index) { char *result; /* Désignation à retourner */ - GLoadedContentIface *iface; /* Interface utilisée */ + GLoadedContentClass *class; /* Classe de l'instance */ - iface = G_LOADED_CONTENT_GET_IFACE(content); + class = G_LOADED_CONTENT_GET_CLASS(content); assert(index <= g_loaded_content_count_views(content)); - result = iface->get_view_name(content, index); + result = class->get_view_name(content, index); return result; @@ -575,11 +646,11 @@ char *g_loaded_content_get_view_name(const GLoadedContent *content, unsigned int GtkWidget *g_loaded_content_build_default_view(GLoadedContent *content) { GtkWidget *result; /* Support à retourner */ - GLoadedContentIface *iface; /* Interface utilisée */ + GLoadedContentClass *class; /* Classe de l'instance */ - iface = G_LOADED_CONTENT_GET_IFACE(content); + class = G_LOADED_CONTENT_GET_CLASS(content); - result = iface->build_def_view(content); + result = class->build_def_view(content); return result; @@ -602,13 +673,13 @@ GtkWidget *g_loaded_content_build_default_view(GLoadedContent *content) GtkWidget *g_loaded_content_build_view(GLoadedContent *content, unsigned int index) { GtkWidget *result; /* Support à retourner */ - GLoadedContentIface *iface; /* Interface utilisée */ + GLoadedContentClass *class; /* Classe de l'instance */ - iface = G_LOADED_CONTENT_GET_IFACE(content); + class = G_LOADED_CONTENT_GET_CLASS(content); assert(index <= g_loaded_content_count_views(content)); - result = iface->build_view(content, index); + result = class->build_view(content, index); return result; @@ -631,11 +702,11 @@ GtkWidget *g_loaded_content_build_view(GLoadedContent *content, unsigned int ind unsigned int g_loaded_content_get_view_index(GLoadedContent *content, GtkWidget *view) { unsigned int result; /* Indice à retourner */ - GLoadedContentIface *iface; /* Interface utilisée */ + GLoadedContentClass *class; /* Classe de l'instance */ - iface = G_LOADED_CONTENT_GET_IFACE(content); + class = G_LOADED_CONTENT_GET_CLASS(content); - result = iface->get_view_index(content, view); + result = class->get_view_index(content, view); assert(result == -1 || result <= g_loaded_content_count_views(content)); @@ -660,13 +731,13 @@ unsigned int g_loaded_content_get_view_index(GLoadedContent *content, GtkWidget GDisplayOptions *g_loaded_content_get_display_options(const GLoadedContent *content, unsigned int index) { GDisplayOptions *result; /* Accès aux options à renvoyer*/ - GLoadedContentIface *iface; /* Interface utilisée */ + GLoadedContentClass *class; /* Classe de l'instance */ assert(index <= g_loaded_content_count_views(content)); - iface = G_LOADED_CONTENT_GET_IFACE(content); + class = G_LOADED_CONTENT_GET_CLASS(content); - result = iface->get_options(content, index); + result = class->get_options(content, index); return result; diff --git a/src/analysis/loaded.h b/src/analysis/loaded.h index 46404e1..9a88f8c 100644 --- a/src/analysis/loaded.h +++ b/src/analysis/loaded.h @@ -33,7 +33,6 @@ #include "content.h" #include "../common/xml.h" #include "../glibext/gdisplayoptions.h" -#include "../glibext/named.h" #include "../gtkext/gtkdockstation.h" @@ -41,27 +40,24 @@ /* ---------------------- GESTION SOUS FORME DE CONTENU CHARGE ---------------------- */ -#define G_TYPE_LOADED_CONTENT (g_loaded_content_get_type()) -#define G_LOADED_CONTENT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), G_TYPE_LOADED_CONTENT, GLoadedContent)) -#define G_LOADED_CONTENT_CLASS(vtable) (G_TYPE_CHECK_CLASS_CAST((vtable), G_TYPE_LOADED_CONTENT, GLoadedContentIface)) -#define G_IS_LOADED_CONTENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), G_TYPE_LOADED_CONTENT)) -#define G_IS_LOADED_CONTENT_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE((vtable), G_TYPE_LOADED_CONTENT)) -#define G_LOADED_CONTENT_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE((inst), G_TYPE_LOADED_CONTENT, GLoadedContentIface)) +#define G_TYPE_LOADED_CONTENT g_loaded_content_get_type() +#define G_LOADED_CONTENT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), G_TYPE_LOADED_CONTENT, GLoadedContent)) +#define G_IS_LOADED_CONTENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), G_TYPE_LOADED_CONTENT)) +#define G_LOADED_CONTENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_LOADED_CONTENT, GLoadedContentClass)) +#define G_IS_LOADED_CONTENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_LOADED_CONTENT)) +#define G_LOADED_CONTENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_LOADED_CONTENT, GLoadedContentClass)) -/* Accès à un contenu binaire quelconque (coquille vide) */ +/* Accès à un contenu binaire quelconque (instance) */ typedef struct _GLoadedContent GLoadedContent; -/* Accès à un contenu binaire quelconque (interface) */ -typedef struct _GLoadedContentIface GLoadedContentIface; +/* Accès à un contenu binaire quelconque (instance) */ +typedef struct _GLoadedContentClass GLoadedContentClass; /* Détermine le type d'une interface pour l'intégration de contenu chargé. */ GType g_loaded_content_get_type(void) G_GNUC_CONST; -/* Procède à l'initialisation de l'interface de composant nommé. */ -void g_loaded_content_named_interface_init(GNamedWidgetIface *); - /* Interprète un contenu chargé avec un appui XML. */ bool g_loaded_content_restore(GLoadedContent *, xmlDoc *, xmlXPathContext *, const char *); |