1 '\" t -*- coding: UTF-8 -*-
3 .\" Copyright 2004 Werner Fink, 2004 SuSE LINUX AG, Germany.
4 .\" Copyright 2006 Werner Fink, 2006 SuSE Products GmbH, Germany.
5 .\" Copyright 2008 Werner Fink, 2008 SuSE Products GmbH, Germany.
6 .\" Copyright 2009 Werner Fink, 2009 SuSE Products GmbH, Germany.
8 .\" This program is free software; you can redistribute it and/or modify
9 .\" it under the terms of the GNU General Public License as published by
10 .\" the Free Software Foundation; either version 2 of the License, or
11 .\" (at your option) any later version.
13 .TH fzopen 3 "Apr 20, 2006" "Version @@VERSION@@" " Linux Programmer's Manual"
17 fzopen \- stream open functions on compressed files
19 fdzopen \- stream open functions on compressed files
24 .BI "FILE *fzopen (const char *" path ", const char *" mode );
26 .BI "FILE *fdzopen (int " fildes ", const char *" mode ", const char *" what );
30 function opens the compressed file whose name is the string to by
32 and associates a stream with it.
35 function associates a stream for the existing files descriptor
37 for a compressed file.
41 points to a string beginning with one of the following sequences
42 (Additional characters may follow these sequences.):
45 Open compressed text file for reading. The stream is positioned
46 at the beginning of the file.
49 Truncate file to zero length or create compressed text file for writing.
50 The stream is positioned at the beginning of the file.
53 Just like above but provides also the compression level.
59 specifies the underlying compression method which should be used:
62 The file descriptor points to a gziped file.
65 The file descriptor points to a bzip2ed file.
68 The file descriptor points to a lzma2ed file.
71 The file descriptor points to a file in LZW format.
77 can only open a compressed text file for reading
83 is not possible. Nor can any compressed text file open for appending,
90 The program using libzio with
92 at linking time should also be linked with
93 the appropriate library for accessing compressed
94 text files. This is the libz with
96 for accessing gziped text files and/or with
98 for accessing bzip2ed text files.
100 For writing gzip/bzip2 files,
102 only supports the suffixes
104 for gzipped files and
106 for bzip2ed files. All supported formats can be found in
113 fread fwrite fseek suffix library
114 gzip yes yes yes .gz -lz
115 bzip2 yes yes yes .bz2 -lbz2
116 LZW yes no yes .Z builtin
117 lzma yes yes(no) yes .lzma -llzma (-llzmadec)
118 xz yes yes yes .xz -llzma
122 On reading first the appropriate suffixes are checked
123 if not provided. If no file is found the magic
124 byte sequence at the beginning of the file is checked
125 to detect a gzip or bzip2 file.
133 and a few lines in the common file
137 found in many source packages a programmer or maintainer
138 can extend the automatic configuration to find the
139 appropriate libraries together with the libzio:
143 AC_CHECK_HEADER(zio.h, [
144 AC_CHECK_LIB(zio, fzopen, [
145 AC_CHECK_LIB(zio, fdzopen, [LIBS="$LIBS -lzio"; am_cv_libzio=yes])
148 if test "$am_cv_libzio" = yes; then
150 AC_DEFINE(HAVE_ZIO, 1, [Define if you have libzio for opening compressed files.])
151 AC_CHECK_HEADER(zlib.h, [
153 AC_CHECK_LIB($lib, gzopen, [
155 am_cv_libzio="$am_cv_libzio lib$lib"
160 AC_CHECK_HEADER(bzlib.h, [
161 for lib in bz2 bzip2; do
162 AC_CHECK_LIB($lib, BZ2_bzopen, [
164 am_cv_libzio="$am_cv_libzio lib$lib"
169 AC_CHECK_HEADER(lzmadec.h, [
170 for lib in lzma lzmadec; do
171 AC_CHECK_LIB($lib, lzmadec_open, [
173 am_cv_libzio="$am_cv_libzio lib$lib"
178 AC_CHECK_HEADER(lzma.h, [
180 AC_CHECK_LIB($lib, lzma_easy_encoder, [
182 am_cv_libzio="$am_cv_libzio lib$lib"
187 AC_MSG_NOTICE([libzio is used [$]am_cv_libzio])
191 combined with two lines in the common file
197 /* Define to 1 if you have libzio for opening compressed files */
202 (automatically added by
204 it is easy to use the
215 Upon successful completion
221 is returned and the global variable errno is set to
236 is not linked with the appropriate library
245 has specified a wrong mode for a
253 The call of the library functions of the
257 fails due failed memory allocation.
262 is used in the case of seesking files is not
270 may not be applied on streams opened by
272 An further explanation will be found in section
279 files due to the fact that the
281 does not provide a function like
286 compressed file will be opened by
290 only for reading. Also a seek
295 compressed file will be opened by
299 only for reading as the liblzmadec only
305 are custom-made streams created with the help of
311 known from BSD Systems
312 it is not possible to use the file descriptor with e.g.
314 in combination with system calls like
316 as this will evade the underlying read/write
317 functions of the e.g.
321 .BR /usr/include/zio.h
337 .BR /usr/include/zlib.h ,
339 .BR /usr/include/bzlib.h .
341 .BR /usr/include/lzma.h .
343 .BR /usr/include/lzmadec.h .
346 2004 SuSE LINUX AG Nuernberg, Germany.
348 2006,2008,2009 Werner Fink,
349 2006,2008,2009 SuSE Products GmbH, Germany.
351 Werner Fink <werner@suse.de>