fzopen(3)

NAME
fzopen - stream open functions on compressed files

SYNOPSIS
#include <zio.h>

FILE *fzopen (const char *path, const char *mode);

DESCRIPTION
The fzopen function opens the compressed file whose name is the string to by path and associates a stream with it.

The argument mode points to a string beginning with one of the following sequences (Additional characters may follow these sequences.):

r   Open compressed text file for reading. The stream is positioned at the beginning of the file.

w   Truncate file to zero length or create compressed text file for writing. The stream is positioned at the beginning of the file.

w1-9
    Just like above but provides also the compression level.

Note that fzopen can only open a compressed text file for reading or writing, but both, which means that the + is not possible. Nor can any compressed text file open for appending, which makes a not usable with fzopen.

NOTE
The program using libzio with -lzio at linking time should also be linked with the appropriate library for accessing compressed text files. This is the libz with -lz for accessing gziped text files and/or with -lbz2 for accessing bzip2ed text files.

For writing gzip/bzip2 files, fzopen only supports the suffixes .z and .gz for gzipped files and .bz2 for bzip2ed files.

On reading first the appropriate suffixes are checked if not provided. If no file is found the magic byte sequence at the beginning of the file is checked to detect a gzip or bzip2 file.

RETURN VALUES
Upon successful completion fzopen return a FILE pointer. Otherwise, NULL is returned and the global variable errno is set to indicate the error.

ERRORS

EINVAL
    The mode provided to fzopen was invalid.

ENOSYS
    The program using fzopen is not linked with the appropriate library (-lz for gziped files and -lbz2 for bzip2ed files.)

ENOMEM
    The call of the library functions of the libz or libbz2 fails due falied memory allocation.

ESPIPE
    This happens if fseek(3) is used in the case of bzip2ed files because the libbz2 does not provide a seek function.

BUGS
Fzopen can not seek within bzip2 files due to the fact that the libbz2 does not provide a function like libz does with gzseek.

FILES
/usr/include/zio.h

SEE ALSO
fopen(8),
gzip(1),
bzip2(1),
/usr/include/zlib.h,
/usr/include/bzlib.h.

COPYRIGHT
2004 Werner Fink, 2004 SuSE LINUX AG Nuernberg, Germany.

AUTHOR
Werner Fink <werner@suse.de>