aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTobias Brunner <tobias@strongswan.org>2010-03-01 16:07:07 +0100
committerTobias Brunner <tobias@strongswan.org>2010-03-02 09:10:32 +0100
commit3724668b3d37df67f687cb718ded7fa87c748deb (patch)
tree6bff88499165bc0980fb6c6506d96a91059a2b12 /src
parent3372ad144b5e4edbc7c81989b3db38b5b74e694d (diff)
downloadstrongswan-3724668b3d37df67f687cb718ded7fa87c748deb.tar.bz2
strongswan-3724668b3d37df67f687cb718ded7fa87c748deb.tar.xz
Enabling the plugin loader to be able to load plugins without explicitly loading a shared object file first.
Diffstat (limited to 'src')
-rw-r--r--src/libstrongswan/plugins/plugin_loader.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/libstrongswan/plugins/plugin_loader.c b/src/libstrongswan/plugins/plugin_loader.c
index fb970b4d7..5dfeb873f 100644
--- a/src/libstrongswan/plugins/plugin_loader.c
+++ b/src/libstrongswan/plugins/plugin_loader.c
@@ -67,6 +67,40 @@ static char* sanitize(char *str)
return str;
}
+#ifdef MONOLITHIC
+/**
+ * load a single plugin in monolithic mode
+ */
+static plugin_t* load_plugin(private_plugin_loader_t *this,
+ char *path, char *name)
+{
+ char create[128];
+ plugin_t *plugin;
+ plugin_constructor_t constructor;
+
+ if (snprintf(create, sizeof(create), "%s_plugin_create",
+ name) >= sizeof(create))
+ {
+ return NULL;
+ }
+ sanitize(create);
+ constructor = dlsym(RTLD_DEFAULT, create);
+ if (constructor == NULL)
+ {
+ DBG1("plugin '%s': failed to load - %s not found", name, create);
+ return NULL;
+ }
+ plugin = constructor();
+ if (plugin == NULL)
+ {
+ DBG1("plugin '%s': failed to load - %s returned NULL", name, create);
+ return NULL;
+ }
+ DBG2("plugin '%s': loaded successfully", name);
+
+ return plugin;
+}
+#else
/**
* load a single plugin
*/
@@ -131,6 +165,7 @@ static plugin_t* load_plugin(private_plugin_loader_t *this,
* the modules to keep loaded until leak report */
return plugin;
}
+#endif
/**
* Implementation of plugin_loader_t.load_plugins.
@@ -141,10 +176,12 @@ static bool load(private_plugin_loader_t *this, char *path, char *list)
char *token;
bool critical_failed = FALSE;
+#ifndef MONOLITHIC
if (path == NULL)
{
path = PLUGINDIR;
}
+#endif
enumerator = enumerator_create_token(list, " ", " ");
while (!critical_failed && enumerator->enumerate(enumerator, &token))