summaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2017-04-19 14:43:11 -0700
committerGuy Harris <guy@alum.mit.edu>2017-04-19 21:43:47 +0000
commit4362e63dd54d8d35603d81fd2468cfe710b88f3e (patch)
tree8d670fa2ff4042858f08d1330ab54516d351f865 /ui
parent26cc3f06a7541578ed216ab37e8c07683f2e9b3a (diff)
downloadwireshark-4362e63dd54d8d35603d81fd2468cfe710b88f3e.tar.gz
Have a common "capture file close alert box" routine.
Take the code from cf_read() to pop up an alert box and put it into libui, with the name cfile_read_failure_alert_box(). Use it in a couple of places where we pop up such an error dialog. While we're at it, get rid of the "err" argument to rescan_file(); nobody uses what it returns. Change-Id: Iba7099b95de24309359d94eb96f606020e2ff2c3 Reviewed-on: https://code.wireshark.org/review/21232 Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'ui')
-rw-r--r--ui/alert_box.c64
-rw-r--r--ui/alert_box.h9
2 files changed, 72 insertions, 1 deletions
diff --git a/ui/alert_box.c b/ui/alert_box.c
index 26d2b49d8c..bdf71e20fa 100644
--- a/ui/alert_box.c
+++ b/ui/alert_box.c
@@ -25,7 +25,6 @@
#include <string.h>
-
#include <wiretap/wtap.h>
#include <wsutil/filesystem.h>
@@ -209,6 +208,69 @@ cfile_open_failure_alert_box(const char *filename, int err, gchar *err_info,
}
/*
+ * Alert box for a failed attempt to read from a capture file.
+ * "err" is assumed to be a UNIX-style errno or a WTAP_ERR_ value;
+ * "err_info" is assumed to be a string giving further information for
+ * some WTAP_ERR_ values.
+ */
+void
+cfile_read_failure_alert_box(const char *filename, int err, gchar *err_info)
+{
+ gchar *display_name;
+
+ if (filename == NULL)
+ display_name = g_strdup("capture file");
+ else {
+ gchar *display_basename;
+
+ display_basename = g_filename_display_basename(filename);
+ display_name = g_strdup_printf("capture file %s", display_basename);
+ g_free(display_basename);
+ }
+
+ switch (err) {
+
+ case WTAP_ERR_UNSUPPORTED:
+ simple_error_message_box(
+ "The %s contains record data that Wireshark doesn't support.\n(%s)",
+ display_name,
+ err_info != NULL ? err_info : "no information supplied");
+ g_free(err_info);
+ break;
+
+ case WTAP_ERR_SHORT_READ:
+ simple_error_message_box(
+ "The %s appears to have been cut short in the middle of a packet.",
+ display_name);
+ break;
+
+ case WTAP_ERR_BAD_FILE:
+ simple_error_message_box(
+ "The %s appears to be damaged or corrupt.\n(%s)",
+ display_name,
+ err_info != NULL ? err_info : "no information supplied");
+ g_free(err_info);
+ break;
+
+ case WTAP_ERR_DECOMPRESS:
+ simple_error_message_box(
+ "The compressed %s appears to be damaged or corrupt.\n(%s)",
+ display_name,
+ err_info != NULL ? err_info : "no information supplied");
+ g_free(err_info);
+ break;
+
+ default:
+ simple_error_message_box(
+ "An error occurred while reading the %s: %s.",
+ display_name,
+ wtap_strerror(err));
+ break;
+ }
+ g_free(display_name);
+}
+
+/*
* Alert box for a failed attempt to close a capture file.
* "err" is assumed to be a UNIX-style errno or a WTAP_ERR_ value.
*
diff --git a/ui/alert_box.h b/ui/alert_box.h
index bd19963279..1660749dc7 100644
--- a/ui/alert_box.h
+++ b/ui/alert_box.h
@@ -53,6 +53,15 @@ extern void cfile_open_failure_alert_box(const char *filename, int err,
int file_type);
/*
+ * Alert box for a failed attempt to read from a capture file.
+ * "err" is assumed to be a UNIX-style errno or a WTAP_ERR_ value;
+ * "err_info" is assumed to be a string giving further information for
+ * some WTAP_ERR_ values.
+ */
+extern void cfile_read_failure_alert_box(const char *filename, int err,
+ gchar *err_info);
+
+/*
* Alert box for a failed attempt to close a capture file.
* "err" is assumed to be a UNIX-style errno or a WTAP_ERR_ value.
*