diff options
author | Guy Harris <guy@alum.mit.edu> | 2014-06-29 14:37:21 -0700 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2014-06-29 23:03:24 +0000 |
commit | fe42762f236e23fefe47e67b6c248507d0ac5c8a (patch) | |
tree | 57947515414aa27789b5aea2b1e4d32c0da7e97e /dumpcap.c | |
parent | dd63ae2b8c889aa91577efe4621e6d0fe5432a99 (diff) |
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 <eapache@gmail.com>
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'dumpcap.c')
-rw-r--r-- | dumpcap.c | 30 |
1 files changed, 12 insertions, 18 deletions
@@ -71,6 +71,7 @@ #include <zlib.h> /* to get the libz version number */ #endif +#include <wsutil/cmdarg_err.h> #include <wsutil/crash_info.h> #include <wsutil/copyright_info.h> #include <wsutil/ws_version_info.h> @@ -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 <wsutil/clopts_common.h> #include <wsutil/privileges.h> #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); |