diff options
author | Martin Willi <martin@strongswan.org> | 2008-07-02 08:19:43 +0000 |
---|---|---|
committer | Martin Willi <martin@strongswan.org> | 2008-07-02 08:19:43 +0000 |
commit | 11e855179e94c1cbc6580c19d499e9aaca0d48cf (patch) | |
tree | e2497a78b7f27ddf6c2bc318a4f594fb6c83d3e6 /src | |
parent | 5848e473e81ed2b48924b331d60feee5f21a1916 (diff) | |
download | strongswan-11e855179e94c1cbc6580c19d499e9aaca0d48cf.tar.bz2 strongswan-11e855179e94c1cbc6580c19d499e9aaca0d48cf.tar.xz |
using token enumerator to parser plugin list
Diffstat (limited to 'src')
-rw-r--r-- | src/libstrongswan/plugins/plugin_loader.c | 35 |
1 files changed, 7 insertions, 28 deletions
diff --git a/src/libstrongswan/plugins/plugin_loader.c b/src/libstrongswan/plugins/plugin_loader.c index b19a6af0d..b2d4d66b2 100644 --- a/src/libstrongswan/plugins/plugin_loader.c +++ b/src/libstrongswan/plugins/plugin_loader.c @@ -96,43 +96,22 @@ static plugin_t* load_plugin(private_plugin_loader_t *this, static int load(private_plugin_loader_t *this, char *path, char *list) { plugin_t *plugin; - char *pos; + enumerator_t *enumerator; + char *token; int count = 0; - list = strdupa(list); - while (TRUE) + enumerator = enumerator_create_token(list, " ", " "); + while (enumerator->enumerate(enumerator, &token)) { - /* eat any whitespace in front */ - while (*list == ' ') - { - list++; - } - /* have we reached the end of the list? */ - if (!*list) - { - break; - } - pos = strchr(list, ' '); - if (pos) - { - *pos++ = '\0'; - } - plugin = load_plugin(this, path, list); + plugin = load_plugin(this, path, token); if (plugin) { /* insert in front to destroy them in reverse order */ this->plugins->insert_last(this->plugins, plugin); - this->names->insert_last(this->names, strdup(list)); + this->names->insert_last(this->names, strdup(token)); count++; } - if (pos) - { - list = pos; - } - else - { - break; - } } + enumerator->destroy(enumerator); return count; } |