From cda45d92fa7a3268dc0fed66e63ca55d251199bc Mon Sep 17 00:00:00 2001 From: Brian Norris Date: Sat, 8 Sep 2012 00:38:03 -0700 Subject: [PATCH] main: add parameter parsing Only has a help message for now. --- main.cc | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) 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; -- 2.34.1