diff options
author | Jeff Morriss <jeff.morriss.ws@gmail.com> | 2014-06-20 14:48:27 -0400 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2014-06-21 01:05:02 +0000 |
commit | 3773a7561c79e3545fca664c2a25cf2312de0ada (patch) | |
tree | 083e9fda037f4811ebe3cf7aa9564ee57df33c9b /text2pcap.c | |
parent | c11ae8ac827afa50ef226ebaef134f54ac0e532b (diff) | |
download | wireshark-3773a7561c79e3545fca664c2a25cf2312de0ada.tar.gz |
Add command-line argument to request the version to a number of the utilities.
In some cases "-v" was already used so "-V" is the option.
Note that the version information in these utilities is much shorter than what
is presented by the big programs.
As requested by https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=5804
Bug: 5804
Change-Id: I35db35a4eace2797afd895f9be7322ef39928480
Reviewed-on: https://code.wireshark.org/review/2489
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'text2pcap.c')
-rw-r--r-- | text2pcap.c | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/text2pcap.c b/text2pcap.c index 4b1a349a89..5c17436baa 100644 --- a/text2pcap.c +++ b/text2pcap.c @@ -1420,6 +1420,16 @@ fail_null_str: } +static void +print_version(FILE *output) +{ + fprintf(output, "Text2pcap %s" +#ifdef GITVERSION + " (" GITVERSION " from " GITBRANCH ")" +#endif + "\n", VERSION); +} + /*---------------------------------------------------------------------- * Print usage string and exit */ @@ -1435,12 +1445,8 @@ usage (gboolean is_error) output = stderr; } + print_version(output); fprintf(output, - "Text2pcap %s" -#ifdef GITVERSION - " (" GITVERSION " from " GITBRANCH ")" -#endif - "\n" "Generate a capture file from an ASCII hexdump of packets.\n" "See http://www.wireshark.org for more information.\n" "\n" @@ -1520,7 +1526,7 @@ usage (gboolean is_error) " -q generate no output at all (automatically disables -d).\n" " -n use PCAP-NG instead of PCAP as output format.\n" "", - VERSION, MAX_PACKET); + MAX_PACKET); exit(is_error ? 1 : 0); } @@ -1540,7 +1546,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:4:6:")) != -1) { + while ((c = getopt(argc, argv, "aDdhqe:i:l:m:no:u:s:S:t:T:v4:6:")) != -1) { switch (c) { case '?': usage(TRUE); break; case 'h': usage(FALSE); break; @@ -1720,6 +1726,11 @@ parse_options (int argc, char *argv[]) identify_ascii = TRUE; break; + case 'v': + print_version(stdout); + exit(0); + break; + case '4': case '6': p = strchr(optarg, ','); |