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 --- dumpcap.c | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) (limited to 'dumpcap.c') diff --git a/dumpcap.c b/dumpcap.c index 90b12b1079..0c91b7341b 100644 --- a/dumpcap.c +++ b/dumpcap.c @@ -71,6 +71,7 @@ #include /* to get the libz version number */ #endif +#include #include #include #include @@ -89,8 +90,6 @@ #endif #include "ringbuffer.h" -#include "clopts_common.h" -#include "cmdarg_err.h" #include "version_info.h" #include "capture-pcap-util.h" @@ -113,6 +112,7 @@ # include "wsutil/inet_v6defs.h" #endif +#include #include #include "sync_pipe.h" @@ -580,49 +580,41 @@ show_version(GString *comp_info_str, GString *runtime_info_str) /* * Report an error in command-line arguments. + * If we're a capture child, send a message back to the parent, otherwise + * just print it. */ -void -cmdarg_err(const char *fmt, ...) +static void +dumpcap_cmdarg_err(const char *fmt, va_list ap) { - va_list ap; - if (capture_child) { gchar *msg; /* Generate a 'special format' message back to parent */ - va_start(ap, fmt); msg = g_strdup_vprintf(fmt, ap); sync_pipe_errmsg_to_parent(2, msg, ""); g_free(msg); - va_end(ap); } else { - va_start(ap, fmt); fprintf(stderr, "dumpcap: "); vfprintf(stderr, fmt, ap); fprintf(stderr, "\n"); - va_end(ap); } } /* * Report additional information for an error in command-line arguments. + * If we're a capture child, send a message back to the parent, otherwise + * just print it. */ -void -cmdarg_err_cont(const char *fmt, ...) +static void +dumpcap_cmdarg_err_cont(const char *fmt, va_list ap) { - va_list ap; - if (capture_child) { gchar *msg; - va_start(ap, fmt); msg = g_strdup_vprintf(fmt, ap); sync_pipe_errmsg_to_parent(2, msg, ""); g_free(msg); - va_end(ap); } else { - va_start(ap, fmt); vfprintf(stderr, fmt, ap); fprintf(stderr, "\n"); - va_end(ap); } } @@ -4232,6 +4224,8 @@ main(int argc, char *argv[]) #endif GString *str; + cmdarg_err_init(dumpcap_cmdarg_err, dumpcap_cmdarg_err_cont); + /* Assemble the compile-time version information string */ comp_info_str = g_string_new("Compiled "); get_compiled_version_info(comp_info_str, NULL, NULL); -- cgit v1.2.3