diff options
author | Guy Harris <guy@alum.mit.edu> | 2014-07-02 19:33:27 -0700 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2014-07-03 02:33:52 +0000 |
commit | a4304de1ccb3646dec74ed3a380485e80006b877 (patch) | |
tree | eefc377c1b42a730d562834f8332c876f1cc271c /rawshark.c | |
parent | 6b3391c60ab4302ebe06baaaecad25210b3edbed (diff) |
Add long-option support.
That way, --help and --version, as well as -h and -v, work.
Change-Id: I095e0dcef9f6181d6fbe6337f9f33e80bc44f11a
Reviewed-on: https://code.wireshark.org/review/2790
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'rawshark.c')
-rw-r--r-- | rawshark.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/rawshark.c b/rawshark.c index b85c87b2ed..b67cc06749 100644 --- a/rawshark.c +++ b/rawshark.c @@ -45,6 +45,10 @@ #include <unistd.h> #endif +#ifdef HAVE_GETOPT_H +#include <getopt.h> +#endif + #include <errno.h> #ifdef HAVE_FCNTL_H @@ -459,6 +463,11 @@ main(int argc, char *argv[]) GPtrArray *disp_fields = g_ptr_array_new(); guint fc; gboolean skip_pcap_header = FALSE; + static const struct option long_options[] = { + {(char *)"help", no_argument, NULL, 'h'}, + {(char *)"version", no_argument, NULL, 'v'}, + {0, 0, 0, 0 } + }; #define OPTSTRING_INIT "d:F:hlnN:o:pr:R:sS:t:v" @@ -617,7 +626,7 @@ main(int argc, char *argv[]) /* Now get our args */ /* XXX - We should probably have an option to dump libpcap link types */ - while ((opt = getopt(argc, argv, optstring)) != -1) { + while ((opt = getopt_long(argc, argv, optstring, long_options, NULL)) != -1) { switch (opt) { case 'd': /* Payload type */ if (!set_link_type(optarg)) { |