aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2017-04-20 13:25:21 -0700
committerGuy Harris <guy@alum.mit.edu>2017-04-20 20:25:59 +0000
commit64ec2b2e5ed590a6f1a3d22c8b24a6e70420d1f9 (patch)
treeaab752fe44790898535c850d89e015b75b569149 /ui
parent2e6cb9dbab154531b306e472642ff6033f0e341c (diff)
Take the error message generation out of the merge_files routines.
Have them just return the information needed for the caller to produce an error message, and have the callers use the new cfile_ routines for reporting errors. This requires that the "write failure alert box" routine take the *input* file name as an argument, so that, on a merge, if the problem is that a record from a given input file can't be written out to the type of output file we're generating, the input file name can be given, along with the record number in that file. Change-Id: If5a5e00539e7e652008a523dec92c0b359a48e71 Reviewed-on: https://code.wireshark.org/review/21257 Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'ui')
-rw-r--r--ui/alert_box.c68
-rw-r--r--ui/alert_box.h20
2 files changed, 53 insertions, 35 deletions
diff --git a/ui/alert_box.c b/ui/alert_box.c
index 8f870269e9..d387dacb8d 100644
--- a/ui/alert_box.c
+++ b/ui/alert_box.c
@@ -307,21 +307,30 @@ 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.
+ * "in_filename" is the name of the file from which the record being
+ * written came; "out_filename" is the name of the file to which we're
+ * writing; "err" is assumed "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)
+cfile_write_failure_alert_box(const char *in_filename, const char *out_filename,
+ int err, gchar *err_info, guint32 framenum,
+ int file_type_subtype)
{
- char *display_basename;
+ char *in_file_string;
+ char *out_display_basename;
if (err < 0) {
/* Wiretap error. */
+ if (in_filename == NULL)
+ in_file_string = g_strdup("");
+ else
+ in_file_string = g_strdup_printf(" of file \"%s\"", in_filename);
+
switch (err) {
case WTAP_ERR_UNWRITABLE_ENCAP:
@@ -331,8 +340,9 @@ cfile_write_failure_alert_box(const char *filename, int err, gchar *err_info,
* 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));
+ "Frame %u%s has a network type that can't be saved in a \"%s\" file.",
+ framenum, in_file_string,
+ wtap_file_type_subtype_string(file_type_subtype));
break;
case WTAP_ERR_PACKET_TOO_LARGE:
@@ -342,8 +352,9 @@ cfile_write_failure_alert_box(const char *filename, int err, gchar *err_info,
* 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));
+ "Frame %u%s is larger than Wireshark supports in a \"%s\" file.",
+ framenum, in_file_string,
+ wtap_file_type_subtype_string(file_type_subtype));
break;
case WTAP_ERR_UNWRITABLE_REC_TYPE:
@@ -353,43 +364,46 @@ cfile_write_failure_alert_box(const char *filename, int err, gchar *err_info,
* 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));
+ "Record %u%s has a record type that can't be saved in a \"%s\" file.",
+ framenum, in_file_string,
+ 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
+ * 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 frame number and file type/subtype.
+ * the record number and file type/subtype.
*/
simple_error_message_box(
- "Record %u has data that can't be saved in a \"%s\" file.\n"
+ "Record %u%s has data that can't be saved in a \"%s\" file.\n"
"(%s)",
- framenum, wtap_file_type_subtype_string(file_type_subtype),
+ framenum, in_file_string,
+ wtap_file_type_subtype_string(file_type_subtype),
err_info != NULL ? err_info : "no information supplied");
g_free(err_info);
break;
case WTAP_ERR_SHORT_WRITE:
- display_basename = g_filename_display_basename(filename);
+ out_display_basename = g_filename_display_basename(out_filename);
simple_error_message_box(
"A full write couldn't be done to the file \"%s\".",
- display_basename);
- g_free(display_basename);
+ out_display_basename);
+ g_free(out_display_basename);
break;
default:
- display_basename = g_filename_display_basename(filename);
+ out_display_basename = g_filename_display_basename(out_filename);
simple_error_message_box(
"An error occurred while writing to the file \"%s\": %s.",
- display_basename, wtap_strerror(err));
- g_free(display_basename);
+ out_display_basename, wtap_strerror(err));
+ g_free(out_display_basename);
break;
- }
+ }
+ g_free(in_file_string);
} else {
/* OS error. */
- write_failure_alert_box(filename, err);
+ write_failure_alert_box(out_filename, err);
}
}
diff --git a/ui/alert_box.h b/ui/alert_box.h
index 74d3261474..5d392e7107 100644
--- a/ui/alert_box.h
+++ b/ui/alert_box.h
@@ -69,15 +69,19 @@ extern void cfile_read_failure_alert_box(const char *filename, int err,
/*
* 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.
+ * "in_filename" is the name of the file from which the record being
+ * written came; "out_filename" is the name of the file to which we're
+ * writing; "err" is assumed "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,
+extern void cfile_write_failure_alert_box(const char *in_filename,
+ const char *out_filename,
+ int err, gchar *err_info,
+ guint32 framenum,
int file_type_subtype);
/*