From fe42762f236e23fefe47e67b6c248507d0ac5c8a Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Sun, 29 Jun 2014 14:37:21 -0700 Subject: Move some more stuff into wsutil. Move the routines to parse numerical command-line arguments there. Make cmdarg_err() and cmdarg_err_cont() routines in wsutil that just call routines specified by a call to cmdarg_err_init(), and have programs supply the appropriate routines to it. Change-Id: Ic24fc758c0e647f4ff49eb91673529bcb9587b01 Reviewed-on: https://code.wireshark.org/review/2704 Reviewed-by: Evan Huus Reviewed-by: Guy Harris --- tshark.c | 32 +++++++++----------------------- 1 file changed, 9 insertions(+), 23 deletions(-) (limited to 'tshark.c') diff --git a/tshark.c b/tshark.c index 8d27037772..2be3e8b81b 100644 --- a/tshark.c +++ b/tshark.c @@ -64,6 +64,9 @@ #include #include #include + +#include +#include #include #include #include @@ -88,8 +91,6 @@ #include #include "ui/util.h" #include "ui/ui_util.h" -#include "clopts_common.h" -#include "cmdarg_err.h" #include "version_info.h" #include "register.h" #include @@ -212,6 +213,7 @@ static void open_failure_message(const char *filename, int err, static void failure_message(const char *msg_format, va_list ap); static void read_failure_message(const char *filename, int err); static void write_failure_message(const char *filename, int err); +static void failure_message_cont(const char *msg_format, va_list ap); capture_file cfile; @@ -1009,6 +1011,8 @@ main(int argc, char *argv[]) } #endif + cmdarg_err_init(failure_message, failure_message_cont); + /* Assemble the compile-time version information string */ comp_info_str = g_string_new("Compiled "); get_compiled_version_info(comp_info_str, NULL, epan_get_compiled_version_info); @@ -4314,34 +4318,16 @@ write_failure_message(const char *filename, int err) filename, g_strerror(err)); } -/* - * Report an error in command-line arguments. - */ -void -cmdarg_err(const char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - failure_message(fmt, ap); - va_end(ap); -} - /* * Report additional information for an error in command-line arguments. */ -void -cmdarg_err_cont(const char *fmt, ...) +static void +failure_message_cont(const char *msg_format, va_list ap) { - va_list ap; - - va_start(ap, fmt); - vfprintf(stderr, fmt, ap); + vfprintf(stderr, msg_format, ap); fprintf(stderr, "\n"); - va_end(ap); } - /* * Editor modelines - http://www.wireshark.org/tools/modelines.html * -- cgit v1.2.1