Respect line with in Makefile.am's, other cosmetics
[strongswan.git] / src / libhydra / hydra.c
1 /*
2 * Copyright (C) 2010 Tobias Brunner
3 * 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 "hydra.h"
17
18 #include <debug.h>
19
20 typedef struct private_hydra_t private_hydra_t;
21
22 /**
23 * Private additions to hydra_t.
24 */
25 struct private_hydra_t {
26
27 /**
28 * Public members of hydra_t.
29 */
30 hydra_t public;
31 };
32
33 /**
34 * Single instance of hydra_t.
35 */
36 hydra_t *hydra;
37
38 /**
39 * Described in header.
40 */
41 void libhydra_deinit()
42 {
43 private_hydra_t *this = (private_hydra_t*)hydra;
44 this->public.attributes->destroy(this->public.attributes);
45 free(this);
46 hydra = NULL;
47 }
48
49 /**
50 * Described in header.
51 */
52 bool libhydra_init()
53 {
54 private_hydra_t *this;
55
56 INIT(this,
57 .public = {
58 .attributes = attribute_manager_create(),
59 },
60 );
61 hydra = &this->public;
62
63 if (lib->integrity &&
64 !lib->integrity->check(lib->integrity, "libhydra", libhydra_init))
65 {
66 DBG1("integrity check of libhydra failed");
67 return FALSE;
68 }
69 return TRUE;
70 }
71