1b6f7731dSXin LI.\" Copyright (c) 2014 Xin LI <delphij@FreeBSD.org> 241de1082SXin LI.\" 341de1082SXin LI.\" Redistribution and use in source and binary forms, with or without 441de1082SXin LI.\" modification, are permitted provided that the following conditions 541de1082SXin LI.\" are met: 641de1082SXin LI.\" 1. Redistributions of source code must retain the above copyright 741de1082SXin LI.\" notice, this list of conditions and the following disclaimer. 841de1082SXin LI.\" 2. Redistributions in binary form must reproduce the above copyright 941de1082SXin LI.\" notice, this list of conditions and the following disclaimer in the 1041de1082SXin LI.\" documentation and/or other materials provided with the distribution. 1141de1082SXin LI.\" 1241de1082SXin LI.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1341de1082SXin LI.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1441de1082SXin LI.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1541de1082SXin LI.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1641de1082SXin LI.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 1741de1082SXin LI.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 1841de1082SXin LI.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 1941de1082SXin LI.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2041de1082SXin LI.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2141de1082SXin LI.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2241de1082SXin LI.\" SUCH DAMAGE. 2341de1082SXin LI.\" 24*8e2a46c8SMark Johnston.Dd December 6, 2018 2541de1082SXin LI.Dt ZOPEN 3 2641de1082SXin LI.Os 2741de1082SXin LI.Sh NAME 2841de1082SXin LI.Nm zopen 2941de1082SXin LI.Nd open a gzip compressed stream 3041de1082SXin LI.Sh LIBRARY 3141de1082SXin LI.Lb libz 3241de1082SXin LI.Sh SYNOPSIS 3341de1082SXin LI.Ft FILE * 3441de1082SXin LI.Fn zopen "const char *path" "const char *mode" 35*8e2a46c8SMark Johnston.Ft FILE * 36*8e2a46c8SMark Johnston.Fn zdopen "int fd" "const char *mode" 3741de1082SXin LI.Sh DESCRIPTION 3841de1082SXin LIThe 3941de1082SXin LI.Fn zopen 40*8e2a46c8SMark Johnstonfunction opens a gzip file whose name is the string pointed to by 4141de1082SXin LI.Fa path 42*8e2a46c8SMark Johnstonand returns a stream which can be used to access the uncompressed contents 43*8e2a46c8SMark Johnstonof the file. 44*8e2a46c8SMark JohnstonThe 45*8e2a46c8SMark Johnston.Fn zdopen 46*8e2a46c8SMark Johnstonvariant takes a gzip file referenced by the file descriptor 47*8e2a46c8SMark Johnston.Fa fd , 48*8e2a46c8SMark Johnstonanalogous to 49*8e2a46c8SMark Johnston.Xr fdopen 3 . 50*8e2a46c8SMark JohnstonThey are wrappers around 5141de1082SXin LI.Xr zlib 3 52*8e2a46c8SMark Johnstonand the standard stream I/O APIs. 5341de1082SXin LI.Pp 5441de1082SXin LIThe argument 5541de1082SXin LI.Fa mode 56*8e2a46c8SMark Johnstonhas the same meaning as it does in 5741de1082SXin LI.Xr fopen 3 . 5841de1082SXin LI.Pp 5941de1082SXin LIThe 60*8e2a46c8SMark Johnston.Fn zopen 61*8e2a46c8SMark Johnstonand 62*8e2a46c8SMark Johnston.Fn zdopen 63*8e2a46c8SMark Johnstonfunctions will associate the read, write, seek and close 6441de1082SXin LIfunctions of 6541de1082SXin LI.Xr zlib 3 66*8e2a46c8SMark Johnstonwith the returned stream. 6741de1082SXin LI.Sh RETURN VALUES 6841de1082SXin LIUpon successful completion 69*8e2a46c8SMark Johnston.Fn zopen 70*8e2a46c8SMark Johnstonand 71*8e2a46c8SMark Johnston.Fn zdopen 72*8e2a46c8SMark Johnstonreturn a 7341de1082SXin LI.Tn FILE 7441de1082SXin LIpointer. 7541de1082SXin LIOtherwise, 7641de1082SXin LI.Dv NULL 7741de1082SXin LIis returned and the global variable 7841de1082SXin LI.Va errno 7941de1082SXin LIis set to indicate the error. 8041de1082SXin LI.Sh ERRORS 8141de1082SXin LIIn addition to the errors documented for 82*8e2a46c8SMark Johnston.Xr fopen 3 83*8e2a46c8SMark Johnstonand 84*8e2a46c8SMark Johnston.Xr fdopen 3 , 85*8e2a46c8SMark Johnstonthe functions may also fail for: 8641de1082SXin LI.Bl -tag -width Er 8741de1082SXin LI.It Bq Er ENOMEM 8841de1082SXin LIInsufficient memory is available. 8941de1082SXin LI.El 9041de1082SXin LI.Sh COMPATIBILITY 91*8e2a46c8SMark JohnstonThe implementation of 92*8e2a46c8SMark Johnston.Fn zopen 9341de1082SXin LIfunction first appeared in 9441de1082SXin LI.Nx 1.6 9541de1082SXin LIand 9641de1082SXin LI.Fx 4.5 . 97*8e2a46c8SMark Johnston.Fn zdopen 98*8e2a46c8SMark Johnstonfirst appeared in 99*8e2a46c8SMark Johnston.Fx 13.0 . 100*8e2a46c8SMark JohnstonThese functions may not be portable to systems other than 10141de1082SXin LI.Fx . 10241de1082SXin LI.Sh SEE ALSO 103*8e2a46c8SMark Johnston.Xr fdopen 3 , 10441de1082SXin LI.Xr fopen 3 , 10541de1082SXin LI.Xr funopen 3 , 10641de1082SXin LI.Xr zlib 3 107