diff options
author | Ashok Narayanan <ashokn@cisco.com> | 1999-09-22 01:26:50 +0000 |
---|---|---|
committer | Ashok Narayanan <ashokn@cisco.com> | 1999-09-22 01:26:50 +0000 |
commit | 3dfa56c4984047d92a8df46f50b92111a8bdf574 (patch) | |
tree | e41c0cbc0a89e356df2ca7ef5af0596b8fe40fba /wiretap/netmon.c | |
parent | 453a4e95fb0b91201f2950bac43316f330353034 (diff) |
This commit contains support for reading capture files compressed using
gzip. The zLib library is used for this purpose. If zLib is not available
(or it's use is disabled by the --disable-zlib option to configure), you
can still compile Ethereal but it will be unable to read compressed capture
files.
IMPORTANT:
Now all file accesses to capture files should be done through special macros.
Specifically, for any use of the following functions on capture files, replace them.
The arguments for the right-side functions are exactly the same as for the
original stdio functions.
fopen file_open
fdopen filed_open
fread file_read
fwrite file_write
fseek file_seek
fclose file_close
ferror file_error
svn path=/trunk/; revision=695
Diffstat (limited to 'wiretap/netmon.c')
-rw-r--r-- | wiretap/netmon.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/wiretap/netmon.c b/wiretap/netmon.c index b224282981..48b0a94958 100644 --- a/wiretap/netmon.c +++ b/wiretap/netmon.c @@ -1,6 +1,6 @@ /* netmon.c * - * $Id: netmon.c,v 1.13 1999/08/28 01:19:44 guy Exp $ + * $Id: netmon.c,v 1.14 1999/09/22 01:26:47 ashokn Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez <gram@verdict.uthscsa.edu> @@ -25,6 +25,7 @@ #endif #include <errno.h> #include <time.h> +#include "file.h" #include "wtap.h" #include "buffer.h" #include "netmon.h" @@ -117,11 +118,11 @@ int netmon_open(wtap *wth, int *err) /* Read in the string that should be at the start of a Network * Monitor file */ - fseek(wth->fh, 0, SEEK_SET); + file_seek(wth->fh, 0, SEEK_SET); errno = WTAP_ERR_CANT_READ; - bytes_read = fread(magic, 1, sizeof magic, wth->fh); + bytes_read = file_read(magic, 1, sizeof magic, wth->fh); if (bytes_read != sizeof magic) { - if (ferror(wth->fh)) { + if (file_error(wth->fh)) { *err = errno; return -1; } @@ -135,9 +136,9 @@ int netmon_open(wtap *wth, int *err) /* Read the rest of the header. */ errno = WTAP_ERR_CANT_READ; - bytes_read = fread(&hdr, 1, sizeof hdr, wth->fh); + bytes_read = file_read(&hdr, 1, sizeof hdr, wth->fh); if (bytes_read != sizeof hdr) { - if (ferror(wth->fh)) { + if (file_error(wth->fh)) { *err = errno; return -1; } @@ -213,7 +214,7 @@ int netmon_open(wtap *wth, int *err) wth->capture.netmon->end_offset = pletohl(&hdr.frametableoffset); /* Seek to the beginning of the data records. */ - fseek(wth->fh, CAPTUREFILE_HEADER_SIZE, SEEK_SET); + file_seek(wth->fh, CAPTUREFILE_HEADER_SIZE, SEEK_SET); wth->data_offset = CAPTUREFILE_HEADER_SIZE; return 1; @@ -251,9 +252,9 @@ static int netmon_read(wtap *wth, int *err) break; } errno = WTAP_ERR_CANT_READ; - bytes_read = fread(&hdr, 1, hdr_size, wth->fh); + bytes_read = file_read(&hdr, 1, hdr_size, wth->fh); if (bytes_read != hdr_size) { - if (ferror(wth->fh)) { + if (file_error(wth->fh)) { *err = errno; return -1; } @@ -288,11 +289,11 @@ static int netmon_read(wtap *wth, int *err) buffer_assure_space(wth->frame_buffer, packet_size); data_offset = wth->data_offset; errno = WTAP_ERR_CANT_READ; - bytes_read = fread(buffer_start_ptr(wth->frame_buffer), 1, + bytes_read = file_read(buffer_start_ptr(wth->frame_buffer), 1, packet_size, wth->fh); if (bytes_read != packet_size) { - if (ferror(wth->fh)) + if (file_error(wth->fh)) *err = errno; else *err = WTAP_ERR_SHORT_READ; |