plugin-loader: Convenience function added to add plugin dirs in build tree
authorTobias Brunner <tobias@strongswan.org>
Tue, 5 Nov 2013 16:43:20 +0000 (17:43 +0100)
committerMartin Willi <martin@revosec.ch>
Wed, 6 Nov 2013 09:31:07 +0000 (10:31 +0100)
src/libstrongswan/plugins/plugin_loader.c
src/libstrongswan/plugins/plugin_loader.h

index 5ed0a9b..c904323 100644 (file)
@@ -1170,3 +1170,22 @@ plugin_loader_t *plugin_loader_create()
 
        return &this->public;
 }
+
+/*
+ * See header
+ */
+void plugin_loader_add_plugindirs(char *basedir, char *plugins)
+{
+       enumerator_t *enumerator;
+       char *name, path[PATH_MAX], dir[64];
+
+       enumerator = enumerator_create_token(plugins, " ", "");
+       while (enumerator->enumerate(enumerator, &name))
+       {
+               snprintf(dir, sizeof(dir), "%s", name);
+               translate(dir, "-", "_");
+               snprintf(path, sizeof(path), "%s/%s/.libs", basedir, dir);
+               lib->plugins->add_path(lib->plugins, path);
+       }
+       enumerator->destroy(enumerator);
+}
index 285b339..164360c 100644 (file)
@@ -146,4 +146,13 @@ struct plugin_loader_t {
  */
 plugin_loader_t *plugin_loader_create();
 
+/**
+ * Convenience function to add plugin directories for the given plugins within
+ * the given base directory according to the conventions in the src/build tree.
+ *
+ * @param basedir      base directory
+ * @param plugins      space separated list of plugins
+ */
+void plugin_loader_add_plugindirs(char *basedir, char *plugins);
+
 #endif /** PLUGIN_LOADER_H_ @}*/