diff options
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/core.c | 86 | ||||
| -rw-r--r-- | src/core/core.h | 14 | ||||
| -rw-r--r-- | src/core/demanglers.c | 6 | ||||
| -rw-r--r-- | src/core/paths.c | 49 |
4 files changed, 114 insertions, 41 deletions
diff --git a/src/core/core.c b/src/core/core.c index fe7a5e0..636e41e 100644 --- a/src/core/core.c +++ b/src/core/core.c @@ -44,7 +44,6 @@ #include "../common/io.h" #include "../common/xdg.h" #include "../glibext/linesegment.h" -#include "../plugins/dt.h" @@ -101,9 +100,11 @@ bool load_all_core_components(bool cs) explorer = g_content_explorer_new(); set_current_content_explorer(explorer); + g_object_unref(G_OBJECT(explorer)); resolver = g_content_resolver_new(); set_current_content_resolver(resolver); + g_object_unref(G_OBJECT(resolver)); #ifdef INCLUDE_MAGIC_SUPPORT if (result) result = init_magic_cookie(); @@ -111,6 +112,7 @@ bool load_all_core_components(bool cs) root_ns = g_scan_namespace_new(NULL); set_rost_root_namespace(root_ns); + g_object_unref(G_OBJECT(root_ns)); if (result) result = populate_main_scan_namespace(root_ns); if (result) result = load_all_known_scan_token_modifiers(); @@ -120,8 +122,6 @@ bool load_all_core_components(bool cs) register_arch_gtypes(); init_operands_factory(); - if (result) result = init_chrysalide_dynamic_types(); - } } @@ -147,10 +147,10 @@ void unload_all_core_components(bool cs) { if (cs) { - exit_chrysalide_dynamic_types(); - exit_operands_factory(); + exit_segment_content_hash_table(); + unload_demanglers_definitions(); unload_processors_definitions(); @@ -179,3 +179,79 @@ void unload_all_core_components(bool cs) ERR_free_strings(); } + + +/****************************************************************************** +* * +* Paramètres : selected = liste d'éléments à décharger. * +* * +* Description : Charge une sélection d'éléments de base du programme. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool load_core_components(AvailableCoreComponent flags) +{ + static bool result = false; /* Bilan à retourner */ + static bool done = false; /* Mémorisation des passages */ + GScanNamespace *root_ns; /* Espace de noms ROST racine */ + + /** + * On mémorise les passages réussis. + */ + if (!done) + { + done = true; + result = true; + + if (flags & ACC_SCAN_FEATURES) + { +#ifdef INCLUDE_MAGIC_SUPPORT + if (result) result = init_magic_cookie(); +#endif + + root_ns = g_scan_namespace_new(NULL); + set_rost_root_namespace(root_ns); + g_object_unref(G_OBJECT(root_ns)); + + if (result) result = populate_main_scan_namespace(root_ns); + if (result) result = load_all_known_scan_token_modifiers(); + + } + + } + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : selected = liste d'éléments à décharger. * +* * +* Description : Décharge une sélection d'éléments de base du programme. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +void unload_core_components(AvailableCoreComponent flags) +{ + if (flags & ACC_SCAN_FEATURES) + { + unload_all_scan_token_modifiers(); + set_rost_root_namespace(NULL); + +#ifdef INCLUDE_MAGIC_SUPPORT + exit_magic_cookie(); +#endif + + } + +} diff --git a/src/core/core.h b/src/core/core.h index 0221f56..def2813 100644 --- a/src/core/core.h +++ b/src/core/core.h @@ -36,5 +36,19 @@ bool load_all_core_components(bool); void unload_all_core_components(bool); +/* Eléments à (dé)charger disponibles */ +typedef enum _AvailableCoreComponent +{ + ACC_SCAN_FEATURES = (1 << 0), /* Espace de noms pour scan */ + +} AvailableCoreComponent; + +/* Charge une sélection d'éléments de base du programme. */ +bool load_core_components(AvailableCoreComponent); + +/* Décharge une sélection d'éléments de base du programme. */ +void unload_core_components(AvailableCoreComponent); + + #endif /* _CORE_CORE_H */ diff --git a/src/core/demanglers.c b/src/core/demanglers.c index 0eb4e36..5518008 100644 --- a/src/core/demanglers.c +++ b/src/core/demanglers.c @@ -85,12 +85,12 @@ bool register_demangler_type(GType type) else { - _demanglers_definitions = (demangler_t *)realloc(_demanglers_definitions, - ++_demanglers_definitions_count * sizeof(demangler_t)); + _demanglers_definitions = realloc(_demanglers_definitions, + ++_demanglers_definitions_count * sizeof(demangler_t)); new = &_demanglers_definitions[_demanglers_definitions_count - 1]; - new->key = strdup(key); + new->key = key; new->type = type; result = true; diff --git a/src/core/paths.c b/src/core/paths.c index 5902e83..c9213bc 100644 --- a/src/core/paths.c +++ b/src/core/paths.c @@ -125,15 +125,13 @@ char *get_effective_directory(const char *template) char *get_effective_directory_new(TargetDirectoryType type) { char *result; /* Répertoire à retourner */ -#ifdef DISCARD_LOCAL +#if defined DISCARD_LOCAL && defined PYTHON_PACKAGE Dl_info info; /* Informations dynamiques */ int ret; /* Bilan d'une récupération */ char *dyn_path_tmp; /* Chemin d'accès modifiable */ const char *dyn_path; /* Chemin d'accès courant */ -# ifdef PYTHON_PACKAGE size_t len; /* Taille de comparaison */ size_t pos; /* Position dans une chaîne */ -# endif #endif /** @@ -155,20 +153,6 @@ char *get_effective_directory_new(TargetDirectoryType type) result = NULL; -#ifdef DISCARD_LOCAL - - ret = dladdr(__FUNCTION__, &info); - if (ret == 0) - { - LOG_ERROR_DL_N("dladdr"); - goto exit; - } - - dyn_path_tmp = strdup(info.dli_fname); - dyn_path = dirname(dyn_path_tmp); - -#endif - switch (type) { case TDT_PLUGINS_LIB: @@ -178,6 +162,16 @@ char *get_effective_directory_new(TargetDirectoryType type) #else # ifdef PYTHON_PACKAGE + ret = dladdr(__FUNCTION__, &info); + if (ret == 0) + { + LOG_ERROR_DL_N("dladdr"); + break; + } + + dyn_path_tmp = strdup(info.dli_fname); + dyn_path = dirname(dyn_path_tmp); + len = strlen("chrysalide-libs"); pos = strlen(dyn_path); @@ -193,9 +187,12 @@ char *get_effective_directory_new(TargetDirectoryType type) result[pos] = '\0'; result = stradd(result, "chrysalide-plugins"); + bad_sync: + + free(dyn_path_tmp); + # else - result = strdup(dyn_path); - result = stradd(result, G_DIR_SEPARATOR_S "chrysalide-plugins"); + result = strdup(PLUGINS_LIB_DIR); # endif #endif break; @@ -206,20 +203,6 @@ char *get_effective_directory_new(TargetDirectoryType type) } -#ifdef DISCARD_LOCAL - -# ifdef PYTHON_PACKAGE - - bad_sync: - -# endif - - free(dyn_path_tmp); - - exit: - -#endif - assert(result != NULL); return result; |
