2014-05-11 19:43:23 +02:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Wireless daemon for Linux
|
|
|
|
*
|
2017-03-22 23:21:12 +01:00
|
|
|
* Copyright (C) 2013-2017 Intel Corporation. All rights reserved.
|
2014-05-11 19:43:23 +02:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
|
2018-08-03 23:35:41 +02:00
|
|
|
#include <errno.h>
|
2018-11-01 22:09:19 +01:00
|
|
|
#include <signal.h>
|
2014-05-21 06:45:03 +02:00
|
|
|
#include <ell/ell.h>
|
|
|
|
|
2017-04-12 22:04:52 +02:00
|
|
|
#include "command.h"
|
2017-03-24 00:32:11 +01:00
|
|
|
#include "display.h"
|
2017-03-23 17:48:56 +01:00
|
|
|
#include "dbus-proxy.h"
|
|
|
|
|
2018-11-01 20:48:03 +01:00
|
|
|
static void signal_handler(uint32_t signo, void *user_data)
|
2016-04-02 01:05:42 +02:00
|
|
|
{
|
|
|
|
switch (signo) {
|
|
|
|
case SIGINT:
|
|
|
|
case SIGTERM:
|
2019-04-05 19:46:58 +02:00
|
|
|
display("Terminate\n");
|
2016-04-02 01:05:42 +02:00
|
|
|
l_main_quit();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-11 19:43:23 +02:00
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
2014-05-21 06:45:03 +02:00
|
|
|
int exit_status;
|
2019-09-17 23:09:11 +02:00
|
|
|
bool all_done;
|
2016-04-02 01:05:42 +02:00
|
|
|
|
2016-06-09 00:39:35 +02:00
|
|
|
if (!l_main_init())
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
|
2014-05-21 06:45:03 +02:00
|
|
|
l_log_set_stderr();
|
|
|
|
|
2019-09-17 23:09:11 +02:00
|
|
|
all_done = command_init(argv, argc);
|
|
|
|
if (all_done)
|
2019-08-15 20:40:39 +02:00
|
|
|
goto done;
|
|
|
|
|
2019-09-17 23:09:11 +02:00
|
|
|
if (command_is_interactive_mode())
|
2018-08-03 23:35:41 +02:00
|
|
|
display_init();
|
|
|
|
|
2017-03-23 17:48:56 +01:00
|
|
|
dbus_proxy_init();
|
|
|
|
|
2018-11-01 20:48:03 +01:00
|
|
|
l_main_run_with_signal(signal_handler, NULL);
|
2014-05-21 06:45:03 +02:00
|
|
|
|
2017-03-23 17:48:56 +01:00
|
|
|
dbus_proxy_exit();
|
2018-08-03 23:35:41 +02:00
|
|
|
|
2019-09-17 23:09:11 +02:00
|
|
|
if (command_is_interactive_mode())
|
2018-08-03 23:35:41 +02:00
|
|
|
display_exit();
|
|
|
|
|
2019-08-15 20:40:39 +02:00
|
|
|
done:
|
2019-09-17 23:09:11 +02:00
|
|
|
exit_status = command_get_exit_status();
|
|
|
|
|
2017-04-12 22:04:52 +02:00
|
|
|
command_exit();
|
2017-03-23 17:48:56 +01:00
|
|
|
|
2016-06-09 00:39:35 +02:00
|
|
|
l_main_exit();
|
|
|
|
|
2014-05-21 06:45:03 +02:00
|
|
|
return exit_status;
|
2014-05-11 19:43:23 +02:00
|
|
|
}
|