diff options
author | Martin Willi <martin@revosec.ch> | 2011-04-11 18:54:18 +0200 |
---|---|---|
committer | Martin Willi <martin@revosec.ch> | 2011-04-15 10:07:12 +0200 |
commit | 787b5884aaf873fb9fda2b0d8b7c3d54e38ae7a5 (patch) | |
tree | f8c05bcf7572117763fd50eaf315a13c2e6261d2 /src/libstrongswan/plugins/plugin_loader.c | |
parent | 6e2791715b7534b601ff5d5163d63d88ad7a8a5e (diff) | |
download | strongswan-787b5884aaf873fb9fda2b0d8b7c3d54e38ae7a5.tar.bz2 strongswan-787b5884aaf873fb9fda2b0d8b7c3d54e38ae7a5.tar.xz |
Added a get_name() function to plugin_t, create_plugin_enumerator enumerates over plugin_t
Diffstat (limited to 'src/libstrongswan/plugins/plugin_loader.c')
-rw-r--r-- | src/libstrongswan/plugins/plugin_loader.c | 25 |
1 files changed, 6 insertions, 19 deletions
diff --git a/src/libstrongswan/plugins/plugin_loader.c b/src/libstrongswan/plugins/plugin_loader.c index 222ebb928..dafe64798 100644 --- a/src/libstrongswan/plugins/plugin_loader.c +++ b/src/libstrongswan/plugins/plugin_loader.c @@ -43,11 +43,6 @@ struct private_plugin_loader_t { * list of loaded plugins */ linked_list_t *plugins; - - /** - * names of loaded plugins - */ - linked_list_t *names; }; /** @@ -151,12 +146,12 @@ static bool plugin_loaded(private_plugin_loader_t *this, char *name) { enumerator_t *enumerator; bool found = FALSE; - char *current; + plugin_t *plugin; - enumerator = this->names->create_enumerator(this->names); - while (enumerator->enumerate(enumerator, ¤t)) + enumerator = this->plugins->create_enumerator(this->plugins); + while (enumerator->enumerate(enumerator, &plugin)) { - if (streq(name, current)) + if (streq(plugin->get_name(plugin), name)) { found = TRUE; break; @@ -201,7 +196,6 @@ METHOD(plugin_loader_t, load_plugins, bool, if (plugin) { this->plugins->insert_last(this->plugins, plugin); - this->names->insert_last(this->names, token); } else { @@ -210,8 +204,8 @@ METHOD(plugin_loader_t, load_plugins, bool, critical_failed = TRUE; DBG1(DBG_LIB, "loading critical plugin '%s' failed", token); } - free(token); } + free(token); } enumerator->destroy(enumerator); return !critical_failed; @@ -221,7 +215,6 @@ METHOD(plugin_loader_t, unload, void, private_plugin_loader_t *this) { plugin_t *plugin; - char *name; /* unload plugins in reverse order */ while (this->plugins->remove_last(this->plugins, @@ -229,23 +222,18 @@ METHOD(plugin_loader_t, unload, void, { plugin->destroy(plugin); } - while (this->names->remove_last(this->names, (void**)&name) == SUCCESS) - { - free(name); - } } METHOD(plugin_loader_t, create_plugin_enumerator, enumerator_t*, private_plugin_loader_t *this) { - return this->names->create_enumerator(this->names); + return this->plugins->create_enumerator(this->plugins); } METHOD(plugin_loader_t, destroy, void, private_plugin_loader_t *this) { this->plugins->destroy_offset(this->plugins, offsetof(plugin_t, destroy)); - this->names->destroy_function(this->names, free); free(this); } @@ -264,7 +252,6 @@ plugin_loader_t *plugin_loader_create() .destroy = _destroy, }, .plugins = linked_list_create(), - .names = linked_list_create(), ); return &this->public; |