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 --- text2pcap.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'text2pcap.c') diff --git a/text2pcap.c b/text2pcap.c index 5c17436baa..2103c86960 100644 --- a/text2pcap.c +++ b/text2pcap.c @@ -120,6 +120,10 @@ # include #endif +#ifdef HAVE_GETOPT_H +#include +#endif + #include #include @@ -1539,6 +1543,11 @@ parse_options (int argc, char *argv[]) { int c; char *p; + static const struct option long_options[] = { + {(char *)"help", no_argument, NULL, 'h'}, + {(char *)"version", no_argument, NULL, 'v'}, + {0, 0, 0, 0 } + }; #ifdef _WIN32 arg_list_utf_16to8(argc, argv); @@ -1546,7 +1555,7 @@ parse_options (int argc, char *argv[]) #endif /* _WIN32 */ /* Scan CLI parameters */ - while ((c = getopt(argc, argv, "aDdhqe:i:l:m:no:u:s:S:t:T:v4:6:")) != -1) { + while ((c = getopt_long(argc, argv, "aDdhqe:i:l:m:no:u:s:S:t:T:v4:6:", long_options, NULL)) != -1) { switch (c) { case '?': usage(TRUE); break; case 'h': usage(FALSE); break; -- cgit v1.2.1