aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Brunner <tobias@strongswan.org>2012-01-19 11:51:51 +0100
committerTobias Brunner <tobias@strongswan.org>2012-01-19 11:51:51 +0100
commitad1aaf4be37e70f29421df1c1a288b0c40756641 (patch)
treea4fbb4d6091bf1a1d82d2f50394240338641afbd
parent498d172c333c7b47e3151362ce19763f6e3ad679 (diff)
downloadstrongswan-ad1aaf4be37e70f29421df1c1a288b0c40756641.tar.bz2
strongswan-ad1aaf4be37e70f29421df1c1a288b0c40756641.tar.xz
Function added to plugin_loader to get a list of the names of loaded plugins.
-rw-r--r--src/libstrongswan/plugins/plugin_loader.c27
-rw-r--r--src/libstrongswan/plugins/plugin_loader.h8
2 files changed, 34 insertions, 1 deletions
diff --git a/src/libstrongswan/plugins/plugin_loader.c b/src/libstrongswan/plugins/plugin_loader.c
index 4d26a77f8..1747cba6e 100644
--- a/src/libstrongswan/plugins/plugin_loader.c
+++ b/src/libstrongswan/plugins/plugin_loader.c
@@ -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(),
diff --git a/src/libstrongswan/plugins/plugin_loader.h b/src/libstrongswan/plugins/plugin_loader.h
index b3ad7a35f..0f677c2fe 100644
--- a/src/libstrongswan/plugins/plugin_loader.h
+++ b/src/libstrongswan/plugins/plugin_loader.h
@@ -1,4 +1,5 @@
/*
+ * Copyright (C) 2012 Tobias Brunner
* Copyright (C) 2007 Martin Willi
* Hochschule fuer Technik Rapperswil
*
@@ -68,6 +69,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.
*/
void (*destroy)(plugin_loader_t *this);