Plugin loading and unloading. More...
Typedefs | |
| typedef void *(* | GNUNET_PLUGIN_Callback) (void *arg) |
| Signature of any function exported by a plugin. | |
| typedef void(* | GNUNET_PLUGIN_LoaderCallback) (void *cls, const char *library_name, void *lib_ret) |
| Signature of a function called by GNUNET_PLUGIN_load_all(). | |
Functions | |
| enum GNUNET_GenericReturnValue | GNUNET_PLUGIN_test (const struct GNUNET_OS_ProjectData *pd, const char *library_name) |
| Test if a plugin exists. | |
| void * | GNUNET_PLUGIN_load (const struct GNUNET_OS_ProjectData *pd, const char *library_name, void *arg) |
| Setup plugin (runs the "init" callback and returns whatever "init" returned). | |
| void | GNUNET_PLUGIN_load_all (const struct GNUNET_OS_ProjectData *pd, const char *basename, void *arg, GNUNET_PLUGIN_LoaderCallback cb, void *cb_cls) |
| Load all compatible plugins with the given base name. | |
| void * | GNUNET_PLUGIN_unload (const char *library_name, void *arg) |
| Unload plugin (runs the "done" callback and returns whatever "done" returned). | |
Plugin loading and unloading.
| typedef void *(* GNUNET_PLUGIN_Callback) (void *arg) |
Signature of any function exported by a plugin.
| arg | argument to the function (context) |
Definition at line 60 of file gnunet_plugin_lib.h.
| typedef void(* GNUNET_PLUGIN_LoaderCallback) (void *cls, const char *library_name, void *lib_ret) |
Signature of a function called by GNUNET_PLUGIN_load_all().
| cls | closure |
| library_name | full name of the library (to be used with GNUNET_PLUGIN_unload) |
| lib_ret | return value from the initialization function of the library (same as what GNUNET_PLUGIN_load would have returned for the given library name) |
Definition at line 108 of file gnunet_plugin_lib.h.
| enum GNUNET_GenericReturnValue GNUNET_PLUGIN_test | ( | const struct GNUNET_OS_ProjectData * | pd, |
| const char * | library_name | ||
| ) |
Test if a plugin exists.
Note that the library must export a symbol called "library_name_init" for the test to succeed.
| pd | project data with library search path |
| library_name | name of the plugin to test if it is installed |
Definition at line 172 of file plugin.c.
References GNUNET_break, GNUNET_NO, GNUNET_YES, PluginList::handle, init, initialized, PluginList::name, open_library(), plugin_fini(), plugin_init(), plugins, and resolve_function().
Referenced by main().
| void * GNUNET_PLUGIN_load | ( | const struct GNUNET_OS_ProjectData * | pd, |
| const char * | library_name, | ||
| void * | arg | ||
| ) |
Setup plugin (runs the "init" callback and returns whatever "init" returned).
If "init" returns NULL, the plugin is unloaded.
Note that the library must export symbols called "library_name_init" and "library_name_done". These will be called when the library is loaded and unloaded respectively.
| pd | project data with library search path |
| library_name | name of the plugin to load |
| arg | argument to the plugin initialization function |
Definition at line 221 of file plugin.c.
References _, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_new, GNUNET_NO, GNUNET_strdup, GNUNET_YES, PluginList::handle, init, initialized, LOG, PluginList::name, PluginList::next, open_library(), plugin_fini(), plugin_init(), plugins, resolve_function(), and ret.
Referenced by client_connect_cb(), find_libraries(), GNUNET_DATACACHE_create(), handle_helper_init(), load_plugin(), run(), run(), run(), and run().
| void GNUNET_PLUGIN_load_all | ( | const struct GNUNET_OS_ProjectData * | pd, |
| const char * | basename, | ||
| void * | arg, | ||
| GNUNET_PLUGIN_LoaderCallback | cb, | ||
| void * | cb_cls | ||
| ) |
Load all compatible plugins with the given base name.
Note that the library must export symbols called "basename_ANYTHING_init" and "basename_ANYTHING__done". These will be called when the library is loaded and unloaded respectively.
| pd | project data with library search path |
| basename | basename of the plugins to load |
| arg | argument to the plugin initialization function |
| cb | function to call for each plugin found |
| cb_cls | closure for cb |
Definition at line 401 of file plugin.c.
References _, LoadAllContext::arg, LoadAllContext::basename, LoadAllContext::cb, LoadAllContext::cb_cls, find_libraries(), GNUNET_DISK_directory_scan(), GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_log, GNUNET_OS_installation_get_path(), GNUNET_OS_IPK_LIBDIR, and LoadAllContext::pd.
Referenced by GNUNET_BLOCK_context_create(), init(), init(), and init().
| void * GNUNET_PLUGIN_unload | ( | const char * | library_name, |
| void * | arg | ||
| ) |
Unload plugin (runs the "done" callback and returns whatever "done" returned).
The plugin is then unloaded.
| library_name | name of the plugin to unload |
| arg | argument to the plugin shutdown function |
Definition at line 277 of file plugin.c.
References getenv(), GNUNET_free, GNUNET_NO, PluginList::handle, initialized, PluginList::name, PluginList::next, plugin_fini(), plugins, resolve_function(), and ret.
Referenced by __attribute__(), cleanup_task(), cleanup_task(), client_disconnect_cb(), do_shutdown_later(), GNUNET_BLOCK_context_destroy(), GNUNET_DATACACHE_destroy(), run(), shutdown_task(), and unload_plugin().