fixed crash if crl fetching fails
[strongswan.git] / src / manager / main.c
1 /*
2 * Copyright (C) 2007 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 * $Id$
16 */
17
18 #include <dispatcher.h>
19 #include <stdio.h>
20
21 #include "manager.h"
22 #include "storage.h"
23 #include "controller/auth_controller.h"
24 #include "controller/ikesa_controller.h"
25 #include "controller/gateway_controller.h"
26 #include "controller/control_controller.h"
27 #include "controller/config_controller.h"
28
29 #define DBFILE IPSECDIR "/manager.db"
30 #define SESSION_TIMEOUT 900
31 #define THREADS 10
32
33 int main (int arc, char *argv[])
34 {
35 dispatcher_t *dispatcher;
36 storage_t *storage;
37 char *socket = NULL;
38 bool debug = FALSE;
39
40 #ifdef FCGI_SOCKET
41 socket = FCGI_SOCKET;
42 debug = TRUE;
43 #endif /* FCGI_SOCKET */
44
45 library_init(IPSECDIR "/manager.conf");
46
47 storage = storage_create("sqlite://"DBFILE);
48 if (storage == NULL)
49 {
50 fprintf(stderr, "opening database '%s' failed.\n", DBFILE);
51 return 1;
52 }
53
54 dispatcher = dispatcher_create(socket, debug, SESSION_TIMEOUT,
55 (context_constructor_t)manager_create, storage);
56 dispatcher->add_controller(dispatcher, ikesa_controller_create, NULL);
57 dispatcher->add_controller(dispatcher, gateway_controller_create, NULL);
58 dispatcher->add_controller(dispatcher, auth_controller_create, NULL);
59 dispatcher->add_controller(dispatcher, control_controller_create, NULL);
60 dispatcher->add_controller(dispatcher, config_controller_create, NULL);
61
62 dispatcher->run(dispatcher, THREADS);
63
64 dispatcher->waitsignal(dispatcher);
65
66 dispatcher->destroy(dispatcher);
67 storage->destroy(storage);
68
69 library_deinit();
70
71 return 0;
72 }
73