summaryrefslogtreecommitdiff
path: root/src/util/plugin.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/plugin.c')
-rw-r--r--src/util/plugin.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/util/plugin.c b/src/util/plugin.c
index d169bc911..feb661f24 100644
--- a/src/util/plugin.c
+++ b/src/util/plugin.c
@@ -388,6 +388,11 @@ find_libraries (void *cls,
* `basename_ANYTHING_init` and `basename_ANYTHING__done`. These will
* be called when the library is loaded and unloaded respectively.
*
+ * If you are writing a service to which third-party applications can connect,
+ * like GNUnet's own GNS service for example, you should use
+ * #GNUNET_PLUGIN_load_all_in_context instead of this function, passing your
+ * service's project data as context.
+ *
* @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
@@ -420,4 +425,32 @@ GNUNET_PLUGIN_load_all (const char *basename,
}
+/**
+ * Load all compatible plugins with the given base name while inside the given
+ * context (i.e. a specific project data structure.)
+ *
+ * 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 ctx the context used to find the plugins
+ * @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 @a cb
+ */
+void
+GNUNET_PLUGIN_load_all_in_context (const struct GNUNET_OS_ProjectData *ctx,
+ const char *basename,
+ void *arg,
+ GNUNET_PLUGIN_LoaderCallback cb,
+ void *cb_cls)
+{
+ const struct GNUNET_OS_ProjectData *cpd = GNUNET_OS_project_data_get ();
+ GNUNET_OS_init (ctx);
+ GNUNET_PLUGIN_load_all (basename, arg, cb, cb_cls);
+ GNUNET_OS_init (cpd);
+}
+
+
/* end of plugin.c */