#include #include #include #include "gui.h" #include "limox.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 { limox_init(); gui_run(); } } // 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" ); }