Tizen Native API
|
Functions | |
Eina_Module * | eina_module_new (const char *file) |
Return a new module. | |
Eina_Bool | eina_module_free (Eina_Module *module) |
Delete a module. | |
Eina_Bool | eina_module_load (Eina_Module *module) |
Load a module. | |
Eina_Bool | eina_module_unload (Eina_Module *module) |
Unload a module. | |
void * | eina_module_symbol_get (const Eina_Module *module, const char *symbol) |
Retrieve the data associated to a symbol. | |
const char * | eina_module_file_get (const Eina_Module *module) |
Return the file name associated to the module. | |
char * | eina_module_symbol_path_get (const void *symbol, const char *sub_dir) |
Return the path built from the location of a library and a given sub directory. | |
char * | eina_module_environment_path_get (const char *env, const char *sub_dir) |
Return the path built from the value of an environment variable and a given sub directory. | |
Eina_Array * | eina_module_arch_list_get (Eina_Array *array, const char *path, const char *arch) |
Get an array of modules found on the directory path matching an arch type. | |
Eina_Array * | eina_module_list_get (Eina_Array *array, const char *path, Eina_Bool recursive, Eina_Module_Cb cb, void *data) |
Get a list of modules found on the directory path. | |
void | eina_module_list_load (Eina_Array *array) |
Load every module on the list of modules. | |
void | eina_module_list_unload (Eina_Array *array) |
Unload every module on the list of modules. | |
void | eina_module_list_free (Eina_Array *array) |
Free every module on the list of modules. | |
Eina_Module * | eina_module_find (const Eina_Array *array, const char *module) |
Find an module in array. | |
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) |
Defines | |
#define | EINA_MODULE_INIT(f) EXPORTAPI Eina_Module_Init __eina_module_init = &f |
#define | EINA_MODULE_SHUTDOWN(f) EXPORTAPI Eina_Module_Shutdown __eina_module_shutdown = &f |
These functions provide module management.
Eina module provides some helpers over POSIX dlopen(). It is not meant to replace, abstract or make a "portable" version of the POSIX, but enhance its usage by defining some good practices.
Modules are created with eina_module_new() and later loaded with eina_module_load(). Loads are reference counted and there must be the same number of eina_module_unload() in order to have it to call dlclose(). This makes simple to have different users for the same module.
The loaded shared objects may have two visible functions that will be called and might provide initialization and shutdown procedures. The symbols are __eina_module_init
and __eina_module_shutdown
and will be defined by the macros EINA_MODULE_INIT() and EINA_MODULE_SHUTDOWN().
There are some helpers to automatically create modules based on directory listing. See eina_module_arch_list_get(), eina_module_list_get() and eina_module_find().
Define Documentation
#define EINA_MODULE_INIT | ( | f | ) | EXPORTAPI Eina_Module_Init __eina_module_init = &f |
declares the given function as the module initializer (__eina_module_init). It must be of signature Eina_Module_Init
#define EINA_MODULE_SHUTDOWN | ( | f | ) | EXPORTAPI Eina_Module_Shutdown __eina_module_shutdown = &f |
declares the given function as the module shutdownializer (__eina_module_shutdown). It must be of signature Eina_Module_Shutdown
Typedef Documentation
Dynamic module loader handle.
Dynamic module loader callback.
If a function with such signature is exported by module as __eina_module_init, it will be called on the first load after dlopen() and if EINA_FALSE is returned, load will fail, EINA_TRUE means the module was successfully initialized.
- See also:
- Eina_Module_Shutdown
If a function with such signature is exported by module as __eina_module_shutdown, it will be called before calling dlclose()
- See also:
- Eina_Module_Init
Function Documentation
Eina_Array* eina_module_arch_list_get | ( | Eina_Array * | array, |
const char * | path, | ||
const char * | arch | ||
) |
Get an array of modules found on the directory path matching an arch type.
- Since :
- 2.3
- Parameters:
-
[in] array The array that stores the list of the modules. [in] path The directory's path to search for modules. [in] arch The architecture string.
- Returns:
- The array of modules found in
path
matchingarch
.
- Remarks:
- This function adds to
array
the module names found inpath
which match the cpu architecturearch
. Ifpath
orarch
isNULL
, the function returns immediatelyarray
.array
can beNULL
. In that case, it is created with 4 elements.
char* eina_module_environment_path_get | ( | const char * | env, |
const char * | sub_dir | ||
) |
Return the path built from the value of an environment variable and a given sub directory.
- Since :
- 2.3
- Parameters:
-
[in] env The environment variable to expand. [in] sub_dir The subdirectory to append.
- Returns:
- The built path on success,
NULL
otherwise.
- Remarks:
- This function returns the path built by concatenating the value of the environment variable named
env
andsub_dir
.sub_dir
can beNULL
. The returned path must be freed when not used anymore. If the symbol is not found, orenv
does not exist, or allocation fails, this function returnsNULL
.
const char* eina_module_file_get | ( | const Eina_Module * | module | ) |
Return the file name associated to the module.
- Since :
- 2.3
- Parameters:
-
[in] module The module.
- Returns:
- The file name.
- Remarks:
- This function returns the file name passed in eina_module_new(). If
module
isNULL
, the function returns immediatelyNULL
. The returned value must no be freed.
Eina_Module* eina_module_find | ( | const Eina_Array * | array, |
const char * | module | ||
) |
Find an module in array.
- Since :
- 2.3
- Parameters:
-
[in] array The array to find the module. [in] module The name of module to be searched.
- Returns:
- The module to find on success,
NULL
otherwise.
- Remarks:
- This function finds an
module
inarray
. If the element is found the function returns the module, elseNULL
is returned.
Eina_Bool eina_module_free | ( | Eina_Module * | module | ) |
Delete a module.
- Since :
- 2.3
- Parameters:
-
[in] module The module to delete.
- Returns:
- EINA_TRUE on success, EINA_FALSE otherwise.
- Remarks:
- This function calls eina_module_unload() if
module
has been previously loaded and frees the allocated memory. On success this function returns EINA_TRUE and EINA_FALSE otherwise. Ifmodule
isNULL
, the function returns immediately.
void eina_module_list_free | ( | Eina_Array * | array | ) |
Free
every module on the list of modules.
- Since :
- 2.3
- Parameters:
-
[in] array The array of modules to free.
- Remarks:
- This function calls eina_module_free() on each element found in
array
. Ifarray
isNULL
, this function does nothing.
Eina_Array* eina_module_list_get | ( | Eina_Array * | array, |
const char * | path, | ||
Eina_Bool | recursive, | ||
Eina_Module_Cb | cb, | ||
void * | data | ||
) |
Get a list of modules found on the directory path.
- Since :
- 2.3
- Parameters:
-
[in] array The array that stores the list of the modules. [in] path The directory's path to search for modules. [in] recursive Iterate recursively on the path. [in] cb Callback function to call on each module. [in] data Data passed to the callback function.
- Returns:
- The array of modules found in
path
.
- Remarks:
- This function adds to
array
the list of modules found inpath
. Ifrecursive
is EINA_TRUE, then recursive search is done. The callbackcb
is called on each module found, anddata
is passed tocb
. Ifpath
isNULL
, the function returns immediatelyarray
. If the returned value ofcb
is0
, the module will not be added to the list, otherwise it will be added. -
array
can beNULL
. In that case, it is created with 4 elements.cb
can beNULL
.
void eina_module_list_load | ( | Eina_Array * | array | ) |
Load every module on the list of modules.
- Since :
- 2.3
- Parameters:
-
[in] array The array of modules to load.
- Remarks:
- This function calls eina_module_load() on each element found in
array
. Ifarray
isNULL
, this function does nothing.
void eina_module_list_unload | ( | Eina_Array * | array | ) |
Unload every module on the list of modules.
- Since :
- 2.3
- Parameters:
-
[in] array The array of modules to unload.
- Remarks:
- This function calls eina_module_unload() on each element found in
array
. Ifarray
isNULL
, this function does nothing.
Eina_Bool eina_module_load | ( | Eina_Module * | module | ) |
Load a module.
- Since :
- 2.3
- Parameters:
-
[in] module The module to load.
- Returns:
- EINA_TRUE on success, EINA_FALSE otherwise.
- Remarks:
- 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. If the shared file object can not be loaded, EINA_FALSE is returned. If it is an internal Eina module and the module can not be initialized, EINA_FALSE is returned. If the module has already been loaded, it's reference counter is increased by one and EINA_TRUE is returned. If
module
isNULL
, the function returns immediately EINA_FALSE. - When the symbols of the shared file objects are not needed anymore, call eina_module_unload() to unload the module.
Eina_Module* eina_module_new | ( | const char * | file | ) |
Return a new module.
- Since :
- 2.3
- Parameters:
-
[in] file The name of the file module to load.
- Returns:
- A new module. If
file
isNULL
, or if it does not exist, the function returnsNULL
, otherwise, it allocates an Eina_Module, stores a duplicate string offile
, sets its reference to0
and its handle toNULL
.
- Remarks:
- When the new module is not needed anymore, use eina_module_free() to free the allocated memory.
- See also:
- eina_module_load
void* eina_module_symbol_get | ( | const Eina_Module * | module, |
const char * | symbol | ||
) |
Retrieve the data associated to a symbol.
- Since :
- 2.3
- Parameters:
-
[in] module The module. [in] symbol The symbol.
- Returns:
- The data associated to the symbol, or
NULL
on failure.
- Remarks:
- This function returns the data associated to
symbol
ofmodule
.module
must have been loaded before with eina_module_load(). Ifmodule
isNULL
, or if it has not been correctly loaded before, the function returns immediatelyNULL
.
char* eina_module_symbol_path_get | ( | const void * | symbol, |
const char * | sub_dir | ||
) |
Return the path built from the location of a library and a given sub directory.
- Since :
- 2.3
- Parameters:
-
[in] symbol The symbol to search for. [in] sub_dir The subdirectory to append.
- Returns:
- The built path on success,
NULL
otherwise.
- Remarks:
- This function returns the path built by concatenating the path of the library containing the symbol
symbol
andsub_dir
.sub_dir
can beNULL
. The returned path must be freed when not used anymore. If the symbol is not found, or dl_addr() is not supported, or allocation fails, this function returnsNULL
.
Eina_Bool eina_module_unload | ( | Eina_Module * | module | ) |
Unload a module.
- Since :
- 2.3
- Parameters:
-
[in] module The module to load.
- Returns:
- EINA_TRUE on success, EINA_FALSE otherwise.
- Remarks:
- This function unload the module
module
that has been previously loaded by eina_module_load(). If the reference counter ofmodule
is strictly greater than1
, 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. Ifmodule
isNULL
, the function returns immediately EINA_FALSE.