aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Bennée <alex.bennee@linaro.org>2017-11-07 15:05:50 +0000
committerPeter Maydell <peter.maydell@linaro.org>2017-11-21 16:45:45 +0000
commiteae7bc6d0b2bac6d5447bf8c7cdba8a0c827bcc1 (patch)
treecd7ee5f841022f6bbd85c5f349e51d799040b154
parentbdbd11726cfa3d2ccdbba1373e92546986dc624f (diff)
risu.c: split out setting up options
This is a prerequisite to properly handling architecture specific options. Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Message-id: 20171107150558.22131-3-alex.bennee@linaro.org Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
-rw-r--r--risu.c29
1 files changed, 19 insertions, 10 deletions
diff --git a/risu.c b/risu.c
index 47471c6..a5d155d 100644
--- a/risu.c
+++ b/risu.c
@@ -282,6 +282,21 @@ void usage(void)
"(default 9191)\n");
}
+struct option * setup_options(char **short_opts)
+{
+ static struct option default_longopts[] = {
+ {"help", no_argument, 0, '?'},
+ {"master", no_argument, &ismaster, 1},
+ {"host", required_argument, 0, 'h'},
+ {"port", required_argument, 0, 'p'},
+ {"test-fp-exc", no_argument, &test_fp_exc, 1},
+ {0, 0, 0, 0}
+ };
+
+ *short_opts = "h:p:t:";
+ return default_longopts;
+}
+
int main(int argc, char **argv)
{
/* some handy defaults to make testing easier */
@@ -289,20 +304,14 @@ int main(int argc, char **argv)
char *hostname = "localhost";
char *imgfile;
char *trace_fn = NULL;
+ struct option *longopts;
+ char *shortopts;
- /* TODO clean this up later */
+ longopts = setup_options(&shortopts);
for (;;) {
- static struct option longopts[] = {
- {"help", no_argument, 0, '?'},
- {"master", no_argument, &ismaster, 1},
- {"host", required_argument, 0, 'h'},
- {"port", required_argument, 0, 'p'},
- {"test-fp-exc", no_argument, &test_fp_exc, 1},
- {0, 0, 0, 0}
- };
int optidx = 0;
- int c = getopt_long(argc, argv, "h:p:t:", longopts, &optidx);
+ int c = getopt_long(argc, argv, shortopts, longopts, &optidx);
if (c == -1) {
break;
}