using token enumerator to parser plugin list
This commit is contained in:
@@ -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)
|
static int load(private_plugin_loader_t *this, char *path, char *list)
|
||||||
{
|
{
|
||||||
plugin_t *plugin;
|
plugin_t *plugin;
|
||||||
char *pos;
|
enumerator_t *enumerator;
|
||||||
|
char *token;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
list = strdupa(list);
|
enumerator = enumerator_create_token(list, " ", " ");
|
||||||
while (TRUE)
|
while (enumerator->enumerate(enumerator, &token))
|
||||||
{
|
{
|
||||||
/* eat any whitespace in front */
|
plugin = load_plugin(this, path, token);
|
||||||
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);
|
|
||||||
if (plugin)
|
if (plugin)
|
||||||
{ /* insert in front to destroy them in reverse order */
|
{ /* insert in front to destroy them in reverse order */
|
||||||
this->plugins->insert_last(this->plugins, plugin);
|
this->plugins->insert_last(this->plugins, plugin);
|
||||||
this->names->insert_last(this->names, strdup(list));
|
this->names->insert_last(this->names, strdup(token));
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
if (pos)
|
|
||||||
{
|
|
||||||
list = pos;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
enumerator->destroy(enumerator);
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user