2 This file is part of GNUnet.
3 Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 Christian Grothoff (and other contributing authors)
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
55 typedef void *(*GNUNET_PLUGIN_Callback) (void *arg);
59 * Test if a plugin exists.
61 * Note that the library must export a symbol called
62 * "library_name_init" for the test to succeed.
64 * @param library_name name of the plugin to test if it is installed
65 * @return #GNUNET_YES if the plugin exists, #GNUNET_NO if not
68 GNUNET_PLUGIN_test (const char *library_name);
72 * Setup plugin (runs the "init" callback and returns whatever "init"
73 * returned). If "init" returns NULL, the plugin is unloaded.
75 * Note that the library must export symbols called
76 * "library_name_init" and "library_name_done". These will be called
77 * when the library is loaded and unloaded respectively.
79 * @param library_name name of the plugin to load
80 * @param arg argument to the plugin initialization function
81 * @return whatever the initialization function returned, NULL on error
84 GNUNET_PLUGIN_load (const char *library_name, void *arg);
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)
97 typedef void (*GNUNET_PLUGIN_LoaderCallback) (void *cls,
98 const char *library_name,
103 * Load all compatible plugins with the given base name.
105 * Note that the library must export symbols called
106 * "basename_ANYTHING_init" and "basename_ANYTHING__done". These will
107 * be called when the library is loaded and unloaded respectively.
109 * @param basename basename of the plugins to load
110 * @param arg argument to the plugin initialization function
111 * @param cb function to call for each plugin found
112 * @param cb_cls closure for @a cb
115 GNUNET_PLUGIN_load_all (const char *basename, void *arg,
116 GNUNET_PLUGIN_LoaderCallback cb, void *cb_cls);
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, void *arg);
132 #if 0 /* keep Emacsens' auto-indent happy */
139 /* ifndef GNUNET_PLUGIN_LIB_H */
142 /** @} */ /* end of group */
144 /* end of gnunet_plugin_lib.h */