Include library.h in plugin.h
[strongswan.git] / src / libstrongswan / library.h
1 /*
2 * Copyright (C) 2008 Martin Willi
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 /**
17 * @defgroup libstrongswan libstrongswan
18 *
19 * @defgroup asn1 asn1
20 * @ingroup libstrongswan
21 *
22 * @defgroup bio bio
23 * @ingroup libstrongswan
24 *
25 * @defgroup credentials credentials
26 * @ingroup libstrongswan
27 *
28 * @defgroup keys keys
29 * @ingroup credentials
30 *
31 * @defgroup certificates certificates
32 * @ingroup credentials
33 *
34 * @defgroup sets sets
35 * @ingroup credentials
36 *
37 * @defgroup crypto crypto
38 * @ingroup libstrongswan
39 *
40 * @defgroup database database
41 * @ingroup libstrongswan
42 *
43 * @defgroup fetcher fetcher
44 * @ingroup libstrongswan
45 *
46 * @defgroup plugins plugins
47 * @ingroup libstrongswan
48 *
49 * @defgroup processing processing
50 * @ingroup libstrongswan
51 *
52 * @defgroup jobs jobs
53 * @ingroup processing
54 *
55 * @defgroup threading threading
56 * @ingroup libstrongswan
57 *
58 * @defgroup utils utils
59 * @ingroup libstrongswan
60 */
61
62 /**
63 * @defgroup library library
64 * @{ @ingroup libstrongswan
65 */
66
67 #ifndef LIBRARY_H_
68 #define LIBRARY_H_
69
70 #include "printf_hook.h"
71 #include "utils.h"
72 #include "chunk.h"
73 #include "settings.h"
74 #include "integrity_checker.h"
75 #include "processing/processor.h"
76 #include "processing/scheduler.h"
77 #include "crypto/crypto_factory.h"
78 #include "fetcher/fetcher_manager.h"
79 #include "database/database_factory.h"
80 #include "credentials/credential_factory.h"
81 #include "credentials/credential_manager.h"
82 #include "credentials/cred_encoding.h"
83 #include "utils/leak_detective.h"
84 #include "plugins/plugin_loader.h"
85
86 typedef struct library_t library_t;
87
88 /**
89 * Libstrongswan library context, contains library relevant globals.
90 */
91 struct library_t {
92
93 /**
94 * Get an arbitrary object registered by name.
95 *
96 * @param name name of the object to get
97 * @return object, NULL if none found
98 */
99 void* (*get)(library_t *this, char *name);
100
101 /**
102 * (Un-)Register an arbitrary object using the given name.
103 *
104 * @param name name to register object under
105 * @param object object to register, NULL to unregister
106 * @return TRUE if registered, FALSE if name already taken
107 */
108 bool (*set)(library_t *this, char *name, void *object);
109
110 /**
111 * Printf hook registering facility
112 */
113 printf_hook_t *printf_hook;
114
115 /**
116 * crypto algorithm registry and factory
117 */
118 crypto_factory_t *crypto;
119
120 /**
121 * credential constructor registry and factory
122 */
123 credential_factory_t *creds;
124
125 /**
126 * Manager for the credential set backends
127 */
128 credential_manager_t *credmgr;
129
130 /**
131 * Credential encoding registry and factory
132 */
133 cred_encoding_t *encoding;
134
135 /**
136 * URL fetching facility
137 */
138 fetcher_manager_t *fetcher;
139
140 /**
141 * database construction factory
142 */
143 database_factory_t *db;
144
145 /**
146 * plugin loading facility
147 */
148 plugin_loader_t *plugins;
149
150 /**
151 * process jobs using a thread pool
152 */
153 processor_t *processor;
154
155 /**
156 * schedule jobs
157 */
158 scheduler_t *scheduler;
159
160 /**
161 * various settings loaded from settings file
162 */
163 settings_t *settings;
164
165 /**
166 * integrity checker to verify code integrity
167 */
168 integrity_checker_t *integrity;
169
170 /**
171 * Leak detective, if built and enabled
172 */
173 leak_detective_t *leak_detective;
174 };
175
176 /**
177 * Initialize library, creates "lib" instance.
178 *
179 * @param settings file to read settings from, may be NULL for default
180 * @return FALSE if integrity check failed
181 */
182 bool library_init(char *settings);
183
184 /**
185 * Deinitialize library, destroys "lib" instance.
186 */
187 void library_deinit();
188
189 /**
190 * Library instance, set after library_init() and before library_deinit() calls.
191 */
192 extern library_t *lib;
193
194 #endif /** LIBRARY_H_ @}*/