summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorxengineering <me@xengineering.eu>2022-08-14 13:33:56 +0200
committerxengineering <me@xengineering.eu>2022-08-14 13:33:56 +0200
commit15229dbf21535abe8b4c68cf4b0bab370f06f48f (patch)
treec3e894db170831fc781e1b8322f6cb1d5c314bd4 /main.c
downloadlimox-15229dbf21535abe8b4c68cf4b0bab370f06f48f.tar
limox-15229dbf21535abe8b4c68cf4b0bab370f06f48f.tar.zst
limox-15229dbf21535abe8b4c68cf4b0bab370f06f48f.zip
First public version
Diffstat (limited to 'main.c')
-rw-r--r--main.c80
1 files changed, 80 insertions, 0 deletions
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 <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"
+ );
+
+}