diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2020-01-02 12:52:00 +0100 |
---|---|---|
committer | Gerd Hoffmann <kraxel@redhat.com> | 2020-01-02 12:52:00 +0100 |
commit | 379274ad7a79d3aee1bd23573264377bbb7cb39c (patch) | |
tree | 509e435fbb2890f403c2a08a912013d20e1b2b5c | |
parent | 1c7ffa384fada955ee2722436ad2345f2118adc3 (diff) | |
download | drminfo-379274ad7a79d3aee1bd23573264377bbb7cb39c.tar.gz |
virtio: long options
-rw-r--r-- | virtiotest.c | 47 |
1 files changed, 40 insertions, 7 deletions
diff --git a/virtiotest.c b/virtiotest.c index d718e7f..6133251 100644 --- a/virtiotest.c +++ b/virtiotest.c @@ -231,15 +231,48 @@ static void usage(FILE *fp) "usage: virtiotest [ options ]\n" "\n" "options:\n" - " -h print this\n" - " -a autotest mode\n" - " -c <nr> pick card\n" - " -s <secs> set sleep time (default: 60)\n" - " -i print device info\n" - " -l list formats\n" + " -h | --help print this\n" + " -a | --autotest autotest mode\n" + " -i | --info print virtio device info\n" + " -l | --list list formats\n" + " -c | --card <nr> pick card\n" + " -s | --sleep <secs> set sleep time (default: 60)\n" "\n"); } +struct option long_opts[] = { + { + /* --- no argument --- */ + .name = "help", + .has_arg = false, + .val = 'h', + },{ + .name = "autotest", + .has_arg = false, + .val = 'a', + },{ + .name = "info", + .has_arg = false, + .val = 'i', + },{ + .name = "list", + .has_arg = false, + .val = 'l', + },{ + + /* --- with argument --- */ + .name = "card", + .has_arg = true, + .val = 'c', + },{ + .name = "sleep", + .has_arg = true, + .val = 's', + },{ + /* end of list */ + } +}; + int main(int argc, char **argv) { int card = 0; @@ -252,7 +285,7 @@ int main(int argc, char **argv) int c, i; for (;;) { - c = getopt(argc, argv, "hailc:s:"); + c = getopt_long(argc, argv, "hailc:s:", long_opts, NULL); if (c == -1) break; switch (c) { |