GZFOPEN(3) BSD Programmer's Manual GZFOPEN(3)NAME
gzfopen, gzfdopen - deflated stream open functions
SYNOPSIS
#include <zlib.h>
FILE *
gzfopen(const char *path, const char *mode);
FILE *
gzfdopen(int filedes, const char *mode);
DESCRIPTION
The gzfopen() function opens the file whose name is the string pointed to
by path and associates a zlib stream with it.
The gzfdopen() function associates a zlib stream with the existing file
descriptor filedes. The mode of the stream must be compatible with the
mode of the file descriptor. The stream is positioned at the file offset
of the file descriptor, which must point to the first byte of the deflate
magic in read mode. If gzfdopen() fails, the file descriptor filedes is
not affected in any way. If gzfdopen() succeeds, any subsequential
fclose() will also close and invalidate filedes.
The argument mode points to a string beginning with one of the following
characters (additional characters may follow):
"r" Open file for reading.
"w" Truncate file to zero length or create text file for writing.
"a" Open for writing. The file is created if it does not exist.
The characters which can follow are the same as for the gzopen() func-
tion:
"b" Binary mode (meaningless under UNIX).
"f" Set the zlib stream strategy to filtered.
"h" Set the zlib stream strategy to huffman-only.
"R" Set the zlib stream to use RLE compression instead of deflate.
"0..9" Set the compression level of the zlib stream used for writing.
RETURN VALUES
Upon successful completion, gzfopen() and gzfdopen() return a FILE
pointer. Otherwise, NULL is returned and the global variable errno is set
to indicate the error.
ERRORS
For both the gzfopen() and gzfdopen() functions, as well as stream opera-
tions (read, write, seek, close), the code tries to meaningful map the
zlib error codes to errno values. An unknown error is mapped to
ENOCOFFEE.
gzfopen() and gzfdopen() can return any error code which the underlying
funopen() function returns, and fail for additional reasons.
SEE ALSOclose(2), funopen(3), gzclose(3), gzdopen(3), gzopen(3), gzread(3),
gzseek(3), gzwrite(3), lseek(2), open(2), read(2), write(2)
The description of deflateInit2() inside compress(3).
HISTORYgzfopen and gzfdopen first appeared in MirOS #9.
AUTHORS
The code and manual page have been written by Thorsten Glaser
<tg@mirbsd.de>.
CAVEATS
Attempt to lseek() on the stream is subject to the same limitations as
gzseek() is, and discouraged.
MirOS BSD #10-current January 24, 2006 1