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 /rawshark.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 'rawshark.c')
-rw-r--r-- | rawshark.c | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/rawshark.c b/rawshark.c index 5e0e629e15..13d8d24b78 100644 --- a/rawshark.c +++ b/rawshark.c @@ -64,6 +64,8 @@ #include <glib.h> #include <epan/epan-int.h> #include <epan/epan.h> + +#include <wsutil/cmdarg_err.h> #include <wsutil/crash_info.h> #include <wsutil/privileges.h> #include <wsutil/file_util.h> @@ -83,8 +85,6 @@ #include <epan/print.h> #include <epan/addr_resolv.h> #include "ui/util.h" -#include "clopts_common.h" -#include "cmdarg_err.h" #include "version_info.h" #include "register.h" #include "conditions.h" @@ -102,6 +102,7 @@ #include <wiretap/libpcap.h> #include <wiretap/pcap-encap.h> +#include <wsutil/clopts_common.h> #include <wsutil/ws_version_info.h> #ifdef HAVE_LIBPCAP @@ -158,6 +159,8 @@ 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 rawshark_cmdarg_err(const char *fmt, va_list ap); +static void rawshark_cmdarg_err_cont(const char *fmt, va_list ap); static void protocolinfo_init(char *field); static gboolean parse_field_string_format(char *format); @@ -473,6 +476,8 @@ main(int argc, char *argv[]) static const char optstring[] = OPTSTRING_INIT; + cmdarg_err_init(rawshark_cmdarg_err, rawshark_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, epan_get_compiled_version_info); @@ -1732,33 +1737,24 @@ write_failure_message(const char *filename, int err) /* * Report an error in command-line arguments. */ -void -cmdarg_err(const char *fmt, ...) +static void +rawshark_cmdarg_err(const char *fmt, va_list ap) { - va_list ap; - - va_start(ap, fmt); fprintf(stderr, "rawshark: "); vfprintf(stderr, fmt, ap); fprintf(stderr, "\n"); - va_end(ap); } /* * Report additional information for an error in command-line arguments. */ -void -cmdarg_err_cont(const char *fmt, ...) +static void +rawshark_cmdarg_err_cont(const char *fmt, va_list ap) { - va_list ap; - - va_start(ap, fmt); vfprintf(stderr, fmt, ap); fprintf(stderr, "\n"); - va_end(ap); } - /* * Editor modelines * |