swanctl: Be more verbose while loading connections and credentials
[strongswan.git] / src / swanctl / swanctl.c
1 /*
2 * Copyright (C) 2014 Martin Willi
3 * Copyright (C) 2014 revosec AG
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 #include "command.h"
17
18 #include <unistd.h>
19
20 #include <library.h>
21
22 /**
23 * Cleanup library atexit()
24 */
25 static void cleanup()
26 {
27 lib->processor->cancel(lib->processor);
28 library_deinit();
29 }
30
31 /**
32 * Library initialization and operation parsing
33 */
34 int main(int argc, char *argv[])
35 {
36 atexit(cleanup);
37 if (!library_init(NULL, "swanctl"))
38 {
39 exit(SS_RC_LIBSTRONGSWAN_INTEGRITY);
40 }
41 if (lib->integrity &&
42 !lib->integrity->check_file(lib->integrity, "swanctl", argv[0]))
43 {
44 fprintf(stderr, "integrity check of swanctl failed\n");
45 exit(SS_RC_DAEMON_INTEGRITY);
46 }
47 if (!lib->plugins->load(lib->plugins,
48 lib->settings->get_str(lib->settings, "swanctl.load", PLUGINS)))
49 {
50 exit(SS_RC_INITIALIZATION_FAILED);
51 }
52 dbg_default_set_level(0);
53 lib->processor->set_threads(lib->processor, 4);
54 dbg_default_set_level(0);
55
56 return command_dispatch(argc, argv);
57 }