summaryrefslogtreecommitdiff
path: root/wiretap
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2000-01-26 19:22:04 +0000
committerGuy Harris <guy@alum.mit.edu>2000-01-26 19:22:04 +0000
commit9f458a52fcf3a8fb5c028608c062b3929b6b3c36 (patch)
treec2a42de6577a26882a12a076126b2f960f2e5b2f /wiretap
parent0c64bc440066e5f16246c45b76833ba5ec469871 (diff)
downloadwireshark-9f458a52fcf3a8fb5c028608c062b3929b6b3c36.tar.gz
Always declare, and define, "file_seek()" to return a "long", as it's
supposed to look like "ftell()". If you don't have zlib, just define "file_seek" as an alias for "fseek", rather than defining it as a routine. svn path=/trunk/; revision=1571
Diffstat (limited to 'wiretap')
-rw-r--r--wiretap/file_wrappers.c21
-rw-r--r--wiretap/file_wrappers.h6
2 files changed, 13 insertions, 14 deletions
diff --git a/wiretap/file_wrappers.c b/wiretap/file_wrappers.c
index 48d7558421..849558f692 100644
--- a/wiretap/file_wrappers.c
+++ b/wiretap/file_wrappers.c
@@ -1,6 +1,6 @@
/* file_wrappers.c
*
- * $Id: file_wrappers.c,v 1.4 2000/01/25 04:49:55 guy Exp $
+ * $Id: file_wrappers.c,v 1.5 2000/01/26 19:22:04 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@xiexie.org>
@@ -56,11 +56,16 @@
* in the first place, so we don't know whether to include "zlib.h"
* until we include "config.h"....
*
+ * A similar problem appears to occur with "gztell()", at least on
+ * NetBSD.
+ *
* So what we do is *undefine* HAVE_UNISTD_H before including "wtap.h"
* (we need "wtap.h" to get the WTAP_ERR_ZLIB values, and it also includes
- * "zlib.h" if HAVE_ZLIB" is defined), 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()".
+ * "zlib.h" if HAVE_ZLIB" is defined), and, if we have zlib, make
+ * "file_seek()" and "file_tell()" subroutines, so that the only calls to
+ * "gzseek()" and "gztell()" are in this file, which, by dint of the
+ * hackery described above, manages to correctly declare "gzseek()" and
+ * "gztell()".
*
* DO NOT, UNDER ANY CIRCUMSTANCES, REMOVE THE FOLLOWING LINE, OR MOVE
* IT AFTER THE INCLUDE OF "wtap.h"! Doing so will cause any program
@@ -81,7 +86,7 @@
#include "file_wrappers.h"
#ifdef HAVE_LIBZ
-int
+long
file_seek(void *stream, long offset, int whence)
{
return gzseek(stream, (z_off_t)offset, whence);
@@ -92,12 +97,6 @@ file_tell(void *stream)
{
return (long)gztell(stream);
}
-#else /* HAVE_LIBZ */
-long
-file_seek(FILE *stream, long offset, int whence)
-{
- return fseek(stream, offset, whence);
-}
#endif /* HAVE_LIBZ */
/*
diff --git a/wiretap/file_wrappers.h b/wiretap/file_wrappers.h
index cfda764a07..61c5376a90 100644
--- a/wiretap/file_wrappers.h
+++ b/wiretap/file_wrappers.h
@@ -1,6 +1,6 @@
/* file_wrappers.h
*
- * $Id: file_wrappers.h,v 1.3 2000/01/25 04:49:55 guy Exp $
+ * $Id: file_wrappers.h,v 1.4 2000/01/26 19:22:04 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@xiexie.org>
@@ -27,7 +27,7 @@
#ifdef HAVE_LIBZ
#define file_open gzopen
#define filed_open gzdopen
-extern int file_seek(void *stream, long offset, int whence);
+extern long 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
-extern int file_seek(FILE *stream, long offset, int whence);
+#define file_seek fseek
#define file_read fread
#define file_write fwrite
#define file_close fclose