2018-05-10 06:41:08 +00:00
|
|
|
.\" Copyright (c) 2014 Xin LI <delphij@FreeBSD.org>
|
2014-03-06 00:25:21 +00:00
|
|
|
.\"
|
|
|
|
.\" 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$
|
|
|
|
.\"
|
2018-12-06 20:03:06 +00:00
|
|
|
.Dd December 6, 2018
|
2014-03-06 00:25:21 +00:00
|
|
|
.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"
|
2018-12-06 20:03:06 +00:00
|
|
|
.Ft FILE *
|
|
|
|
.Fn zdopen "int fd" "const char *mode"
|
2014-03-06 00:25:21 +00:00
|
|
|
.Sh DESCRIPTION
|
|
|
|
The
|
|
|
|
.Fn zopen
|
2018-12-06 20:03:06 +00:00
|
|
|
function opens a gzip file whose name is the string pointed to by
|
2014-03-06 00:25:21 +00:00
|
|
|
.Fa path
|
2018-12-06 20:03:06 +00:00
|
|
|
and returns a stream which can be used to access the uncompressed contents
|
|
|
|
of the file.
|
|
|
|
The
|
|
|
|
.Fn zdopen
|
|
|
|
variant takes a gzip file referenced by the file descriptor
|
|
|
|
.Fa fd ,
|
|
|
|
analogous to
|
|
|
|
.Xr fdopen 3 .
|
|
|
|
They are wrappers around
|
2014-03-06 00:25:21 +00:00
|
|
|
.Xr zlib 3
|
2018-12-06 20:03:06 +00:00
|
|
|
and the standard stream I/O APIs.
|
2014-03-06 00:25:21 +00:00
|
|
|
.Pp
|
|
|
|
The argument
|
|
|
|
.Fa mode
|
2018-12-06 20:03:06 +00:00
|
|
|
has the same meaning as it does in
|
2014-03-06 00:25:21 +00:00
|
|
|
.Xr fopen 3 .
|
|
|
|
.Pp
|
|
|
|
The
|
2018-12-06 20:03:06 +00:00
|
|
|
.Fn zopen
|
|
|
|
and
|
|
|
|
.Fn zdopen
|
|
|
|
functions will associate the read, write, seek and close
|
2014-03-06 00:25:21 +00:00
|
|
|
functions of
|
|
|
|
.Xr zlib 3
|
2018-12-06 20:03:06 +00:00
|
|
|
with the returned stream.
|
2014-03-06 00:25:21 +00:00
|
|
|
.Sh RETURN VALUES
|
|
|
|
Upon successful completion
|
2018-12-06 20:03:06 +00:00
|
|
|
.Fn zopen
|
|
|
|
and
|
|
|
|
.Fn zdopen
|
|
|
|
return a
|
2014-03-06 00:25:21 +00:00
|
|
|
.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
|
2018-12-06 20:03:06 +00:00
|
|
|
.Xr fopen 3
|
|
|
|
and
|
|
|
|
.Xr fdopen 3 ,
|
|
|
|
the functions may also fail for:
|
2014-03-06 00:25:21 +00:00
|
|
|
.Bl -tag -width Er
|
|
|
|
.It Bq Er ENOMEM
|
|
|
|
Insufficient memory is available.
|
|
|
|
.El
|
|
|
|
.Sh COMPATIBILITY
|
2018-12-06 20:03:06 +00:00
|
|
|
The implementation of
|
|
|
|
.Fn zopen
|
2014-03-06 00:25:21 +00:00
|
|
|
function first appeared in
|
|
|
|
.Nx 1.6
|
|
|
|
and
|
|
|
|
.Fx 4.5 .
|
2018-12-06 20:03:06 +00:00
|
|
|
.Fn zdopen
|
|
|
|
first appeared in
|
|
|
|
.Fx 13.0 .
|
|
|
|
These functions may not be portable to systems other than
|
2014-03-06 00:25:21 +00:00
|
|
|
.Fx .
|
|
|
|
.Sh SEE ALSO
|
2018-12-06 20:03:06 +00:00
|
|
|
.Xr fdopen 3 ,
|
2014-03-06 00:25:21 +00:00
|
|
|
.Xr fopen 3 ,
|
|
|
|
.Xr funopen 3 ,
|
|
|
|
.Xr zlib 3
|