xref: /original-bsd/usr.bin/compress/zopen.3 (revision 3705696b)
1.\" Copyright (c) 1992, 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" %sccs.include.redist.roff%
5.\"
6.\"	@(#)zopen.3	8.1 (Berkeley) 06/09/93
7.\"
8.Dd
9.Dt ZOPEN 3
10.Os
11.Sh NAME
12.Nm zopen
13.Nd compressed stream open function
14.Sh SYNOPSIS
15.Fd #include <stdio.h>
16.Ft FILE *
17.Fn zopen "const char *path" "const char *mode" "int bits"
18.Sh DESCRIPTION
19The
20.Fn zopen
21function
22opens the compressed file whose name is the string pointed to by
23.Fa path
24and associates a stream with it.
25.Pp
26The argument
27.Fa mode
28points to one of the following one-character strings:
29.Bl -tag -width indent
30.It Dq Li r
31Open compressed file for reading.
32The stream is positioned at the beginning of the file.
33.It Dq Li w
34Truncate file to zero length or create compressed file for writing.
35The stream is positioned at the beginning of the file.
36.El
37.Pp
38Any created files will have mode
39.Pf \\*q Dv S_IRUSR
40\&|
41.Dv S_IWUSR
42\&|
43.Dv S_IRGRP
44\&|
45.Dv S_IWGRP
46\&|
47.Dv S_IROTH
48\&|
49.Dv S_IWOTH Ns \\*q
50.Pq Li 0666 ,
51as modified by the process'
52umask value (see
53.Xr umask 2 ) .
54.Pp
55Files may only be read or written.
56Seek operations are not allowed.
57.Pp
58The
59.Fa bits
60argument, if non-zero, is set to the bits code limit.
61If zero, the default is 16.
62See
63.Fn compress 1
64for more information.
65.Sh RETURN VALUES
66Upon successful completion
67.Fn zopen
68returns a
69.Tn FILE
70pointer.
71Otherwise,
72.Dv NULL
73is returned and the global variable
74.Va errno
75is set to indicate the error.
76.Sh ERRORS
77.Bl -tag -width [EINVAL]
78.It Bq Er EINVAL
79The
80.Fa mode
81or
82.Fa bits
83arguments specified to
84.Fn zopen
85were invalid.
86.It Bq Er EFTYPE
87The compressed file starts with an invalid header, or the compressed
88file is compressed with more bits than can be handled.
89.El
90.Pp
91The
92.Fn zopen
93function may also fail and set
94.Va errno
95for any of the errors specified for the routines
96.Xr fopen 3
97or
98.Xr funopen 3 .
99.Sh SEE ALSO
100.Xr compress 1 ,
101.Xr fopen 3 ,
102.Xr funopen 3
103.Sh HISTORY
104The
105.Nm zopen
106function
107first appeared in 4.4BSD.
108.Sh BUGS
109The
110.Fn zopen
111function
112may not be portable to systems other than
113.Bx .
114