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
23 #include <utils/identification.h>
24 #include <utils/host.h>
26 #include <utils/leak_detective.h>
29 typedef struct private_library_t private_library_t
;
32 * private data of library
34 struct private_library_t
{
43 * Memory leak detective, if enabled
45 leak_detective_t
*detective
;
46 #endif /* LEAK_DETECTIVE */
55 * Implementation of library_t.destroy
59 private_library_t
*this = (private_library_t
*)lib
;
61 this->public.plugins
->destroy(this->public.plugins
);
62 this->public.settings
->destroy(this->public.settings
);
63 this->public.creds
->destroy(this->public.creds
);
64 this->public.crypto
->destroy(this->public.crypto
);
65 this->public.fetcher
->destroy(this->public.fetcher
);
66 this->public.db
->destroy(this->public.db
);
67 this->public.printf_hook
->destroy(this->public.printf_hook
);
72 this->detective
->destroy(this->detective
);
74 #endif /* LEAK_DETECTIVE */
82 void library_init(char *settings
)
85 private_library_t
*this = malloc_thing(private_library_t
);
88 lib
->leak_detective
= FALSE
;
91 this->detective
= leak_detective_create();
92 #endif /* LEAK_DETECTIVE */
94 pfh
= printf_hook_create();
95 this->public.printf_hook
= pfh
;
97 pfh
->add_handler(pfh
, 'b', mem_printf_hook
,
98 PRINTF_HOOK_ARGTYPE_POINTER
, PRINTF_HOOK_ARGTYPE_INT
,
99 PRINTF_HOOK_ARGTYPE_END
);
100 pfh
->add_handler(pfh
, 'B', chunk_printf_hook
,
101 PRINTF_HOOK_ARGTYPE_POINTER
, PRINTF_HOOK_ARGTYPE_END
);
102 pfh
->add_handler(pfh
, 'H', host_printf_hook
,
103 PRINTF_HOOK_ARGTYPE_POINTER
, PRINTF_HOOK_ARGTYPE_END
);
104 pfh
->add_handler(pfh
, 'N', enum_printf_hook
,
105 PRINTF_HOOK_ARGTYPE_POINTER
, PRINTF_HOOK_ARGTYPE_INT
,
106 PRINTF_HOOK_ARGTYPE_END
);
107 pfh
->add_handler(pfh
, 'T', time_printf_hook
,
108 PRINTF_HOOK_ARGTYPE_POINTER
, PRINTF_HOOK_ARGTYPE_INT
,
109 PRINTF_HOOK_ARGTYPE_END
);
110 pfh
->add_handler(pfh
, 'V', time_delta_printf_hook
,
111 PRINTF_HOOK_ARGTYPE_POINTER
, PRINTF_HOOK_ARGTYPE_POINTER
,
112 PRINTF_HOOK_ARGTYPE_END
);
113 pfh
->add_handler(pfh
, 'Y', identification_printf_hook
,
114 PRINTF_HOOK_ARGTYPE_POINTER
, PRINTF_HOOK_ARGTYPE_END
);
116 this->public.settings
= settings_create(settings
);
117 this->public.crypto
= crypto_factory_create();
118 this->public.creds
= credential_factory_create();
119 this->public.fetcher
= fetcher_manager_create();
120 this->public.db
= database_factory_create();
121 this->public.plugins
= plugin_loader_create();