cleaned up whitespace
[strongswan.git] / src / libcharon / plugins / tnc_imc / tnc_imc_plugin.c
1 /*
2 * Copyright (C) 2010 Andreas Steffen
3 * 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 "tnc_imc_plugin.h"
17 #include "tnc_imc.h"
18
19 #include <daemon.h>
20
21 METHOD(plugin_t, destroy, void,
22 tnc_imc_plugin_t *this)
23 {
24 imc_t *imc;
25
26 while (charon->imcs->remove_last(charon->imcs, (void**)&imc) == SUCCESS)
27 {
28 if (imc->terminate(imc->get_id(imc)) != TNC_RESULT_SUCCESS)
29 {
30 DBG1(DBG_TNC, "IMC '%s' not terminated successfully",
31 imc->get_name(imc));
32 }
33 imc->destroy(imc);
34 }
35 free(this);
36 }
37
38 /*
39 * see header file
40 */
41 plugin_t *tnc_imc_plugin_create()
42 {
43 TNC_IMCID next_id = 1;
44 TNC_Version version;
45 char *tnc_config, *pref_lang, *name, *filename;
46 tnc_imc_plugin_t *this;
47 imc_t *imc;
48
49 INIT(this,
50 .plugin = {
51 .destroy = _destroy,
52 },
53 );
54
55 pref_lang = lib->settings->get_str(lib->settings,
56 "charon.plugins.tnc-imc.preferred_language", "en");
57 tnc_config = lib->settings->get_str(lib->settings,
58 "charon.plugins.tnc-imc.tnc_config", "/etc/tnc_config");
59
60 name = "Dummy";
61 filename = "/usr/local/lib/libdummyimc.so";
62 imc = tnc_imc_create(name, filename, next_id);
63 if (imc)
64 {
65 /* Initialize the module */
66 if (imc->initialize(next_id, TNC_IFIMC_VERSION_1, TNC_IFIMC_VERSION_1,
67 &version) != TNC_RESULT_SUCCESS)
68 {
69 DBG1(DBG_TNC, "could not initialize IMC '%s'\n",
70 imc->get_name(imc));
71 imc->destroy(imc);
72 }
73 else
74 {
75 charon->imcs->insert_last(charon->imcs, imc);
76 next_id++;
77 }
78 }
79 return &this->plugin;
80 }
81