Elektra
0.8.25
|
Loading Modules for Elektra. More...
Functions | |
int | elektraModulesInit (KeySet *modules, Key *error) |
Initialises the module loading system. More... | |
elektraPluginFactory | elektraModulesLoad (KeySet *modules, const char *name, Key *error) |
Load a library with the given name. More... | |
int | elektraModulesClose (KeySet *modules, Key *error) |
Close all modules. More... | |
Loading Modules for Elektra.
Unfortunately there is no portable way to load modules, plugins or libraries. So Elektra needed a framework which abstracts the loading of modules. Depending of the operating system the build system chooses different source files which actually implement the loading of a module.
The goals are:
int elektraModulesClose | ( | KeySet * | modules, |
Key * | error | ||
) |
Close all modules.
Iterates over all modules and closes each of them.
Finish all affairs with the modules. Delete all keys where the appropriate module could be closed.
If it is not possible to close a module, still try to close all other modules, but report the error with the error key.
modules | all modules in this keyset will be closed |
error | a key to append the error information if it is not null |
int elektraModulesInit | ( | KeySet * | modules, |
Key * | error | ||
) |
Initialises the module loading system.
Most operating systems will have to do nothing here. Anyway you are required to add the key system/elektra/modules if it was successful.
On error -1 is returned and if error != 0 error information is added to it.
modules | an empty keyset |
error | a key to append the error information if it is not null |
elektraPluginFactory elektraModulesLoad | ( | KeySet * | modules, |
const char * | name, | ||
Key * | error | ||
) |
Load a library with the given name.
Make sure that you first lookup if this module was already loaded. If it was, just return the pointer and you are done.
Otherwise load the module/library given by name. You need to take care that a proper name is used. The name does not have any path, pre- or postfixes.
The next step is to fetch the symbol elektraPluginFactory.
If everything was successful append all information to the keyset modules and return the pointer. Take care that you can close the module with that information. All information needs to be stored within system/elektra/modules/name You might want to use an struct and store it there as binary key.
If anything goes wrong don't append anything to modules. Instead report the error to the error key and return with 0.
modules | where to get existing modules from a new module will be added there |
name | the name for the plugin to load. Note that it does not have any prefixes or postfixes, you need to add them yourself. |
error | the key to add warnings or report errors |