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 Affero 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.
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 * @author Christian Grothoff
23 * Plugin loading and unloading
25 * @defgroup plugin Plugin library
26 * Plugin loading and unloading
30 #ifndef GNUNET_PLUGIN_LIB_H
31 #define GNUNET_PLUGIN_LIB_H
36 #if 0 /* keep Emacsens' auto-indent happy */
41 #include "gnunet_common.h"
42 #include "gnunet_configuration_lib.h"
46 * Signature of any function exported by a plugin.
48 * @param arg argument to the function (context)
49 * @return some pointer, NULL if the plugin was
50 * shutdown or if there was an error, otherwise
51 * the plugin's API on success
54 (*GNUNET_PLUGIN_Callback) (void *arg);
58 * Test if a plugin exists.
60 * Note that the library must export a symbol called
61 * "library_name_init" for the test to succeed.
63 * @param library_name name of the plugin to test if it is installed
64 * @return #GNUNET_YES if the plugin exists, #GNUNET_NO if not
67 GNUNET_PLUGIN_test (const char *library_name);
71 * Setup plugin (runs the "init" callback and returns whatever "init"
72 * returned). If "init" returns NULL, the plugin is unloaded.
74 * Note that the library must export symbols called
75 * "library_name_init" and "library_name_done". These will be called
76 * when the library is loaded and unloaded respectively.
78 * @param library_name name of the plugin to load
79 * @param arg argument to the plugin initialization function
80 * @return whatever the initialization function returned, NULL on error
83 GNUNET_PLUGIN_load (const char *library_name,
88 * Signature of a function called by #GNUNET_PLUGIN_load_all().
91 * @param library_name full name of the library (to be used with
92 * #GNUNET_PLUGIN_unload)
93 * @param lib_ret return value from the initialization function
94 * of the library (same as what #GNUNET_PLUGIN_load would
95 * have returned for the given library name)
98 (*GNUNET_PLUGIN_LoaderCallback) (void *cls,
99 const char *library_name,
104 * Load all compatible plugins with the given base name.
106 * Note that the library must export symbols called
107 * "basename_ANYTHING_init" and "basename_ANYTHING__done". These will
108 * be called when the library is loaded and unloaded respectively.
110 * @param basename basename of the plugins to load
111 * @param arg argument to the plugin initialization function
112 * @param cb function to call for each plugin found
113 * @param cb_cls closure for @a cb
116 GNUNET_PLUGIN_load_all (const char *basename,
118 GNUNET_PLUGIN_LoaderCallback cb,
123 * Unload plugin (runs the "done" callback and returns whatever "done"
124 * returned). The plugin is then unloaded.
126 * @param library_name name of the plugin to unload
127 * @param arg argument to the plugin shutdown function
128 * @return whatever the shutdown function returned, typically NULL
129 * or a "char *" representing the error message
132 GNUNET_PLUGIN_unload (const char *library_name,
136 #if 0 /* keep Emacsens' auto-indent happy */
143 /* ifndef GNUNET_PLUGIN_LIB_H */
146 /** @} */ /* end of group */
148 /* end of gnunet_plugin_lib.h */