aboutsummaryrefslogtreecommitdiffstats
path: root/file.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2014-12-17 16:02:50 -0800
committerGuy Harris <guy@alum.mit.edu>2014-12-18 00:03:26 +0000
commit51522b33723dec4dd0481dcabc261010be39937c (patch)
tree4c772ba5dd3a61a470784464e39573ca27c5028c /file.c
parent8ce0f122011f26ab4e81172e9899ed27a5508abd (diff)
Handle "I can't map this for that file format" better.
For cases where record (meta)data is something that can't be written out in a particular file format, return WTAP_ERR_UNWRITABLE_REC_DATA along with an err_info string. Report (and free) that err_info string in cases where WTAP_ERR_UNWRITABLE_REC_DATA is returned. Clean up some other error reporting cases, and flag with an XXX some cases where we aren't reporting errors at all, while we're at it. Change-Id: I91d02093af0d42c24ec4634c2c773b30f3d39ab3 Reviewed-on: https://code.wireshark.org/review/5823 Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'file.c')
-rw-r--r--file.c61
1 files changed, 58 insertions, 3 deletions
diff --git a/file.c b/file.c
index 3d744571c2..160c31de5e 100644
--- a/file.c
+++ b/file.c
@@ -1248,7 +1248,7 @@ cf_merge_files(char **out_filenamep, int in_file_count,
int out_fd;
wtap_dumper *pdh;
int open_err, read_err, write_err, close_err;
- gchar *err_info;
+ gchar *err_info, *write_err_info;
int err_fileno;
int i;
gboolean got_read_error = FALSE, got_write_error = FALSE;
@@ -1491,7 +1491,7 @@ cf_merge_files(char **out_filenamep, int in_file_count,
phdr->presence_flags = phdr->presence_flags | WTAP_HAS_INTERFACE_ID;
}
if (!wtap_dump(pdh, wtap_phdr(in_file->wth),
- wtap_buf_ptr(in_file->wth), &write_err)) {
+ wtap_buf_ptr(in_file->wth), &write_err, &write_err_info)) {
got_write_error = TRUE;
break;
}
@@ -1599,6 +1599,36 @@ cf_merge_files(char **out_filenamep, int in_file_count,
g_free(display_basename);
break;
+ case WTAP_ERR_REC_TYPE_UNSUPPORTED:
+ /*
+ * 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.
+ */
+ display_basename = g_filename_display_basename(in_file ? in_file->filename : "UNKNOWN");
+ simple_error_message_box(
+ "Record %u of \"%s\" has a record type that can't be saved in a \"%s\" file.",
+ in_file ? in_file->packet_num : 0, display_basename,
+ wtap_file_type_subtype_string(file_type));
+ g_free(display_basename);
+ break;
+
+ case WTAP_ERR_UNWRITABLE_REC_DATA:
+ /*
+ * 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.
+ */
+ display_basename = g_filename_display_basename(in_file ? in_file->filename : "UNKNOWN");
+ simple_error_message_box(
+ "Record %u of \"%s\" has data that can't be saved in a \"%s\" file.\n(%s)",
+ in_file ? in_file->packet_num : 0, display_basename,
+ wtap_file_type_subtype_string(file_type),
+ write_err_info);
+ g_free(write_err_info);
+ g_free(display_basename);
+ break;
+
default:
display_basename = g_filename_display_basename(out_filename);
simple_error_message_box(
@@ -4098,6 +4128,7 @@ save_record(capture_file *cf, frame_data *fdata,
save_callback_args_t *args = (save_callback_args_t *)argsp;
struct wtap_pkthdr hdr;
int err;
+ gchar *err_info;
gchar *display_basename;
const char *pkt_comment;
@@ -4145,7 +4176,7 @@ save_record(capture_file *cf, frame_data *fdata,
hdr.pack_flags = /* XXX - 0 for now (any value for "we don't have it"?) */
#endif
/* and save the packet */
- if (!wtap_dump(args->pdh, &hdr, pd, &err)) {
+ if (!wtap_dump(args->pdh, &hdr, pd, &err, &err_info)) {
if (err < 0) {
/* Wiretap error. */
switch (err) {
@@ -4172,6 +4203,30 @@ save_record(capture_file *cf, frame_data *fdata,
fdata->num, wtap_file_type_subtype_string(args->file_type));
break;
+ case WTAP_ERR_REC_TYPE_UNSUPPORTED:
+ /*
+ * 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);
+ g_free(err_info);
+ break;
+
default:
display_basename = g_filename_display_basename(args->fname);
simple_error_message_box(