aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--wiretap/Makefile.am5
-rw-r--r--wiretap/ascend.c4
-rw-r--r--wiretap/configure.in43
-rw-r--r--wiretap/file.c42
-rw-r--r--wiretap/file_wrappers.c131
-rw-r--r--wiretap/file_wrappers.h (renamed from wiretap/file.h)8
-rw-r--r--wiretap/i4btrace.c4
-rw-r--r--wiretap/iptrace.c4
-rw-r--r--wiretap/lanalyzer.c4
-rw-r--r--wiretap/libpcap.c4
-rw-r--r--wiretap/netmon.c4
-rw-r--r--wiretap/nettl.c4
-rw-r--r--wiretap/netxray.c4
-rw-r--r--wiretap/ngsniffer.c4
-rw-r--r--wiretap/radcom.c4
-rw-r--r--wiretap/snoop.c4
-rw-r--r--wiretap/toshiba.c4
-rw-r--r--wiretap/wtap.c4
18 files changed, 167 insertions, 114 deletions
diff --git a/wiretap/Makefile.am b/wiretap/Makefile.am
index 70c31d82cc..2f677da6a9 100644
--- a/wiretap/Makefile.am
+++ b/wiretap/Makefile.am
@@ -1,7 +1,7 @@
# Makefile.am
# Automake file for Wiretap
#
-# $Id: Makefile.am,v 1.25 1999/12/12 22:40:07 gram Exp $
+# $Id: Makefile.am,v 1.26 2000/01/13 07:09:15 guy Exp $
#
# Ethereal - Network traffic analyzer
# By Gerald Combs <gerald@zing.org>
@@ -39,7 +39,8 @@ libwiretap_a_SOURCES = \
buffer.c \
buffer.h \
file.c \
- file.h \
+ file_wrappers.c \
+ file_wrappers.h \
i4btrace.c \
i4btrace.h \
i4b_trace.h \
diff --git a/wiretap/ascend.c b/wiretap/ascend.c
index 4d90b1b734..98f9b6df4e 100644
--- a/wiretap/ascend.c
+++ b/wiretap/ascend.c
@@ -1,6 +1,6 @@
/* ascend.c
*
- * $Id: ascend.c,v 1.10 2000/01/10 17:33:16 gram Exp $
+ * $Id: ascend.c,v 1.11 2000/01/13 07:09:15 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@verdict.uthscsa.edu>
@@ -27,7 +27,7 @@
#include "buffer.h"
#include "ascend.h"
#include "ascend-int.h"
-#include "file.h"
+#include "file_wrappers.h"
#include <sys/stat.h>
diff --git a/wiretap/configure.in b/wiretap/configure.in
index dbd1c9ea7e..884f901e14 100644
--- a/wiretap/configure.in
+++ b/wiretap/configure.in
@@ -1,4 +1,4 @@
-# $Id: configure.in,v 1.19 2000/01/10 17:33:17 gram Exp $
+# $Id: configure.in,v 1.20 2000/01/13 07:09:15 guy Exp $
dnl
dnl Process this file with autoconf 2.13 or later to produce a
dnl configure script; 2.12 doesn't generate a "configure" script that
@@ -45,47 +45,6 @@ if test "x$GLIB_CFLAGS" = x ; then
fi
dnl Checks for header files
-dnl WARNING: do *NOT* check for "unistd.h" unless you work around the
-dnl following problem:
-dnl
-dnl At least on FreeBSD 3.2, "/usr/include/zlib.h" includes
-dnl "/usr/include/zconf.h", which, if HAVE_UNISTD_H is defined,
-dnl #defines "z_off_t" to be "off_t", and if HAVE_UNISTD_H is
-dnl not defines, #defines "z_off_t" to be "long" if it's not
-dnl already #defined.
-dnl
-dnl In 4.4-Lite-derived systems such as FreeBSD, "off_t" is
-dnl "long long int", not "long int", so the definition of "z_off_t" -
-dnl and therefore the types of the arguments to routines such as
-dnl "gzseek()", as declared, with prototypes, in "zlib.h" - depends
-dnl on whether HAVE_UNISTD_H is defined prior to including "zlib.h"!
-dnl
-dnl It's not defined in the FreeBSD 3.2 "zlib", so if we include "zlib.h"
-dnl after defining HAVE_UNISTD_H, we get a misdeclaration of "gzseek()",
-dnl and, if we're building with "zlib" support, anything that seeks
-dnl on a file may not work.
-dnl
-dnl Other BSDs may have the same problem, if they haven't done something
-dnl such as defining HAVE_UNISTD_H in "zconf.h".
-dnl
-dnl If "config.h" defines HAVE_UNISTD_H - which it will, on all systems
-dnl that have it, if we test for it here, and all 4.4-Lite-derived
-dnl BSDs have it - then, given that "zlib.h" is included by "file.h",
-dnl that means that unless we include "zlib.h" before we include
-dnl "config.h", we get a misdeclaration of "gzseek()".
-dnl
-dnl Unfortunately, it's "config.h" that tells us whether we have "zlib"
-dnl in the first place, so we don't know whether to include "zlib.h"
-dnl until we include "config.h"....
-dnl
-dnl Fortunately, we don't use "unistd.h", so we don't need to check
-dnl for it.
-dnl
-dnl If we ever *do* end up requiring HAVE_UNISTD_H, a fix might be to
-dnl turn "file_seek()" into a subroutine, at least if HAVE_ZLIB is
-dnl defined, have it take an "off_t" as its second argument, and
-dnl put it into a file that doesn't require HAVE_UNISTD_H.
-dnl
AC_HEADER_STDC
AC_CHECK_HEADERS(sys/time.h netinet/in.h unistd.h)
diff --git a/wiretap/file.c b/wiretap/file.c
index 5ae3a0431e..441deafdfa 100644
--- a/wiretap/file.c
+++ b/wiretap/file.c
@@ -1,6 +1,6 @@
/* file.c
*
- * $Id: file.c,v 1.44 2000/01/10 17:33:17 gram Exp $
+ * $Id: file.c,v 1.45 2000/01/13 07:09:15 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@verdict.uthscsa.edu>
@@ -36,7 +36,7 @@
#endif
#include "wtap.h"
-#include "file.h"
+#include "file_wrappers.h"
#include "buffer.h"
#include "lanalyzer.h"
#include "ngsniffer.h"
@@ -448,41 +448,3 @@ gboolean wtap_dump_close(wtap_dumper *wdh, int *err)
g_free(wdh);
return ret;
}
-
-/*
- * Routine to return a Wiretap error code (0 for no error, an errno
- * for a file error, or a WTAP_ERR_ code for other errors) for an
- * I/O stream.
- */
-#ifdef HAVE_LIBZ
-int
-file_error(void *fh)
-{
- int errnum;
-
- gzerror(fh, &errnum);
- switch (errnum) {
-
- case Z_OK: /* no error */
- return 0;
-
- case Z_STREAM_END: /* EOF - not an error */
- return 0;
-
- case Z_ERRNO: /* file I/O error */
- return errno;
-
- default:
- return WTAP_ERR_ZLIB + errnum;
- }
-}
-#else /* HAVE_LIBZ */
-int
-file_error(FILE *fh)
-{
- if (ferror(fh))
- return errno;
- else
- return 0;
-}
-#endif /* HAVE_LIBZ */
diff --git a/wiretap/file_wrappers.c b/wiretap/file_wrappers.c
new file mode 100644
index 0000000000..f040a1da0c
--- /dev/null
+++ b/wiretap/file_wrappers.c
@@ -0,0 +1,131 @@
+/* file_wrappers.c
+ *
+ * $Id: file_wrappers.c,v 1.1 2000/01/13 07:09:16 guy Exp $
+ *
+ * Wiretap Library
+ * Copyright (c) 1998 by Gilbert Ramirez <gram@verdict.uthscsa.edu>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+/*
+ * OK, now this is tricky.
+ *
+ * At least on FreeBSD 3.2, "/usr/include/zlib.h" includes
+ * "/usr/include/zconf.h", which, if HAVE_UNISTD_H is defined,
+ * #defines "z_off_t" to be "off_t", and if HAVE_UNISTD_H is
+ * not defines, #defines "z_off_t" to be "long" if it's not
+ * already #defined.
+ *
+ * In 4.4-Lite-derived systems such as FreeBSD, "off_t" is
+ * "long long int", not "long int", so the definition of "z_off_t" -
+ * and therefore the types of the arguments to routines such as
+ * "gzseek()", as declared, with prototypes, in "zlib.h" - depends
+ * on whether HAVE_UNISTD_H is defined prior to including "zlib.h"!
+ *
+ * It's not defined in the FreeBSD 3.2 "zlib", so if we include "zlib.h"
+ * after defining HAVE_UNISTD_H, we get a misdeclaration of "gzseek()",
+ * and, if we're building with "zlib" support, anything that seeks
+ * on a file may not work.
+ *
+ * Other BSDs may have the same problem, if they haven't done something
+ * such as defining HAVE_UNISTD_H in "zconf.h".
+ *
+ * "config.h" defines HAVE_UNISTD_H, on all systems that have it, and all
+ * 4.4-Lite-derived BSDs have it. Therefore, given that "zlib.h" is included
+ * by "file_wrappers.h", that means that unless we include "zlib.h" before
+ * we include "config.h", we get a misdeclaration of "gzseek()".
+ *
+ * Unfortunately, it's "config.h" that tells us whether we have "zlib"
+ * in the first place, so we don't know whether to include "zlib.h"
+ * until we include "config.h"....
+ *
+ * So what we do is *undefine* HAVE_UNISTD_H before including "zlib.h",
+ * and make "file_seek()" a subroutine, so that the only call to "gzseek()"
+ * is in this file, which, by dint of the hackery described above,
+ * manages to correctly declare "gzseek()".
+ *
+ * DO NOT, UNDER ANY CIRCUMSTANCES, REMOVE THE FOLLOWING LINE, OR MOVE
+ * IT AFTER THE INCLUDE OF "zlib.h"! Doing so will cause any program
+ * using Wiretap to read capture files to fail miserably on a FreeBSD
+ * 3.2 or 3.3 system - and possibly other BSD systems - if zlib is
+ * installed. If you *must* include <unistd.h> here, do so *before*
+ * including "zlib.h", and before undefining HAVE_UNISTD_H.
+ */
+#undef HAVE_UNISTD_H
+
+#ifdef HAVE_LIBZ
+#include "zlib.h"
+#endif
+
+#include <errno.h>
+#include <stdio.h>
+#include "file_wrappers.h"
+
+#ifdef HAVE_LIBZ
+int
+file_seek(void *stream, long offset, int whence)
+{
+ return gzseek(stream, offset, whence);
+}
+#else /* HAVE_LIBZ */
+int
+file_seek(FILE *stream, long offset, int whence)
+{
+ return fseek(stream, offset, whence);
+}
+#endif /* HAVE_LIBZ */
+
+/*
+ * Routine to return a Wiretap error code (0 for no error, an errno
+ * for a file error, or a WTAP_ERR_ code for other errors) for an
+ * I/O stream.
+ */
+#ifdef HAVE_LIBZ
+int
+file_error(void *fh)
+{
+ int errnum;
+
+ gzerror(fh, &errnum);
+ switch (errnum) {
+
+ case Z_OK: /* no error */
+ return 0;
+
+ case Z_STREAM_END: /* EOF - not an error */
+ return 0;
+
+ case Z_ERRNO: /* file I/O error */
+ return errno;
+
+ default:
+ return WTAP_ERR_ZLIB + errnum;
+ }
+}
+#else /* HAVE_LIBZ */
+int
+file_error(FILE *fh)
+{
+ if (ferror(fh))
+ return errno;
+ else
+ return 0;
+}
+#endif /* HAVE_LIBZ */
diff --git a/wiretap/file.h b/wiretap/file_wrappers.h
index 035970dbf4..85e90f1056 100644
--- a/wiretap/file.h
+++ b/wiretap/file_wrappers.h
@@ -1,6 +1,6 @@
-/* file.h
+/* file_wrappers.h
*
- * $Id: file.h,v 1.5 1999/10/31 17:46:07 gram Exp $
+ * $Id: file_wrappers.h,v 1.1 2000/01/13 07:09:16 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@verdict.uthscsa.edu>
@@ -27,7 +27,7 @@
#ifdef HAVE_LIBZ
#define file_open gzopen
#define filed_open gzdopen
-#define file_seek gzseek
+extern int file_seek(void *stream, long offset, int whence);
#define file_read(buf, bsize, count, file) gzread((file),(buf),((count)*(bsize)))
#define file_write(buf, bsize, count, file) gzwrite((file),(buf),((count)*(bsize)))
#define file_close gzclose
@@ -39,7 +39,7 @@ extern int file_error(void *fh);
#else /* No zLib */
#define file_open fopen
#define filed_open fdopen
-#define file_seek fseek
+extern int file_seek(FILE *stream, long offset, int whence);
#define file_read fread
#define file_write fwrite
#define file_close fclose
diff --git a/wiretap/i4btrace.c b/wiretap/i4btrace.c
index 80df4367b7..7ddd847f78 100644
--- a/wiretap/i4btrace.c
+++ b/wiretap/i4btrace.c
@@ -1,6 +1,6 @@
/* i4btrace.c
*
- * $Id: i4btrace.c,v 1.2 1999/12/15 02:25:50 guy Exp $
+ * $Id: i4btrace.c,v 1.3 2000/01/13 07:09:16 guy Exp $
*
* Wiretap Library
* Copyright (c) 1999 by Bert Driehuis <driehuis@playbeing.org>
@@ -28,7 +28,7 @@
#include <errno.h>
#include <time.h>
#include "wtap.h"
-#include "file.h"
+#include "file_wrappers.h"
#include "buffer.h"
#include "i4b_trace.h"
diff --git a/wiretap/iptrace.c b/wiretap/iptrace.c
index 2d77099d47..1ba0d4bcf5 100644
--- a/wiretap/iptrace.c
+++ b/wiretap/iptrace.c
@@ -1,6 +1,6 @@
/* iptrace.c
*
- * $Id: iptrace.c,v 1.22 1999/11/27 01:55:44 guy Exp $
+ * $Id: iptrace.c,v 1.23 2000/01/13 07:09:16 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@verdict.uthscsa.edu>
@@ -28,7 +28,7 @@
#include <time.h>
#include <string.h>
#include "wtap.h"
-#include "file.h"
+#include "file_wrappers.h"
#include "buffer.h"
#include "iptrace.h"
diff --git a/wiretap/lanalyzer.c b/wiretap/lanalyzer.c
index 68d94c9931..20bcf2df05 100644
--- a/wiretap/lanalyzer.c
+++ b/wiretap/lanalyzer.c
@@ -1,6 +1,6 @@
/* lanalyzer.c
*
- * $Id: lanalyzer.c,v 1.18 1999/11/10 19:47:57 gram Exp $
+ * $Id: lanalyzer.c,v 1.19 2000/01/13 07:09:16 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@verdict.uthscsa.edu>
@@ -27,7 +27,7 @@
#include <errno.h>
#include <time.h>
#include "wtap.h"
-#include "file.h"
+#include "file_wrappers.h"
#include "buffer.h"
#include "lanalyzer.h"
diff --git a/wiretap/libpcap.c b/wiretap/libpcap.c
index c9c8efba0a..ddd15e9b78 100644
--- a/wiretap/libpcap.c
+++ b/wiretap/libpcap.c
@@ -1,6 +1,6 @@
/* libpcap.c
*
- * $Id: libpcap.c,v 1.29 2000/01/09 07:55:48 guy Exp $
+ * $Id: libpcap.c,v 1.30 2000/01/13 07:09:17 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@verdict.uthscsa.edu>
@@ -26,7 +26,7 @@
#include <stdlib.h>
#include <errno.h>
#include "wtap.h"
-#include "file.h"
+#include "file_wrappers.h"
#include "buffer.h"
#include "libpcap.h"
diff --git a/wiretap/netmon.c b/wiretap/netmon.c
index 1f0939fddb..c9b998e99e 100644
--- a/wiretap/netmon.c
+++ b/wiretap/netmon.c
@@ -1,6 +1,6 @@
/* netmon.c
*
- * $Id: netmon.c,v 1.22 1999/12/15 01:34:17 guy Exp $
+ * $Id: netmon.c,v 1.23 2000/01/13 07:09:17 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@verdict.uthscsa.edu>
@@ -27,7 +27,7 @@
#include <time.h>
#include <string.h>
#include "wtap.h"
-#include "file.h"
+#include "file_wrappers.h"
#include "buffer.h"
#include "netmon.h"
diff --git a/wiretap/nettl.c b/wiretap/nettl.c
index 396b279d6f..58e1ee14f2 100644
--- a/wiretap/nettl.c
+++ b/wiretap/nettl.c
@@ -1,6 +1,6 @@
/* nettl.c
*
- * $Id: nettl.c,v 1.2 1999/10/31 19:23:37 guy Exp $
+ * $Id: nettl.c,v 1.3 2000/01/13 07:09:18 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@verdict.uthscsa.edu>
@@ -28,7 +28,7 @@
#include <errno.h>
#include <time.h>
#include "wtap.h"
-#include "file.h"
+#include "file_wrappers.h"
#include "buffer.h"
#include "nettl.h"
diff --git a/wiretap/netxray.c b/wiretap/netxray.c
index d8ff11cd2b..77ff72994b 100644
--- a/wiretap/netxray.c
+++ b/wiretap/netxray.c
@@ -1,6 +1,6 @@
/* netxray.c
*
- * $Id: netxray.c,v 1.20 1999/12/15 01:34:16 guy Exp $
+ * $Id: netxray.c,v 1.21 2000/01/13 07:09:18 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@verdict.uthscsa.edu>
@@ -29,7 +29,7 @@
#include <time.h>
#include <string.h>
#include "wtap.h"
-#include "file.h"
+#include "file_wrappers.h"
#include "netxray.h"
#include "buffer.h"
diff --git a/wiretap/ngsniffer.c b/wiretap/ngsniffer.c
index ad912e0b13..c6dbd60e08 100644
--- a/wiretap/ngsniffer.c
+++ b/wiretap/ngsniffer.c
@@ -1,6 +1,6 @@
/* ngsniffer.c
*
- * $Id: ngsniffer.c,v 1.33 1999/12/14 12:41:13 oabad Exp $
+ * $Id: ngsniffer.c,v 1.34 2000/01/13 07:09:18 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@verdict.uthscsa.edu>
@@ -64,7 +64,7 @@
#include <time.h>
#include <string.h>
#include "wtap.h"
-#include "file.h"
+#include "file_wrappers.h"
#include "buffer.h"
#include "ngsniffer.h"
diff --git a/wiretap/radcom.c b/wiretap/radcom.c
index ee6f5c396a..5e74156cb6 100644
--- a/wiretap/radcom.c
+++ b/wiretap/radcom.c
@@ -1,6 +1,6 @@
/* radcom.c
*
- * $Id: radcom.c,v 1.15 1999/11/18 21:48:52 guy Exp $
+ * $Id: radcom.c,v 1.16 2000/01/13 07:09:19 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@verdict.uthscsa.edu>
@@ -28,7 +28,7 @@
#include <errno.h>
#include <time.h>
#include "wtap.h"
-#include "file.h"
+#include "file_wrappers.h"
#include "buffer.h"
#include "radcom.h"
diff --git a/wiretap/snoop.c b/wiretap/snoop.c
index ca4c796373..bd42807b66 100644
--- a/wiretap/snoop.c
+++ b/wiretap/snoop.c
@@ -1,6 +1,6 @@
/* snoop.c
*
- * $Id: snoop.c,v 1.22 1999/12/04 11:19:04 guy Exp $
+ * $Id: snoop.c,v 1.23 2000/01/13 07:09:19 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@verdict.uthscsa.edu>
@@ -25,7 +25,7 @@
#endif
#include <errno.h>
#include "wtap.h"
-#include "file.h"
+#include "file_wrappers.h"
#include "buffer.h"
#include "snoop.h"
#ifdef HAVE_NETINET_IN_H
diff --git a/wiretap/toshiba.c b/wiretap/toshiba.c
index 3ca88125d8..bfd899c68a 100644
--- a/wiretap/toshiba.c
+++ b/wiretap/toshiba.c
@@ -1,6 +1,6 @@
/* toshiba.c
*
- * $Id: toshiba.c,v 1.6 2000/01/01 04:01:41 gram Exp $
+ * $Id: toshiba.c,v 1.7 2000/01/13 07:09:19 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@xiexie.org>
@@ -26,7 +26,7 @@
#include "wtap.h"
#include "buffer.h"
#include "toshiba.h"
-#include "file.h"
+#include "file_wrappers.h"
#include <stdio.h>
#include <stdlib.h>
diff --git a/wiretap/wtap.c b/wiretap/wtap.c
index 404bea3094..0263ef2634 100644
--- a/wiretap/wtap.c
+++ b/wiretap/wtap.c
@@ -1,6 +1,6 @@
/* wtap.c
*
- * $Id: wtap.c,v 1.35 1999/12/12 22:53:25 guy Exp $
+ * $Id: wtap.c,v 1.36 2000/01/13 07:09:20 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@verdict.uthscsa.edu>
@@ -27,7 +27,7 @@
#include "config.h"
#endif
#include "wtap.h"
-#include "file.h"
+#include "file_wrappers.h"
#include "buffer.h"
#include "ascend.h"
#include "toshiba.h"