aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--file.c65
-rw-r--r--ui/alert_box.c88
-rw-r--r--ui/alert_box.h20
3 files changed, 103 insertions, 70 deletions
diff --git a/file.c b/file.c
index 7bdc8e80ae..23a010ccaf 100644
--- a/file.c
+++ b/file.c
@@ -4006,7 +4006,6 @@ save_record(capture_file *cf, frame_data *fdata,
struct wtap_pkthdr hdr;
int err;
gchar *err_info;
- gchar *display_basename;
const char *pkt_comment;
if (fdata->flags.has_user_comment)
@@ -4053,68 +4052,8 @@ save_record(capture_file *cf, frame_data *fdata,
#endif
/* and save the packet */
if (!wtap_dump(args->pdh, &hdr, pd, &err, &err_info)) {
- if (err < 0) {
- /* Wiretap error. */
- switch (err) {
-
- case WTAP_ERR_UNWRITABLE_ENCAP:
- /*
- * This is a problem with the particular frame we're writing and
- * the file type and subtype we're writing; note that, and report
- * the frame number and file type/subtype.
- */
- simple_error_message_box(
- "Frame %u has a network type that can't be saved in a \"%s\" file.",
- fdata->num, wtap_file_type_subtype_string(args->file_type));
- break;
-
- case WTAP_ERR_PACKET_TOO_LARGE:
- /*
- * This is a problem with the particular frame we're writing and
- * the file type and subtype we're writing; note that, and report
- * the frame number and file type/subtype.
- */
- simple_error_message_box(
- "Frame %u is larger than Wireshark supports in a \"%s\" file.",
- fdata->num, wtap_file_type_subtype_string(args->file_type));
- break;
-
- case WTAP_ERR_UNWRITABLE_REC_TYPE:
- /*
- * This is a problem with the particular record we're writing and
- * the file type and subtype we're writing; note that, and report
- * the record number and file type/subtype.
- */
- simple_error_message_box(
- "Record %u has a record type that can't be saved in a \"%s\" file.",
- fdata->num, wtap_file_type_subtype_string(args->file_type));
- break;
-
- case WTAP_ERR_UNWRITABLE_REC_DATA:
- /*
- * This is a problem with the particular frame we're writing and
- * the file type and subtype we're writing; note that, and report
- * the frame number and file type/subtype.
- */
- simple_error_message_box(
- "Record %u has data that can't be saved in a \"%s\" file.\n(%s)",
- fdata->num, wtap_file_type_subtype_string(args->file_type),
- err_info != NULL ? err_info : "no information supplied");
- g_free(err_info);
- break;
-
- default:
- display_basename = g_filename_display_basename(args->fname);
- simple_error_message_box(
- "An error occurred while writing to the file \"%s\": %s.",
- display_basename, wtap_strerror(err));
- g_free(display_basename);
- break;
- }
- } else {
- /* OS error. */
- write_failure_alert_box(args->fname, err);
- }
+ cfile_write_failure_alert_box(args->fname, err, err_info, fdata->num,
+ args->file_type);
return FALSE;
}
diff --git a/ui/alert_box.c b/ui/alert_box.c
index bdf71e20fa..327bf61cc2 100644
--- a/ui/alert_box.c
+++ b/ui/alert_box.c
@@ -63,8 +63,9 @@ vwarning_alert_box(const char *msg_format, va_list ap)
* "err_info" is assumed to be a string giving further information for
* some WTAP_ERR_ values; "for_writing" is TRUE if the file is being
* opened for writing and FALSE if it's being opened for reading;
- * "file_type" is a WTAP_FILE_TYPE_SUBTYPE_ value for the type of
- * file being written (it's ignored for opening-for-reading errors).
+ * "file_type_subtype" is a WTAP_FILE_TYPE_SUBTYPE_ value for the type
+ * and subtype of file being opened for writing (it's ignored for
+ * opening-for-reading errors).
*
* XXX - add explanatory secondary text for at least some of the errors;
* various HIGs suggest that you should, for example, suggest that the
@@ -74,7 +75,7 @@ vwarning_alert_box(const char *msg_format, va_list ap)
*/
void
cfile_open_failure_alert_box(const char *filename, int err, gchar *err_info,
- gboolean for_writing, int file_type)
+ gboolean for_writing, int file_type_subtype)
{
gchar *display_basename;
@@ -119,7 +120,7 @@ cfile_open_failure_alert_box(const char *filename, int err, gchar *err_info,
simple_error_message_box(
"The file \"%s\" is a pipe, and %s capture files can't be "
"written to a pipe.",
- display_basename, wtap_file_type_subtype_string(file_type));
+ display_basename, wtap_file_type_subtype_string(file_type_subtype));
break;
case WTAP_ERR_UNWRITABLE_FILE_TYPE:
@@ -271,6 +272,85 @@ cfile_read_failure_alert_box(const char *filename, int err, gchar *err_info)
}
/*
+ * Alert box for a failed attempt to write to 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; "framenum" is the frame number of the record
+ * on which the error occurred; "file_type_subtype" is a
+ * WTAP_FILE_TYPE_SUBTYPE_ value for the type and subtype of file being
+ * written.
+ */
+void
+cfile_write_failure_alert_box(const char *filename, int err, gchar *err_info,
+ guint32 framenum, int file_type_subtype)
+{
+ char *display_basename;
+
+ if (err < 0) {
+ /* Wiretap error. */
+ switch (err) {
+
+ case WTAP_ERR_UNWRITABLE_ENCAP:
+ /*
+ * This is a problem with the particular frame we're writing and
+ * the file type and subtype we're writing; note that, and report
+ * the frame number and file type/subtype.
+ */
+ simple_error_message_box(
+ "Frame %u has a network type that can't be saved in a \"%s\" file.",
+ framenum, wtap_file_type_subtype_string(file_type_subtype));
+ break;
+
+ case WTAP_ERR_PACKET_TOO_LARGE:
+ /*
+ * This is a problem with the particular frame we're writing and
+ * the file type and subtype we're writing; note that, and report
+ * the frame number and file type/subtype.
+ */
+ simple_error_message_box(
+ "Frame %u is larger than Wireshark supports in a \"%s\" file.",
+ framenum, wtap_file_type_subtype_string(file_type_subtype));
+ break;
+
+ case WTAP_ERR_UNWRITABLE_REC_TYPE:
+ /*
+ * This is a problem with the particular record we're writing and
+ * the file type and subtype we're writing; note that, and report
+ * the record number and file type/subtype.
+ */
+ simple_error_message_box(
+ "Record %u has a record type that can't be saved in a \"%s\" file.",
+ framenum, wtap_file_type_subtype_string(file_type_subtype));
+ break;
+
+ case WTAP_ERR_UNWRITABLE_REC_DATA:
+ /*
+ * This is a problem with the particular frame we're writing and
+ * the file type and subtype we're writing; note that, and report
+ * the frame number and file type/subtype.
+ */
+ simple_error_message_box(
+ "Record %u has data that can't be saved in a \"%s\" file.\n(%s)",
+ framenum, wtap_file_type_subtype_string(file_type_subtype),
+ err_info != NULL ? err_info : "no information supplied");
+ g_free(err_info);
+ break;
+
+ default:
+ display_basename = g_filename_display_basename(filename);
+ simple_error_message_box(
+ "An error occurred while writing to the file \"%s\": %s.",
+ display_basename, wtap_strerror(err));
+ g_free(display_basename);
+ break;
+ }
+ } else {
+ /* OS error. */
+ write_failure_alert_box(filename, err);
+ }
+}
+
+/*
* 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 1660749dc7..ee8d22cdbc 100644
--- a/ui/alert_box.h
+++ b/ui/alert_box.h
@@ -45,12 +45,13 @@ extern void vwarning_alert_box(const char *msg_format, va_list ap);
* "err_info" is assumed to be a string giving further information for
* some WTAP_ERR_ values; "for_writing" is TRUE if the file is being
* opened for writing and FALSE if it's being opened for reading;
- * "file_type" is a WTAP_FILE_TYPE_SUBTYPE_ value for the type of
- * file being written (it's ignored for opening-for-reading errors).
+ * "file_type_subtype" is a WTAP_FILE_TYPE_SUBTYPE_ value for the type
+ * and subtype of file being opened for writing (it's ignored for
+ * opening-for-reading errors).
*/
extern void cfile_open_failure_alert_box(const char *filename, int err,
gchar *err_info, gboolean for_writing,
- int file_type);
+ int file_type_subtype);
/*
* Alert box for a failed attempt to read from a capture file.
@@ -62,6 +63,19 @@ extern void cfile_read_failure_alert_box(const char *filename, int err,
gchar *err_info);
/*
+ * Alert box for a failed attempt to write to 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; "framenum" is the frame number of the record
+ * on which the error occurred; "file_type_subtype" is a
+ * WTAP_FILE_TYPE_SUBTYPE_ value for the type and subtype of file being
+ * written.
+ */
+extern void cfile_write_failure_alert_box(const char *filename, int err,
+ gchar *err_info, guint32 framenum,
+ int file_type_subtype);
+
+/*
* 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.
*