This commit contains support for reading capture files compressed using
[obnox/wireshark/wip.git] / wiretap / netmon.c
index b22428298131111ff1a9c660a2c7401a3c3a319e..48b0a949587354eeef9c602ab805a10069293375 100644 (file)
@@ -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;