aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap/file_wrappers.c
diff options
context:
space:
mode:
authorAshok Narayanan <ashokn@cisco.com>2001-09-20 16:36:45 +0000
committerAshok Narayanan <ashokn@cisco.com>2001-09-20 16:36:45 +0000
commit29c8fa03b3a2d73b52f4731b06b801d9e28de9a2 (patch)
tree3ce1bb901498f45652612641036a013d27a49e32 /wiretap/file_wrappers.c
parentd1ec951825b9cee63227ef9347d1d2b082966e4d (diff)
Removed the dependency on gzgetc and gzgets by implementing internal
versions of these commands in file_wrappers.c. This allows us to compile successfully even on platforms where X has an older zlib built in. Removed this restriction from acinclude.m4 svn path=/trunk/; revision=3948
Diffstat (limited to 'wiretap/file_wrappers.c')
-rw-r--r--wiretap/file_wrappers.c26
1 files changed, 25 insertions, 1 deletions
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