aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap/toshiba.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2002-03-05 08:40:27 +0000
committerGuy Harris <guy@alum.mit.edu>2002-03-05 08:40:27 +0000
commitb5e9cef2bfa66c607b3282952cfb4ce11976dd18 (patch)
tree2c75bbaa81b557864090331ad07e44813683b7ea /wiretap/toshiba.c
parente300f4db52ddfcdfbf8a53d69d88e037365cb7a3 (diff)
Make "wtap_seek_read()" return TRUE on success and FALSE on error, like
"wtap_read()". Add some additional error checks to the Sniffer file reader. svn path=/trunk/; revision=4875
Diffstat (limited to 'wiretap/toshiba.c')
-rw-r--r--wiretap/toshiba.c31
1 files changed, 15 insertions, 16 deletions
diff --git a/wiretap/toshiba.c b/wiretap/toshiba.c
index c356959286..06d2a9ed47 100644
--- a/wiretap/toshiba.c
+++ b/wiretap/toshiba.c
@@ -1,6 +1,6 @@
/* toshiba.c
*
- * $Id: toshiba.c,v 1.22 2002/03/05 05:58:41 guy Exp $
+ * $Id: toshiba.c,v 1.23 2002/03/05 08:39:29 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
@@ -110,10 +110,12 @@ static const char toshiba_rec_magic[] = { '[', 'N', 'o', '.' };
#define TOSHIBA_MAX_PACKET_LEN 16384
static gboolean toshiba_read(wtap *wth, int *err, long *data_offset);
-static int toshiba_seek_read(wtap *wth, long seek_off,
+static gboolean toshiba_seek_read(wtap *wth, long seek_off,
union wtap_pseudo_header *pseudo_header, guint8 *pd, int len, int *err);
-static gboolean parse_single_hex_dump_line(char* rec, guint8 *buf, guint byte_offset);
-static int parse_toshiba_hex_dump(FILE_T fh, int pkt_len, guint8* buf, int *err);
+static gboolean parse_single_hex_dump_line(char* rec, guint8 *buf,
+ guint byte_offset);
+static gboolean parse_toshiba_hex_dump(FILE_T fh, int pkt_len, guint8* buf,
+ int *err);
static int parse_toshiba_rec_hdr(wtap *wth, FILE_T fh,
union wtap_pseudo_header *pseudo_header, int *err);
@@ -248,7 +250,7 @@ static gboolean toshiba_read(wtap *wth, int *err, long *data_offset)
buf = buffer_start_ptr(wth->frame_buffer);
/* Convert the ASCII hex dump to binary data */
- if (parse_toshiba_hex_dump(wth->fh, pkt_len, buf, err) == -1)
+ if (!parse_toshiba_hex_dump(wth->fh, pkt_len, buf, err))
return FALSE;
wth->data_offset = offset;
@@ -257,7 +259,7 @@ static gboolean toshiba_read(wtap *wth, int *err, long *data_offset)
}
/* Used to read packets in random-access fashion */
-static int
+static gboolean
toshiba_seek_read (wtap *wth, long seek_off,
union wtap_pseudo_header *pseudo_header, guint8 *pd, int len, int *err)
{
@@ -265,7 +267,7 @@ toshiba_seek_read (wtap *wth, long seek_off,
if (file_seek(wth->random_fh, seek_off - 1, SEEK_SET) == -1) {
*err = file_error(wth->random_fh);
- return -1;
+ return FALSE;
}
pkt_len = parse_toshiba_rec_hdr(NULL, wth->random_fh, pseudo_header,
@@ -274,13 +276,10 @@ toshiba_seek_read (wtap *wth, long seek_off,
if (pkt_len != len) {
if (pkt_len != -1)
*err = WTAP_ERR_BAD_RECORD;
- return -1;
+ return FALSE;
}
- if (parse_toshiba_hex_dump(wth->random_fh, pkt_len, pd, err) == -1)
- return -1;
-
- return 0;
+ return parse_toshiba_hex_dump(wth->random_fh, pkt_len, pd, err);
}
/* Parses a packet record header. */
@@ -373,7 +372,7 @@ parse_toshiba_rec_hdr(wtap *wth, FILE_T fh,
}
/* Converts ASCII hex dump to binary data */
-static int
+static gboolean
parse_toshiba_hex_dump(FILE_T fh, int pkt_len, guint8* buf, int *err)
{
char line[TOSHIBA_LINE_LENGTH];
@@ -389,14 +388,14 @@ parse_toshiba_hex_dump(FILE_T fh, int pkt_len, guint8* buf, int *err)
if (*err == 0) {
*err = WTAP_ERR_SHORT_READ;
}
- return -1;
+ return FALSE;
}
if (!parse_single_hex_dump_line(line, buf, i * 16)) {
*err = WTAP_ERR_BAD_RECORD;
- return -1;
+ return FALSE;
}
}
- return 0;
+ return TRUE;
}
/*