X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Finclude%2Fgnunet_plugin_lib.h;h=387ca381c2dd34fd514f26c2d3bf12349e4a7639;hb=83b19539f4d322b43683f5838b72e9ec2c8e6073;hp=b8c7b99fe41e6cf2fe37853603ab2dc1753b1cbf;hpb=f1b9c5c115139b02cac1cae4f053792e1e5b1ccb;p=oweals%2Fgnunet.git diff --git a/src/include/gnunet_plugin_lib.h b/src/include/gnunet_plugin_lib.h index b8c7b99fe..387ca381c 100644 --- a/src/include/gnunet_plugin_lib.h +++ b/src/include/gnunet_plugin_lib.h @@ -50,6 +50,19 @@ extern "C" typedef void *(*GNUNET_PLUGIN_Callback) (void *arg); +/** + * Test if a plugin exists. + * + * Note that the library must export a symbol called + * "library_name_init" for the test to succeed. + * + * @param library_name name of the plugin to test if it is installed + * @return GNUNET_YES if the plugin exists, GNUNET_NO if not + */ +int +GNUNET_PLUGIN_test (const char *library_name); + + /** * Setup plugin (runs the "init" callback and returns whatever "init" * returned). If "init" returns NULL, the plugin is unloaded. @@ -62,7 +75,40 @@ typedef void *(*GNUNET_PLUGIN_Callback) (void *arg); * @param arg argument to the plugin initialization function * @return whatever the initialization function returned, NULL on error */ -void *GNUNET_PLUGIN_load (const char *library_name, void *arg); +void * +GNUNET_PLUGIN_load (const char *library_name, void *arg); + + +/** + * Signature of a function called by 'GNUNET_PLUGIN_load_all'. + * + * @param cls closure + * @param library_name full name of the library (to be used with + * 'GNUNET_PLUGIN_unload') + * @param 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) + */ +typedef void (*GNUNET_PLUGIN_LoaderCallback) (void *cls, + const char *library_name, + void *lib_ret); + + +/** + * 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. + * + * @param basename basename of the plugins to load + * @param arg argument to the plugin initialization function + * @param cb function to call for each plugin found + * @param cb_cls closure for 'cb' + */ +void +GNUNET_PLUGIN_load_all (const char *basename, void *arg, + GNUNET_PLUGIN_LoaderCallback cb, void *cb_cls); /** @@ -74,7 +120,8 @@ void *GNUNET_PLUGIN_load (const char *library_name, void *arg); * @return whatever the shutdown function returned, typically NULL * or a "char *" representing the error message */ -void *GNUNET_PLUGIN_unload (const char *library_name, void *arg); +void * +GNUNET_PLUGIN_unload (const char *library_name, void *arg); #if 0 /* keep Emacsens' auto-indent happy */