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