aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap/lanalyzer.c
diff options
context:
space:
mode:
authorAshok Narayanan <ashokn@cisco.com>1999-09-22 01:26:50 +0000
committerAshok Narayanan <ashokn@cisco.com>1999-09-22 01:26:50 +0000
commit3dfa56c4984047d92a8df46f50b92111a8bdf574 (patch)
treee41c0cbc0a89e356df2ca7ef5af0596b8fe40fba /wiretap/lanalyzer.c
parent453a4e95fb0b91201f2950bac43316f330353034 (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/lanalyzer.c')
-rw-r--r--wiretap/lanalyzer.c41
1 files changed, 21 insertions, 20 deletions
diff --git a/wiretap/lanalyzer.c b/wiretap/lanalyzer.c
index e85705de7d..6a086554fc 100644
--- a/wiretap/lanalyzer.c
+++ b/wiretap/lanalyzer.c
@@ -1,6 +1,6 @@
/* lanalyzer.c
*
- * $Id: lanalyzer.c,v 1.14 1999/08/28 01:19:43 guy Exp $
+ * $Id: lanalyzer.c,v 1.15 1999/09/22 01:26:47 ashokn Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@verdict.uthscsa.edu>
@@ -26,6 +26,7 @@
#include <stdlib.h>
#include <errno.h>
#include <time.h>
+#include "file.h"
#include "wtap.h"
#include "buffer.h"
#include "lanalyzer.h"
@@ -60,13 +61,13 @@ int lanalyzer_open(wtap *wth, int *err)
guint8 cr_day, cr_month, cr_year;
struct tm tm;
- fseek(wth->fh, 0, SEEK_SET);
+ file_seek(wth->fh, 0, SEEK_SET);
wth->data_offset = 0;
errno = WTAP_ERR_CANT_READ;
- bytes_read = fread(LE_record_type, 1, 2, wth->fh);
- bytes_read += fread(LE_record_length, 1, 2, wth->fh);
+ bytes_read = file_read(LE_record_type, 1, 2, wth->fh);
+ bytes_read += file_read(LE_record_length, 1, 2, wth->fh);
if (bytes_read != 4) {
- if (ferror(wth->fh)) {
+ if (file_error(wth->fh)) {
*err = errno;
return -1;
}
@@ -90,13 +91,13 @@ int lanalyzer_open(wtap *wth, int *err)
/* Read records until we find the start of packets */
while (1) {
- fseek(wth->fh, record_length, SEEK_CUR);
+ file_seek(wth->fh, record_length, SEEK_CUR);
wth->data_offset += record_length;
errno = WTAP_ERR_CANT_READ;
- bytes_read = fread(LE_record_type, 1, 2, wth->fh);
- bytes_read += fread(LE_record_length, 1, 2, wth->fh);
+ bytes_read = file_read(LE_record_type, 1, 2, wth->fh);
+ bytes_read += file_read(LE_record_length, 1, 2, wth->fh);
if (bytes_read != 4) {
- if (ferror(wth->fh)) {
+ if (file_error(wth->fh)) {
*err = errno;
free(wth->capture.lanalyzer);
return -1;
@@ -114,10 +115,10 @@ int lanalyzer_open(wtap *wth, int *err)
/* Trace Summary Record */
case REC_TRACE_SUMMARY:
errno = WTAP_ERR_CANT_READ;
- bytes_read = fread(summary, 1, sizeof summary,
+ bytes_read = file_read(summary, 1, sizeof summary,
wth->fh);
if (bytes_read != sizeof summary) {
- if (ferror(wth->fh)) {
+ if (file_error(wth->fh)) {
*err = errno;
g_free(wth->capture.lanalyzer);
return -1;
@@ -180,7 +181,7 @@ int lanalyzer_open(wtap *wth, int *err)
case REC_TRACE_PACKET_DATA:
/* Go back header number ob ytes so that lanalyzer_read
* can read this header */
- fseek(wth->fh, -bytes_read, SEEK_CUR);
+ file_seek(wth->fh, -bytes_read, SEEK_CUR);
wth->data_offset -= bytes_read;
return 1;
@@ -211,9 +212,9 @@ static int lanalyzer_read(wtap *wth, int *err)
/* read the record type and length. */
errno = WTAP_ERR_CANT_READ;
- bytes_read = fread(LE_record_type, 1, 2, wth->fh);
+ bytes_read = file_read(LE_record_type, 1, 2, wth->fh);
if (bytes_read != 2) {
- if (ferror(wth->fh)) {
+ if (file_error(wth->fh)) {
*err = errno;
return -1;
}
@@ -224,9 +225,9 @@ static int lanalyzer_read(wtap *wth, int *err)
return 0;
}
wth->data_offset += 2;
- bytes_read = fread(LE_record_length, 1, 2, wth->fh);
+ bytes_read = file_read(LE_record_length, 1, 2, wth->fh);
if (bytes_read != 2) {
- if (ferror(wth->fh))
+ if (file_error(wth->fh))
*err = errno;
else
*err = WTAP_ERR_SHORT_READ;
@@ -252,9 +253,9 @@ static int lanalyzer_read(wtap *wth, int *err)
/* Read the descriptor data */
errno = WTAP_ERR_CANT_READ;
- bytes_read = fread(descriptor, 1, DESCRIPTOR_LEN, wth->fh);
+ bytes_read = file_read(descriptor, 1, DESCRIPTOR_LEN, wth->fh);
if (bytes_read != DESCRIPTOR_LEN) {
- if (ferror(wth->fh))
+ if (file_error(wth->fh))
*err = errno;
else
*err = WTAP_ERR_SHORT_READ;
@@ -266,11 +267,11 @@ static int lanalyzer_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;