svn commit: r256644 - head/lib/libz

Xin LI delphij at FreeBSD.org
Wed Oct 16 17:16:41 UTC 2013


Author: delphij
Date: Wed Oct 16 17:16:40 2013
New Revision: 256644
URL: http://svnweb.freebsd.org/changeset/base/256644

Log:
  Make it possible to seek within a gzip stream.

Modified:
  head/lib/libz/zopen.c

Modified: head/lib/libz/zopen.c
==============================================================================
--- head/lib/libz/zopen.c	Wed Oct 16 17:03:46 2013	(r256643)
+++ head/lib/libz/zopen.c	Wed Oct 16 17:16:40 2013	(r256644)
@@ -29,6 +29,12 @@ xgzclose(void *cookie)
     return gzclose(cookie);
 }
 
+static fpos_t
+xgzseek(void *cookie,  fpos_t offset, int whence)
+{
+	return gzseek(cookie, (z_off_t)offset, whence);
+}
+
 FILE *
 zopen(const char *fname, const char *mode)
 {
@@ -37,7 +43,7 @@ zopen(const char *fname, const char *mod
 	return NULL;
 
     if(*mode == 'r')
-	return (funopen(gz, xgzread, NULL, NULL, xgzclose));
+	return (funopen(gz, xgzread, NULL, xgzseek, xgzclose));
     else
-	return (funopen(gz, NULL, xgzwrite, NULL, xgzclose));
+	return (funopen(gz, NULL, xgzwrite, xgzseek, xgzclose));
 }


More information about the svn-src-head mailing list