Move some more stuff into wsutil.
authorGuy Harris <guy@alum.mit.edu>
Sun, 29 Jun 2014 21:37:21 +0000 (14:37 -0700)
committerGuy Harris <guy@alum.mit.edu>
Sun, 29 Jun 2014 23:03:24 +0000 (23:03 +0000)
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>
15 files changed:
CMakeLists.txt
Makefile.common
capture_opts.c
dumpcap.c
rawshark.c
tfshark.c
tshark.c
ui/gtk/main.c
ui/qt/main.cpp
wsutil/CMakeLists.txt
wsutil/Makefile.common
wsutil/clopts_common.c [moved from clopts_common.c with 93% similarity]
wsutil/clopts_common.h [moved from clopts_common.h with 73% similarity]
wsutil/cmdarg_err.c [new file with mode: 0644]
wsutil/cmdarg_err.h [moved from cmdarg_err.h with 69% similarity]

index 69aaa2c5243e6c31f01b0a160eda4c4b216c9ee6..8e2cabf322ec929d81b1f0b84dea161fd8bb1b64 100644 (file)
@@ -915,7 +915,6 @@ set(SHARK_COMMON_SRC
        ${PLATFORM_PCAP_SRC}
        capture-pcap-util.c
        cfile.c
-       clopts_common.c
        frame_tvbuff.c
        version.h
        sync_pipe_write.c
@@ -1351,7 +1350,6 @@ if(BUILD_dumpcap AND PCAP_FOUND)
                capture_opts.c
                capture-pcap-util.c
                capture_stop_conditions.c
-               clopts_common.c
                conditions.c
                dumpcap.c
                pcapio.c
index 34205d70c7a616f0288f168faf538b66ee3b6a7e..97e3cef31a6793813d66d1286220011cac196e54 100644 (file)
@@ -44,7 +44,6 @@ SHARK_COMMON_SRC =    \
        $(PLATFORM_PCAP_SRC)    \
        capture-pcap-util.c     \
        cfile.c                 \
-       clopts_common.c         \
        frame_tvbuff.c          \
        sync_pipe_write.c       \
        version_info.c
@@ -55,8 +54,6 @@ SHARK_COMMON_INCLUDES =       \
        capture-pcap-util.h     \
        capture-pcap-util-int.h \
        cfile.h                 \
-       clopts_common.h         \
-       cmdarg_err.h            \
        color.h                 \
        file.h                  \
        fileset.h               \
@@ -172,7 +169,6 @@ dumpcap_SOURCES =   \
        capture_opts.c  \
        capture-pcap-util.c     \
        capture_stop_conditions.c       \
-       clopts_common.c \
        conditions.c    \
        dumpcap.c       \
        pcapio.c        \
index 6b17189e05f341f7bcfadcf93dd9a6ae201edce5..d9ec2d3e933b44e6ea58c9de2fe544b497e38af9 100644 (file)
 
 #include "capture_opts.h"
 #include "ringbuffer.h"
-#include "clopts_common.h"
-#include "cmdarg_err.h"
 
 #include <capchild/capture_ifinfo.h>
 #include "capture-pcap-util.h"
+#include <wsutil/clopts_common.h>
+#include <wsutil/cmdarg_err.h>
 #include <wsutil/file_util.h>
 
 static gboolean capture_opts_output_to_pipe(const char *save_file, gboolean *is_pipe);
index 90b12b1079b3649777d0fe4b5eee97fc3d6bf33c..0c91b7341baec2d49178459ee626dc529f98ff9e 100644 (file)
--- a/dumpcap.c
+++ b/dumpcap.c
@@ -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"
 # 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);
index 5e0e629e15e5afe7195f7ff1bc1c1bfd342597d5..13d8d24b7808d654c84c6a1274ad999a2c2d4167 100644 (file)
@@ -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"
 #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
  *
index 8eb2565d8357674ee270f0b70067a8817d107cac..2f71ee9256fae21f0290fad856e22c98f5f881df 100644 (file)
--- a/tfshark.c
+++ b/tfshark.c
@@ -59,6 +59,9 @@
 #include <epan/exceptions.h>
 #include <epan/epan-int.h>
 #include <epan/epan.h>
+
+#include <wsutil/clopts_common.h>
+#include <wsutil/cmdarg_err.h>
 #include <wsutil/crash_info.h>
 #include <wsutil/privileges.h>
 #include <wsutil/file_util.h>
@@ -81,8 +84,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 <epan/epan_dissect.h>
@@ -792,6 +793,8 @@ main(int argc, char *argv[])
 
   static const char    optstring[] = OPTSTRING;
 
+  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);
@@ -2767,34 +2770,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
  *
index 8d270377723ac370cfb477206c080bc2d498d75e..2be3e8b81b4ff720c397806337531b13af7cd724 100644 (file)
--- a/tshark.c
+++ b/tshark.c
@@ -64,6 +64,9 @@
 #include <epan/exceptions.h>
 #include <epan/epan-int.h>
 #include <epan/epan.h>
+
+#include <wsutil/clopts_common.h>
+#include <wsutil/cmdarg_err.h>
 #include <wsutil/crash_info.h>
 #include <wsutil/privileges.h>
 #include <wsutil/file_util.h>
@@ -88,8 +91,6 @@
 #include <epan/addr_resolv.h>
 #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 <epan/epan_dissect.h>
@@ -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
  *
index 5c54337cb63bac34a1444ad9797d223e239ad077..ff5bf274b389a059de9163fa97f780314be2c705 100644 (file)
@@ -60,6 +60,7 @@
 #include <portaudio.h>
 #endif /* HAVE_LIBPORTAUDIO */
 
+#include <wsutil/clopts_common.h>
 #include <wsutil/crash_info.h>
 #include <wsutil/filesystem.h>
 #include <wsutil/file_util.h>
@@ -92,6 +93,7 @@
 #include <epan/print.h>
 #include <epan/timestamp.h>
 
+#include <wsutil/cmdarg_err.h>
 #include <wsutil/plugins.h>
 
 /* general (not GTK specific) */
 #include "../register.h"
 #include "../ringbuffer.h"
 #include "ui/util.h"
-#include "../clopts_common.h"
-#include "../cmdarg_err.h"
 #include "../version_info.h"
 #include "../log.h"
 
@@ -1279,19 +1279,17 @@ show_version(void)
 /*
  * Report an error in command-line arguments.
  * Creates a console on Windows.
+ * XXX - pop this up in a window of some sort on UNIX+X11 if the controlling
+ * terminal isn't the standard error?
  */
-void
-cmdarg_err(const char *fmt, ...)
+static void
+wireshark_cmdarg_err(const char *fmt, va_list ap)
 {
-    va_list ap;
-
 #ifdef _WIN32
     create_console();
 #endif
     fprintf(stderr, "wireshark: ");
-    va_start(ap, fmt);
     vfprintf(stderr, fmt, ap);
-    va_end(ap);
     fprintf(stderr, "\n");
 }
 
@@ -1301,18 +1299,14 @@ cmdarg_err(const char *fmt, ...)
  * XXX - pop this up in a window of some sort on UNIX+X11 if the controlling
  * terminal isn't the standard error?
  */
-void
-cmdarg_err_cont(const char *fmt, ...)
+static void
+wireshark_cmdarg_err_cont(const char *fmt, va_list ap)
 {
-    va_list ap;
-
 #ifdef _WIN32
     create_console();
 #endif
-    va_start(ap, fmt);
     vfprintf(stderr, fmt, ap);
     fprintf(stderr, "\n");
-    va_end(ap);
 }
 
 /*
@@ -2184,6 +2178,7 @@ main(int argc, char *argv[])
 
     static const char optstring[] = OPTSTRING;
 
+    cmdarg_err_init(wireshark_cmdarg_err, wireshark_cmdarg_err_cont);
 
     /* Set the C-language locale to the native environment. */
     setlocale(LC_ALL, "");
index d14e6226f75b0fe875608d067b026955dab0ef3c..ef4704bc4f19730ba46fddfe4e0cc77987672c48 100644 (file)
@@ -41,6 +41,8 @@
 #  include <getopt.h>
 #endif
 
+#include <wsutil/clopts_common.h>
+#include <wsutil/cmdarg_err.h>
 #include <wsutil/crash_info.h>
 #include <wsutil/filesystem.h>
 #include <wsutil/file_util.h>
@@ -88,8 +90,6 @@
 #include "register.h"
 #include "ringbuffer.h"
 #include "ui/util.h"
-#include "clopts_common.h"
-#include "cmdarg_err.h"
 #include "version_info.h"
 #include "log.h"
 
@@ -317,18 +317,14 @@ show_version(void)
  * Creates a console on Windows.
  */
 // xxx copied from ../gtk/main.c
-void
-cmdarg_err(const char *fmt, ...)
+static void
+wireshark_cmdarg_err(const char *fmt, va_list ap)
 {
-    va_list ap;
-
 #ifdef _WIN32
     create_console();
 #endif
     fprintf(stderr, "wireshark: ");
-    va_start(ap, fmt);
     vfprintf(stderr, fmt, ap);
-    va_end(ap);
     fprintf(stderr, "\n");
 }
 
@@ -339,18 +335,14 @@ cmdarg_err(const char *fmt, ...)
  * terminal isn't the standard error?
  */
 // xxx copied from ../gtk/main.c
-void
-cmdarg_err_cont(const char *fmt, ...)
+static void
+wireshark_cmdarg_err_cont(const char *fmt, va_list ap)
 {
-    va_list ap;
-
 #ifdef _WIN32
     create_console();
 #endif
-    va_start(ap, fmt);
     vfprintf(stderr, fmt, ap);
     fprintf(stderr, "\n");
-    va_end(ap);
 }
 
 static void
@@ -493,6 +485,8 @@ int main(int argc, char *argv[])
     e_prefs             *prefs_p;
     GLogLevelFlags       log_flags;
 
+    cmdarg_err_init(wireshark_cmdarg_err, wireshark_cmdarg_err_cont);
+
 #ifdef _WIN32
     create_app_running_mutex();
 #endif
index 0157e747858ccc0570a6382b5ed6237a37cd8ef7..d8e2f04de132be404fd0c93b07a21aa17c14f76c 100644 (file)
@@ -45,6 +45,8 @@ set(WSUTIL_FILES
        base64.c
        bitswap.c
        cfutils.c
+       clopts_common.c
+       cmdarg_err.c
        compiler_info.c
        copyright_info.c
        cpu_info.c
index 4bb8dea86bbaac59dc214a4f545f5e9bdee3ac65..2c0595c94e94917e0fa88573c3024d0544419b3f 100644 (file)
@@ -33,6 +33,8 @@ LIBWSUTIL_SRC =       \
        base64.c        \
        bitswap.c       \
        cfutils.c       \
+       clopts_common.c \
+       cmdarg_err.c    \
        compiler_info.c \
        copyright_info.c \
        cpu_info.c      \
@@ -79,8 +81,10 @@ LIBWSUTIL_INCLUDES =         \
        base64.h        \
        bits_ctz.h      \
        bits_count_ones.h       \
-       bitswap.h               \
+       bitswap.h       \
        cfutils.h       \
+       clopts_common.h \
+       cmdarg_err.h    \
        compiler_info.h \
        copyright_info.h \
        cpu_info.h      \
similarity index 93%
rename from clopts_common.c
rename to wsutil/clopts_common.c
index 1ffcdedbc93fd910646ba7cb41759593022667d8..8b1878758bceb12b63e18b549d5a98cb4b8dea4a 100644 (file)
@@ -1,5 +1,5 @@
 /* clopts_common.c
- * Handle command-line arguments common to Wireshark and TShark
+ * Handle command-line arguments common to various programs
  *
  * Wireshark - Network traffic analyzer
  * By Gerald Combs <gerald@wireshark.org>
@@ -26,8 +26,9 @@
 #include <string.h>
 #include <stdlib.h>
 
-#include "clopts_common.h"
-#include "cmdarg_err.h"
+#include <wsutil/cmdarg_err.h>
+
+#include <wsutil/clopts_common.h>
 
 int
 get_natural_int(const char *string, const char *name)
similarity index 73%
rename from clopts_common.h
rename to wsutil/clopts_common.h
index e98d7b4986e60066e6ea57791e78b544dc1d6c92..c409e8957a044bf4fdc43fbb1d776fe172f79f84 100644 (file)
@@ -1,5 +1,5 @@
 /* clopts_common.h
- * Handle command-line arguments common to Wireshark and TShark
+ * Handle command-line arguments common to various programs
  *
  * Wireshark - Network traffic analyzer
  * By Gerald Combs <gerald@wireshark.org>
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#ifndef __PROTO_DUMPOPTS_H__
-#define __PROTO_DUMPOPTS_H__
+#ifndef __WSUTIL_CLOPTS_COMMON_H__
+#define __WSUTIL_CLOPTS_COMMON_H__
+
+#include "ws_symbol_export.h"
 
 #ifdef __cplusplus
 extern "C" {
 #endif /* __cplusplus */
 
-int get_natural_int(const char *string, const char *name);
+WS_DLL_PUBLIC int
+get_natural_int(const char *string, const char *name);
 
-int get_positive_int(const char *string, const char *name);
+WS_DLL_PUBLIC int
+get_positive_int(const char *string, const char *name);
 
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
 
-#endif /* __PROTO_DUMPOPTS_H__ */
+#endif /* __WSUTIL_CLOPTS_COMMON_H__ */
diff --git a/wsutil/cmdarg_err.c b/wsutil/cmdarg_err.c
new file mode 100644 (file)
index 0000000..7dd2fa2
--- /dev/null
@@ -0,0 +1,67 @@
+/* cmdarg_err.c
+ * Routines to report command-line argument errors.
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 1998 Gerald Combs
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "config.h"
+
+#include <stdio.h>
+
+#include <wsutil/cmdarg_err.h>
+
+static void (*print_err)(const char *, va_list ap);
+static void (*print_err_cont)(const char *, va_list ap);
+
+/*
+ * Set the reporting functions for error messages.
+ */
+void
+cmdarg_err_init(void (*err)(const char *, va_list),
+                void (*err_cont)(const char *, va_list))
+{
+    print_err = err;
+    print_err_cont = err_cont;
+}
+
+/*
+ * Report an error in command-line arguments.
+ */
+void
+cmdarg_err(const char *fmt, ...)
+{
+    va_list ap;
+
+    va_start(ap, fmt);
+    print_err(fmt, ap);
+    va_end(ap);
+}
+
+/*
+ * Report additional information for an error in command-line arguments.
+ */
+void
+cmdarg_err_cont(const char *fmt, ...)
+{
+    va_list ap;
+
+    va_start(ap, fmt);
+    print_err_cont(fmt, ap);
+    va_end(ap);
+}
similarity index 69%
rename from cmdarg_err.h
rename to wsutil/cmdarg_err.h
index b4d639f8f13e69a40df947e9f17969bd77246b09..169c893b9f164ab68dcf01489d149c913e552788 100644 (file)
@@ -1,5 +1,5 @@
 /* cmdarg_err.h
- * Declarations of routines to report command-line errors.
+ * Declarations of routines to report command-line argument errors.
  *
  * Wireshark - Network traffic analyzer
  * By Gerald Combs <gerald@wireshark.org>
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#ifndef __CMDARG_ERR_H__
-#define __CMDARG_ERR_H__
+#ifndef __WSUTIL_CMDARG_ERR_H__
+#define __WSUTIL_CMDARG_ERR_H__
+
+#include <stdarg.h>
 
 #include <glib.h>
 
+#include "ws_symbol_export.h"
+
 #ifdef __cplusplus
 extern "C" {
 #endif /* __cplusplus */
 
+/*
+ * Set the reporting functions for error messages.
+ */
+WS_DLL_PUBLIC void
+cmdarg_err_init(void (*err)(const char *, va_list),
+                void (*err_cont)(const char *, va_list));
+
 /*
  * Report an error in command-line arguments.
  */
-extern void cmdarg_err(const char *fmt, ...)
+WS_DLL_PUBLIC void
+cmdarg_err(const char *fmt, ...)
     G_GNUC_PRINTF(1, 2);
 
 /*
  * Report additional information for an error in command-line arguments.
  */
-extern void cmdarg_err_cont(const char *fmt, ...)
+WS_DLL_PUBLIC void
+cmdarg_err_cont(const char *fmt, ...)
     G_GNUC_PRINTF(1, 2);
 
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
 
-#endif /* __CMDARG_ERR_H__ */
+#endif /* __WSUTIL_CMDARG_ERR_H__ */