From 8afe3313697e4e5adcb5eebc9bd31b375dee92b0 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Wed, 2 Jul 2014 21:50:54 -0700 Subject: More getopt_long, to add --help and --version support. Change-Id: I946067b972a70154f02ab561bc0fd029a7a5abc4 Reviewed-on: https://code.wireshark.org/review/2791 Reviewed-by: Guy Harris --- capinfos.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'capinfos.c') diff --git a/capinfos.c b/capinfos.c index b01b7e2142..b8e74e91bd 100644 --- a/capinfos.c +++ b/capinfos.c @@ -67,6 +67,10 @@ #include #endif +#ifdef HAVE_GETOPT_H +#include +#endif + #ifdef HAVE_SYS_TIME_H #include #endif @@ -1111,6 +1115,11 @@ main(int argc, char *argv[]) gchar *err_info; int opt; int overall_error_status; + static const struct option long_options[] = { + {(char *)"help", no_argument, NULL, 'h'}, + {(char *)"version", no_argument, NULL, 'v'}, + {0, 0, 0, 0 } + }; int status = 0; #ifdef HAVE_PLUGINS @@ -1211,7 +1220,7 @@ main(int argc, char *argv[]) g_option_context_free(ctx); #endif /* USE_GOPTION */ - while ((opt = getopt(argc, argv, "tEcs" FILE_HASH_OPT "dluaeyizvhxokCALTMRrSNqQBmb")) !=-1) { + while ((opt = getopt_long(argc, argv, "tEcs" FILE_HASH_OPT "dluaeyizvhxokCALTMRrSNqQBmb", long_options, NULL)) !=-1) { switch (opt) { -- cgit v1.2.3