aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap/libpcap.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>1999-10-05 07:06:08 +0000
committerGuy Harris <guy@alum.mit.edu>1999-10-05 07:06:08 +0000
commit5f7868c7e039265d585f79952d1cd1867ab5cf1e (patch)
treefc21365a3ed0d03130e733c2c10a8abe4aa946a2 /wiretap/libpcap.c
parent03b75d6279db74fd3fd175cb572ea9340e452b65 (diff)
Better handle errors from zlib:
Assign a range of Wiretap errors for zlib errors, and have "wtap_strerror()" use "zError()" to get an error message for them. Have the internal "file_error()" routine return 0 for no error and a Wiretap error code for an error. svn path=/trunk/; revision=769
Diffstat (limited to 'wiretap/libpcap.c')
-rw-r--r--wiretap/libpcap.c22
1 files changed, 9 insertions, 13 deletions
diff --git a/wiretap/libpcap.c b/wiretap/libpcap.c
index 2f22d78154..f4dfc19d35 100644
--- a/wiretap/libpcap.c
+++ b/wiretap/libpcap.c
@@ -1,6 +1,6 @@
/* libpcap.c
*
- * $Id: libpcap.c,v 1.20 1999/09/24 05:49:51 guy Exp $
+ * $Id: libpcap.c,v 1.21 1999/10/05 07:06:06 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@verdict.uthscsa.edu>
@@ -152,10 +152,9 @@ int libpcap_open(wtap *wth, int *err)
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&magic, 1, sizeof magic, wth->fh);
if (bytes_read != sizeof magic) {
- if (file_error(wth->fh)) {
- *err = errno;
+ *err = file_error(wth->fh);
+ if (*err != 0)
return -1;
- }
return 0;
}
wth->data_offset += sizeof magic;
@@ -173,10 +172,9 @@ int libpcap_open(wtap *wth, int *err)
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&hdr, 1, sizeof hdr, wth->fh);
if (bytes_read != sizeof hdr) {
- if (file_error(wth->fh)) {
- *err = errno;
+ *err = file_error(wth->fh);
+ if (*err != 0)
return -1;
- }
return 0;
}
wth->data_offset += sizeof hdr;
@@ -227,10 +225,9 @@ static int libpcap_read(wtap *wth, int *err)
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(&hdr, 1, sizeof hdr, wth->fh);
if (bytes_read != sizeof hdr) {
- if (file_error(wth->fh)) {
- *err = errno;
+ *err = file_error(wth->fh);
+ if (*err != 0)
return -1;
- }
if (bytes_read != 0) {
*err = WTAP_ERR_SHORT_READ;
return -1;
@@ -285,9 +282,8 @@ static int libpcap_read(wtap *wth, int *err)
packet_size, wth->fh);
if (bytes_read != packet_size) {
- if (file_error(wth->fh))
- *err = errno;
- else
+ *err = file_error(wth->fh);
+ if (*err == 0)
*err = WTAP_ERR_SHORT_READ;
return -1;
}