30#define LOG(kind, ...) GNUNET_log_from (kind, "util-plugin", __VA_ARGS__)
77 _ (
"Initialization of plugin mechanism failed: %s!\n"),
90 if (NULL ==
getenv (
"VALGRINDING_PLUGINS"))
113 mptr = lt_dlsym (plug->
handle,
116 mptr = lt_dlsym (plug->
handle,
120 _ (
"`%s' failed to resolve method '%s' with error: %s\n"),
138 const char *library_name)
145 opath = lt_dlgetsearchpath ();
156 lt_dlsetsearchpath (cpath);
161 lt_dlsetsearchpath (path);
165 libhandle = lt_dlopenext (library_name);
166 lt_dlsetsearchpath (opath);
173 const char *library_name)
186 if (NULL == libhandle)
196 plug.
name = (
char *) library_name;
202 lt_dlclose (libhandle);
210 lt_dlclose (libhandle);
222 const char *library_name,
237 if (NULL == libhandle)
240 _ (
"`%s' failed for library `%s' with error: %s\n"),
258 if ( (NULL ==
init) ||
261 lt_dlclose (libhandle);
287 while ( (NULL != pos) &&
288 (0 != strcmp (pos->
name,
306 if (NULL ==
getenv (
"VALGRINDING_PLUGINS"))
366 const char *slashpos;
374 while (NULL != (slashpos = strstr (libname,
376 libname = slashpos + 1;
377 n = strlen (libname);
383 (0 == strcmp (&libname[n - 3],
".la")) )
386 if (NULL != (dot = strstr (
basename,
".")))
421 _ (
"Could not determine plugin installation path.\n"));
static int ret
Final status code.
static char * init
Set to the name of a service to start.
static char * name
Name (label) of the records to list.
int GNUNET_DISK_directory_scan(const char *dir_name, GNUNET_FileNameCallback callback, void *callback_cls)
Scan a directory for files.
#define GNUNET_log(kind,...)
GNUNET_GenericReturnValue
Named constants for return values.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
@ GNUNET_ERROR_TYPE_ERROR
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
char * GNUNET_OS_installation_get_path(const struct GNUNET_OS_ProjectData *pd, enum GNUNET_OS_InstallationPathKind dirkind)
Get the path to a specific GNUnet installation directory or, with GNUNET_OS_IPK_SELF_PREFIX,...
@ GNUNET_OS_IPK_LIBDIR
Return the directory where libraries are installed.
void * GNUNET_PLUGIN_load(const struct GNUNET_OS_ProjectData *pd, const char *library_name, void *arg)
Setup plugin (runs the "init" callback and returns whatever "init" returned).
void *(* GNUNET_PLUGIN_Callback)(void *arg)
Signature of any function exported by a plugin.
enum GNUNET_GenericReturnValue GNUNET_PLUGIN_test(const struct GNUNET_OS_ProjectData *pd, const char *library_name)
Test if a plugin exists.
void GNUNET_PLUGIN_load_all(const struct GNUNET_OS_ProjectData *pd, const char *basename, void *arg, GNUNET_PLUGIN_LoaderCallback cb, void *cb_cls)
Load all compatible plugins with the given base name.
void * GNUNET_PLUGIN_unload(const char *library_name, void *arg)
Unload plugin (runs the "done" callback and returns whatever "done" returned).
void(* GNUNET_PLUGIN_LoaderCallback)(void *cls, const char *library_name, void *lib_ret)
Signature of a function called by GNUNET_PLUGIN_load_all().
static void plugin_fini(void)
Shutdown libtool.
static GNUNET_PLUGIN_Callback resolve_function(struct PluginList *plug, const char *name)
Lookup a function in the plugin.
static void plugin_init(void)
Setup libtool paths.
static enum GNUNET_GenericReturnValue find_libraries(void *cls, const char *filename)
Function called on each plugin in the directory.
static void * open_library(const struct GNUNET_OS_ProjectData *pd, const char *library_name)
Open library library_name using search path from pd.
static struct PluginList * plugins
List of plugins we have loaded.
static int initialized
Have we been initialized?
Project-specific data used to help the OS subsystem find installation paths.
Closure for find_libraries().
const char * basename
Prefix the plugin names we find have to match.
void * cb_cls
Closure for cb.
const struct GNUNET_OS_ProjectData * pd
Project data to determine load paths.
void * arg
Argument to give to 'init' when loading the plugin.
GNUNET_PLUGIN_LoaderCallback cb
Function to call for each plugin.
Linked list of active plugins.
char * name
Name of the library.
struct PluginList * next
This is a linked list.
void * handle
System handle.