diff options
author | xengineering <me@xengineering.eu> | 2022-08-14 13:33:56 +0200 |
---|---|---|
committer | xengineering <me@xengineering.eu> | 2022-08-14 13:33:56 +0200 |
commit | 15229dbf21535abe8b4c68cf4b0bab370f06f48f (patch) | |
tree | c3e894db170831fc781e1b8322f6cb1d5c314bd4 /main.c | |
download | limox-15229dbf21535abe8b4c68cf4b0bab370f06f48f.tar limox-15229dbf21535abe8b4c68cf4b0bab370f06f48f.tar.zst limox-15229dbf21535abe8b4c68cf4b0bab370f06f48f.zip |
First public version
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 80 |
1 files changed, 80 insertions, 0 deletions
@@ -0,0 +1,80 @@ + + +#include <stdbool.h> +#include <stdio.h> +#include <unistd.h> + +#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" + ); + +} |