summaryrefslogtreecommitdiff
path: root/wiretap/file_wrappers.h
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2000-01-13 07:09:20 +0000
committerGuy Harris <guy@alum.mit.edu>2000-01-13 07:09:20 +0000
commit7a36bede0b7367182c6dfbfa4e0352566df885c4 (patch)
treef0c0dd538dbefaaf38246921b8311118abbf5a3a /wiretap/file_wrappers.h
parentb558dc21ec489263992a3a2037d40d01de4bf389 (diff)
downloadwireshark-7a36bede0b7367182c6dfbfa4e0352566df885c4.tar.gz
We are obliged to define HAVE_UNISTD_H in "config.h"; to avoid the
hideous problem on FreeBSD 3.[23] (and perhaps other BSDs) if HAVE_UNISTD_H is defined before "zlib.h" is included, turn "file_seek()" into a subroutine defined in a file that *undefines* HAVE_UNISTD_H before including "zlib.h", so that the *only* call to "gzseek()" is made from a file that does not have HAVE_UNISTD_H defined when it includes "zlib.h". Move "file_error()" to that file while you're at it, so it holds all the wrappers that hide the presence or absence of zlib from routines to read capture files. Turn "file.h", which declared those wrapper functions as well as wrapper macros, into "file_wrapper.h" - it belongs with the "file_wrapper.c" file that defines the wrapper functions, not with "file.c" which handles higher-layer file access functions. Remove the comment in "configure.in" that explained why defining HAVE_UNISTD_H was a bad idea, as we're not obliged to define it and work around the problem. (The comment in "file_wrapper.c" explains the workaround.) svn path=/trunk/; revision=1463
Diffstat (limited to 'wiretap/file_wrappers.h')
-rw-r--r--wiretap/file_wrappers.h52
1 files changed, 52 insertions, 0 deletions
diff --git a/wiretap/file_wrappers.h b/wiretap/file_wrappers.h
new file mode 100644
index 0000000000..85e90f1056
--- /dev/null
+++ b/wiretap/file_wrappers.h
@@ -0,0 +1,52 @@
+/* file_wrappers.h
+ *
+ * $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>
+ *
+ * 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.
+ *
+ */
+
+#ifndef __FILE_H__
+#define __FILE_H__
+
+#ifdef HAVE_LIBZ
+#define file_open gzopen
+#define filed_open gzdopen
+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
+#define file_tell gztell
+#define file_getc gzgetc
+#define file_gets(buf, len, file) gzgets((file), (buf), (len))
+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_read fread
+#define file_write fwrite
+#define file_close fclose
+extern int file_error(FILE *fh);
+#define file_tell ftell
+#define file_getc fgetc
+#define file_gets fgets
+#endif /* HAVE_LIBZ */
+
+#endif /* __FILE_H__ */