File: main.c

package info (click to toggle)
iwd 3.10-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 8,112 kB
  • sloc: ansic: 140,705; sh: 4,960; makefile: 714
file content (86 lines) | stat: -rw-r--r-- 1,862 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*
 *
 *  Wireless daemon for Linux
 *
 *  Copyright (C) 2013-2019  Intel Corporation. All rights reserved.
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License as published by the Free Software Foundation; either
 *  version 2.1 of the License, or (at your option) any later version.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 */

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <errno.h>
#include <locale.h>
#include <signal.h>
#include <ell/ell.h>

#include "client/command.h"
#include "client/display.h"
#include "client/dbus-proxy.h"

static int exit_status = EXIT_SUCCESS;

static void signal_handler(uint32_t signo, void *user_data)
{
	switch (signo) {
	case SIGINT:
	case SIGTERM:
		display("Terminate\n");
		exit_status = EXIT_FAILURE;
		l_main_quit();
		break;
	}
}

int main(int argc, char *argv[])
{
	bool all_done;

	setlocale(LC_CTYPE, "");

	if (!l_main_init())
		return EXIT_FAILURE;

	l_log_set_stderr();

	all_done = command_init(argv, argc);
	if (all_done)
		goto done;

	if (command_is_interactive_mode())
		display_init();

	dbus_proxy_init();

	l_main_run_with_signal(signal_handler, NULL);

	dbus_proxy_exit();

	if (command_is_interactive_mode())
		display_exit();

done:
	if (!exit_status)
		exit_status = command_get_exit_status();

	command_exit();

	l_main_exit();

	return exit_status;
}