xref: /freebsd/usr.bin/compress/zopen.3 (revision 7899f917b1c0ea178f1d2be0cfb452086d079d23)
1.\" Copyright (c) 1992, 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\" 3. Neither the name of the University nor the names of its contributors
13.\"    may be used to endorse or promote products derived from this software
14.\"    without specific prior written permission.
15.\"
16.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26.\" SUCH DAMAGE.
27.\"
28.Dd June 9, 1993
29.Dt ZOPEN 3
30.Os
31.Sh NAME
32.Nm zopen
33.Nd compressed stream open function
34.Sh SYNOPSIS
35.Fd #include \&"zopen.h\&"
36.Ft FILE *
37.Fn zopen "const char *path" "const char *mode" "int bits"
38.Sh DESCRIPTION
39The
40.Fn zopen
41function
42opens the compressed file whose name is the string pointed to by
43.Fa path
44and associates a stream with it.
45.Pp
46The argument
47.Fa mode
48points to one of the following one-character strings:
49.Bl -tag -width indent
50.It Dq Li r
51Open compressed file for reading.
52The stream is positioned at the beginning of the file.
53.It Dq Li w
54Truncate file to zero length or create compressed file for writing.
55The stream is positioned at the beginning of the file.
56.El
57.Pp
58Any created files will have mode
59.Pf \\*q Dv S_IRUSR
60\&|
61.Dv S_IWUSR
62\&|
63.Dv S_IRGRP
64\&|
65.Dv S_IWGRP
66\&|
67.Dv S_IROTH
68\&|
69.Dv S_IWOTH Ns \\*q
70.Pq Li 0666 ,
71as modified by the process'
72umask value (see
73.Xr umask 2 ) .
74.Pp
75Files may only be read or written.
76Seek operations are not allowed.
77.Pp
78The
79.Fa bits
80argument, if non-zero, is set to the bits code limit.
81If zero, the default is 16.
82See
83.Xr compress 1
84for more information.
85.Sh RETURN VALUES
86Upon successful completion
87.Fn zopen
88returns a
89.Tn FILE
90pointer.
91Otherwise,
92.Dv NULL
93is returned and the global variable
94.Va errno
95is set to indicate the error.
96.Sh ERRORS
97.Bl -tag -width [EINVAL]
98.It Bq Er EINVAL
99The
100.Fa mode
101or
102.Fa bits
103arguments specified to
104.Fn zopen
105were invalid.
106.It Bq Er EFTYPE
107The compressed file starts with an invalid header, or the compressed
108file is compressed with more bits than can be handled.
109.El
110.Pp
111The
112.Fn zopen
113function may also fail and set
114.Va errno
115for any of the errors specified for the routines
116.Xr fopen 3
117or
118.Xr funopen 3 .
119.Sh SEE ALSO
120.Xr compress 1 ,
121.Xr fopen 3 ,
122.Xr funopen 3
123.Sh HISTORY
124The
125.Nm
126function
127first appeared in
128.Bx 4.4 .
129.Sh BUGS
130The
131.Fn zopen
132function
133may not be portable to systems other than
134.Bx .
135