summaryrefslogtreecommitdiff
path: root/main.c
blob: a06abf0346acbafff6cb9f2a594d789d8a8fe516 (plain)
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


#include <stdbool.h>
#include <stdio.h>
#include <getopt.h>

#include "gui.h"


// configuration struct for all command line options
typedef struct options {
	bool unknown;
	bool help;
} Options;


// parses all command line arguments.
static void get_opts(Options* opts, int argc, char* argv[]) {

	// initialize Options struct
	opts->unknown = false;
	opts->help = false;

	// parse all arguments to Options struct
	int c;
	while ((c=getopt(argc, argv, "h")) != -1) {

		switch (c) {
			case 'h':
				opts->help = true;
				break;
			default:
				opts->unknown = true;
		}
	}
}

// prints out the help page.
static void print_help(void) {

	printf(
		"The Linux on mobile XMPP (LimoX) client.\n"
		"\n"
		"Usage: limox [-h]\n"
		"\n"
		"Options:\n"
		"          -h        print help page\n"
	);

}

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

	// parse command line options
	Options opts;
	get_opts(&opts, argc, argv);

	// handle correct use case
	if (opts.unknown || opts.help) {
		print_help();
	} else {
		gui_run();
	}

}