diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2020-01-02 12:47:16 +0100 |
---|---|---|
committer | Gerd Hoffmann <kraxel@redhat.com> | 2020-01-02 12:47:16 +0100 |
commit | 1c7ffa384fada955ee2722436ad2345f2118adc3 (patch) | |
tree | 04570ce8d6e8d73c694bf5a28fcfbbcd8dadf223 | |
parent | 9ef3f868cbd8ab306fdb57e046f4bc7a90e72233 (diff) | |
download | drminfo-1c7ffa384fada955ee2722436ad2345f2118adc3.tar.gz |
prime: long options
-rw-r--r-- | prime.c | 23 |
1 files changed, 19 insertions, 4 deletions
@@ -240,11 +240,26 @@ static void usage(FILE *fp) "usage: prime [ options ]\n" "\n" "options:\n" - " -h print this\n" - " -l list cards\n" + " -h | --help print this\n" + " -l | --list list cards\n" "\n"); } +struct option long_opts[] = { + { + /* --- no argument --- */ + .name = "help", + .has_arg = false, + .val = 'h', + },{ + .name = "list", + .has_arg = false, + .val = 'l', + },{ + /* end of list */ + } +}; + int main(int argc, char **argv) { struct dev *devs[DEV_COUNT] = {}; @@ -252,7 +267,7 @@ int main(int argc, char **argv) bool list = false; for (;;) { - c = getopt(argc, argv, "hl"); + c = getopt_long(argc, argv, "hl", long_opts, NULL); if (c == -1) break; switch (c) { @@ -297,8 +312,8 @@ int main(int argc, char **argv) fprintf(stderr, "\n"); } - fprintf(stderr, "dma-buf transfer tests\n"); if (!list) { + fprintf(stderr, "dma-buf transfer tests\n"); for (e = 0; e < DEV_COUNT; e++) { if (!devs[e] || !devs[e]->gbm || |