aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap/toshiba.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2011-04-21 09:41:52 +0000
committerGuy Harris <guy@alum.mit.edu>2011-04-21 09:41:52 +0000
commit6cbf6ce16c45c4855ebddd3516465885e3c476d5 (patch)
tree299ce4fc08cb26cc0c0712c6b54de9c76893e7ca /wiretap/toshiba.c
parent0315e063e4267b97fc7716301350af07dd0f2bea (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. svn path=/trunk/; revision=36748
Diffstat (limited to 'wiretap/toshiba.c')
-rw-r--r--wiretap/toshiba.c28
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;
}