home · contact · privacy
Read interface config from one file (which can be set as command line argument)
[plomrogue] / src / client / main.c
1 /* main.c */
2
3 #include <signal.h> /* struct sigaction, sigaction() */
4 #include <stdlib.h> /* exit() */
5 #include <string.h> /* memset() */
6 #include "../common/rexit.h" /* set_cleanup_func(), exit_trouble() */
7 #include "cleanup.h" /* cleanup() */
8 #include "command_db.h" /* init_command_db() */
9 #include "io.h" /* io_loop(), try_send() */
10 #include "misc.h" /* load_interface_conf(), winch_called() */
11 #include "windows.h" /* init_wmeta_and_ncurses(); */
12 #include "world.h" /* struct World */
13
14
15
16 struct World world;
17
18
19
20 int main(int argc, char * argv[])
21 {
22     char * f_name = "main()";
23
24     /* Declare hard-coded paths here. */
25     world.path_server_in = "server/in";
26     world.path_interface_conf = "confclient/interface_conf";
27
28     /* Parse command line arguments. */
29     obey_argv(argc, argv);
30
31     /* So error exits also go through the client's cleanup() function. */
32     set_cleanup_func(cleanup);
33
34     /* Initialize the whole interface. */
35     init_wmeta_and_ncurses();
36     keypad(world.wmeta.screen, TRUE);
37     init_command_db();      /* The command DB needs to be initialized before  */
38     load_interface_conf();  /* the interface, whose keybindings depend on it. */
39
40     /* Set handler for terminal window resizing. */
41     struct sigaction act;
42     memset(&act, 0, sizeof(act));
43     act.sa_handler = &winch_called;
44     exit_trouble(sigaction(SIGWINCH, &act, NULL), f_name, "sigaction()");
45
46     /* This is where most everything happens. */
47     char * quit_msg = io_loop();
48
49     /* Leave properly. */
50     cleanup();
51     printf("%s\n", quit_msg);
52     exit(EXIT_SUCCESS);
53 }