2 This file is part of GNUnet.
3 Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 GNUnet e.V.
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
17 * @author Christian Grothoff
20 * Plugin loading and unloading
22 * @defgroup plugin Plugin library
23 * Plugin loading and unloading
27 #ifndef GNUNET_PLUGIN_LIB_H
28 #define GNUNET_PLUGIN_LIB_H
33 #if 0 /* keep Emacsens' auto-indent happy */
38 #include "gnunet_common.h"
39 #include "gnunet_configuration_lib.h"
43 * Signature of any function exported by a plugin.
45 * @param arg argument to the function (context)
46 * @return some pointer, NULL if the plugin was
47 * shutdown or if there was an error, otherwise
48 * the plugin's API on success
51 (*GNUNET_PLUGIN_Callback) (void *arg);
55 * Test if a plugin exists.
57 * Note that the library must export a symbol called
58 * "library_name_init" for the test to succeed.
60 * @param library_name name of the plugin to test if it is installed
61 * @return #GNUNET_YES if the plugin exists, #GNUNET_NO if not
64 GNUNET_PLUGIN_test (const char *library_name);
68 * Setup plugin (runs the "init" callback and returns whatever "init"
69 * returned). If "init" returns NULL, the plugin is unloaded.
71 * Note that the library must export symbols called
72 * "library_name_init" and "library_name_done". These will be called
73 * when the library is loaded and unloaded respectively.
75 * @param library_name name of the plugin to load
76 * @param arg argument to the plugin initialization function
77 * @return whatever the initialization function returned, NULL on error
80 GNUNET_PLUGIN_load (const char *library_name,
85 * Signature of a function called by #GNUNET_PLUGIN_load_all().
88 * @param library_name full name of the library (to be used with
89 * #GNUNET_PLUGIN_unload)
90 * @param lib_ret return value from the initialization function
91 * of the library (same as what #GNUNET_PLUGIN_load would
92 * have returned for the given library name)
95 (*GNUNET_PLUGIN_LoaderCallback) (void *cls,
96 const char *library_name,
101 * Load all compatible plugins with the given base name.
103 * Note that the library must export symbols called
104 * "basename_ANYTHING_init" and "basename_ANYTHING__done". These will
105 * be called when the library is loaded and unloaded respectively.
107 * @param basename basename of the plugins to load
108 * @param arg argument to the plugin initialization function
109 * @param cb function to call for each plugin found
110 * @param cb_cls closure for @a cb
113 GNUNET_PLUGIN_load_all (const char *basename,
115 GNUNET_PLUGIN_LoaderCallback cb,
120 * Unload plugin (runs the "done" callback and returns whatever "done"
121 * returned). The plugin is then unloaded.
123 * @param library_name name of the plugin to unload
124 * @param arg argument to the plugin shutdown function
125 * @return whatever the shutdown function returned, typically NULL
126 * or a "char *" representing the error message
129 GNUNET_PLUGIN_unload (const char *library_name,
133 #if 0 /* keep Emacsens' auto-indent happy */
140 /* ifndef GNUNET_PLUGIN_LIB_H */
143 /** @} */ /* end of group */
145 /* end of gnunet_plugin_lib.h */