diff options
author | Simon J. Gerraty <sjg@FreeBSD.org> | 2014-04-27 08:13:43 +0000 |
---|---|---|
committer | Simon J. Gerraty <sjg@FreeBSD.org> | 2014-04-27 08:13:43 +0000 |
commit | 9d2ab4a62d6733c45958627ac113bdbd818d1e2a (patch) | |
tree | b92e741b68057a24e381faa9809f32030d65574c /lib/libz | |
parent | 1991e07af89dbccabfb71af86738da2a979b3d20 (diff) | |
parent | 8be1b6d975fae2513af1b0e5ad6923c3c2428ddd (diff) | |
download | src-9d2ab4a62d6733c45958627ac113bdbd818d1e2a.tar.gz src-9d2ab4a62d6733c45958627ac113bdbd818d1e2a.zip |
Merge head
Notes
Notes:
svn path=/projects/bmake/; revision=265006
Diffstat (limited to 'lib/libz')
-rw-r--r-- | lib/libz/FREEBSD-upgrade | 2 | ||||
-rw-r--r-- | lib/libz/Makefile | 4 | ||||
-rw-r--r-- | lib/libz/Symbol.map | 2 | ||||
-rw-r--r-- | lib/libz/Versions.def | 2 | ||||
-rw-r--r-- | lib/libz/zopen.3 | 96 | ||||
-rw-r--r-- | lib/libz/zopen.c | 12 |
6 files changed, 110 insertions, 8 deletions
diff --git a/lib/libz/FREEBSD-upgrade b/lib/libz/FREEBSD-upgrade index d2d251b0cdf1..4ee4eebedb63 100644 --- a/lib/libz/FREEBSD-upgrade +++ b/lib/libz/FREEBSD-upgrade @@ -1,4 +1,4 @@ -$FreeBSD: head/lib/libz/FREEBSD-upgrade 146082 2005-05-11 03:50:50Z kientzle $ +$FreeBSD$ ZLib 1.2.2 diff --git a/lib/libz/Makefile b/lib/libz/Makefile index 4ecb022c9a79..fe6fb298cd74 100644 --- a/lib/libz/Makefile +++ b/lib/libz/Makefile @@ -1,11 +1,11 @@ # -# $FreeBSD: head/lib/libz/Makefile 232263 2012-02-28 18:30:18Z dim $ +# $FreeBSD$ # LIB= z SHLIBDIR?= /lib SHLIB_MAJOR= 6 -MAN= zlib.3 +MAN= zlib.3 zopen.3 #CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7 #CFLAGS=-g -DDEBUG diff --git a/lib/libz/Symbol.map b/lib/libz/Symbol.map index b117cdd14778..731ce0ab5ba9 100644 --- a/lib/libz/Symbol.map +++ b/lib/libz/Symbol.map @@ -1,5 +1,5 @@ /* - * $FreeBSD: head/lib/libz/Symbol.map 206709 2010-04-16 20:07:24Z delphij $ + * $FreeBSD$ */ ZLIB_1.2.7.1 { diff --git a/lib/libz/Versions.def b/lib/libz/Versions.def index f8e642574d9e..4651e776ab0f 100644 --- a/lib/libz/Versions.def +++ b/lib/libz/Versions.def @@ -1,4 +1,4 @@ -# $FreeBSD: head/lib/libz/Versions.def 205486 2010-03-22 22:12:27Z delphij $ +# $FreeBSD$ ZLIB_1.2.4.0 { }; diff --git a/lib/libz/zopen.3 b/lib/libz/zopen.3 new file mode 100644 index 000000000000..d7e631afd320 --- /dev/null +++ b/lib/libz/zopen.3 @@ -0,0 +1,96 @@ +.\" Copyright (c) 2014 Xin Li <delphij@FreeBSD.org> +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $FreeBSD$ +.\" +.Dd March 5, 2014 +.Dt ZOPEN 3 +.Os +.Sh NAME +.Nm zopen +.Nd open a gzip compressed stream +.Sh LIBRARY +.Lb libz +.Sh SYNOPSIS +.Ft FILE * +.Fn zopen "const char *path" "const char *mode" +.Sh DESCRIPTION +The +.Fn zopen +opens a gzip file whose name is the string pointed to by +.Fa path +and associates a stream with it. +It is a wrapper around +.Xr zlib 3 +and standard stream I/O APIs. +.Pp +The argument +.Fa mode +have the same meaning as it does in +.Xr fopen 3 . +.Pp +The +.Nm +function will associate read, write, seek and close +functions of +.Xr zlib 3 +after successfully opened a file with +.Xr funopen 3 +so that they will be used to read or write the new stream. +.Sh RETURN VALUES +Upon successful completion +.Nm +returns a +.Tn FILE +pointer. +Otherwise, +.Dv NULL +is returned and the global variable +.Va errno +is set to indicate the error. +.Sh ERRORS +In addition to the errors documented for +.Xr fopen 3 , +the +.Nm +function may also fail for: +.Bl -tag -width Er +.It Bq Er ENOMEM +Insufficient memory is available. +.El +.Sh COMPATIBILITY +This implementation of +.Nm +function first appeared in +.Nx 1.6 +and +.Fx 4.5 . +The +.Nm +function may not be portable to systems other than +.Fx . +.Sh SEE ALSO +.Xr fopen 3 , +.Xr funopen 3 , +.Xr zlib 3 diff --git a/lib/libz/zopen.c b/lib/libz/zopen.c index 822a5e1c0335..cde022dcf0e6 100644 --- a/lib/libz/zopen.c +++ b/lib/libz/zopen.c @@ -3,7 +3,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: head/lib/libz/zopen.c 84228 2001-09-30 22:39:00Z dillon $"); +__FBSDID("$FreeBSD$"); #include <stdio.h> #include <zlib.h> @@ -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 *mode) 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)); } |