added missing enumerator implementation
[strongswan.git] / src / manager / main.c
1 /**
2 * @file main.c
3 *
4 * @brief Implementation of dispatcher_t.
5 *
6 */
7
8 /*
9 * Copyright (C) 2007 Martin Willi
10 * Hochschule fuer Technik Rapperswil
11 *
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 * for more details.
21 */
22
23 #include <dispatcher.h>
24 #include <stdio.h>
25
26 #include "manager.h"
27 #include "database.h"
28 #include "controller/auth_controller.h"
29 #include "controller/status_controller.h"
30 #include "controller/gateway_controller.h"
31
32 #define DBFILE IPSECDIR "/manager.db"
33 #define SESSION_TIMEOUT 180
34 #define THREADS 10
35
36 int main (int arc, char *argv[])
37 {
38 dispatcher_t *dispatcher;
39 database_t *database;
40 char *socket = NULL;
41
42 #ifdef FCGI_SOCKET
43 socket = FCGI_SOCKET;
44 #endif /* FCGI_SOCKET */
45
46 database = database_create(DBFILE);
47 if (database == NULL)
48 {
49 fprintf(stderr, "opening database '%s' failed.\n", DBFILE);
50 return 1;
51 }
52
53 dispatcher = dispatcher_create(socket, SESSION_TIMEOUT,
54 (context_constructor_t)manager_create, database);
55 dispatcher->add_controller(dispatcher, status_controller_create, NULL);
56 dispatcher->add_controller(dispatcher, gateway_controller_create, NULL);
57 dispatcher->add_controller(dispatcher, auth_controller_create, NULL);
58
59 dispatcher->run(dispatcher, THREADS, NULL, NULL, NULL, NULL);
60
61 dispatcher->waitsignal(dispatcher);
62
63 dispatcher->destroy(dispatcher);
64 database->destroy(database);
65
66 return 0;
67 }
68