/* Chrysalide - Outil d'analyse de fichiers binaires * self.h - définitions de fonctionnalités facilitant la mise en place d'extensions natives * * Copyright (C) 2020-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 this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _PLUGINS_SELF_H #define _PLUGINS_SELF_H #include #include #include "plugin.h" #include "../common/compiler.h" /* Symboles principaux */ #define PLUGIN_CORE_SELF \ static GPluginModule *_this_plugin = NULL; \ static void chrysalide_plugin_set_self(GPluginModule *); \ static void chrysalide_plugin_set_self(GPluginModule *plugin) \ { \ assert(_this_plugin == NULL); \ _this_plugin = plugin; \ }; \ __private GPluginModule *_chrysalide_plugin_get_self(void); \ __private GPluginModule *_chrysalide_plugin_get_self(void) \ { \ return _this_plugin; \ }; #define NATIVE_PLUGIN_ENTRYPOINT(fc) \ PLUGIN_CORE_SELF; \ G_MODULE_EXPORT GPluginModule *get_chrysalide_plugin_instance(GModule *); \ G_MODULE_EXPORT GPluginModule *get_chrysalide_plugin_instance(GModule *module) \ { \ GPluginModule *result; /* Instance à retourner */ \ result = fc(module); \ chrysalide_plugin_set_self(result); \ return result; \ } /* Spécifications */ #define CHRYSALIDE_WEBSITE(p) "https://www.chrysalide.re/" p #define NO_REQ NULL, 0 #define BUILD_PG_LIST(lst) lst, sizeof(lst) / sizeof(lst[0]) #define REQ_LIST(...) BUILD_PG_LIST((const char *[]){ __VA_ARGS__ }) /* Journalisation */ __private GPluginModule *_chrysalide_plugin_get_self(void); #define log_plugin_simple_message(type, msg) \ do \ { \ GPluginModule *__this; \ __this = _chrysalide_plugin_get_self(); \ if (__this != NULL) \ g_plugin_module_log_simple_message(__this, type, msg); \ else \ log_simple_message(type, msg); \ } \ while (0) #define log_plugin_variadic_message(type, msg, ...) \ do \ { \ GPluginModule *__this; \ __this = _chrysalide_plugin_get_self(); \ if (__this != NULL) \ g_plugin_module_log_variadic_message(__this, type, msg, __VA_ARGS__); \ else \ log_variadic_message(type, msg, __VA_ARGS__); \ } \ while (0) #endif /* _PLUGINS_SELF_H */