]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
Function added to plugin_loader to get a list of the names of loaded plugins.
authorTobias Brunner <tobias@strongswan.org>
Thu, 19 Jan 2012 10:51:51 +0000 (11:51 +0100)
committerTobias Brunner <tobias@strongswan.org>
Thu, 19 Jan 2012 10:51:51 +0000 (11:51 +0100)
src/libstrongswan/plugins/plugin_loader.c
src/libstrongswan/plugins/plugin_loader.h

index 4d26a77f850b19a6820af6765fe424ae37a4099a..1747cba6e1c58befd97258df3fee94813a51fcc6 100644 (file)
@@ -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(),
index b3ad7a35fd2f9e34b9462a8437afd8a608c1ba84..0f677c2fe64a279d1ba12511649b6f8f344c28f7 100644 (file)
@@ -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.
         */