aboutsummaryrefslogtreecommitdiffstats
path: root/captype.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2017-04-20 00:19:01 -0700
committerGuy Harris <guy@alum.mit.edu>2017-04-20 07:19:41 +0000
commitbce5ec919e2fd197e0042dfabf5186d0d6f6eb47 (patch)
treee96213c604d0a596e9cbef5c4d9d4839b4b872d1 /captype.c
parentb0c48f3b4fd4a1e8e7552265c1b5393ca991a40f (diff)
Use the new cfile_XXX_failure_message() routines more broadly.
Change-Id: I7814b3fd0353f4836ae61cbdbd4e13f659cbcb59 Reviewed-on: https://code.wireshark.org/review/21239 Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'captype.c')
-rw-r--r--captype.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/captype.c b/captype.c
index a61ba4bc81..71fe572d93 100644
--- a/captype.c
+++ b/captype.c
@@ -40,6 +40,7 @@
#include <wiretap/wtap.h>
+#include <wsutil/cmdarg_err.h>
#include <wsutil/crash_info.h>
#include <wsutil/file_util.h>
#include <wsutil/filesystem.h>
@@ -61,6 +62,8 @@
#include "wsutil/wsgetopt.h"
#endif
+#include "ui/failure_message.h"
+
static void
print_usage(FILE *output)
{
@@ -68,7 +71,6 @@ print_usage(FILE *output)
fprintf(output, "Usage: captype <infile> ...\n");
}
-#ifdef HAVE_PLUGINS
/*
* General errors and warnings are reported with an console message
* in captype.
@@ -80,7 +82,16 @@ failure_warning_message(const char *msg_format, va_list ap)
vfprintf(stderr, msg_format, ap);
fprintf(stderr, "\n");
}
-#endif
+
+/*
+ * Report additional information for an error in command-line arguments.
+ */
+static void
+failure_message_cont(const char *msg_format, va_list ap)
+{
+ vfprintf(stderr, msg_format, ap);
+ fprintf(stderr, "\n");
+}
int
main(int argc, char *argv[])
@@ -103,6 +114,8 @@ main(int argc, char *argv[])
/* Set the C-language locale to the native environment. */
setlocale(LC_ALL, "");
+ cmdarg_err_init(failure_warning_message, failure_message_cont);
+
/* Get the compile-time version information string */
comp_info_str = get_compiled_version_info(NULL, NULL);
@@ -206,12 +219,8 @@ main(int argc, char *argv[])
if (err == WTAP_ERR_FILE_UNKNOWN_FORMAT)
printf("%s: unknown\n", argv[i]);
else {
- fprintf(stderr, "captype: Can't open %s: %s\n", argv[i],
- wtap_strerror(err));
- if (err_info != NULL) {
- fprintf(stderr, "(%s)\n", err_info);
- g_free(err_info);
- }
+ cfile_open_failure_message("captype", argv[i], err, err_info, FALSE,
+ WTAP_TYPE_AUTO);
overall_error_status = 2; /* remember that an error has occurred */
}
}