diff options
Diffstat (limited to 'src/application.c')
-rw-r--r-- | src/application.c | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/src/application.c b/src/application.c new file mode 100644 index 0000000..78d5a77 --- /dev/null +++ b/src/application.c | |||
@@ -0,0 +1,82 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | Copyright (C) 2022 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | /* | ||
21 | * @author Tobias Frisch | ||
22 | * @file application.c | ||
23 | */ | ||
24 | |||
25 | #include "application.h" | ||
26 | |||
27 | void | ||
28 | application_init(MESSENGER_Application *app, | ||
29 | int argc, | ||
30 | char **argv) | ||
31 | { | ||
32 | memset(app, 0, sizeof(*app)); | ||
33 | |||
34 | app->argc = argc; | ||
35 | app->argv = argv; | ||
36 | |||
37 | initscr(); | ||
38 | noecho(); | ||
39 | |||
40 | keypad(stdscr, TRUE); | ||
41 | timeout(100); | ||
42 | } | ||
43 | |||
44 | static void | ||
45 | run (void *cls, | ||
46 | UNUSED char* const* args, | ||
47 | UNUSED const char *cfgfile, | ||
48 | const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
49 | { | ||
50 | MESSENGER_Application *app = cls; | ||
51 | |||
52 | chat_start(&(app->chat), app, cfg); | ||
53 | } | ||
54 | |||
55 | void | ||
56 | application_run(MESSENGER_Application *app) | ||
57 | { | ||
58 | struct GNUNET_GETOPT_CommandLineOption options[] = { | ||
59 | GNUNET_GETOPT_OPTION_END | ||
60 | }; | ||
61 | |||
62 | app->status = GNUNET_PROGRAM_run( | ||
63 | app->argc, | ||
64 | app->argv, | ||
65 | "messenger_cli", | ||
66 | gettext_noop("A CLI for the Messenger service of GNUnet."), | ||
67 | options, | ||
68 | &run, | ||
69 | app | ||
70 | ); | ||
71 | |||
72 | endwin(); | ||
73 | } | ||
74 | |||
75 | int | ||
76 | application_status(MESSENGER_Application *app) | ||
77 | { | ||
78 | if (app->status != GNUNET_OK) | ||
79 | return EXIT_FAILURE; | ||
80 | else | ||
81 | return EXIT_SUCCESS; | ||
82 | } | ||