From 15229dbf21535abe8b4c68cf4b0bab370f06f48f Mon Sep 17 00:00:00 2001 From: xengineering Date: Sun, 14 Aug 2022 13:33:56 +0200 Subject: First public version --- main.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 main.c (limited to 'main.c') diff --git a/main.c b/main.c new file mode 100644 index 0000000..2d2b330 --- /dev/null +++ b/main.c @@ -0,0 +1,80 @@ + + +#include +#include +#include + +#include "gui.h" + + +// error code definition +typedef enum error { + Ok = 0, + UnknownError = 1, + WrongArgs = 2, + GuiError = 3, +} Error; + +// configuration struct for all command line options +typedef struct options { + bool unknown; + bool help; +} Options; + + +// prototypes +static void get_opts(Options* opts, int argc, char* argv[]); +static void print_help(void); + + +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 { + run_gui(); + } + +} + +// getOpts 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; + } + + } + +} + +// printHelp prints out the help page. +static void print_help(void) { + + fprintf(stderr, + "The Linux on mobile XMPP (LimoX) client.\n" + "\n" + "Usage: limox [-h]\n" + "\n" + "Options:\n" + " -h print help page\n" + ); + +} -- cgit v1.2.3-70-g09d2