From: Brian Norris Date: Sat, 8 Sep 2012 07:38:03 +0000 (-0700) Subject: main: add parameter parsing X-Git-Tag: pldi2013~226 X-Git-Url: http://plrg.eecs.uci.edu/git/?p=model-checker.git;a=commitdiff_plain;h=cda45d92fa7a3268dc0fed66e63ca55d251199bc main: add parameter parsing Only has a help message for now. --- diff --git a/main.cc b/main.cc index 75efafe..f58f304 100644 --- a/main.cc +++ b/main.cc @@ -2,6 +2,8 @@ * @brief Entry point for the model checker. */ +#include + #include "libthreads.h" #include "common.h" #include "threads.h" @@ -12,7 +14,32 @@ #include "model.h" #include "snapshot-interface.h" +static void print_usage() { + printf( +"Usage: [OPTIONS]\n" +"\n" +"Options:\n" +"-h Display this help message and exit\n" +); + exit(EXIT_SUCCESS); +} + static void parse_options(struct model_params *params, int argc, char **argv) { + const char *shortopts = "h"; + int opt; + bool error = false; + while (!error && (opt = getopt(argc, argv, shortopts)) != -1) { + switch (opt) { + case 'h': + print_usage(); + break; + default: /* '?' */ + error = true; + break; + } + } + if (error) + print_usage(); } int main_argc;