eiwd

no dbus iwd with iwctl functionality
git clone https://git.daat.foo/repos/eiwd.git
Log | Files | Refs | Submodules | README | LICENSE

main.c (1862B)


      1 /*
      2  *
      3  *  Wireless daemon for Linux
      4  *
      5  *  Copyright (C) 2013-2019  Intel Corporation. All rights reserved.
      6  *
      7  *  This library is free software; you can redistribute it and/or
      8  *  modify it under the terms of the GNU Lesser General Public
      9  *  License as published by the Free Software Foundation; either
     10  *  version 2.1 of the License, or (at your option) any later version.
     11  *
     12  *  This library is distributed in the hope that it will be useful,
     13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
     14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     15  *  Lesser General Public License for more details.
     16  *
     17  *  You should have received a copy of the GNU Lesser General Public
     18  *  License along with this library; if not, write to the Free Software
     19  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
     20  *
     21  */
     22 
     23 #ifdef HAVE_CONFIG_H
     24 #include <config.h>
     25 #endif
     26 
     27 #include <errno.h>
     28 #include <locale.h>
     29 #include <signal.h>
     30 #include <ell/ell.h>
     31 
     32 #include "client/command.h"
     33 #include "client/display.h"
     34 #include "client/dbus-proxy.h"
     35 
     36 static int exit_status = EXIT_SUCCESS;
     37 
     38 static void signal_handler(uint32_t signo, void *user_data)
     39 {
     40 	switch (signo) {
     41 	case SIGINT:
     42 	case SIGTERM:
     43 		display("Terminate\n");
     44 		exit_status = EXIT_FAILURE;
     45 		l_main_quit();
     46 		break;
     47 	}
     48 }
     49 
     50 int main(int argc, char *argv[])
     51 {
     52 	bool all_done;
     53 
     54 	setlocale(LC_CTYPE, "");
     55 
     56 	if (!l_main_init())
     57 		return EXIT_FAILURE;
     58 
     59 	l_log_set_stderr();
     60 
     61 	all_done = command_init(argv, argc);
     62 	if (all_done)
     63 		goto done;
     64 
     65 	if (command_is_interactive_mode())
     66 		display_init();
     67 
     68 	dbus_proxy_init();
     69 
     70 	l_main_run_with_signal(signal_handler, NULL);
     71 
     72 	dbus_proxy_exit();
     73 
     74 	if (command_is_interactive_mode())
     75 		display_exit();
     76 
     77 done:
     78 	if (!exit_status)
     79 		exit_status = command_get_exit_status();
     80 
     81 	command_exit();
     82 
     83 	l_main_exit();
     84 
     85 	return exit_status;
     86 }