diff options
Diffstat (limited to 'src/plugins')
| -rw-r--r-- | src/plugins/Makefile.am | 4 | ||||
| -rw-r--r-- | src/plugins/manager-int.h | 10 | ||||
| -rw-r--r-- | src/plugins/pglist.c | 28 | ||||
| -rw-r--r-- | src/plugins/pglist.h | 69 | ||||
| -rw-r--r-- | src/plugins/plugin.c | 2 | ||||
| -rw-r--r-- | src/plugins/tweakable-int.h | 50 | ||||
| -rw-r--r-- | src/plugins/tweakable.c | 98 | ||||
| -rw-r--r-- | src/plugins/tweakable.h | 62 | 
8 files changed, 271 insertions, 52 deletions
| diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am index 7d375e3..fa65484 100644 --- a/src/plugins/Makefile.am +++ b/src/plugins/Makefile.am @@ -10,7 +10,9 @@ libplugins_la_SOURCES =						\  	plugin-def.h							\  	plugin-int.h							\  	plugin.h plugin.c						\ -	self.h +	self.h									\ +	tweakable-int.h							\ +	tweakable.h tweakable.c  libplugins_la_CFLAGS = $(TOOLKIT_CFLAGS) $(LIBXML_CFLAGS) diff --git a/src/plugins/manager-int.h b/src/plugins/manager-int.h index 5ccc8f8..dbd1d69 100644 --- a/src/plugins/manager-int.h +++ b/src/plugins/manager-int.h @@ -1,6 +1,6 @@  /* Chrysalide - Outil d'analyse de fichiers binaires - * singleton-int.h - définitions internes propres aux interventions dans la gestion des extensions + * manager-int.h - définitions internes propres aux interventions dans la gestion des extensions   *   * Copyright (C) 2025 Cyrille Bagard   * @@ -21,8 +21,8 @@   */ -#ifndef _PLUGINS_CONTAINER_INT_H -#define _PLUGINS_CONTAINER_INT_H +#ifndef _PLUGINS_MANAGER_INT_H +#define _PLUGINS_MANAGER_INT_H  #include "manager.h" @@ -39,7 +39,7 @@ typedef void (* handle_native_plugins_cb) (GPluginManager *);  typedef void (* handle_all_plugins_cb) (GPluginManager *); -/* Instance d'objet visant à être unique (interface) */ +/* Accompagnant dans la gestion des extensions (interface) */  struct _GPluginManagerInterface  {      GTypeInterface base_iface;              /* A laisser en premier        */ @@ -51,4 +51,4 @@ struct _GPluginManagerInterface -#endif  /* _PLUGINS_CONTAINER_INT_H */ +#endif  /* _PLUGINS_MANAGER_INT_H */ diff --git a/src/plugins/pglist.c b/src/plugins/pglist.c index 6dc2d9c..3e107b8 100644 --- a/src/plugins/pglist.c +++ b/src/plugins/pglist.c @@ -344,22 +344,10 @@ static void browse_directory_for_plugins(const char *dir)          else          { - -            printf("// Candidate // %s\n", filename); -              has_alt = check_for_plugin_versions(dir, namelist[k]->d_name, &is_nox, &is_ui); -            printf("  -> nox=%d  ui=%d  -> alt? %d\n", is_nox, is_ui, has_alt); - -              if ((nox_mode && is_nox) || (!nox_mode && ((is_nox && !has_alt) || is_ui)))              { - - -                printf(" ---> load!\n"); - - -                  module = g_module_open(filename, G_MODULE_BIND_LAZY);                  if (module == NULL)                  { @@ -369,32 +357,18 @@ static void browse_directory_for_plugins(const char *dir)                      goto next_file;                  } - -                printf(" (main) module=%p '%s'\n", module, g_module_name(module)); - +                get_instance = NULL;                  if (!g_module_symbol(module, "get_chrysalide_plugin_instance", (gpointer *)&get_instance)) -                {                      log_variadic_message(LMT_ERROR,                                           _("No '%s' entry in plugin candidate '%s'"),                                           "<sym>", filename); - - -                } - -                  if (get_instance == NULL)                      plugin = NULL;                  else                      plugin = get_instance(module); - - -                printf(" ===> plugin: %p\n", plugin); - - -                  if (plugin != NULL)                  {                      register_plugin(plugin); diff --git a/src/plugins/pglist.h b/src/plugins/pglist.h index 5541493..777b19c 100644 --- a/src/plugins/pglist.h +++ b/src/plugins/pglist.h @@ -69,25 +69,60 @@ GPluginModule **get_all_plugins(size_t *);   * Définitions des opérations appliquables à une catégories de greffons.   */ -#define process_all_plugins_for(tp, cst, fc)                    \ -    do                                                          \ -    {                                                           \ -        size_t __count;                                         \ -        GPluginModule **__list;                                 \ -        size_t __i;                                             \ -        __list = get_all_plugins(&__count);                     \ -        for (__i = 0; __i < __count; __i++)                     \ -        {                                                       \ -            if (G_TYPE_CHECK_INSTANCE_TYPE(__list[__i], tp))    \ -                fc(cst(__list[__i]));                           \ -            unref_object(__list[__i]);                          \ -        }                                                       \ -        if (__list != NULL)                                     \ -            free(__list);                                       \ -    }                                                           \ +#define process_all_plugins_for(tp, cst, fc)            \ +    do                                                  \ +    {                                                   \ +        size_t __count;                                 \ +        GPluginModule **__list;                         \ +        size_t __i;                                     \ +        GPluginModule *__pg;                            \ +        __list = get_all_plugins(&__count);             \ +        for (__i = 0; __i < __count; __i++)             \ +        {                                               \ +         __pg = __list[__i];                            \ +            if (G_TYPE_CHECK_INSTANCE_TYPE(__pg, tp))   \ +                fc(cst(__pg));                          \ +            unref_object(__pg);                         \ +        }                                               \ +        if (__list != NULL)                             \ +            free(__list);                               \ +    }                                                   \      while (0) - +#define accumulate_from_all_plugins(tp, cst, fc, atp, cnt)                      \ +    ({                                                                          \ +        atp *__acc_list;                                                        \ +        size_t __count;                                                         \ +        GPluginModule **__list;                                                 \ +        size_t __i;                                                             \ +        GPluginModule *__pg;                                                    \ +        size_t __tmp_count;                                                     \ +        atp *__tmp_list;                                                        \ +        *cnt = 0;                                                               \ +        __acc_list = NULL;                                                      \ +        __list = get_all_plugins(&__count);                                     \ +        for (__i = 0; __i < __count; __i++)                                     \ +        {                                                                       \ +            __pg = __list[__i];                                                 \ +            if (G_TYPE_CHECK_INSTANCE_TYPE(__pg, tp))                           \ +            {                                                                   \ +                __tmp_list = fc(cst(__pg), &__tmp_count);                       \ +                if (__tmp_list != NULL)                                         \ +                {                                                               \ +                    __acc_list = realloc(__acc_list,                            \ +                                         (*cnt + __tmp_count) * sizeof(atp));   \ +                    memcpy(&__acc_list[*cnt], __tmp_list,                       \ +                           __tmp_count * sizeof(atp));                          \ +                    *cnt += __tmp_count;                                        \ +                    free(__tmp_list);                                           \ +                }                                                               \ +            }                                                                   \ +            unref_object(__pg);                                                 \ +        }                                                                       \ +        if (__list != NULL)                                                     \ +            free(__list);                                                       \ +        __acc_list;                                                             \ +    }) diff --git a/src/plugins/plugin.c b/src/plugins/plugin.c index b7f85d5..dfdf3ed 100644 --- a/src/plugins/plugin.c +++ b/src/plugins/plugin.c @@ -196,8 +196,6 @@ static void g_plugin_module_finalize(GPluginModule *plugin)  {      size_t i;                               /* Boucle de parcours          */ -    printf("[!!!] Finalizing plugin %s\n", plugin->name); -      if (plugin->name != NULL)          free(plugin->name); diff --git a/src/plugins/tweakable-int.h b/src/plugins/tweakable-int.h new file mode 100644 index 0000000..776626f --- /dev/null +++ b/src/plugins/tweakable-int.h @@ -0,0 +1,50 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * tweakable-int.h - définitions internes propres aux participations aux mécanismes de configuration + * + * Copyright (C) 2025 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/>. + */ + + +#ifndef _PLUGINS_TWEAKABLE_INT_H +#define _PLUGINS_TWEAKABLE_INT_H + + +#include "tweakable.h" + + + +/* ------------------- INTEGRATION DANS L'EDITION DES PREFERENCES ------------------- */ + + +/* Fournit une liste de sections de configuration. */ +typedef tweak_info_t * (* get_tweakable_plugin_info) (const GTweakablePlugin *, size_t *); + + +/* Greffon avec des compléments pour l'interface de configuration (interface) */ +struct _GTweakablePluginInterface +{ +    GTypeInterface base_iface;              /* A laisser en premier        */ + +    get_tweakable_plugin_info get_info;     /* Récupération de section(s)  */ + +}; + + + +#endif  /* _PLUGINS_TWEAKABLE_INT_H */ diff --git a/src/plugins/tweakable.c b/src/plugins/tweakable.c new file mode 100644 index 0000000..517c4a3 --- /dev/null +++ b/src/plugins/tweakable.c @@ -0,0 +1,98 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * tweakable.c - participation aux mécanismes de configuration + * + * Copyright (C) 2025 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 "tweakable.h" + + +#include "tweakable-int.h" + + + +/* ------------------- INTEGRATION DANS L'EDITION DES PREFERENCES ------------------- */ + + +/* Procède à l'initialisation de l'interface d'intervention. */ +static void g_tweakable_plugin_default_init(GTweakablePluginInterface *); + + + +/* ---------------------------------------------------------------------------------- */ +/*                     INTEGRATION DANS L'EDITION DES PREFERENCES                     */ +/* ---------------------------------------------------------------------------------- */ + + +/* Détermine le type d'une interface pour l'intervention dans la gestion des greffons. */ +G_DEFINE_INTERFACE(GTweakablePlugin, g_tweakable_plugin, G_TYPE_OBJECT) + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : iface = interface GLib à initialiser.                        * +*                                                                             * +*  Description : Procède à l'initialisation de l'interface d'intervention.    * +*                                                                             * +*  Retour      : -                                                            * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +static void g_tweakable_plugin_default_init(GTweakablePluginInterface *iface) +{ +    iface->get_info = NULL; + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : plugin = interface à manipuler.                              * +*                count  = taille de la liste renvoyée. [OUT]                  * +*                                                                             * +*  Description : Fournit une liste de sections de configuration.              * +*                                                                             * +*  Retour      : Définition(s) de section de configuration ou NULL.           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +tweak_info_t *g_tweakable_plugin_get_tweak_info(const GTweakablePlugin *plugin, size_t *count) +{ +    tweak_info_t *result;                   /* Liste à renvoyer            */ +    GTweakablePluginInterface *iface;       /* Interface utilisée          */ + +    iface = G_TWEAKABLE_PLUGIN_GET_IFACE(plugin); + +    if (iface->get_info != NULL) +        result = iface->get_info(plugin, count); + +    else +    { +        *count = 0; +        result = NULL; +    } + +    return result; + +} diff --git a/src/plugins/tweakable.h b/src/plugins/tweakable.h new file mode 100644 index 0000000..aea70b4 --- /dev/null +++ b/src/plugins/tweakable.h @@ -0,0 +1,62 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * tweakable.h - prototypes pour la participation aux mécanismes de configuration + * + * Copyright (C) 2025 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 _PLUGINS_TWEAKABLE_H +#define _PLUGINS_TWEAKABLE_H + + +#include "../glibext/helpers.h" +#include "../gtkext/tweak.h" + + + +/* ------------------- INTEGRATION DANS L'EDITION DES PREFERENCES ------------------- */ + + +#define G_TYPE_TWEAKABLE_PLUGIN (g_tweakable_plugin_get_type()) + +DECLARE_INTERFACE(GTweakablePlugin, g_tweakable_plugin, G, TWEAKABLE_PLUGIN); + + +/* Fournit une liste de sections de configuration. */ +tweak_info_t *g_tweakable_plugin_get_tweak_info(const GTweakablePlugin *, size_t *); + + + +/* -------------------- SOLLICITATION DES FONCTIONNALITES CREEES -------------------- */ + + +#define get_tweakable_plugins_info(c)                                               \ +    ({                                                                              \ +        tweak_info_t *__all_info;                                                   \ +        __all_info = accumulate_from_all_plugins(G_TYPE_TWEAKABLE_PLUGIN,           \ +                                                 G_TWEAKABLE_PLUGIN,                \ +                                                 g_tweakable_plugin_get_tweak_info, \ +                                                 tweak_info_t,                      \ +                                                 c);                                \ +        __all_info;                                                                 \ +    }) + + + +#endif  /* _PLUGINS_TWEAKABLE_H */ | 
