Lumiera
0.pre.03
»edit your freedom«
|
Go to the source code of this file.
Plugin loader implementation.
Definition in file plugin.c.
#include "include/logging.h"
#include "lib/safeclib.h"
#include "lib/tmpbuf.h"
#include "lib/psplay.h"
#include "lib/recmutex.h"
#include "lib/error.h"
#include "include/config-facade.h"
#include "common/interfaceregistry.h"
#include "common/config.h"
#include "common/plugin.h"
#include <glob.h>
#include <nobug.h>
Classes | |
struct | lumiera_plugin |
struct | lumiera_plugintype |
record the extension and a callback function for loading the associated plugin for each plugin type More... | |
Typedefs | |
typedef lumiera_plugintype * | LumieraPlugintype |
Macros | |
#define | LUMIERA_PLUGIN_TYPE(type, ext) |
#define | LUMIERA_PLUGIN_TYPE(type, ext) {lumiera_plugin_load_##type, lumiera_plugin_unload_##type, ext}, |
#define | LUMIERA_PLUGIN_TYPE_PLANNED(name, ext) |
#define | LUMIERA_PLUGIN_TYPES |
Supported (and planned) plugin types and their file extensions This maps filename extensions to implementations (of the respective _load_NAME and _unload_NAME functions) So far we only support platform dynamic libraries, later we may add plugins implemented in Lua and c source modules which get compiled on the fly. More... | |
Functions | |
static char * | init_exts_globs (void) |
LUMIERA_ERROR_DEFINE (PLUGIN_INIT, "Initialisation error") | |
LUMIERA_ERROR_DEFINE (PLUGIN_OPEN, "Could not open plugin") | |
LUMIERA_ERROR_DEFINE (PLUGIN_WTF, "Not a Lumiera plugin") | |
LUMIERA_ERROR_DEFINE (PLUGIN_REGISTER, "Could not register plugin") | |
LUMIERA_ERROR_DEFINE (PLUGIN_VERSION, "Plugin Version unsupported") | |
int | lumiera_plugin_cmp_fn (const void *keya, const void *keyb) |
void | lumiera_plugin_delete_fn (PSplaynode node) |
int | lumiera_plugin_discover (LumieraPlugin(*callback_load)(const char *plugin), int(*callback_register)(LumieraPlugin)) |
discover new plugins traverses the configured plugin paths and calls the callback_load function for any plugin not actually loaded. More... | |
lumiera_err | lumiera_plugin_error (LumieraPlugin self) |
Query the error state of a plugin. More... | |
void * | lumiera_plugin_handle (LumieraPlugin self) |
Query the plugin handle. More... | |
LumieraPlugin | lumiera_plugin_init (LumieraPlugin self, void *handle, LumieraInterface plugin) |
const void * | lumiera_plugin_key_fn (const PSplaynode node) |
LumieraPlugin | lumiera_plugin_load (const char *plugin) |
Tries to load a plugin Creates a new plugin structure and tries to load and initialise the plugin. More... | |
LumieraPlugin | lumiera_plugin_lookup (const char *name) |
Lookup a plugin handle in the pluginregistry. More... | |
const char * | lumiera_plugin_name (LumieraPlugin self) |
Query the plugin name The name is the path and filename under which it was loaded. More... | |
LumieraPlugin | lumiera_plugin_new (const char *name) |
Allocates an preinitialises a plugin structure. More... | |
void | lumiera_plugin_refdec (LumieraPlugin self) |
void | lumiera_plugin_refinc (LumieraPlugin self) |
int | lumiera_plugin_register (LumieraPlugin plugin) |
Register a plugin and its interfaces. More... | |
unsigned | lumiera_plugin_unload (LumieraPlugin self) |
Tries to unload a plugin. More... | |
Variables | |
static lumiera_plugintype | lumiera_plugin_types [] |
PSplay | lumiera_pluginregistry |
#define LUMIERA_PLUGIN_TYPES |
Supported (and planned) plugin types and their file extensions This maps filename extensions to implementations (of the respective _load_NAME and _unload_NAME functions) So far we only support platform dynamic libraries, later we may add plugins implemented in Lua and c source modules which get compiled on the fly.
#define LUMIERA_PLUGIN_TYPE | ( | type, | |
ext | |||
) |
struct lumiera_plugin_struct |
LumieraPlugin lumiera_plugin_new | ( | const char * | name | ) |
Allocates an preinitialises a plugin structure.
name | path/filename of the plugin |
LUMIERA_ERROR_PLUGIN_INIT
Definition at line 132 of file plugin.c.
References lumiera_malloc(), lumiera_strndup(), and psplaynode_init().
LumieraPlugin lumiera_plugin_init | ( | LumieraPlugin | self, |
void * | handle, | ||
LumieraInterface | plugin | ||
) |
Complete plugin initialisation Stores any pending error (from loading) in self which clears out the LUMIERA_ERROR_PLUGIN_INIT error state which was initialised by lumiera_plugin_new(), stores the handle and plugin pointers in the plugin struct.
self | pointer to the plugin struct |
handle | opaque handle referring to some plugin type specific data |
plugin | a lumieraorg__plugin interface which will be used to initialise this plugin |
Definition at line 148 of file plugin.c.
References lumiera_error().
lumiera_err lumiera_plugin_error | ( | LumieraPlugin | self | ) |
void* lumiera_plugin_handle | ( | LumieraPlugin | self | ) |
const char* lumiera_plugin_name | ( | LumieraPlugin | self | ) |
void lumiera_plugin_refinc | ( | LumieraPlugin | self | ) |
void lumiera_plugin_refdec | ( | LumieraPlugin | self | ) |
int lumiera_plugin_discover | ( | LumieraPlugin(*)(const char *plugin) | callback_load, |
int(*)(LumieraPlugin) | callback_register | ||
) |
discover new plugins traverses the configured plugin paths and calls the callback_load function for any plugin not actually loaded.
If callback_load returns a plugin (and not NULL) then this is feed to the callback_register function.
Definition at line 196 of file plugin.c.
References lumiera_config_setdefault().
LumieraPlugin lumiera_plugin_load | ( | const char * | plugin | ) |
Tries to load a plugin Creates a new plugin structure and tries to load and initialise the plugin.
The plugins error state may be set on any problem which should be queried later.
plugin | path/filename of the plugin to load |
int lumiera_plugin_register | ( | LumieraPlugin | self | ) |
Register a plugin and its interfaces.
Registers the plugin (unconditionally) at the plugin registry. When the error state of the plugin is NULL then use its lumieraorg__plugin interface to register all interfaces offered by the plugin at the interface registry. Registered plugins will be automatic unloaded at application end.
self | the plugin to be registered (calling with NULL is a no-op) |
Definition at line 269 of file plugin.c.
References LUMIERA_RECMUTEX_SECTION.
unsigned lumiera_plugin_unload | ( | LumieraPlugin | self | ) |
Tries to unload a plugin.
When the Plugin is unused, then all resources associated with it are freed and it will be removed from memory
plugin | the plugin to be unloaded. |
LumieraPlugin lumiera_plugin_lookup | ( | const char * | name | ) |
|
static |