2 * Copyright (C) 2009 Tobias Brunner
3 * Copyright (C) 2008 Martin Willi
4 * Hochschule fuer Technik Rapperswil
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
24 #include <utils/identification.h>
25 #include <utils/host.h>
27 #include <utils/leak_detective.h>
30 typedef struct private_library_t private_library_t
;
33 * private data of library
35 struct private_library_t
{
44 * Memory leak detective, if enabled
46 leak_detective_t
*detective
;
47 #endif /* LEAK_DETECTIVE */
56 * Implementation of library_t.destroy
60 private_library_t
*this = (private_library_t
*)lib
;
62 this->public.plugins
->destroy(this->public.plugins
);
63 this->public.settings
->destroy(this->public.settings
);
64 this->public.creds
->destroy(this->public.creds
);
65 this->public.crypto
->destroy(this->public.crypto
);
66 this->public.fetcher
->destroy(this->public.fetcher
);
67 this->public.db
->destroy(this->public.db
);
68 this->public.printf_hook
->destroy(this->public.printf_hook
);
69 if (this->public.integrity
)
71 this->public.integrity
->destroy(this->public.integrity
);
77 this->detective
->destroy(this->detective
);
79 #endif /* LEAK_DETECTIVE */
87 void library_init(char *settings
)
90 private_library_t
*this = malloc_thing(private_library_t
);
93 lib
->leak_detective
= FALSE
;
96 this->detective
= leak_detective_create();
97 #endif /* LEAK_DETECTIVE */
99 pfh
= printf_hook_create();
100 this->public.printf_hook
= pfh
;
102 pfh
->add_handler(pfh
, 'b', mem_printf_hook
,
103 PRINTF_HOOK_ARGTYPE_POINTER
, PRINTF_HOOK_ARGTYPE_INT
,
104 PRINTF_HOOK_ARGTYPE_END
);
105 pfh
->add_handler(pfh
, 'B', chunk_printf_hook
,
106 PRINTF_HOOK_ARGTYPE_POINTER
, PRINTF_HOOK_ARGTYPE_END
);
107 pfh
->add_handler(pfh
, 'H', host_printf_hook
,
108 PRINTF_HOOK_ARGTYPE_POINTER
, PRINTF_HOOK_ARGTYPE_END
);
109 pfh
->add_handler(pfh
, 'N', enum_printf_hook
,
110 PRINTF_HOOK_ARGTYPE_POINTER
, PRINTF_HOOK_ARGTYPE_INT
,
111 PRINTF_HOOK_ARGTYPE_END
);
112 pfh
->add_handler(pfh
, 'T', time_printf_hook
,
113 PRINTF_HOOK_ARGTYPE_POINTER
, PRINTF_HOOK_ARGTYPE_INT
,
114 PRINTF_HOOK_ARGTYPE_END
);
115 pfh
->add_handler(pfh
, 'V', time_delta_printf_hook
,
116 PRINTF_HOOK_ARGTYPE_POINTER
, PRINTF_HOOK_ARGTYPE_POINTER
,
117 PRINTF_HOOK_ARGTYPE_END
);
118 pfh
->add_handler(pfh
, 'Y', identification_printf_hook
,
119 PRINTF_HOOK_ARGTYPE_POINTER
, PRINTF_HOOK_ARGTYPE_END
);
121 this->public.settings
= settings_create(settings
);
122 this->public.crypto
= crypto_factory_create();
123 this->public.creds
= credential_factory_create();
124 this->public.fetcher
= fetcher_manager_create();
125 this->public.db
= database_factory_create();
126 this->public.plugins
= plugin_loader_create();
127 this->public.integrity
= NULL
;
129 if (lib
->settings
->get_bool(lib
->settings
,
130 "libstrongswan.integrity_test", FALSE
))
132 this->public.integrity
= integrity_checker_create();