diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2019-12-19 13:32:59 +0100 |
---|---|---|
committer | Gerd Hoffmann <kraxel@redhat.com> | 2019-12-19 13:32:59 +0100 |
commit | d41ce26d029a3bc11d0154087257d44926f78c44 (patch) | |
tree | 10101a9bbcafe35ba4c5dc93b8fe9e61cb281a7d | |
parent | 17bca547816cdc2fabe15b38052cec07580cc8a6 (diff) | |
download | drminfo-d41ce26d029a3bc11d0154087257d44926f78c44.tar.gz |
drminfo: start getopt_long
-rw-r--r-- | drminfo.c | 60 |
1 files changed, 45 insertions, 15 deletions
@@ -440,23 +440,53 @@ static void usage(FILE *fp) "usage: drminfo [ options ]\n" "\n" "options:\n" - " -h print this text\n" - " -c <nr> pick card\n" - " -a print all card info\n" - " -A print all card info, with plane modifiers\n" - " -m print misc card info\n" - " -s print capabilities\n" - " -o print supported outputs (crtcs)\n" - " -p print supported planes\n" - " -P print supported planes, with modifiers\n" - " -f print supported formats\n" - " -F print testable (drmtest) formats\n" - " -r list properties\n" - " -l list all known formats\n" - " -L <output> get a drm lease for output\n" + " -h | --help print this text\n" + " -c | --card <nr> pick card\n" + " --lease <output> get a drm lease for output\n" + "\n" + " -a print all card info\n" + " -A print all card info, with plane modifiers\n" + " -m print misc card info\n" + " -s print capabilities\n" + " -o print supported outputs (crtcs)\n" + " -p print supported planes\n" + " -P print supported planes, with modifiers\n" + " -f print supported formats\n" + " -F print testable (drmtest) formats\n" + " -r list properties\n" + " -l | --list-formats list all known formats\n" "\n"); } +enum { + OPT_LONG_LEASE = 0x100, +}; + +struct option long_opts[] = { + { + /* --- no argument --- */ + .name = "help", + .has_arg = false, + .val = 'h', + },{ + .name = "list-formats", + .has_arg = false, + .val = 'l', + },{ + + /* --- with argument --- */ + .name = "card", + .has_arg = true, + .val = 'c', + },{ + .name = "lease", + .has_arg = true, + .val = OPT_LONG_LEASE, + },{ + /* end of list */ + } +}; + int main(int argc, char **argv) { int card = 0; @@ -473,7 +503,7 @@ int main(int argc, char **argv) char *columns; for (;;) { - c = getopt(argc, argv, "hlaAmsopPfFrL:c:"); + c = getopt(argc, argv, "hlaAmsopPfFrc:"); if (c == -1) break; switch (c) { |