diff options
author | guy <guy@f5534014-38df-0310-8fa8-9805f1628bb7> | 2011-04-21 09:41:52 +0000 |
---|---|---|
committer | guy <guy@f5534014-38df-0310-8fa8-9805f1628bb7> | 2011-04-21 09:41:52 +0000 |
commit | bf5d8d18e36e02f7f197738afc830e2c4341dd69 (patch) | |
tree | 299ce4fc08cb26cc0c0712c6b54de9c76893e7ca /wiretap/toshiba.c | |
parent | bf80a1d2d0395923cfd70fe3ce9a5e20b6f94466 (diff) |
Add a new WTAP_ERR_DECOMPRESS error, and use that for errors discovered
by the gunzipping code. Have it also supply a err_info string, and
report it. Have file_error() supply an err_info string.
Put "the file" - or, for WTAP_ERR_DECOMPRESS, "the compressed file", to
suggest a decompression error - into the rawshark and tshark errors,
along the lines of what other programs print.
Fix a case in the Netscaler code where we weren't fetching the error
code on a read failure.
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@36748 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'wiretap/toshiba.c')
-rw-r--r-- | wiretap/toshiba.c | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/wiretap/toshiba.c b/wiretap/toshiba.c index bfaf304bbb..2072ccddc2 100644 --- a/wiretap/toshiba.c +++ b/wiretap/toshiba.c @@ -122,8 +122,9 @@ static int parse_toshiba_rec_hdr(wtap *wth, FILE_T fh, union wtap_pseudo_header *pseudo_header, int *err, gchar **err_info); /* Seeks to the beginning of the next packet, and returns the - byte offset. Returns -1 on failure, and sets "*err" to the error. */ -static gint64 toshiba_seek_next_packet(wtap *wth, int *err) + byte offset. Returns -1 on failure, and sets "*err" to the error + and "*err_info" to null or an additional error string. */ +static gint64 toshiba_seek_next_packet(wtap *wth, int *err, gchar **err_info) { int byte; guint level = 0; @@ -137,7 +138,7 @@ static gint64 toshiba_seek_next_packet(wtap *wth, int *err) cur_off = file_tell(wth->fh); if (cur_off == -1) { /* Error. */ - *err = file_error(wth->fh); + *err = file_error(wth->fh, err_info); return -1; } return cur_off + 1; @@ -151,7 +152,7 @@ static gint64 toshiba_seek_next_packet(wtap *wth, int *err) *err = 0; } else { /* We got an error. */ - *err = file_error(wth->fh); + *err = file_error(wth->fh, err_info); } return -1; } @@ -163,9 +164,10 @@ static gint64 toshiba_seek_next_packet(wtap *wth, int *err) * a Toshiba trace file. * * Returns TRUE if it is, FALSE if it isn't or if we get an I/O error; - * if we get an I/O error, "*err" will be set to a non-zero value. + * if we get an I/O error, "*err" will be set to a non-zero value and + * "*err_info" will be set to null or an additional error string. */ -static gboolean toshiba_check_file_type(wtap *wth, int *err) +static gboolean toshiba_check_file_type(wtap *wth, int *err, gchar **err_info) { char buf[TOSHIBA_LINE_LENGTH]; guint i, reclen, level, line; @@ -200,7 +202,7 @@ static gboolean toshiba_check_file_type(wtap *wth, int *err) if (file_eof(wth->fh)) *err = 0; else - *err = file_error(wth->fh); + *err = file_error(wth->fh, err_info); return FALSE; } } @@ -209,10 +211,10 @@ static gboolean toshiba_check_file_type(wtap *wth, int *err) } -int toshiba_open(wtap *wth, int *err, gchar **err_info _U_) +int toshiba_open(wtap *wth, int *err, gchar **err_info) { /* Look for Toshiba header */ - if (!toshiba_check_file_type(wth, err)) { + if (!toshiba_check_file_type(wth, err, err_info)) { if (*err == 0) return 0; else @@ -239,7 +241,7 @@ static gboolean toshiba_read(wtap *wth, int *err, gchar **err_info, int pkt_len; /* Find the next packet */ - offset = toshiba_seek_next_packet(wth, err); + offset = toshiba_seek_next_packet(wth, err, err_info); if (offset < 1) return FALSE; @@ -303,7 +305,7 @@ parse_toshiba_rec_hdr(wtap *wth, FILE_T fh, * extract the useful information */ if (file_gets(line, TOSHIBA_LINE_LENGTH, fh) == NULL) { - *err = file_error(fh); + *err = file_error(fh, err_info); if (*err == 0) { *err = WTAP_ERR_SHORT_READ; } @@ -333,7 +335,7 @@ parse_toshiba_rec_hdr(wtap *wth, FILE_T fh, */ do { if (file_gets(line, TOSHIBA_LINE_LENGTH, fh) == NULL) { - *err = file_error(fh); + *err = file_error(fh, err_info); if (*err == 0) { *err = WTAP_ERR_SHORT_READ; } @@ -398,7 +400,7 @@ parse_toshiba_hex_dump(FILE_T fh, int pkt_len, guint8* buf, int *err, for (i = 0; i < hex_lines; i++) { if (file_gets(line, TOSHIBA_LINE_LENGTH, fh) == NULL) { - *err = file_error(fh); + *err = file_error(fh, err_info); if (*err == 0) { *err = WTAP_ERR_SHORT_READ; } |