From owner-svn-src-all@FreeBSD.ORG Wed Oct 16 17:16:40 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id E133FF1B; Wed, 16 Oct 2013 17:16:40 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id CEFC92D03; Wed, 16 Oct 2013 17:16:40 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r9GHGeLs053795; Wed, 16 Oct 2013 17:16:40 GMT (envelope-from delphij@svn.freebsd.org) Received: (from delphij@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r9GHGeX2053794; Wed, 16 Oct 2013 17:16:40 GMT (envelope-from delphij@svn.freebsd.org) Message-Id: <201310161716.r9GHGeX2053794@svn.freebsd.org> From: Xin LI Date: Wed, 16 Oct 2013 17:16:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r256644 - head/lib/libz X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Oct 2013 17:16:41 -0000 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)); }