aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--acinclude.m433
-rw-r--r--wiretap/file_wrappers.c26
-rw-r--r--wiretap/file_wrappers.h8
3 files changed, 31 insertions, 36 deletions
diff --git a/acinclude.m4 b/acinclude.m4
index b889cd52f1..02b85af48f 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -2,7 +2,7 @@ dnl Macros that test for specific features.
dnl This file is part of the Autoconf packaging for Ethereal.
dnl Copyright (C) 1998-2000 by Gerald Combs.
dnl
-dnl $Id: acinclude.m4,v 1.33 2001/09/17 23:35:22 guy Exp $
+dnl $Id: acinclude.m4,v 1.34 2001/09/20 16:36:44 ashokn Exp $
dnl
dnl This program is free software; you can redistribute it and/or modify
dnl it under the terms of the GNU General Public License as published by
@@ -373,37 +373,6 @@ AC_DEFUN(AC_ETHEREAL_ZLIB_CHECK,
AC_CHECK_LIB(z, gzgets,,enable_zlib=no)
fi
- if test x$enable_zlib != xno
- then
- #
- # Well, we at least have the zlib header file and a zlib
- # with "gzgets()".
- #
- # Now check for "gzgets()" in zlib when linking with the
- # linker flags for GTK+ applications; people often grab
- # XFree86 source and build and install it on their systems,
- # and they appear sometimes to misconfigure XFree86 so that,
- # even on systems with zlib, it assumes there is no zlib,
- # so the XFree86 build process builds and installs its
- # own zlib in the X11 library directory.
- #
- # The XFree86 zlib is an older version that lacks
- # "gzgets()", and that's the zlib with which Ethereal
- # gets linked, so the build of Ethereal fails.
- #
- ac_save_CFLAGS="$CFLAGS"
- ac_save_LIBS="$LIBS"
- CFLAGS="$CFLAGS $GTK_CFLAGS"
- LIBS="$GTK_LIBS -lz $LIBS"
- AC_MSG_CHECKING([for gzgets missing when linking with X11])
- AC_TRY_LINK_FUNC(gzgets, AC_MSG_RESULT(no),
- [
- AC_MSG_RESULT(yes)
- AC_MSG_ERROR(old XFree86 zlib found - rebuild XFree86 using system zlib or configure Ethereal without compressed file support.)
- ])
- CFLAGS="$ac_save_CFLAGS"
- LIBS="$ac_save_LIBS"
- fi
])
#
diff --git a/wiretap/file_wrappers.c b/wiretap/file_wrappers.c
index 61ff2261be..57d074a2e9 100644
--- a/wiretap/file_wrappers.c
+++ b/wiretap/file_wrappers.c
@@ -1,6 +1,6 @@
/* file_wrappers.c
*
- * $Id: file_wrappers.c,v 1.7 2000/05/19 23:06:50 gram Exp $
+ * $Id: file_wrappers.c,v 1.8 2001/09/20 16:36:45 ashokn Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@xiexie.org>
@@ -153,3 +153,27 @@ file_error(FILE *fh)
return 0;
}
#endif /* HAVE_LIBZ */
+
+#ifdef HAVE_LIBZ
+/*
+ * On some platforms, an older version of zlib is compiled into X. This causes
+ * gzgets() to be unavailable. So here is an implementation of gzgets()
+ */
+
+char *
+internal_gzgets(gzFile file, char *buf, int len)
+{
+ char *b = buf;
+ if (buf == NULL || len <= 0)
+ return NULL;
+ while (--len > 0 && gzread(file, buf, 1) == 1 && *buf++ != '\n') ;
+ *buf = '\0';
+ return b == buf && len > 0 ? NULL : b;
+}
+
+int internal_gzgetc(gzFile file)
+{
+ unsigned char c;
+ return gzread(file, &c, 1) == 1 ? c : -1;
+}
+#endif
diff --git a/wiretap/file_wrappers.h b/wiretap/file_wrappers.h
index 61c5376a90..7be3b0b8d5 100644
--- a/wiretap/file_wrappers.h
+++ b/wiretap/file_wrappers.h
@@ -1,6 +1,6 @@
/* file_wrappers.h
*
- * $Id: file_wrappers.h,v 1.4 2000/01/26 19:22:04 guy Exp $
+ * $Id: file_wrappers.h,v 1.5 2001/09/20 16:36:45 ashokn Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@xiexie.org>
@@ -32,8 +32,10 @@ extern long file_seek(void *stream, long offset, int whence);
#define file_write(buf, bsize, count, file) gzwrite((file),(buf),((count)*(bsize)))
#define file_close gzclose
extern long file_tell(void *stream);
-#define file_getc gzgetc
-#define file_gets(buf, len, file) gzgets((file), (buf), (len))
+char * internal_gzgets(gzFile file, char *buf, int len);
+int internal_gzgetc(gzFile file);
+#define file_getc internal_gzgetc
+#define file_gets(buf, len, file) internal_gzgets((file), (buf), (len))
extern int file_error(void *fh);
#else /* No zLib */