Annotation of embedaddon/strongswan/src/medsrv/main.c, revision 1.1.1.1

1.1       misho       1: /*
                      2:  * Copyright (C) 2008 Martin Willi
                      3:  * Copyright (C) 2008 Philip Boetschi, Adrian Doerig
                      4:  * HSR Hochschule fuer Technik Rapperswil
                      5:  *
                      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>.
                     10:  *
                     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
                     14:  * for more details.
                     15:  */
                     16: 
                     17: #include <stdio.h>
                     18: 
                     19: #include <fast_dispatcher.h>
                     20: #include <utils/debug.h>
                     21: #include <database/database.h>
                     22: 
                     23: #include "filter/auth_filter.h"
                     24: #include "controller/user_controller.h"
                     25: #include "controller/peer_controller.h"
                     26: 
                     27: int main(int arc, char *argv[])
                     28: {
                     29:        fast_dispatcher_t *dispatcher;
                     30:        database_t *db;
                     31:        char *socket;
                     32:        bool debug;
                     33:        char *uri;
                     34:        int timeout, threads;
                     35: 
                     36:        library_init(NULL, "medsrv");
                     37:        if (!lib->plugins->load(lib->plugins,
                     38:                        lib->settings->get_str(lib->settings, "medsrv.load", PLUGINS)))
                     39:        {
                     40:                return 1;
                     41:        }
                     42: 
                     43:        socket = lib->settings->get_str(lib->settings, "medsrv.socket", NULL);
                     44:        debug = lib->settings->get_bool(lib->settings, "medsrv.debug", FALSE);
                     45:        timeout = lib->settings->get_time(lib->settings, "medsrv.timeout", 900);
                     46:        threads = lib->settings->get_int(lib->settings, "medsrv.threads", 5);
                     47:        uri = lib->settings->get_str(lib->settings, "medsrv.database", NULL);
                     48:        if (uri == NULL)
                     49:        {
                     50:                fprintf(stderr, "database URI medsrv.database not defined.\n");
                     51:                return 1;
                     52:        }
                     53: 
                     54:        db = lib->db->create(lib->db, uri);
                     55:        if (db == NULL)
                     56:        {
                     57:                fprintf(stderr, "opening database failed.\n");
                     58:                return 1;
                     59:        }
                     60: 
                     61:        dispatcher = fast_dispatcher_create(socket, debug, timeout,
                     62:                                        (fast_context_constructor_t)user_create, db);
                     63:        dispatcher->add_filter(dispatcher,
                     64:                                        (fast_filter_constructor_t)auth_filter_create, db);
                     65:        dispatcher->add_controller(dispatcher,
                     66:                                        (fast_controller_constructor_t)user_controller_create, db);
                     67:        dispatcher->add_controller(dispatcher,
                     68:                                        (fast_controller_constructor_t)peer_controller_create, db);
                     69: 
                     70:        dispatcher->run(dispatcher, threads);
                     71: 
                     72:        dispatcher->waitsignal(dispatcher);
                     73:        dispatcher->destroy(dispatcher);
                     74:        db->destroy(db);
                     75: 
                     76:        library_deinit();
                     77:        return 0;
                     78: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>