499218904c38e80ae407d47140b5a804c59b9947
[strongswan.git] / src / pluto / plugin_list.c
1 /*
2 * Copyright (C) 2011 Martin Willi, revosec AG
3 * Copyright (C) 2011 Andreas Steffen, HSR Hochschule fuer Technik Rapperswil
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
14 */
15
16 #include <whack.h>
17 #include <log.h>
18
19 #include <library.h>
20 #include <utils/linked_list.h>
21
22 /**
23 * List loaded plugin information
24 */
25 void plugin_list(void)
26 {
27 plugin_feature_t *features, *fp;
28 enumerator_t *enumerator;
29 linked_list_t *list;
30 plugin_t *plugin;
31 int count, i;
32 bool loaded;
33 char *str;
34
35 whack_log(RC_COMMENT, " ");
36 whack_log(RC_COMMENT, "List of loaded Plugins:");
37 whack_log(RC_COMMENT, " ");
38
39 enumerator = lib->plugins->create_plugin_enumerator(lib->plugins);
40 while (enumerator->enumerate(enumerator, &plugin, &list))
41 {
42 whack_log(RC_COMMENT, "%s:", plugin->get_name(plugin));
43 if (plugin->get_features)
44 {
45 count = plugin->get_features(plugin, &features);
46 for (i = 0; i < count; i++)
47 {
48 str = plugin_feature_get_string(&features[i]);
49 switch (features[i].kind)
50 {
51 case FEATURE_PROVIDE:
52 fp = &features[i];
53 loaded = list->find_first(list, NULL,
54 (void**)&fp) == SUCCESS;
55 whack_log(RC_COMMENT, " %s%s",
56 str, loaded ? "" : " (not loaded)");
57 break;
58 case FEATURE_DEPENDS:
59 whack_log(RC_COMMENT, " %s", str);
60 break;
61 case FEATURE_SDEPEND:
62 whack_log(RC_COMMENT, " %s(soft)", str);
63 break;
64 default:
65 break;
66 }
67 free(str);
68 }
69 }
70 }
71 enumerator->destroy(enumerator);
72 }