From 4bb02bdf378f5631ac65d1609bfd5fd3e6d88bdf Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Wed, 22 Oct 2008 08:56:19 +0000 Subject: [PATCH] Add more error information during eina module load. SVN revision: 36955 --- legacy/eina/src/include/eina_module.h | 4 ++++ legacy/eina/src/lib/eina_module.c | 20 ++++++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/legacy/eina/src/include/eina_module.h b/legacy/eina/src/include/eina_module.h index 6296882399..185a69eaca 100644 --- a/legacy/eina/src/include/eina_module.h +++ b/legacy/eina/src/include/eina_module.h @@ -21,6 +21,7 @@ #include "eina_types.h" #include "eina_array.h" +#include "eina_error.h" /** * @defgroup Module_Group Module @@ -36,6 +37,9 @@ typedef void (*Eina_Module_Shutdown)(void); #define EINA_MODULE_INIT(f) Eina_Module_Init __eina_module_init = &f; #define EINA_MODULE_SHUTDOWN(f) Eina_Module_Shutdown __eina_module_shutdown = &f; +extern EAPI Eina_Error EINA_ERROR_WRONG_MODULE; +extern EAPI Eina_Error EINA_ERROR_MODULE_INIT_FAILED; + EAPI int eina_module_init(void); EAPI int eina_module_shutdown(void); diff --git a/legacy/eina/src/lib/eina_module.c b/legacy/eina/src/lib/eina_module.c index 8fbbd70fdc..6021808315 100644 --- a/legacy/eina/src/lib/eina_module.c +++ b/legacy/eina/src/lib/eina_module.c @@ -26,6 +26,7 @@ #include #include +#include "eina_error.h" #include "eina_module.h" #include "eina_file.h" #include "eina_private.h" @@ -47,6 +48,9 @@ #define EINA_MODULE_SYMBOL_INIT "__eina_module_init" #define EINA_MODULE_SYMBOL_SHUTDOWN "__eina_module_shutdown" +EAPI Eina_Error EINA_ERROR_WRONG_MODULE = 0; +EAPI Eina_Error EINA_ERROR_MODULE_INIT_FAILED = 0; + struct _Eina_Module { char *file; @@ -121,6 +125,11 @@ eina_module_init(void) if (_eina_module_count != 1) goto end_init; + eina_error_init(); + + EINA_ERROR_WRONG_MODULE = eina_error_msg_register("Wrong file format or no file module found"); + EINA_ERROR_MODULE_INIT_FAILED = eina_error_msg_register("Module initialisation function failed"); + end_init: return _eina_module_count; } @@ -134,11 +143,12 @@ eina_module_shutdown(void) _eina_module_count--; if (_eina_module_count != 0) goto end_shutdown; + + eina_error_shutdown(); + /* TODO should we store every module when "new" is called and * delete the list of modules here */ - - end_shutdown: return _eina_module_count; @@ -154,9 +164,13 @@ EAPI Eina_Bool eina_module_load(Eina_Module *m) if (m->handle) goto loaded; + eina_error_set(EINA_ERROR_WRONG_MODULE); + dl_handle = dlopen(m->file, RTLD_NOW); if (!dl_handle) return EINA_FALSE; + eina_error_set(EINA_ERROR_MODULE_INIT_FAILED); + initcall = dlsym(dl_handle, EINA_MODULE_SYMBOL_INIT); if ((!initcall) || (!(*initcall))) goto ok; @@ -169,6 +183,8 @@ ok: m->handle = dl_handle; loaded: m->ref++; + + eina_error_set(0); return EINA_TRUE; } /**