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 --- reordercap.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'reordercap.c') diff --git a/reordercap.c b/reordercap.c index 7b107fa329..7a9890e177 100644 --- a/reordercap.c +++ b/reordercap.c @@ -32,6 +32,10 @@ #include #endif +#ifdef HAVE_GETOPT_H +#include +#endif + #include "wtap.h" #ifndef HAVE_GETOPT @@ -184,12 +188,17 @@ main(int argc, char *argv[]) FrameRecord_t *prevFrame = NULL; int opt; + static const struct option long_options[] = { + {(char *)"help", no_argument, NULL, 'h'}, + {(char *)"version", no_argument, NULL, 'v'}, + {0, 0, 0, 0 } + }; int file_count; char *infile; char *outfile; /* Process the options first */ - while ((opt = getopt(argc, argv, "hnv")) != -1) { + while ((opt = getopt_long(argc, argv, "hnv", long_options, NULL)) != -1) { switch (opt) { case 'n': write_output_regardless = FALSE; -- cgit v1.2.1