From a90cc2fc89a0ba63888becbe7e09b5b13fd7c48e Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Thu, 2 Jan 2020 12:09:22 +0100 Subject: fbinfo: long options --- fbinfo.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'fbinfo.c') diff --git a/fbinfo.c b/fbinfo.c index fe6fab2..dceca01 100644 --- a/fbinfo.c +++ b/fbinfo.c @@ -21,21 +21,38 @@ static void usage(FILE *fp) { fprintf(fp, "\n" - "usage: fbtest [ options ]\n" + "usage: fbinfo [ options ]\n" "\n" "options:\n" - " -h print this\n" - " -f pick framebuffer\n" + " -h | --help print this\n" + " -f | --fbdev pick framebuffer\n" "\n"); } +struct option long_opts[] = { + { + /* --- no argument --- */ + .name = "help", + .has_arg = false, + .val = 'h', + },{ + + /* --- with argument --- */ + .name = "fbdev", + .has_arg = true, + .val = 'f', + },{ + /* end of list */ + } +}; + int main(int argc, char **argv) { int framebuffer = 0; int c; for (;;) { - c = getopt(argc, argv, "hf:"); + c = getopt_long(argc, argv, "hf:", long_opts, NULL); if (c == -1) break; switch (c) { -- cgit