Added a listplugins stroke command to show plugin features

This commit is contained in:
Martin Willi
2011-10-14 10:05:44 +02:00
parent fa7c8338ca
commit 2d2ffa58f6
5 changed files with 62 additions and 1 deletions
@@ -1206,6 +1206,57 @@ static void list_algs(FILE *out)
fprintf(out, "\n");
}
/**
* List loaded plugin information
*/
static void list_plugins(FILE *out)
{
plugin_feature_t *features, *fp;
enumerator_t *enumerator;
linked_list_t *list;
plugin_t *plugin;
int count, i;
bool loaded;
char *str;
fprintf(out, "\n");
fprintf(out, "List of loaded plugins:\n");
enumerator = lib->plugins->create_plugin_enumerator(lib->plugins);
while (enumerator->enumerate(enumerator, &plugin, &list))
{
fprintf(out, "%s:\n", plugin->get_name(plugin));
if (plugin->get_features)
{
count = plugin->get_features(plugin, &features);
for (i = 0; i < count; i++)
{
str = plugin_feature_get_string(&features[i]);
switch (features[i].kind)
{
case FEATURE_PROVIDE:
fp = &features[i];
loaded = list->find_first(list, NULL,
(void**)&fp) == SUCCESS;
fprintf(out, " %s%s\n",
str, loaded ? "" : " (not loaded)");
break;
case FEATURE_DEPENDS:
fprintf(out, " %s\n", str);
break;
case FEATURE_SDEPEND:
fprintf(out, " %s(soft)\n", str);
break;
default:
break;
}
free(str);
}
}
}
enumerator->destroy(enumerator);
}
METHOD(stroke_list_t, list, void,
private_stroke_list_t *this, stroke_msg_t *msg, FILE *out)
{
@@ -1277,6 +1328,10 @@ METHOD(stroke_list_t, list, void,
{
list_algs(out);
}
if (msg->list.flags & LIST_PLUGINS)
{
list_plugins(out);
}
}
/**