mirror of
https://github.com/strongswan/strongswan.git
synced 2025-10-07 00:01:49 -04:00
Function added to plugin_loader to get a list of the names of loaded plugins.
This commit is contained in:
parent
498d172c33
commit
ad1aaf4be3
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2010 Tobias Brunner
|
||||
* Copyright (C) 2010-2012 Tobias Brunner
|
||||
* Copyright (C) 2007 Martin Willi
|
||||
* Hochschule fuer Technik Rapperswil
|
||||
*
|
||||
@ -606,6 +606,30 @@ METHOD(plugin_loader_t, reload, u_int,
|
||||
return reloaded;
|
||||
}
|
||||
|
||||
METHOD(plugin_loader_t, loaded_plugins, char*,
|
||||
private_plugin_loader_t *this)
|
||||
{
|
||||
#define BUF_LEN 512
|
||||
char *buf = malloc(BUF_LEN);
|
||||
int len = 0;
|
||||
enumerator_t *enumerator;
|
||||
plugin_t *plugin;
|
||||
|
||||
buf[0] = '\0';
|
||||
enumerator = create_plugin_enumerator(this);
|
||||
while (len < BUF_LEN && enumerator->enumerate(enumerator, &plugin, NULL))
|
||||
{
|
||||
len += snprintf(&buf[len], BUF_LEN - len, "%s ",
|
||||
plugin->get_name(plugin));
|
||||
}
|
||||
enumerator->destroy(enumerator);
|
||||
if (len > 0 && buf[len - 1] == ' ')
|
||||
{
|
||||
buf[len - 1] = '\0';
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
METHOD(plugin_loader_t, destroy, void,
|
||||
private_plugin_loader_t *this)
|
||||
{
|
||||
@ -627,6 +651,7 @@ plugin_loader_t *plugin_loader_create()
|
||||
.reload = _reload,
|
||||
.unload = _unload,
|
||||
.create_plugin_enumerator = _create_plugin_enumerator,
|
||||
.loaded_plugins = _loaded_plugins,
|
||||
.destroy = _destroy,
|
||||
},
|
||||
.plugins = linked_list_create(),
|
||||
|
@ -1,4 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2012 Tobias Brunner
|
||||
* Copyright (C) 2007 Martin Willi
|
||||
* Hochschule fuer Technik Rapperswil
|
||||
*
|
||||
@ -67,6 +68,13 @@ struct plugin_loader_t {
|
||||
*/
|
||||
enumerator_t* (*create_plugin_enumerator)(plugin_loader_t *this);
|
||||
|
||||
/**
|
||||
* Get a simple list the names of all loaded plugins.
|
||||
*
|
||||
* @return list of the names of all loaded plugins (allocated)
|
||||
*/
|
||||
char* (*loaded_plugins)(plugin_loader_t *this);
|
||||
|
||||
/**
|
||||
* Unload loaded plugins, destroy plugin_loader instance.
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user