diff options
author | Guy Harris <guy@alum.mit.edu> | 2014-12-17 16:02:50 -0800 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2014-12-18 00:03:26 +0000 |
commit | 51522b33723dec4dd0481dcabc261010be39937c (patch) | |
tree | 4c772ba5dd3a61a470784464e39573ca27c5028c /mergecap.c | |
parent | 8ce0f122011f26ab4e81172e9899ed27a5508abd (diff) | |
download | wireshark-51522b33723dec4dd0481dcabc261010be39937c.tar.gz |
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 'mergecap.c')
-rw-r--r-- | mergecap.c | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/mergecap.c b/mergecap.c index b85f1f04e8..433d44584d 100644 --- a/mergecap.c +++ b/mergecap.c @@ -254,7 +254,7 @@ main(int argc, char *argv[]) struct wtap_pkthdr *phdr, snap_phdr; wtap_dumper *pdh; int open_err, read_err = 0, write_err, close_err; - gchar *err_info; + gchar *err_info, *write_err_info; int err_fileno; char *out_filename = NULL; gboolean got_read_error = FALSE, got_write_error = FALSE; @@ -379,6 +379,7 @@ main(int argc, char *argv[]) case WTAP_ERR_UNSUPPORTED: case WTAP_ERR_UNWRITABLE_ENCAP: case WTAP_ERR_BAD_FILE: + case WTAP_ERR_UNWRITABLE_REC_DATA: fprintf(stderr, "(%s)\n", err_info); g_free(err_info); break; @@ -515,7 +516,7 @@ main(int argc, char *argv[]) phdr = &snap_phdr; } - if (!wtap_dump(pdh, phdr, wtap_buf_ptr(in_file->wth), &write_err)) { + if (!wtap_dump(pdh, phdr, wtap_buf_ptr(in_file->wth), &write_err, &write_err_info)) { got_write_error = TRUE; break; } @@ -548,6 +549,7 @@ main(int argc, char *argv[]) case WTAP_ERR_UNSUPPORTED: case WTAP_ERR_UNWRITABLE_ENCAP: case WTAP_ERR_BAD_FILE: + case WTAP_ERR_UNWRITABLE_REC_DATA: fprintf(stderr, "(%s)\n", err_info); g_free(err_info); break; @@ -576,11 +578,35 @@ main(int argc, char *argv[]) * the file type and subtype we're wwriting; note that, and * report the frame number and file type/subtype. */ - fprintf(stderr, "mergecap: Frame %u of \"%s\" is too large for a \"%s\" file\n.", + fprintf(stderr, "mergecap: Frame %u of \"%s\" is too large for a \"%s\" file.\n", in_file ? in_file->packet_num : 0, in_file ? in_file->filename : "UNKNOWN", wtap_file_type_subtype_string(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 wwriting; note that, and + * report the record number and file type/subtype. + */ + fprintf(stderr, "mergecap: Record %u of \"%s\" has a record type that can't be saved in a \"%s\" file.\n", + in_file ? in_file->packet_num : 0, in_file ? in_file->filename : "UNKNOWN", + wtap_file_type_subtype_string(file_type)); + 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 wwriting; note that, and + * report the record number and file type/subtype. + */ + fprintf(stderr, "mergecap: Record %u of \"%s\" has data that can't be saved in a \"%s\" file.\n(%s)\n", + in_file ? in_file->packet_num : 0, in_file ? in_file->filename : "UNKNOWN", + wtap_file_type_subtype_string(file_type), + write_err_info); + g_free(write_err_info); + break; + default: fprintf(stderr, "mergecap: Error writing to outfile: %s\n", wtap_strerror(write_err)); |