Module
[Tools]
These functions provide module management. More...
Defines | |
#define | EINA_MODULE_INIT(f) EAPI Eina_Module_Init __eina_module_init = &f; |
#define | EINA_MODULE_SHUTDOWN(f) EAPI Eina_Module_Shutdown __eina_module_shutdown = &f; |
Typedefs | |
typedef struct _Eina_Module | Eina_Module |
typedef Eina_Bool(* | Eina_Module_Cb )(Eina_Module *m, void *data) |
typedef Eina_Bool(* | Eina_Module_Init )(void) |
typedef void(* | Eina_Module_Shutdown )(void) |
Functions | |
EAPI int | eina_module_init (void) |
Initialize the eina module internal structure. | |
EAPI int | eina_module_shutdown (void) |
Shut down the eina module internal structures. | |
EAPI Eina_Module * | eina_module_new (const char *file) |
Return a new module. | |
EAPI Eina_Bool | eina_module_free (Eina_Module *m) |
Delete a module. | |
EAPI Eina_Bool | eina_module_load (Eina_Module *m) |
Load a module. | |
EAPI Eina_Bool | eina_module_unload (Eina_Module *m) |
Unload a module. | |
EAPI void * | eina_module_symbol_get (Eina_Module *m, const char *symbol) |
Retrive the data associated to a symbol. | |
EAPI const char * | eina_module_file_get (Eina_Module *m) |
Return the file name associated to the module. | |
EAPI char * | eina_module_symbol_path_get (const void *symbol, const char *sub_dir) EINA_PURE EINA_MALLOC EINA_ARG_NONNULL(1 |
EAPI char *EAPI char * | eina_module_environment_path_get (const char *env, const char *sub_dir) EINA_PURE EINA_MALLOC EINA_ARG_NONNULL(1 |
EAPI char *EAPI char *EAPI Eina_Array * | eina_module_list_get (Eina_Array *array, const char *path, unsigned int recursive, Eina_Module_Cb cb, void *data) |
Get a list of modules found on the directory path. | |
EAPI void | eina_module_list_load (Eina_Array *array) |
Load every module on the list of modules. | |
EAPI void | eina_module_list_unload (Eina_Array *list) EINA_ARG_NONNULL(1) |
EAPI void | eina_module_list_flush (Eina_Array *array) |
Helper function that iterates over the list of modules and calls eina_module_free on each. | |
Variables | |
EAPI Eina_Error | EINA_ERROR_WRONG_MODULE |
EAPI Eina_Error | EINA_ERROR_MODULE_INIT_FAILED |
EAPI void * | EINA_WARN_UNUSED_RESULT |
Detailed Description
These functions provide module management.
Function Documentation
EAPI int eina_module_init | ( | void | ) |
Initialize the eina module internal structure.
- Returns:
- 1 or greater on success, 0 on error.
This function sets up the module module of Eina. It also registers the errors EINA_ERROR_WRONG_MODULE and EINA_ERROR_MODULE_INIT_FAILED. It is also called by eina_init(). It returns 0 on failure, otherwise it returns the number of times it has already been called. See eina_error_init() for the documentation of the initialisation of the dependency modules.
Once the module module is not used anymore, then eina_module_shutdown() must be called to shut down the module module.
- See also:
- eina_error_init()
- eina_init()
References eina_error_init(), and eina_error_msg_register().
EAPI int eina_module_shutdown | ( | void | ) |
Shut down the eina module internal structures.
- Returns:
- 0 when the module module is completely shut down, 1 or greater otherwise.
This function shuts down the module module set up by eina_module_init(). It is called by eina_shutdown(). It returns 0 when it is called the same number of times than eina_module_init().
- See also:
- eina_error_shutdown()
- eina_shutdown()
References eina_error_shutdown().
EAPI Eina_Module * eina_module_new | ( | const char * | file | ) |
Return a new module.
- Parameters:
-
file The name of the file module to load.
This function returns a new module. If file
is NULL
, the function returns NULL
, otherwise, it allocates an Eina_Module, stores a duplicate string of file
, sets its reference to 0
and its handle to NULL
.
When the new module is not needed anymore, use eina_module_free() to free the allocated memory.
- See also:
- eina_module_load
EAPI Eina_Bool eina_module_free | ( | Eina_Module * | m | ) |
Delete a module.
- Parameters:
-
m The module to delete.
- Returns:
- EINA_TRUE on success, EINA_FALSE otherwise.
This function calls eina_module_unload() if m
has been previously loaded and frees the allocated memory. On success this function returns EINA_TRUE and EINA_FALSE otherwise. If m
is NULL
, the function returns immediatly.
References EINA_FALSE, eina_module_unload(), and EINA_TRUE.
Referenced by eina_module_list_flush().
EAPI Eina_Bool eina_module_load | ( | Eina_Module * | m | ) |
Load a module.
- Parameters:
-
m The module to load.
- Returns:
- EINA_TRUE on success, EINA_FALSE otherwise.
This function load the shared file object passed in eina_module_new(). If it is a internal Eina module (like the mempools), it also initialize it. It the shared file object can not be loaded, the error EINA_ERROR_WRONG_MODULE is set and EINA_FALSE is returned. If it is a internal Eina module and the module can not be initialized, the error EINA_ERROR_MODULE_INIT_FAILED is set and EINA_FALSE is returned. If the module has already been loaded, it's refeence counter is increased by one and EINA_TRUE is returned. If m
is NULL
, the function returns immediatly EINA_FALSE.
When the symbols of the shared file objetcts are not needed anymore, call eina_module_unload() to unload the module.
References EINA_ERROR_PDBG, eina_error_set(), EINA_FALSE, and EINA_TRUE.
Referenced by eina_module_list_load().
EAPI Eina_Bool eina_module_unload | ( | Eina_Module * | m | ) |
Unload a module.
- Parameters:
-
m The module to load.
- Returns:
- EINA_TRUE on success, EINA_FALSE otherwise.
This function unload the module m
that has been previously loaded by eina_module_load(). If the reference counter of m
is strictly greater than 1
, EINA_FALSE is returned. Otherwise, the shared object file is closed and if it is a internal Eina module, it is shutted down just before. In that case, EINA_TRUE is returned. In all case, the reference counter is decreased. If m
is NULL
, the function returns immediatly EINA_FALSE.
References EINA_FALSE, and EINA_TRUE.
Referenced by eina_module_free().
EAPI void * eina_module_symbol_get | ( | Eina_Module * | m, | |
const char * | symbol | |||
) |
Retrive the data associated to a symbol.
- Parameters:
-
The module. symbol The symbol.
- Returns:
- The data associated to the symbol, or
NULL
on failure.
This function returns the data associated to symbol
of m
. m
must have been loaded before with eina_module_load(). If m
is NULL
, or if it has not been correctly loaded before, the function returns immediatly NULL
.
EAPI const char * eina_module_file_get | ( | Eina_Module * | m | ) |
Return the file name associated to the module.
- Parameters:
-
m The module.
- Returns:
- The file name.
Return the file name passed in eina_module_new(). If m
is NULL
, the function returns immediatly NULL
. The returned value must no be freed.
EAPI Eina_Array * eina_module_list_get | ( | Eina_Array * | array, | |
const char * | path, | |||
unsigned int | recursive, | |||
Eina_Module_Cb | cb, | |||
void * | data | |||
) |
Get a list of modules found on the directory path.
- Parameters:
-
path The directory's path to search for modules recursive Iterate recursively on the path cb Callback function to call, if the return value of the callback is zero it won't be added to the list, if it is one, it will. data Data passed to the callback function
References eina_array_new(), and eina_file_dir_list().
EAPI void eina_module_list_load | ( | Eina_Array * | array | ) |
Load every module on the list of modules.
- Parameters:
-
list The list of modules
References EINA_ARRAY_ITER_NEXT, and eina_module_load().