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
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 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 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
22 * @author Christian Grothoff
25 * Plugin loading and unloading
27 * @defgroup plugin Plugin library
28 * Plugin loading and unloading
32 #ifndef GNUNET_PLUGIN_LIB_H
33 #define GNUNET_PLUGIN_LIB_H
38 #if 0 /* keep Emacsens' auto-indent happy */
43 #include "gnunet_common.h"
44 #include "gnunet_configuration_lib.h"
48 * Signature of any function exported by a plugin.
50 * @param arg argument to the function (context)
51 * @return some pointer, NULL if the plugin was
52 * shutdown or if there was an error, otherwise
53 * the plugin's API on success
56 (*GNUNET_PLUGIN_Callback) (void *arg);
60 * Test if a plugin exists.
62 * Note that the library must export a symbol called
63 * "library_name_init" for the test to succeed.
65 * @param library_name name of the plugin to test if it is installed
66 * @return #GNUNET_YES if the plugin exists, #GNUNET_NO if not
69 GNUNET_PLUGIN_test (const char *library_name);
73 * Setup plugin (runs the "init" callback and returns whatever "init"
74 * returned). If "init" returns NULL, the plugin is unloaded.
76 * Note that the library must export symbols called
77 * "library_name_init" and "library_name_done". These will be called
78 * when the library is loaded and unloaded respectively.
80 * @param library_name name of the plugin to load
81 * @param arg argument to the plugin initialization function
82 * @return whatever the initialization function returned, NULL on error
85 GNUNET_PLUGIN_load (const char *library_name,
90 * Signature of a function called by #GNUNET_PLUGIN_load_all().
93 * @param library_name full name of the library (to be used with
94 * #GNUNET_PLUGIN_unload)
95 * @param lib_ret return value from the initialization function
96 * of the library (same as what #GNUNET_PLUGIN_load would
97 * have returned for the given library name)
100 (*GNUNET_PLUGIN_LoaderCallback) (void *cls,
101 const char *library_name,
106 * Load all compatible plugins with the given base name.
108 * Note that the library must export symbols called
109 * "basename_ANYTHING_init" and "basename_ANYTHING__done". These will
110 * be called when the library is loaded and unloaded respectively.
112 * @param basename basename of the plugins to load
113 * @param arg argument to the plugin initialization function
114 * @param cb function to call for each plugin found
115 * @param cb_cls closure for @a cb
118 GNUNET_PLUGIN_load_all (const char *basename,
120 GNUNET_PLUGIN_LoaderCallback cb,
125 * Unload plugin (runs the "done" callback and returns whatever "done"
126 * returned). The plugin is then unloaded.
128 * @param library_name name of the plugin to unload
129 * @param arg argument to the plugin shutdown function
130 * @return whatever the shutdown function returned, typically NULL
131 * or a "char *" representing the error message
134 GNUNET_PLUGIN_unload (const char *library_name,
138 #if 0 /* keep Emacsens' auto-indent happy */
145 /* ifndef GNUNET_PLUGIN_LIB_H */
148 /** @} */ /* end of group */
150 /* end of gnunet_plugin_lib.h */