diff options
Diffstat (limited to 'doc/api-documentation/html/zlib_8h-source.html')
-rw-r--r-- | doc/api-documentation/html/zlib_8h-source.html | 907 |
1 files changed, 907 insertions, 0 deletions
diff --git a/doc/api-documentation/html/zlib_8h-source.html b/doc/api-documentation/html/zlib_8h-source.html new file mode 100644 index 0000000..39ecb6b --- /dev/null +++ b/doc/api-documentation/html/zlib_8h-source.html @@ -0,0 +1,907 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> +<title>zlib.h Source File</title> +<link href="doxygen.css" rel="stylesheet" type="text/css"> +</head><body> +<!-- Generated by Doxygen 1.2.15 --> +<center> +<a class="qindex" href="index.html">Main Page</a> <a class="qindex" href="namespaces.html">Namespace List</a> <a class="qindex" href="hierarchy.html">Class Hierarchy</a> <a class="qindex" href="classes.html">Alphabetical List</a> <a class="qindex" href="annotated.html">Compound List</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="functions.html">Compound Members</a> </center> +<hr><h1>zlib.h</h1><div class="fragment"><pre>00001 <font class="comment">/* zlib.h -- interface of the 'zlib' general purpose compression library</font> +00002 <font class="comment"> version 1.1.3, July 9th, 1998</font> +00003 <font class="comment"></font> +00004 <font class="comment"> Copyright (C) 1995-1998 Jean-loup Gailly and Mark Adler</font> +00005 <font class="comment"></font> +00006 <font class="comment"> This software is provided 'as-is', without any express or implied</font> +00007 <font class="comment"> warranty. In no event will the authors be held liable for any damages</font> +00008 <font class="comment"> arising from the use of this software.</font> +00009 <font class="comment"></font> +00010 <font class="comment"> Permission is granted to anyone to use this software for any purpose,</font> +00011 <font class="comment"> including commercial applications, and to alter it and redistribute it</font> +00012 <font class="comment"> freely, subject to the following restrictions:</font> +00013 <font class="comment"></font> +00014 <font class="comment"> 1. The origin of this software must not be misrepresented; you must not</font> +00015 <font class="comment"> claim that you wrote the original software. If you use this software</font> +00016 <font class="comment"> in a product, an acknowledgment in the product documentation would be</font> +00017 <font class="comment"> appreciated but is not required.</font> +00018 <font class="comment"> 2. Altered source versions must be plainly marked as such, and must not be</font> +00019 <font class="comment"> misrepresented as being the original software.</font> +00020 <font class="comment"> 3. This notice may not be removed or altered from any source distribution.</font> +00021 <font class="comment"></font> +00022 <font class="comment"> Jean-loup Gailly Mark Adler</font> +00023 <font class="comment"> jloup@gzip.org madler@alumni.caltech.edu</font> +00024 <font class="comment"></font> +00025 <font class="comment"></font> +00026 <font class="comment"> The data format used by the zlib library is described by RFCs (Request for</font> +00027 <font class="comment"> Comments) 1950 to 1952 in the files ftp://ds.internic.net/rfc/rfc1950.txt</font> +00028 <font class="comment"> (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format).</font> +00029 <font class="comment">*/</font> +00030 +00031 <font class="preprocessor">#ifndef _ZLIB_H</font> +00032 <font class="preprocessor"></font><font class="preprocessor">#define _ZLIB_H</font> +00033 <font class="preprocessor"></font> +00034 <font class="preprocessor">#include "zconf.h"</font> +00035 +00036 <font class="preprocessor">#ifdef __cplusplus</font> +00037 <font class="preprocessor"></font><font class="keyword">extern</font> <font class="stringliteral">"C"</font> { +00038 <font class="preprocessor">#endif</font> +00039 <font class="preprocessor"></font> +00040 <font class="preprocessor">#define ZLIB_VERSION "1.1.3"</font> +00041 <font class="preprocessor"></font> +00042 <font class="comment">/* </font> +00043 <font class="comment"> The 'zlib' compression library provides in-memory compression and</font> +00044 <font class="comment"> decompression functions, including integrity checks of the uncompressed</font> +00045 <font class="comment"> data. This version of the library supports only one compression method</font> +00046 <font class="comment"> (deflation) but other algorithms will be added later and will have the same</font> +00047 <font class="comment"> stream interface.</font> +00048 <font class="comment"></font> +00049 <font class="comment"> Compression can be done in a single step if the buffers are large</font> +00050 <font class="comment"> enough (for example if an input file is mmap'ed), or can be done by</font> +00051 <font class="comment"> repeated calls of the compression function. In the latter case, the</font> +00052 <font class="comment"> application must provide more input and/or consume the output</font> +00053 <font class="comment"> (providing more output space) before each call.</font> +00054 <font class="comment"></font> +00055 <font class="comment"> The library also supports reading and writing files in gzip (.gz) format</font> +00056 <font class="comment"> with an interface similar to that of stdio.</font> +00057 <font class="comment"></font> +00058 <font class="comment"> The library does not install any signal handler. The decoder checks</font> +00059 <font class="comment"> the consistency of the compressed data, so the library should never</font> +00060 <font class="comment"> crash even in case of corrupted input.</font> +00061 <font class="comment">*/</font> +00062 +00063 <font class="keyword">typedef</font> voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); +00064 <font class="keyword">typedef</font> void (*free_func) OF((voidpf opaque, voidpf address)); +00065 +00066 <font class="keyword">struct </font>internal_state; +00067 +00068 <font class="keyword">typedef</font> <font class="keyword">struct </font>z_stream_s { +00069 Bytef *next_in; <font class="comment">/* next input byte */</font> +00070 uInt avail_in; <font class="comment">/* number of bytes available at next_in */</font> +00071 uLong total_in; <font class="comment">/* total nb of input bytes read so far */</font> +00072 +00073 Bytef *next_out; <font class="comment">/* next output byte should be put there */</font> +00074 uInt avail_out; <font class="comment">/* remaining free space at next_out */</font> +00075 uLong total_out; <font class="comment">/* total nb of bytes output so far */</font> +00076 +00077 <font class="keywordtype">char</font> *msg; <font class="comment">/* last error message, NULL if no error */</font> +00078 <font class="keyword">struct </font>internal_state FAR *state; <font class="comment">/* not visible by applications */</font> +00079 +00080 alloc_func zalloc; <font class="comment">/* used to allocate the internal state */</font> +00081 free_func zfree; <font class="comment">/* used to free the internal state */</font> +00082 voidpf opaque; <font class="comment">/* private data object passed to zalloc and zfree */</font> +00083 +00084 <font class="keywordtype">int</font> data_type; <font class="comment">/* best guess about the data type: ascii or binary */</font> +00085 uLong adler; <font class="comment">/* adler32 value of the uncompressed data */</font> +00086 uLong reserved; <font class="comment">/* reserved for future use */</font> +00087 } z_stream; +00088 +00089 <font class="keyword">typedef</font> z_stream FAR *z_streamp; +00090 +00091 <font class="comment">/*</font> +00092 <font class="comment"> The application must update next_in and avail_in when avail_in has</font> +00093 <font class="comment"> dropped to zero. It must update next_out and avail_out when avail_out</font> +00094 <font class="comment"> has dropped to zero. The application must initialize zalloc, zfree and</font> +00095 <font class="comment"> opaque before calling the init function. All other fields are set by the</font> +00096 <font class="comment"> compression library and must not be updated by the application.</font> +00097 <font class="comment"></font> +00098 <font class="comment"> The opaque value provided by the application will be passed as the first</font> +00099 <font class="comment"> parameter for calls of zalloc and zfree. This can be useful for custom</font> +00100 <font class="comment"> memory management. The compression library attaches no meaning to the</font> +00101 <font class="comment"> opaque value.</font> +00102 <font class="comment"></font> +00103 <font class="comment"> zalloc must return Z_NULL if there is not enough memory for the object.</font> +00104 <font class="comment"> If zlib is used in a multi-threaded application, zalloc and zfree must be</font> +00105 <font class="comment"> thread safe.</font> +00106 <font class="comment"></font> +00107 <font class="comment"> On 16-bit systems, the functions zalloc and zfree must be able to allocate</font> +00108 <font class="comment"> exactly 65536 bytes, but will not be required to allocate more than this</font> +00109 <font class="comment"> if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS,</font> +00110 <font class="comment"> pointers returned by zalloc for objects of exactly 65536 bytes *must*</font> +00111 <font class="comment"> have their offset normalized to zero. The default allocation function</font> +00112 <font class="comment"> provided by this library ensures this (see zutil.c). To reduce memory</font> +00113 <font class="comment"> requirements and avoid any allocation of 64K objects, at the expense of</font> +00114 <font class="comment"> compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h).</font> +00115 <font class="comment"></font> +00116 <font class="comment"> The fields total_in and total_out can be used for statistics or</font> +00117 <font class="comment"> progress reports. After compression, total_in holds the total size of</font> +00118 <font class="comment"> the uncompressed data and may be saved for use in the decompressor</font> +00119 <font class="comment"> (particularly if the decompressor wants to decompress everything in</font> +00120 <font class="comment"> a single step).</font> +00121 <font class="comment">*/</font> +00122 +00123 <font class="comment">/* constants */</font> +00124 +00125 <font class="preprocessor">#define Z_NO_FLUSH 0</font> +00126 <font class="preprocessor"></font><font class="preprocessor">#define Z_PARTIAL_FLUSH 1 </font><font class="comment">/* will be removed, use Z_SYNC_FLUSH instead */</font> +00127 <font class="preprocessor">#define Z_SYNC_FLUSH 2</font> +00128 <font class="preprocessor"></font><font class="preprocessor">#define Z_FULL_FLUSH 3</font> +00129 <font class="preprocessor"></font><font class="preprocessor">#define Z_FINISH 4</font> +00130 <font class="preprocessor"></font><font class="comment">/* Allowed flush values; see deflate() below for details */</font> +00131 +00132 <font class="preprocessor">#define Z_OK 0</font> +00133 <font class="preprocessor"></font><font class="preprocessor">#define Z_STREAM_END 1</font> +00134 <font class="preprocessor"></font><font class="preprocessor">#define Z_NEED_DICT 2</font> +00135 <font class="preprocessor"></font><font class="preprocessor">#define Z_ERRNO (-1)</font> +00136 <font class="preprocessor"></font><font class="preprocessor">#define Z_STREAM_ERROR (-2)</font> +00137 <font class="preprocessor"></font><font class="preprocessor">#define Z_DATA_ERROR (-3)</font> +00138 <font class="preprocessor"></font><font class="preprocessor">#define Z_MEM_ERROR (-4)</font> +00139 <font class="preprocessor"></font><font class="preprocessor">#define Z_BUF_ERROR (-5)</font> +00140 <font class="preprocessor"></font><font class="preprocessor">#define Z_VERSION_ERROR (-6)</font> +00141 <font class="preprocessor"></font><font class="comment">/* Return codes for the compression/decompression functions. Negative</font> +00142 <font class="comment"> * values are errors, positive values are used for special but normal events.</font> +00143 <font class="comment"> */</font> +00144 +00145 <font class="preprocessor">#define Z_NO_COMPRESSION 0</font> +00146 <font class="preprocessor"></font><font class="preprocessor">#define Z_BEST_SPEED 1</font> +00147 <font class="preprocessor"></font><font class="preprocessor">#define Z_BEST_COMPRESSION 9</font> +00148 <font class="preprocessor"></font><font class="preprocessor">#define Z_DEFAULT_COMPRESSION (-1)</font> +00149 <font class="preprocessor"></font><font class="comment">/* compression levels */</font> +00150 +00151 <font class="preprocessor">#define Z_FILTERED 1</font> +00152 <font class="preprocessor"></font><font class="preprocessor">#define Z_HUFFMAN_ONLY 2</font> +00153 <font class="preprocessor"></font><font class="preprocessor">#define Z_DEFAULT_STRATEGY 0</font> +00154 <font class="preprocessor"></font><font class="comment">/* compression strategy; see deflateInit2() below for details */</font> +00155 +00156 <font class="preprocessor">#define Z_BINARY 0</font> +00157 <font class="preprocessor"></font><font class="preprocessor">#define Z_ASCII 1</font> +00158 <font class="preprocessor"></font><font class="preprocessor">#define Z_UNKNOWN 2</font> +00159 <font class="preprocessor"></font><font class="comment">/* Possible values of the data_type field */</font> +00160 +00161 <font class="preprocessor">#define Z_DEFLATED 8</font> +00162 <font class="preprocessor"></font><font class="comment">/* The deflate compression method (the only one supported in this version) */</font> +00163 +00164 <font class="preprocessor">#define Z_NULL 0 </font><font class="comment">/* for initializing zalloc, zfree, opaque */</font> +00165 +00166 <font class="preprocessor">#define zlib_version zlibVersion()</font> +00167 <font class="preprocessor"></font><font class="comment">/* for compatibility with versions < 1.0.2 */</font> +00168 +00169 <font class="comment">/* basic functions */</font> +00170 +00171 ZEXTERN <font class="keyword">const</font> <font class="keywordtype">char</font> * ZEXPORT zlibVersion OF((<font class="keywordtype">void</font>)); +00172 <font class="comment">/* The application can compare zlibVersion and ZLIB_VERSION for consistency.</font> +00173 <font class="comment"> If the first character differs, the library code actually used is</font> +00174 <font class="comment"> not compatible with the zlib.h header file used by the application.</font> +00175 <font class="comment"> This check is automatically made by deflateInit and inflateInit.</font> +00176 <font class="comment"> */</font> +00177 +00178 <font class="comment">/* </font> +00179 <font class="comment">ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level));</font> +00180 <font class="comment"></font> +00181 <font class="comment"> Initializes the internal stream state for compression. The fields</font> +00182 <font class="comment"> zalloc, zfree and opaque must be initialized before by the caller.</font> +00183 <font class="comment"> If zalloc and zfree are set to Z_NULL, deflateInit updates them to</font> +00184 <font class="comment"> use default allocation functions.</font> +00185 <font class="comment"></font> +00186 <font class="comment"> The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9:</font> +00187 <font class="comment"> 1 gives best speed, 9 gives best compression, 0 gives no compression at</font> +00188 <font class="comment"> all (the input data is simply copied a block at a time).</font> +00189 <font class="comment"> Z_DEFAULT_COMPRESSION requests a default compromise between speed and</font> +00190 <font class="comment"> compression (currently equivalent to level 6).</font> +00191 <font class="comment"></font> +00192 <font class="comment"> deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not</font> +00193 <font class="comment"> enough memory, Z_STREAM_ERROR if level is not a valid compression level,</font> +00194 <font class="comment"> Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible</font> +00195 <font class="comment"> with the version assumed by the caller (ZLIB_VERSION).</font> +00196 <font class="comment"> msg is set to null if there is no error message. deflateInit does not</font> +00197 <font class="comment"> perform any compression: this will be done by deflate().</font> +00198 <font class="comment">*/</font> +00199 +00200 +00201 ZEXTERN <font class="keywordtype">int</font> ZEXPORT deflate OF((z_streamp strm, <font class="keywordtype">int</font> flush)); +00202 <font class="comment">/*</font> +00203 <font class="comment"> deflate compresses as much data as possible, and stops when the input</font> +00204 <font class="comment"> buffer becomes empty or the output buffer becomes full. It may introduce some</font> +00205 <font class="comment"> output latency (reading input without producing any output) except when</font> +00206 <font class="comment"> forced to flush.</font> +00207 <font class="comment"></font> +00208 <font class="comment"> The detailed semantics are as follows. deflate performs one or both of the</font> +00209 <font class="comment"> following actions:</font> +00210 <font class="comment"></font> +00211 <font class="comment"> - Compress more input starting at next_in and update next_in and avail_in</font> +00212 <font class="comment"> accordingly. If not all input can be processed (because there is not</font> +00213 <font class="comment"> enough room in the output buffer), next_in and avail_in are updated and</font> +00214 <font class="comment"> processing will resume at this point for the next call of deflate().</font> +00215 <font class="comment"></font> +00216 <font class="comment"> - Provide more output starting at next_out and update next_out and avail_out</font> +00217 <font class="comment"> accordingly. This action is forced if the parameter flush is non zero.</font> +00218 <font class="comment"> Forcing flush frequently degrades the compression ratio, so this parameter</font> +00219 <font class="comment"> should be set only when necessary (in interactive applications).</font> +00220 <font class="comment"> Some output may be provided even if flush is not set.</font> +00221 <font class="comment"></font> +00222 <font class="comment"> Before the call of deflate(), the application should ensure that at least</font> +00223 <font class="comment"> one of the actions is possible, by providing more input and/or consuming</font> +00224 <font class="comment"> more output, and updating avail_in or avail_out accordingly; avail_out</font> +00225 <font class="comment"> should never be zero before the call. The application can consume the</font> +00226 <font class="comment"> compressed output when it wants, for example when the output buffer is full</font> +00227 <font class="comment"> (avail_out == 0), or after each call of deflate(). If deflate returns Z_OK</font> +00228 <font class="comment"> and with zero avail_out, it must be called again after making room in the</font> +00229 <font class="comment"> output buffer because there might be more output pending.</font> +00230 <font class="comment"></font> +00231 <font class="comment"> If the parameter flush is set to Z_SYNC_FLUSH, all pending output is</font> +00232 <font class="comment"> flushed to the output buffer and the output is aligned on a byte boundary, so</font> +00233 <font class="comment"> that the decompressor can get all input data available so far. (In particular</font> +00234 <font class="comment"> avail_in is zero after the call if enough output space has been provided</font> +00235 <font class="comment"> before the call.) Flushing may degrade compression for some compression</font> +00236 <font class="comment"> algorithms and so it should be used only when necessary.</font> +00237 <font class="comment"></font> +00238 <font class="comment"> If flush is set to Z_FULL_FLUSH, all output is flushed as with</font> +00239 <font class="comment"> Z_SYNC_FLUSH, and the compression state is reset so that decompression can</font> +00240 <font class="comment"> restart from this point if previous compressed data has been damaged or if</font> +00241 <font class="comment"> random access is desired. Using Z_FULL_FLUSH too often can seriously degrade</font> +00242 <font class="comment"> the compression.</font> +00243 <font class="comment"></font> +00244 <font class="comment"> If deflate returns with avail_out == 0, this function must be called again</font> +00245 <font class="comment"> with the same value of the flush parameter and more output space (updated</font> +00246 <font class="comment"> avail_out), until the flush is complete (deflate returns with non-zero</font> +00247 <font class="comment"> avail_out).</font> +00248 <font class="comment"></font> +00249 <font class="comment"> If the parameter flush is set to Z_FINISH, pending input is processed,</font> +00250 <font class="comment"> pending output is flushed and deflate returns with Z_STREAM_END if there</font> +00251 <font class="comment"> was enough output space; if deflate returns with Z_OK, this function must be</font> +00252 <font class="comment"> called again with Z_FINISH and more output space (updated avail_out) but no</font> +00253 <font class="comment"> more input data, until it returns with Z_STREAM_END or an error. After</font> +00254 <font class="comment"> deflate has returned Z_STREAM_END, the only possible operations on the</font> +00255 <font class="comment"> stream are deflateReset or deflateEnd.</font> +00256 <font class="comment"> </font> +00257 <font class="comment"> Z_FINISH can be used immediately after deflateInit if all the compression</font> +00258 <font class="comment"> is to be done in a single step. In this case, avail_out must be at least</font> +00259 <font class="comment"> 0.1% larger than avail_in plus 12 bytes. If deflate does not return</font> +00260 <font class="comment"> Z_STREAM_END, then it must be called again as described above.</font> +00261 <font class="comment"></font> +00262 <font class="comment"> deflate() sets strm->adler to the adler32 checksum of all input read</font> +00263 <font class="comment"> so far (that is, total_in bytes).</font> +00264 <font class="comment"></font> +00265 <font class="comment"> deflate() may update data_type if it can make a good guess about</font> +00266 <font class="comment"> the input data type (Z_ASCII or Z_BINARY). In doubt, the data is considered</font> +00267 <font class="comment"> binary. This field is only for information purposes and does not affect</font> +00268 <font class="comment"> the compression algorithm in any manner.</font> +00269 <font class="comment"></font> +00270 <font class="comment"> deflate() returns Z_OK if some progress has been made (more input</font> +00271 <font class="comment"> processed or more output produced), Z_STREAM_END if all input has been</font> +00272 <font class="comment"> consumed and all output has been produced (only when flush is set to</font> +00273 <font class="comment"> Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example</font> +00274 <font class="comment"> if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible</font> +00275 <font class="comment"> (for example avail_in or avail_out was zero).</font> +00276 <font class="comment">*/</font> +00277 +00278 +00279 ZEXTERN <font class="keywordtype">int</font> ZEXPORT deflateEnd OF((z_streamp strm)); +00280 <font class="comment">/*</font> +00281 <font class="comment"> All dynamically allocated data structures for this stream are freed.</font> +00282 <font class="comment"> This function discards any unprocessed input and does not flush any</font> +00283 <font class="comment"> pending output.</font> +00284 <font class="comment"></font> +00285 <font class="comment"> deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the</font> +00286 <font class="comment"> stream state was inconsistent, Z_DATA_ERROR if the stream was freed</font> +00287 <font class="comment"> prematurely (some input or output was discarded). In the error case,</font> +00288 <font class="comment"> msg may be set but then points to a static string (which must not be</font> +00289 <font class="comment"> deallocated).</font> +00290 <font class="comment">*/</font> +00291 +00292 +00293 <font class="comment">/* </font> +00294 <font class="comment">ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm));</font> +00295 <font class="comment"></font> +00296 <font class="comment"> Initializes the internal stream state for decompression. The fields</font> +00297 <font class="comment"> next_in, avail_in, zalloc, zfree and opaque must be initialized before by</font> +00298 <font class="comment"> the caller. If next_in is not Z_NULL and avail_in is large enough (the exact</font> +00299 <font class="comment"> value depends on the compression method), inflateInit determines the</font> +00300 <font class="comment"> compression method from the zlib header and allocates all data structures</font> +00301 <font class="comment"> accordingly; otherwise the allocation will be deferred to the first call of</font> +00302 <font class="comment"> inflate. If zalloc and zfree are set to Z_NULL, inflateInit updates them to</font> +00303 <font class="comment"> use default allocation functions.</font> +00304 <font class="comment"></font> +00305 <font class="comment"> inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough</font> +00306 <font class="comment"> memory, Z_VERSION_ERROR if the zlib library version is incompatible with the</font> +00307 <font class="comment"> version assumed by the caller. msg is set to null if there is no error</font> +00308 <font class="comment"> message. inflateInit does not perform any decompression apart from reading</font> +00309 <font class="comment"> the zlib header if present: this will be done by inflate(). (So next_in and</font> +00310 <font class="comment"> avail_in may be modified, but next_out and avail_out are unchanged.)</font> +00311 <font class="comment">*/</font> +00312 +00313 +00314 ZEXTERN <font class="keywordtype">int</font> ZEXPORT inflate OF((z_streamp strm, <font class="keywordtype">int</font> flush)); +00315 <font class="comment">/*</font> +00316 <font class="comment"> inflate decompresses as much data as possible, and stops when the input</font> +00317 <font class="comment"> buffer becomes empty or the output buffer becomes full. It may some</font> +00318 <font class="comment"> introduce some output latency (reading input without producing any output)</font> +00319 <font class="comment"> except when forced to flush.</font> +00320 <font class="comment"></font> +00321 <font class="comment"> The detailed semantics are as follows. inflate performs one or both of the</font> +00322 <font class="comment"> following actions:</font> +00323 <font class="comment"></font> +00324 <font class="comment"> - Decompress more input starting at next_in and update next_in and avail_in</font> +00325 <font class="comment"> accordingly. If not all input can be processed (because there is not</font> +00326 <font class="comment"> enough room in the output buffer), next_in is updated and processing</font> +00327 <font class="comment"> will resume at this point for the next call of inflate().</font> +00328 <font class="comment"></font> +00329 <font class="comment"> - Provide more output starting at next_out and update next_out and avail_out</font> +00330 <font class="comment"> accordingly. inflate() provides as much output as possible, until there</font> +00331 <font class="comment"> is no more input data or no more space in the output buffer (see below</font> +00332 <font class="comment"> about the flush parameter).</font> +00333 <font class="comment"></font> +00334 <font class="comment"> Before the call of inflate(), the application should ensure that at least</font> +00335 <font class="comment"> one of the actions is possible, by providing more input and/or consuming</font> +00336 <font class="comment"> more output, and updating the next_* and avail_* values accordingly.</font> +00337 <font class="comment"> The application can consume the uncompressed output when it wants, for</font> +00338 <font class="comment"> example when the output buffer is full (avail_out == 0), or after each</font> +00339 <font class="comment"> call of inflate(). If inflate returns Z_OK and with zero avail_out, it</font> +00340 <font class="comment"> must be called again after making room in the output buffer because there</font> +00341 <font class="comment"> might be more output pending.</font> +00342 <font class="comment"></font> +00343 <font class="comment"> If the parameter flush is set to Z_SYNC_FLUSH, inflate flushes as much</font> +00344 <font class="comment"> output as possible to the output buffer. The flushing behavior of inflate is</font> +00345 <font class="comment"> not specified for values of the flush parameter other than Z_SYNC_FLUSH</font> +00346 <font class="comment"> and Z_FINISH, but the current implementation actually flushes as much output</font> +00347 <font class="comment"> as possible anyway.</font> +00348 <font class="comment"></font> +00349 <font class="comment"> inflate() should normally be called until it returns Z_STREAM_END or an</font> +00350 <font class="comment"> error. However if all decompression is to be performed in a single step</font> +00351 <font class="comment"> (a single call of inflate), the parameter flush should be set to</font> +00352 <font class="comment"> Z_FINISH. In this case all pending input is processed and all pending</font> +00353 <font class="comment"> output is flushed; avail_out must be large enough to hold all the</font> +00354 <font class="comment"> uncompressed data. (The size of the uncompressed data may have been saved</font> +00355 <font class="comment"> by the compressor for this purpose.) The next operation on this stream must</font> +00356 <font class="comment"> be inflateEnd to deallocate the decompression state. The use of Z_FINISH</font> +00357 <font class="comment"> is never required, but can be used to inform inflate that a faster routine</font> +00358 <font class="comment"> may be used for the single inflate() call.</font> +00359 <font class="comment"></font> +00360 <font class="comment"> If a preset dictionary is needed at this point (see inflateSetDictionary</font> +00361 <font class="comment"> below), inflate sets strm-adler to the adler32 checksum of the</font> +00362 <font class="comment"> dictionary chosen by the compressor and returns Z_NEED_DICT; otherwise </font> +00363 <font class="comment"> it sets strm->adler to the adler32 checksum of all output produced</font> +00364 <font class="comment"> so far (that is, total_out bytes) and returns Z_OK, Z_STREAM_END or</font> +00365 <font class="comment"> an error code as described below. At the end of the stream, inflate()</font> +00366 <font class="comment"> checks that its computed adler32 checksum is equal to that saved by the</font> +00367 <font class="comment"> compressor and returns Z_STREAM_END only if the checksum is correct.</font> +00368 <font class="comment"></font> +00369 <font class="comment"> inflate() returns Z_OK if some progress has been made (more input processed</font> +00370 <font class="comment"> or more output produced), Z_STREAM_END if the end of the compressed data has</font> +00371 <font class="comment"> been reached and all uncompressed output has been produced, Z_NEED_DICT if a</font> +00372 <font class="comment"> preset dictionary is needed at this point, Z_DATA_ERROR if the input data was</font> +00373 <font class="comment"> corrupted (input stream not conforming to the zlib format or incorrect</font> +00374 <font class="comment"> adler32 checksum), Z_STREAM_ERROR if the stream structure was inconsistent</font> +00375 <font class="comment"> (for example if next_in or next_out was NULL), Z_MEM_ERROR if there was not</font> +00376 <font class="comment"> enough memory, Z_BUF_ERROR if no progress is possible or if there was not</font> +00377 <font class="comment"> enough room in the output buffer when Z_FINISH is used. In the Z_DATA_ERROR</font> +00378 <font class="comment"> case, the application may then call inflateSync to look for a good</font> +00379 <font class="comment"> compression block.</font> +00380 <font class="comment">*/</font> +00381 +00382 +00383 ZEXTERN <font class="keywordtype">int</font> ZEXPORT inflateEnd OF((z_streamp strm)); +00384 <font class="comment">/*</font> +00385 <font class="comment"> All dynamically allocated data structures for this stream are freed.</font> +00386 <font class="comment"> This function discards any unprocessed input and does not flush any</font> +00387 <font class="comment"> pending output.</font> +00388 <font class="comment"></font> +00389 <font class="comment"> inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state</font> +00390 <font class="comment"> was inconsistent. In the error case, msg may be set but then points to a</font> +00391 <font class="comment"> static string (which must not be deallocated).</font> +00392 <font class="comment">*/</font> +00393 +00394 <font class="comment">/* Advanced functions */</font> +00395 +00396 <font class="comment">/*</font> +00397 <font class="comment"> The following functions are needed only in some special applications.</font> +00398 <font class="comment">*/</font> +00399 +00400 <font class="comment">/* </font> +00401 <font class="comment">ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,</font> +00402 <font class="comment"> int level,</font> +00403 <font class="comment"> int method,</font> +00404 <font class="comment"> int windowBits,</font> +00405 <font class="comment"> int memLevel,</font> +00406 <font class="comment"> int strategy));</font> +00407 <font class="comment"></font> +00408 <font class="comment"> This is another version of deflateInit with more compression options. The</font> +00409 <font class="comment"> fields next_in, zalloc, zfree and opaque must be initialized before by</font> +00410 <font class="comment"> the caller.</font> +00411 <font class="comment"></font> +00412 <font class="comment"> The method parameter is the compression method. It must be Z_DEFLATED in</font> +00413 <font class="comment"> this version of the library.</font> +00414 <font class="comment"></font> +00415 <font class="comment"> The windowBits parameter is the base two logarithm of the window size</font> +00416 <font class="comment"> (the size of the history buffer). It should be in the range 8..15 for this</font> +00417 <font class="comment"> version of the library. Larger values of this parameter result in better</font> +00418 <font class="comment"> compression at the expense of memory usage. The default value is 15 if</font> +00419 <font class="comment"> deflateInit is used instead.</font> +00420 <font class="comment"></font> +00421 <font class="comment"> The memLevel parameter specifies how much memory should be allocated</font> +00422 <font class="comment"> for the internal compression state. memLevel=1 uses minimum memory but</font> +00423 <font class="comment"> is slow and reduces compression ratio; memLevel=9 uses maximum memory</font> +00424 <font class="comment"> for optimal speed. The default value is 8. See zconf.h for total memory</font> +00425 <font class="comment"> usage as a function of windowBits and memLevel.</font> +00426 <font class="comment"></font> +00427 <font class="comment"> The strategy parameter is used to tune the compression algorithm. Use the</font> +00428 <font class="comment"> value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a</font> +00429 <font class="comment"> filter (or predictor), or Z_HUFFMAN_ONLY to force Huffman encoding only (no</font> +00430 <font class="comment"> string match). Filtered data consists mostly of small values with a</font> +00431 <font class="comment"> somewhat random distribution. In this case, the compression algorithm is</font> +00432 <font class="comment"> tuned to compress them better. The effect of Z_FILTERED is to force more</font> +00433 <font class="comment"> Huffman coding and less string matching; it is somewhat intermediate</font> +00434 <font class="comment"> between Z_DEFAULT and Z_HUFFMAN_ONLY. The strategy parameter only affects</font> +00435 <font class="comment"> the compression ratio but not the correctness of the compressed output even</font> +00436 <font class="comment"> if it is not set appropriately.</font> +00437 <font class="comment"></font> +00438 <font class="comment"> deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough</font> +00439 <font class="comment"> memory, Z_STREAM_ERROR if a parameter is invalid (such as an invalid</font> +00440 <font class="comment"> method). msg is set to null if there is no error message. deflateInit2 does</font> +00441 <font class="comment"> not perform any compression: this will be done by deflate().</font> +00442 <font class="comment">*/</font> +00443 +00444 ZEXTERN <font class="keywordtype">int</font> ZEXPORT deflateSetDictionary OF((z_streamp strm, +00445 <font class="keyword">const</font> Bytef *dictionary, +00446 uInt dictLength)); +00447 <font class="comment">/*</font> +00448 <font class="comment"> Initializes the compression dictionary from the given byte sequence</font> +00449 <font class="comment"> without producing any compressed output. This function must be called</font> +00450 <font class="comment"> immediately after deflateInit, deflateInit2 or deflateReset, before any</font> +00451 <font class="comment"> call of deflate. The compressor and decompressor must use exactly the same</font> +00452 <font class="comment"> dictionary (see inflateSetDictionary).</font> +00453 <font class="comment"></font> +00454 <font class="comment"> The dictionary should consist of strings (byte sequences) that are likely</font> +00455 <font class="comment"> to be encountered later in the data to be compressed, with the most commonly</font> +00456 <font class="comment"> used strings preferably put towards the end of the dictionary. Using a</font> +00457 <font class="comment"> dictionary is most useful when the data to be compressed is short and can be</font> +00458 <font class="comment"> predicted with good accuracy; the data can then be compressed better than</font> +00459 <font class="comment"> with the default empty dictionary.</font> +00460 <font class="comment"></font> +00461 <font class="comment"> Depending on the size of the compression data structures selected by</font> +00462 <font class="comment"> deflateInit or deflateInit2, a part of the dictionary may in effect be</font> +00463 <font class="comment"> discarded, for example if the dictionary is larger than the window size in</font> +00464 <font class="comment"> deflate or deflate2. Thus the strings most likely to be useful should be</font> +00465 <font class="comment"> put at the end of the dictionary, not at the front.</font> +00466 <font class="comment"></font> +00467 <font class="comment"> Upon return of this function, strm->adler is set to the Adler32 value</font> +00468 <font class="comment"> of the dictionary; the decompressor may later use this value to determine</font> +00469 <font class="comment"> which dictionary has been used by the compressor. (The Adler32 value</font> +00470 <font class="comment"> applies to the whole dictionary even if only a subset of the dictionary is</font> +00471 <font class="comment"> actually used by the compressor.)</font> +00472 <font class="comment"></font> +00473 <font class="comment"> deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a</font> +00474 <font class="comment"> parameter is invalid (such as NULL dictionary) or the stream state is</font> +00475 <font class="comment"> inconsistent (for example if deflate has already been called for this stream</font> +00476 <font class="comment"> or if the compression method is bsort). deflateSetDictionary does not</font> +00477 <font class="comment"> perform any compression: this will be done by deflate().</font> +00478 <font class="comment">*/</font> +00479 +00480 ZEXTERN <font class="keywordtype">int</font> ZEXPORT deflateCopy OF((z_streamp dest, +00481 z_streamp source)); +00482 <font class="comment">/*</font> +00483 <font class="comment"> Sets the destination stream as a complete copy of the source stream.</font> +00484 <font class="comment"></font> +00485 <font class="comment"> This function can be useful when several compression strategies will be</font> +00486 <font class="comment"> tried, for example when there are several ways of pre-processing the input</font> +00487 <font class="comment"> data with a filter. The streams that will be discarded should then be freed</font> +00488 <font class="comment"> by calling deflateEnd. Note that deflateCopy duplicates the internal</font> +00489 <font class="comment"> compression state which can be quite large, so this strategy is slow and</font> +00490 <font class="comment"> can consume lots of memory.</font> +00491 <font class="comment"></font> +00492 <font class="comment"> deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not</font> +00493 <font class="comment"> enough memory, Z_STREAM_ERROR if the source stream state was inconsistent</font> +00494 <font class="comment"> (such as zalloc being NULL). msg is left unchanged in both source and</font> +00495 <font class="comment"> destination.</font> +00496 <font class="comment">*/</font> +00497 +00498 ZEXTERN <font class="keywordtype">int</font> ZEXPORT deflateReset OF((z_streamp strm)); +00499 <font class="comment">/*</font> +00500 <font class="comment"> This function is equivalent to deflateEnd followed by deflateInit,</font> +00501 <font class="comment"> but does not free and reallocate all the internal compression state.</font> +00502 <font class="comment"> The stream will keep the same compression level and any other attributes</font> +00503 <font class="comment"> that may have been set by deflateInit2.</font> +00504 <font class="comment"></font> +00505 <font class="comment"> deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source</font> +00506 <font class="comment"> stream state was inconsistent (such as zalloc or state being NULL).</font> +00507 <font class="comment">*/</font> +00508 +00509 ZEXTERN <font class="keywordtype">int</font> ZEXPORT deflateParams OF((z_streamp strm, +00510 <font class="keywordtype">int</font> level, +00511 <font class="keywordtype">int</font> strategy)); +00512 <font class="comment">/*</font> +00513 <font class="comment"> Dynamically update the compression level and compression strategy. The</font> +00514 <font class="comment"> interpretation of level and strategy is as in deflateInit2. This can be</font> +00515 <font class="comment"> used to switch between compression and straight copy of the input data, or</font> +00516 <font class="comment"> to switch to a different kind of input data requiring a different</font> +00517 <font class="comment"> strategy. If the compression level is changed, the input available so far</font> +00518 <font class="comment"> is compressed with the old level (and may be flushed); the new level will</font> +00519 <font class="comment"> take effect only at the next call of deflate().</font> +00520 <font class="comment"></font> +00521 <font class="comment"> Before the call of deflateParams, the stream state must be set as for</font> +00522 <font class="comment"> a call of deflate(), since the currently available input may have to</font> +00523 <font class="comment"> be compressed and flushed. In particular, strm->avail_out must be non-zero.</font> +00524 <font class="comment"></font> +00525 <font class="comment"> deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source</font> +00526 <font class="comment"> stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR</font> +00527 <font class="comment"> if strm->avail_out was zero.</font> +00528 <font class="comment">*/</font> +00529 +00530 <font class="comment">/* </font> +00531 <font class="comment">ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm,</font> +00532 <font class="comment"> int windowBits));</font> +00533 <font class="comment"></font> +00534 <font class="comment"> This is another version of inflateInit with an extra parameter. The</font> +00535 <font class="comment"> fields next_in, avail_in, zalloc, zfree and opaque must be initialized</font> +00536 <font class="comment"> before by the caller.</font> +00537 <font class="comment"></font> +00538 <font class="comment"> The windowBits parameter is the base two logarithm of the maximum window</font> +00539 <font class="comment"> size (the size of the history buffer). It should be in the range 8..15 for</font> +00540 <font class="comment"> this version of the library. The default value is 15 if inflateInit is used</font> +00541 <font class="comment"> instead. If a compressed stream with a larger window size is given as</font> +00542 <font class="comment"> input, inflate() will return with the error code Z_DATA_ERROR instead of</font> +00543 <font class="comment"> trying to allocate a larger window.</font> +00544 <font class="comment"></font> +00545 <font class="comment"> inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough</font> +00546 <font class="comment"> memory, Z_STREAM_ERROR if a parameter is invalid (such as a negative</font> +00547 <font class="comment"> memLevel). msg is set to null if there is no error message. inflateInit2</font> +00548 <font class="comment"> does not perform any decompression apart from reading the zlib header if</font> +00549 <font class="comment"> present: this will be done by inflate(). (So next_in and avail_in may be</font> +00550 <font class="comment"> modified, but next_out and avail_out are unchanged.)</font> +00551 <font class="comment">*/</font> +00552 +00553 ZEXTERN <font class="keywordtype">int</font> ZEXPORT inflateSetDictionary OF((z_streamp strm, +00554 <font class="keyword">const</font> Bytef *dictionary, +00555 uInt dictLength)); +00556 <font class="comment">/*</font> +00557 <font class="comment"> Initializes the decompression dictionary from the given uncompressed byte</font> +00558 <font class="comment"> sequence. This function must be called immediately after a call of inflate</font> +00559 <font class="comment"> if this call returned Z_NEED_DICT. The dictionary chosen by the compressor</font> +00560 <font class="comment"> can be determined from the Adler32 value returned by this call of</font> +00561 <font class="comment"> inflate. The compressor and decompressor must use exactly the same</font> +00562 <font class="comment"> dictionary (see deflateSetDictionary).</font> +00563 <font class="comment"></font> +00564 <font class="comment"> inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a</font> +00565 <font class="comment"> parameter is invalid (such as NULL dictionary) or the stream state is</font> +00566 <font class="comment"> inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the</font> +00567 <font class="comment"> expected one (incorrect Adler32 value). inflateSetDictionary does not</font> +00568 <font class="comment"> perform any decompression: this will be done by subsequent calls of</font> +00569 <font class="comment"> inflate().</font> +00570 <font class="comment">*/</font> +00571 +00572 ZEXTERN <font class="keywordtype">int</font> ZEXPORT inflateSync OF((z_streamp strm)); +00573 <font class="comment">/* </font> +00574 <font class="comment"> Skips invalid compressed data until a full flush point (see above the</font> +00575 <font class="comment"> description of deflate with Z_FULL_FLUSH) can be found, or until all</font> +00576 <font class="comment"> available input is skipped. No output is provided.</font> +00577 <font class="comment"></font> +00578 <font class="comment"> inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR</font> +00579 <font class="comment"> if no more input was provided, Z_DATA_ERROR if no flush point has been found,</font> +00580 <font class="comment"> or Z_STREAM_ERROR if the stream structure was inconsistent. In the success</font> +00581 <font class="comment"> case, the application may save the current current value of total_in which</font> +00582 <font class="comment"> indicates where valid compressed data was found. In the error case, the</font> +00583 <font class="comment"> application may repeatedly call inflateSync, providing more input each time,</font> +00584 <font class="comment"> until success or end of the input data.</font> +00585 <font class="comment">*/</font> +00586 +00587 ZEXTERN <font class="keywordtype">int</font> ZEXPORT inflateReset OF((z_streamp strm)); +00588 <font class="comment">/*</font> +00589 <font class="comment"> This function is equivalent to inflateEnd followed by inflateInit,</font> +00590 <font class="comment"> but does not free and reallocate all the internal decompression state.</font> +00591 <font class="comment"> The stream will keep attributes that may have been set by inflateInit2.</font> +00592 <font class="comment"></font> +00593 <font class="comment"> inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source</font> +00594 <font class="comment"> stream state was inconsistent (such as zalloc or state being NULL).</font> +00595 <font class="comment">*/</font> +00596 +00597 +00598 <font class="comment">/* utility functions */</font> +00599 +00600 <font class="comment">/*</font> +00601 <font class="comment"> The following utility functions are implemented on top of the</font> +00602 <font class="comment"> basic stream-oriented functions. To simplify the interface, some</font> +00603 <font class="comment"> default options are assumed (compression level and memory usage,</font> +00604 <font class="comment"> standard memory allocation functions). The source code of these</font> +00605 <font class="comment"> utility functions can easily be modified if you need special options.</font> +00606 <font class="comment">*/</font> +00607 +00608 ZEXTERN <font class="keywordtype">int</font> ZEXPORT compress OF((Bytef *dest, uLongf *destLen, +00609 <font class="keyword">const</font> Bytef *source, uLong sourceLen)); +00610 <font class="comment">/*</font> +00611 <font class="comment"> Compresses the source buffer into the destination buffer. sourceLen is</font> +00612 <font class="comment"> the byte length of the source buffer. Upon entry, destLen is the total</font> +00613 <font class="comment"> size of the destination buffer, which must be at least 0.1% larger than</font> +00614 <font class="comment"> sourceLen plus 12 bytes. Upon exit, destLen is the actual size of the</font> +00615 <font class="comment"> compressed buffer.</font> +00616 <font class="comment"> This function can be used to compress a whole file at once if the</font> +00617 <font class="comment"> input file is mmap'ed.</font> +00618 <font class="comment"> compress returns Z_OK if success, Z_MEM_ERROR if there was not</font> +00619 <font class="comment"> enough memory, Z_BUF_ERROR if there was not enough room in the output</font> +00620 <font class="comment"> buffer.</font> +00621 <font class="comment">*/</font> +00622 +00623 ZEXTERN <font class="keywordtype">int</font> ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen, +00624 <font class="keyword">const</font> Bytef *source, uLong sourceLen, +00625 <font class="keywordtype">int</font> level)); +00626 <font class="comment">/*</font> +00627 <font class="comment"> Compresses the source buffer into the destination buffer. The level</font> +00628 <font class="comment"> parameter has the same meaning as in deflateInit. sourceLen is the byte</font> +00629 <font class="comment"> length of the source buffer. Upon entry, destLen is the total size of the</font> +00630 <font class="comment"> destination buffer, which must be at least 0.1% larger than sourceLen plus</font> +00631 <font class="comment"> 12 bytes. Upon exit, destLen is the actual size of the compressed buffer.</font> +00632 <font class="comment"></font> +00633 <font class="comment"> compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough</font> +00634 <font class="comment"> memory, Z_BUF_ERROR if there was not enough room in the output buffer,</font> +00635 <font class="comment"> Z_STREAM_ERROR if the level parameter is invalid.</font> +00636 <font class="comment">*/</font> +00637 +00638 ZEXTERN <font class="keywordtype">int</font> ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, +00639 <font class="keyword">const</font> Bytef *source, uLong sourceLen)); +00640 <font class="comment">/*</font> +00641 <font class="comment"> Decompresses the source buffer into the destination buffer. sourceLen is</font> +00642 <font class="comment"> the byte length of the source buffer. Upon entry, destLen is the total</font> +00643 <font class="comment"> size of the destination buffer, which must be large enough to hold the</font> +00644 <font class="comment"> entire uncompressed data. (The size of the uncompressed data must have</font> +00645 <font class="comment"> been saved previously by the compressor and transmitted to the decompressor</font> +00646 <font class="comment"> by some mechanism outside the scope of this compression library.)</font> +00647 <font class="comment"> Upon exit, destLen is the actual size of the compressed buffer.</font> +00648 <font class="comment"> This function can be used to decompress a whole file at once if the</font> +00649 <font class="comment"> input file is mmap'ed.</font> +00650 <font class="comment"></font> +00651 <font class="comment"> uncompress returns Z_OK if success, Z_MEM_ERROR if there was not</font> +00652 <font class="comment"> enough memory, Z_BUF_ERROR if there was not enough room in the output</font> +00653 <font class="comment"> buffer, or Z_DATA_ERROR if the input data was corrupted.</font> +00654 <font class="comment">*/</font> +00655 +00656 +00657 <font class="keyword">typedef</font> voidp gzFile; +00658 +00659 ZEXTERN gzFile ZEXPORT gzopen OF((<font class="keyword">const</font> <font class="keywordtype">char</font> *path, <font class="keyword">const</font> <font class="keywordtype">char</font> *mode)); +00660 <font class="comment">/*</font> +00661 <font class="comment"> Opens a gzip (.gz) file for reading or writing. The mode parameter</font> +00662 <font class="comment"> is as in fopen ("rb" or "wb") but can also include a compression level</font> +00663 <font class="comment"> ("wb9") or a strategy: 'f' for filtered data as in "wb6f", 'h' for</font> +00664 <font class="comment"> Huffman only compression as in "wb1h". (See the description</font> +00665 <font class="comment"> of deflateInit2 for more information about the strategy parameter.)</font> +00666 <font class="comment"></font> +00667 <font class="comment"> gzopen can be used to read a file which is not in gzip format; in this</font> +00668 <font class="comment"> case gzread will directly read from the file without decompression.</font> +00669 <font class="comment"></font> +00670 <font class="comment"> gzopen returns NULL if the file could not be opened or if there was</font> +00671 <font class="comment"> insufficient memory to allocate the (de)compression state; errno</font> +00672 <font class="comment"> can be checked to distinguish the two cases (if errno is zero, the</font> +00673 <font class="comment"> zlib error is Z_MEM_ERROR). */</font> +00674 +00675 ZEXTERN gzFile ZEXPORT gzdopen OF((<font class="keywordtype">int</font> fd, <font class="keyword">const</font> <font class="keywordtype">char</font> *mode)); +00676 <font class="comment">/*</font> +00677 <font class="comment"> gzdopen() associates a gzFile with the file descriptor fd. File</font> +00678 <font class="comment"> descriptors are obtained from calls like open, dup, creat, pipe or</font> +00679 <font class="comment"> fileno (in the file has been previously opened with fopen).</font> +00680 <font class="comment"> The mode parameter is as in gzopen.</font> +00681 <font class="comment"> The next call of gzclose on the returned gzFile will also close the</font> +00682 <font class="comment"> file descriptor fd, just like fclose(fdopen(fd), mode) closes the file</font> +00683 <font class="comment"> descriptor fd. If you want to keep fd open, use gzdopen(dup(fd), mode).</font> +00684 <font class="comment"> gzdopen returns NULL if there was insufficient memory to allocate</font> +00685 <font class="comment"> the (de)compression state.</font> +00686 <font class="comment">*/</font> +00687 +00688 ZEXTERN <font class="keywordtype">int</font> ZEXPORT gzsetparams OF((gzFile file, <font class="keywordtype">int</font> level, <font class="keywordtype">int</font> strategy)); +00689 <font class="comment">/*</font> +00690 <font class="comment"> Dynamically update the compression level or strategy. See the description</font> +00691 <font class="comment"> of deflateInit2 for the meaning of these parameters.</font> +00692 <font class="comment"> gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not</font> +00693 <font class="comment"> opened for writing.</font> +00694 <font class="comment">*/</font> +00695 +00696 ZEXTERN <font class="keywordtype">int</font> ZEXPORT gzread OF((gzFile file, voidp buf, <font class="keywordtype">unsigned</font> len)); +00697 <font class="comment">/*</font> +00698 <font class="comment"> Reads the given number of uncompressed bytes from the compressed file.</font> +00699 <font class="comment"> If the input file was not in gzip format, gzread copies the given number</font> +00700 <font class="comment"> of bytes into the buffer.</font> +00701 <font class="comment"> gzread returns the number of uncompressed bytes actually read (0 for</font> +00702 <font class="comment"> end of file, -1 for error). */</font> +00703 +00704 ZEXTERN <font class="keywordtype">int</font> ZEXPORT gzwrite OF((gzFile file, +00705 <font class="keyword">const</font> voidp buf, <font class="keywordtype">unsigned</font> len)); +00706 <font class="comment">/*</font> +00707 <font class="comment"> Writes the given number of uncompressed bytes into the compressed file.</font> +00708 <font class="comment"> gzwrite returns the number of uncompressed bytes actually written</font> +00709 <font class="comment"> (0 in case of error).</font> +00710 <font class="comment">*/</font> +00711 +00712 ZEXTERN <font class="keywordtype">int</font> ZEXPORTVA gzprintf OF((gzFile file, <font class="keyword">const</font> <font class="keywordtype">char</font> *format, ...)); +00713 <font class="comment">/*</font> +00714 <font class="comment"> Converts, formats, and writes the args to the compressed file under</font> +00715 <font class="comment"> control of the format string, as in fprintf. gzprintf returns the number of</font> +00716 <font class="comment"> uncompressed bytes actually written (0 in case of error).</font> +00717 <font class="comment">*/</font> +00718 +00719 ZEXTERN <font class="keywordtype">int</font> ZEXPORT gzputs OF((gzFile file, <font class="keyword">const</font> <font class="keywordtype">char</font> *s)); +00720 <font class="comment">/*</font> +00721 <font class="comment"> Writes the given null-terminated string to the compressed file, excluding</font> +00722 <font class="comment"> the terminating null character.</font> +00723 <font class="comment"> gzputs returns the number of characters written, or -1 in case of error.</font> +00724 <font class="comment">*/</font> +00725 +00726 ZEXTERN <font class="keywordtype">char</font> * ZEXPORT gzgets OF((gzFile file, <font class="keywordtype">char</font> *buf, <font class="keywordtype">int</font> len)); +00727 <font class="comment">/*</font> +00728 <font class="comment"> Reads bytes from the compressed file until len-1 characters are read, or</font> +00729 <font class="comment"> a newline character is read and transferred to buf, or an end-of-file</font> +00730 <font class="comment"> condition is encountered. The string is then terminated with a null</font> +00731 <font class="comment"> character.</font> +00732 <font class="comment"> gzgets returns buf, or Z_NULL in case of error.</font> +00733 <font class="comment">*/</font> +00734 +00735 ZEXTERN <font class="keywordtype">int</font> ZEXPORT gzputc OF((gzFile file, <font class="keywordtype">int</font> c)); +00736 <font class="comment">/*</font> +00737 <font class="comment"> Writes c, converted to an unsigned char, into the compressed file.</font> +00738 <font class="comment"> gzputc returns the value that was written, or -1 in case of error.</font> +00739 <font class="comment">*/</font> +00740 +00741 ZEXTERN <font class="keywordtype">int</font> ZEXPORT gzgetc OF((gzFile file)); +00742 <font class="comment">/*</font> +00743 <font class="comment"> Reads one byte from the compressed file. gzgetc returns this byte</font> +00744 <font class="comment"> or -1 in case of end of file or error.</font> +00745 <font class="comment">*/</font> +00746 +00747 ZEXTERN <font class="keywordtype">int</font> ZEXPORT gzflush OF((gzFile file, <font class="keywordtype">int</font> flush)); +00748 <font class="comment">/*</font> +00749 <font class="comment"> Flushes all pending output into the compressed file. The parameter</font> +00750 <font class="comment"> flush is as in the deflate() function. The return value is the zlib</font> +00751 <font class="comment"> error number (see function gzerror below). gzflush returns Z_OK if</font> +00752 <font class="comment"> the flush parameter is Z_FINISH and all output could be flushed.</font> +00753 <font class="comment"> gzflush should be called only when strictly necessary because it can</font> +00754 <font class="comment"> degrade compression.</font> +00755 <font class="comment">*/</font> +00756 +00757 ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file, +00758 z_off_t offset, <font class="keywordtype">int</font> whence)); +00759 <font class="comment">/* </font> +00760 <font class="comment"> Sets the starting position for the next gzread or gzwrite on the</font> +00761 <font class="comment"> given compressed file. The offset represents a number of bytes in the</font> +00762 <font class="comment"> uncompressed data stream. The whence parameter is defined as in lseek(2);</font> +00763 <font class="comment"> the value SEEK_END is not supported.</font> +00764 <font class="comment"> If the file is opened for reading, this function is emulated but can be</font> +00765 <font class="comment"> extremely slow. If the file is opened for writing, only forward seeks are</font> +00766 <font class="comment"> supported; gzseek then compresses a sequence of zeroes up to the new</font> +00767 <font class="comment"> starting position.</font> +00768 <font class="comment"></font> +00769 <font class="comment"> gzseek returns the resulting offset location as measured in bytes from</font> +00770 <font class="comment"> the beginning of the uncompressed stream, or -1 in case of error, in</font> +00771 <font class="comment"> particular if the file is opened for writing and the new starting position</font> +00772 <font class="comment"> would be before the current position.</font> +00773 <font class="comment">*/</font> +00774 +00775 ZEXTERN <font class="keywordtype">int</font> ZEXPORT gzrewind OF((gzFile file)); +00776 <font class="comment">/*</font> +00777 <font class="comment"> Rewinds the given file. This function is supported only for reading.</font> +00778 <font class="comment"></font> +00779 <font class="comment"> gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET)</font> +00780 <font class="comment">*/</font> +00781 +00782 ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file)); +00783 <font class="comment">/*</font> +00784 <font class="comment"> Returns the starting position for the next gzread or gzwrite on the</font> +00785 <font class="comment"> given compressed file. This position represents a number of bytes in the</font> +00786 <font class="comment"> uncompressed data stream.</font> +00787 <font class="comment"></font> +00788 <font class="comment"> gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR)</font> +00789 <font class="comment">*/</font> +00790 +00791 ZEXTERN <font class="keywordtype">int</font> ZEXPORT gzeof OF((gzFile file)); +00792 <font class="comment">/*</font> +00793 <font class="comment"> Returns 1 when EOF has previously been detected reading the given</font> +00794 <font class="comment"> input stream, otherwise zero.</font> +00795 <font class="comment">*/</font> +00796 +00797 ZEXTERN <font class="keywordtype">int</font> ZEXPORT gzclose OF((gzFile file)); +00798 <font class="comment">/*</font> +00799 <font class="comment"> Flushes all pending output if necessary, closes the compressed file</font> +00800 <font class="comment"> and deallocates all the (de)compression state. The return value is the zlib</font> +00801 <font class="comment"> error number (see function gzerror below).</font> +00802 <font class="comment">*/</font> +00803 +00804 ZEXTERN <font class="keyword">const</font> <font class="keywordtype">char</font> * ZEXPORT gzerror OF((gzFile file, <font class="keywordtype">int</font> *errnum)); +00805 <font class="comment">/*</font> +00806 <font class="comment"> Returns the error message for the last error which occurred on the</font> +00807 <font class="comment"> given compressed file. errnum is set to zlib error number. If an</font> +00808 <font class="comment"> error occurred in the file system and not in the compression library,</font> +00809 <font class="comment"> errnum is set to Z_ERRNO and the application may consult errno</font> +00810 <font class="comment"> to get the exact error code.</font> +00811 <font class="comment">*/</font> +00812 +00813 <font class="comment">/* checksum functions */</font> +00814 +00815 <font class="comment">/*</font> +00816 <font class="comment"> These functions are not related to compression but are exported</font> +00817 <font class="comment"> anyway because they might be useful in applications using the</font> +00818 <font class="comment"> compression library.</font> +00819 <font class="comment">*/</font> +00820 +00821 ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, <font class="keyword">const</font> Bytef *buf, uInt len)); +00822 +00823 <font class="comment">/*</font> +00824 <font class="comment"> Update a running Adler-32 checksum with the bytes buf[0..len-1] and</font> +00825 <font class="comment"> return the updated checksum. If buf is NULL, this function returns</font> +00826 <font class="comment"> the required initial value for the checksum.</font> +00827 <font class="comment"> An Adler-32 checksum is almost as reliable as a CRC32 but can be computed</font> +00828 <font class="comment"> much faster. Usage example:</font> +00829 <font class="comment"></font> +00830 <font class="comment"> uLong adler = adler32(0L, Z_NULL, 0);</font> +00831 <font class="comment"></font> +00832 <font class="comment"> while (read_buffer(buffer, length) != EOF) {</font> +00833 <font class="comment"> adler = adler32(adler, buffer, length);</font> +00834 <font class="comment"> }</font> +00835 <font class="comment"> if (adler != original_adler) error();</font> +00836 <font class="comment">*/</font> +00837 +00838 ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, <font class="keyword">const</font> Bytef *buf, uInt len)); +00839 <font class="comment">/*</font> +00840 <font class="comment"> Update a running crc with the bytes buf[0..len-1] and return the updated</font> +00841 <font class="comment"> crc. If buf is NULL, this function returns the required initial value</font> +00842 <font class="comment"> for the crc. Pre- and post-conditioning (one's complement) is performed</font> +00843 <font class="comment"> within this function so it shouldn't be done by the application.</font> +00844 <font class="comment"> Usage example:</font> +00845 <font class="comment"></font> +00846 <font class="comment"> uLong crc = crc32(0L, Z_NULL, 0);</font> +00847 <font class="comment"></font> +00848 <font class="comment"> while (read_buffer(buffer, length) != EOF) {</font> +00849 <font class="comment"> crc = crc32(crc, buffer, length);</font> +00850 <font class="comment"> }</font> +00851 <font class="comment"> if (crc != original_crc) error();</font> +00852 <font class="comment">*/</font> +00853 +00854 +00855 <font class="comment">/* various hacks, don't look :) */</font> +00856 +00857 <font class="comment">/* deflateInit and inflateInit are macros to allow checking the zlib version</font> +00858 <font class="comment"> * and the compiler's view of z_stream:</font> +00859 <font class="comment"> */</font> +00860 ZEXTERN <font class="keywordtype">int</font> ZEXPORT deflateInit_ OF((z_streamp strm, <font class="keywordtype">int</font> level, +00861 <font class="keyword">const</font> <font class="keywordtype">char</font> *version, <font class="keywordtype">int</font> stream_size)); +00862 ZEXTERN <font class="keywordtype">int</font> ZEXPORT inflateInit_ OF((z_streamp strm, +00863 <font class="keyword">const</font> <font class="keywordtype">char</font> *version, <font class="keywordtype">int</font> stream_size)); +00864 ZEXTERN <font class="keywordtype">int</font> ZEXPORT deflateInit2_ OF((z_streamp strm, <font class="keywordtype">int</font> level, <font class="keywordtype">int</font> method, +00865 <font class="keywordtype">int</font> windowBits, <font class="keywordtype">int</font> memLevel, +00866 <font class="keywordtype">int</font> strategy, <font class="keyword">const</font> <font class="keywordtype">char</font> *version, +00867 <font class="keywordtype">int</font> stream_size)); +00868 ZEXTERN <font class="keywordtype">int</font> ZEXPORT inflateInit2_ OF((z_streamp strm, <font class="keywordtype">int</font> windowBits, +00869 <font class="keyword">const</font> <font class="keywordtype">char</font> *version, <font class="keywordtype">int</font> stream_size)); +00870 <font class="preprocessor">#define deflateInit(strm, level) \</font> +00871 <font class="preprocessor"> deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream))</font> +00872 <font class="preprocessor"></font><font class="preprocessor">#define inflateInit(strm) \</font> +00873 <font class="preprocessor"> inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream))</font> +00874 <font class="preprocessor"></font><font class="preprocessor">#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \</font> +00875 <font class="preprocessor"> deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\</font> +00876 <font class="preprocessor"> (strategy), ZLIB_VERSION, sizeof(z_stream))</font> +00877 <font class="preprocessor"></font><font class="preprocessor">#define inflateInit2(strm, windowBits) \</font> +00878 <font class="preprocessor"> inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream))</font> +00879 <font class="preprocessor"></font> +00880 +00881 <font class="preprocessor">#if !defined(_Z_UTIL_H) && !defined(NO_DUMMY_DECL)</font> +00882 <font class="preprocessor"></font> <font class="keyword">struct </font>internal_state {<font class="keywordtype">int</font> dummy;}; <font class="comment">/* hack for buggy compilers */</font> +00883 <font class="preprocessor">#endif</font> +00884 <font class="preprocessor"></font> +00885 ZEXTERN <font class="keyword">const</font> <font class="keywordtype">char</font> * ZEXPORT zError OF((<font class="keywordtype">int</font> err)); +00886 ZEXTERN <font class="keywordtype">int</font> ZEXPORT inflateSyncPoint OF((z_streamp z)); +00887 ZEXTERN <font class="keyword">const</font> uLongf * ZEXPORT get_crc_table OF((<font class="keywordtype">void</font>)); +00888 +00889 <font class="preprocessor">#ifdef __cplusplus</font> +00890 <font class="preprocessor"></font>} +00891 <font class="preprocessor">#endif</font> +00892 <font class="preprocessor"></font> +00893 <font class="preprocessor">#endif </font><font class="comment">/* _ZLIB_H */</font> +</pre></div><hr><address align="right"><small>Generated on Thu Jun 20 22:13:01 2002 for The Sword Project by +<a href="http://www.doxygen.org/index.html"> +<img src="doxygen.png" alt="doxygen" align="middle" border=0 +width=110 height=53></a>1.2.15 </small></address> +</body> +</html> |