<ahref="zlib_8h.html">Go to the documentation of this file.</a><divclass="fragment"><divclass="line"><aname="l00001"></a><spanclass="lineno"> 1</span> <spanclass="comment">/* zlib.h -- interface of the 'zlib' general purpose compression library</span></div>
<divclass="line"><aname="l00002"></a><spanclass="lineno"> 2</span> <spanclass="comment"> version 1.2.5, April 19th, 2010</span></div>
<divclass="line"><aname="l00004"></a><spanclass="lineno"> 4</span> <spanclass="comment"> Copyright (C) 1995-2010 Jean-loup Gailly and Mark Adler</span></div>
<divclass="line"><aname="l00006"></a><spanclass="lineno"> 6</span> <spanclass="comment"> This software is provided 'as-is', without any express or implied</span></div>
<divclass="line"><aname="l00007"></a><spanclass="lineno"> 7</span> <spanclass="comment"> warranty. In no event will the authors be held liable for any damages</span></div>
<divclass="line"><aname="l00008"></a><spanclass="lineno"> 8</span> <spanclass="comment"> arising from the use of this software.</span></div>
<divclass="line"><aname="l00010"></a><spanclass="lineno"> 10</span> <spanclass="comment"> Permission is granted to anyone to use this software for any purpose,</span></div>
<divclass="line"><aname="l00011"></a><spanclass="lineno"> 11</span> <spanclass="comment"> including commercial applications, and to alter it and redistribute it</span></div>
<divclass="line"><aname="l00012"></a><spanclass="lineno"> 12</span> <spanclass="comment"> freely, subject to the following restrictions:</span></div>
<divclass="line"><aname="l00014"></a><spanclass="lineno"> 14</span> <spanclass="comment"> 1. The origin of this software must not be misrepresented; you must not</span></div>
<divclass="line"><aname="l00015"></a><spanclass="lineno"> 15</span> <spanclass="comment"> claim that you wrote the original software. If you use this software</span></div>
<divclass="line"><aname="l00016"></a><spanclass="lineno"> 16</span> <spanclass="comment"> in a product, an acknowledgment in the product documentation would be</span></div>
<divclass="line"><aname="l00017"></a><spanclass="lineno"> 17</span> <spanclass="comment"> appreciated but is not required.</span></div>
<divclass="line"><aname="l00018"></a><spanclass="lineno"> 18</span> <spanclass="comment"> 2. Altered source versions must be plainly marked as such, and must not be</span></div>
<divclass="line"><aname="l00019"></a><spanclass="lineno"> 19</span> <spanclass="comment"> misrepresented as being the original software.</span></div>
<divclass="line"><aname="l00020"></a><spanclass="lineno"> 20</span> <spanclass="comment"> 3. This notice may not be removed or altered from any source distribution.</span></div>
<divclass="line"><aname="l00026"></a><spanclass="lineno"> 26</span> <spanclass="comment"> The data format used by the zlib library is described by RFCs (Request for</span></div>
<divclass="line"><aname="l00027"></a><spanclass="lineno"> 27</span> <spanclass="comment"> Comments) 1950 to 1952 in the files http://www.ietf.org/rfc/rfc1950.txt</span></div>
<divclass="line"><aname="l00048"></a><spanclass="lineno"> 48</span> <spanclass="comment"> The 'zlib' compression library provides in-memory compression and</span></div>
<divclass="line"><aname="l00049"></a><spanclass="lineno"> 49</span> <spanclass="comment"> decompression functions, including integrity checks of the uncompressed data.</span></div>
<divclass="line"><aname="l00050"></a><spanclass="lineno"> 50</span> <spanclass="comment"> This version of the library supports only one compression method (deflation)</span></div>
<divclass="line"><aname="l00051"></a><spanclass="lineno"> 51</span> <spanclass="comment"> but other algorithms will be added later and will have the same stream</span></div>
<divclass="line"><aname="l00054"></a><spanclass="lineno"> 54</span> <spanclass="comment"> Compression can be done in a single step if the buffers are large enough,</span></div>
<divclass="line"><aname="l00055"></a><spanclass="lineno"> 55</span> <spanclass="comment"> or can be done by repeated calls of the compression function. In the latter</span></div>
<divclass="line"><aname="l00056"></a><spanclass="lineno"> 56</span> <spanclass="comment"> case, the application must provide more input and/or consume the output</span></div>
<divclass="line"><aname="l00057"></a><spanclass="lineno"> 57</span> <spanclass="comment"> (providing more output space) before each call.</span></div>
<divclass="line"><aname="l00059"></a><spanclass="lineno"> 59</span> <spanclass="comment"> The compressed data format used by default by the in-memory functions is</span></div>
<divclass="line"><aname="l00060"></a><spanclass="lineno"> 60</span> <spanclass="comment"> the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped</span></div>
<divclass="line"><aname="l00061"></a><spanclass="lineno"> 61</span> <spanclass="comment"> around a deflate stream, which is itself documented in RFC 1951.</span></div>
<divclass="line"><aname="l00063"></a><spanclass="lineno"> 63</span> <spanclass="comment"> The library also supports reading and writing files in gzip (.gz) format</span></div>
<divclass="line"><aname="l00064"></a><spanclass="lineno"> 64</span> <spanclass="comment"> with an interface similar to that of stdio using the functions that start</span></div>
<divclass="line"><aname="l00065"></a><spanclass="lineno"> 65</span> <spanclass="comment"> with "gz". The gzip format is different from the zlib format. gzip is a</span></div>
<divclass="line"><aname="l00066"></a><spanclass="lineno"> 66</span> <spanclass="comment"> gzip wrapper, documented in RFC 1952, wrapped around a deflate stream.</span></div>
<divclass="line"><aname="l00068"></a><spanclass="lineno"> 68</span> <spanclass="comment"> This library can optionally read and write gzip streams in memory as well.</span></div>
<divclass="line"><aname="l00070"></a><spanclass="lineno"> 70</span> <spanclass="comment"> The zlib format was designed to be compact and fast for use in memory</span></div>
<divclass="line"><aname="l00071"></a><spanclass="lineno"> 71</span> <spanclass="comment"> and on communications channels. The gzip format was designed for single-</span></div>
<divclass="line"><aname="l00072"></a><spanclass="lineno"> 72</span> <spanclass="comment"> file compression on file systems, has a larger header than zlib to maintain</span></div>
<divclass="line"><aname="l00073"></a><spanclass="lineno"> 73</span> <spanclass="comment"> directory information, and uses a different, slower check method than zlib.</span></div>
<divclass="line"><aname="l00075"></a><spanclass="lineno"> 75</span> <spanclass="comment"> The library does not install any signal handler. The decoder checks</span></div>
<divclass="line"><aname="l00076"></a><spanclass="lineno"> 76</span> <spanclass="comment"> the consistency of the compressed data, so the library should never crash</span></div>
<divclass="line"><aname="l00077"></a><spanclass="lineno"> 77</span> <spanclass="comment"> even in case of corrupted input.</span></div>
<divclass="line"><aname="l00086"></a><spanclass="lineno"><aclass="line"href="zlib_8h.html#a19880e07a77d10515147e23b6379dd49"> 86</a></span> <aclass="code"href="zconf_8h.html#aeb722a888064be47e12d05f692e0f407">Bytef</a> *<aclass="code"href="zlib_8h.html#a19880e07a77d10515147e23b6379dd49">next_in</a>; <spanclass="comment">/* next input byte */</span></div>
<divclass="line"><aname="l00087"></a><spanclass="lineno"><aclass="line"href="zlib_8h.html#a7eb50ccbfeb2368dd84c3a97f409692a"> 87</a></span> <aclass="code"href="zconf_8h.html#a87d141052bcd5ec8a80812a565c70369">uInt</a><aclass="code"href="zlib_8h.html#a7eb50ccbfeb2368dd84c3a97f409692a">avail_in</a>; <spanclass="comment">/* number of bytes available at next_in */</span></div>
<divclass="line"><aname="l00088"></a><spanclass="lineno"><aclass="line"href="zlib_8h.html#aa301948b62e927cb5b34c7fa48b369e7"> 88</a></span> <aclass="code"href="zconf_8h.html#acd2a5701a3aecf6700d2c66c606ecb40">uLong</a><aclass="code"href="zlib_8h.html#aa301948b62e927cb5b34c7fa48b369e7">total_in</a>; <spanclass="comment">/* total nb of input bytes read so far */</span></div>
<divclass="line"><aname="l00090"></a><spanclass="lineno"><aclass="line"href="zlib_8h.html#a6926e8fa9e456364c4a931da1508662e"> 90</a></span> <aclass="code"href="zconf_8h.html#aeb722a888064be47e12d05f692e0f407">Bytef</a> *<aclass="code"href="zlib_8h.html#a6926e8fa9e456364c4a931da1508662e">next_out</a>; <spanclass="comment">/* next output byte should be put there */</span></div>
<divclass="line"><aname="l00091"></a><spanclass="lineno"><aclass="line"href="zlib_8h.html#aaf14708cee6cfc16ac27f3cff686f8d8"> 91</a></span> <aclass="code"href="zconf_8h.html#a87d141052bcd5ec8a80812a565c70369">uInt</a><aclass="code"href="zlib_8h.html#aaf14708cee6cfc16ac27f3cff686f8d8">avail_out</a>; <spanclass="comment">/* remaining free space at next_out */</span></div>
<divclass="line"><aname="l00092"></a><spanclass="lineno"><aclass="line"href="zlib_8h.html#ace45f7b8af1035bc35ee7436fdd41081"> 92</a></span> <aclass="code"href="zconf_8h.html#acd2a5701a3aecf6700d2c66c606ecb40">uLong</a><aclass="code"href="zlib_8h.html#ace45f7b8af1035bc35ee7436fdd41081">total_out</a>; <spanclass="comment">/* total nb of bytes output so far */</span></div>
<divclass="line"><aname="l00094"></a><spanclass="lineno"><aclass="line"href="zlib_8h.html#a32d2f5216cddb59c7cc8fb2806a7e727"> 94</a></span> <spanclass="keywordtype">char</span> *<aclass="code"href="zlib_8h.html#a32d2f5216cddb59c7cc8fb2806a7e727">msg</a>; <spanclass="comment">/* last error message, NULL if no error */</span></div>
<divclass="line"><aname="l00095"></a><spanclass="lineno"><aclass="line"href="zlib_8h.html#ac21f94cab4411ce1c77771033cff040a"> 95</a></span> <spanclass="keyword">struct </span><aclass="code"href="zlib_8h.html#structinternal__state">internal_state</a><aclass="code"href="zconf_8h.html#aef060b3456fdcc093a7210a762d5f2ed">FAR</a> *<aclass="code"href="zlib_8h.html#ac21f94cab4411ce1c77771033cff040a">state</a>; <spanclass="comment">/* not visible by applications */</span></div>
<divclass="line"><aname="l00097"></a><spanclass="lineno"><aclass="line"href="zlib_8h.html#a0b2f68e949d83a93be0e4d0b88148c80"> 97</a></span>  alloc_func <aclass="code"href="zlib_8h.html#a0b2f68e949d83a93be0e4d0b88148c80">zalloc</a>; <spanclass="comment">/* used to allocate the internal state */</span></div>
<divclass="line"><aname="l00098"></a><spanclass="lineno"><aclass="line"href="zlib_8h.html#a7587bb1e332fc8f57ef74071eeec8070"> 98</a></span>  free_func <aclass="code"href="zlib_8h.html#a7587bb1e332fc8f57ef74071eeec8070">zfree</a>; <spanclass="comment">/* used to free the internal state */</span></div>
<divclass="line"><aname="l00099"></a><spanclass="lineno"><aclass="line"href="zlib_8h.html#afb43594753f721206f8751bdc6f311ec"> 99</a></span> <aclass="code"href="zconf_8h.html#a2de3690ae41712f1488ce8b89b07141a">voidpf</a><aclass="code"href="zlib_8h.html#afb43594753f721206f8751bdc6f311ec">opaque</a>; <spanclass="comment">/* private data object passed to zalloc and zfree */</span></div>
<divclass="line"><aname="l00101"></a><spanclass="lineno"><aclass="line"href="zlib_8h.html#a47eb6f1029f8333d4e55b08296f900dd"> 101</a></span> <spanclass="keywordtype">int</span><aclass="code"href="zlib_8h.html#a47eb6f1029f8333d4e55b08296f900dd">data_type</a>; <spanclass="comment">/* best guess about the data type: binary or text */</span></div>
<divclass="line"><aname="l00102"></a><spanclass="lineno"><aclass="line"href="zlib_8h.html#a74bb92610e11a5515a286f04f906d0db"> 102</a></span> <aclass="code"href="zconf_8h.html#acd2a5701a3aecf6700d2c66c606ecb40">uLong</a><aclass="code"href="zlib_8h.html#a74bb92610e11a5515a286f04f906d0db">adler</a>; <spanclass="comment">/* adler32 value of the uncompressed data */</span></div>
<divclass="line"><aname="l00103"></a><spanclass="lineno"><aclass="line"href="zlib_8h.html#ae3bf2150b8009b089ae6878004146180"> 103</a></span> <aclass="code"href="zconf_8h.html#acd2a5701a3aecf6700d2c66c606ecb40">uLong</a><aclass="code"href="zlib_8h.html#ae3bf2150b8009b089ae6878004146180">reserved</a>; <spanclass="comment">/* reserved for future use */</span></div>
<divclass="line"><aname="l00109"></a><spanclass="lineno"> 109</span> <spanclass="comment"> gzip header information passed to and from zlib routines. See RFC 1952</span></div>
<divclass="line"><aname="l00110"></a><spanclass="lineno"> 110</span> <spanclass="comment"> for more details on the meanings of these fields.</span></div>
<divclass="line"><aname="l00113"></a><spanclass="lineno"><aclass="line"href="zlib_8h.html#acb727b700580681a32b288d9ebc9b762"> 113</a></span> <spanclass="keywordtype">int</span><aclass="code"href="zlib_8h.html#acb727b700580681a32b288d9ebc9b762">text</a>; <spanclass="comment">/* true if compressed data believed to be text */</span></div>
<divclass="line"><aname="l00114"></a><spanclass="lineno"><aclass="line"href="zlib_8h.html#a4d66380f18f556788b252ca3bb0492a0"> 114</a></span> <aclass="code"href="zconf_8h.html#acd2a5701a3aecf6700d2c66c606ecb40">uLong</a><aclass="code"href="zlib_8h.html#a4d66380f18f556788b252ca3bb0492a0">time</a>; <spanclass="comment">/* modification time */</span></div>
<divclass="line"><aname="l00115"></a><spanclass="lineno"><aclass="line"href="zlib_8h.html#a5890059f779baab7fc72bca5e3900552"> 115</a></span> <spanclass="keywordtype">int</span><aclass="code"href="zlib_8h.html#a5890059f779baab7fc72bca5e3900552">xflags</a>; <spanclass="comment">/* extra flags (not used when writing a gzip file) */</span></div>
<divclass="line"><aname="l00116"></a><spanclass="lineno"><aclass="line"href="zlib_8h.html#a0c98ab56e4779bc5f994fdff60723115"> 116</a></span> <spanclass="keywordtype">int</span><aclass="code"href="zlib_8h.html#a0c98ab56e4779bc5f994fdff60723115">os</a>; <spanclass="comment">/* operating system */</span></div>
<divclass="line"><aname="l00117"></a><spanclass="lineno"><aclass="line"href="zlib_8h.html#a2b260b4b03b66af0a115704504632b68"> 117</a></span> <aclass="code"href="zconf_8h.html#aeb722a888064be47e12d05f692e0f407">Bytef</a> *<aclass="code"href="zlib_8h.html#a2b260b4b03b66af0a115704504632b68">extra</a>; <spanclass="comment">/* pointer to extra field or Z_NULL if none */</span></div>
<divclass="line"><aname="l00118"></a><spanclass="lineno"><aclass="line"href="zlib_8h.html#a5ded8c4f212b31a3ad229496d74f1239"> 118</a></span> <aclass="code"href="zconf_8h.html#a87d141052bcd5ec8a80812a565c70369">uInt</a><aclass="code"href="zlib_8h.html#a5ded8c4f212b31a3ad229496d74f1239">extra_len</a>; <spanclass="comment">/* extra field length (valid if extra != Z_NULL) */</span></div>
<divclass="line"><aname="l00119"></a><spanclass="lineno"><aclass="line"href="zlib_8h.html#a8dcbcbd67c34445b41842b73a6d768f1"> 119</a></span> <aclass="code"href="zconf_8h.html#a87d141052bcd5ec8a80812a565c70369">uInt</a><aclass="code"href="zlib_8h.html#a8dcbcbd67c34445b41842b73a6d768f1">extra_max</a>; <spanclass="comment">/* space at extra (only when reading header) */</span></div>
<divclass="line"><aname="l00120"></a><spanclass="lineno"><aclass="line"href="zlib_8h.html#adbc87684a91f1ff13ca81f2202630b34"> 120</a></span> <aclass="code"href="zconf_8h.html#aeb722a888064be47e12d05f692e0f407">Bytef</a> *<aclass="code"href="zlib_8h.html#adbc87684a91f1ff13ca81f2202630b34">name</a>; <spanclass="comment">/* pointer to zero-terminated file name or Z_NULL */</span></div>
<divclass="line"><aname="l00121"></a><spanclass="lineno"><aclass="line"href="zlib_8h.html#af5b7779d893562b8e759efd582d4fcba"> 121</a></span> <aclass="code"href="zconf_8h.html#a87d141052bcd5ec8a80812a565c70369">uInt</a><aclass="code"href="zlib_8h.html#af5b7779d893562b8e759efd582d4fcba">name_max</a>; <spanclass="comment">/* space at name (only when reading header) */</span></div>
<divclass="line"><aname="l00122"></a><spanclass="lineno"><aclass="line"href="zlib_8h.html#ac4e81bcead752082c53d69e098298de1"> 122</a></span> <aclass="code"href="zconf_8h.html#aeb722a888064be47e12d05f692e0f407">Bytef</a> *<aclass="code"href="zlib_8h.html#ac4e81bcead752082c53d69e098298de1">comment</a>; <spanclass="comment">/* pointer to zero-terminated comment or Z_NULL */</span></div>
<divclass="line"><aname="l00123"></a><spanclass="lineno"><aclass="line"href="zlib_8h.html#a6cec1c0c3a9ac1b3c0a8975e382a2b7f"> 123</a></span> <aclass="code"href="zconf_8h.html#a87d141052bcd5ec8a80812a565c70369">uInt</a><aclass="code"href="zlib_8h.html#a6cec1c0c3a9ac1b3c0a8975e382a2b7f">comm_max</a>; <spanclass="comment">/* space at comment (only when reading header) */</span></div>
<divclass="line"><aname="l00124"></a><spanclass="lineno"><aclass="line"href="zlib_8h.html#ab54066d1aca7e674fbc6d5579cc48894"> 124</a></span> <spanclass="keywordtype">int</span><aclass="code"href="zlib_8h.html#ab54066d1aca7e674fbc6d5579cc48894">hcrc</a>; <spanclass="comment">/* true if there was or will be a header crc */</span></div>
<divclass="line"><aname="l00132"></a><spanclass="lineno"> 132</span> <spanclass="comment"> The application must update next_in and avail_in when avail_in has dropped</span></div>
<divclass="line"><aname="l00133"></a><spanclass="lineno"> 133</span> <spanclass="comment"> to zero. It must update next_out and avail_out when avail_out has dropped</span></div>
<divclass="line"><aname="l00134"></a><spanclass="lineno"> 134</span> <spanclass="comment"> to zero. The application must initialize zalloc, zfree and opaque before</span></div>
<divclass="line"><aname="l00135"></a><spanclass="lineno"> 135</span> <spanclass="comment"> calling the init function. All other fields are set by the compression</span></div>
<divclass="line"><aname="l00136"></a><spanclass="lineno"> 136</span> <spanclass="comment"> library and must not be updated by the application.</span></div>
<divclass="line"><aname="l00138"></a><spanclass="lineno"> 138</span> <spanclass="comment"> The opaque value provided by the application will be passed as the first</span></div>
<divclass="line"><aname="l00139"></a><spanclass="lineno"> 139</span> <spanclass="comment"> parameter for calls of zalloc and zfree. This can be useful for custom</span></div>
<divclass="line"><aname="l00140"></a><spanclass="lineno"> 140</span> <spanclass="comment"> memory management. The compression library attaches no meaning to the</span></div>
<divclass="line"><aname="l00143"></a><spanclass="lineno"> 143</span> <spanclass="comment"> zalloc must return Z_NULL if there is not enough memory for the object.</span></div>
<divclass="line"><aname="l00144"></a><spanclass="lineno"> 144</span> <spanclass="comment"> If zlib is used in a multi-threaded application, zalloc and zfree must be</span></div>
<divclass="line"><aname="l00147"></a><spanclass="lineno"> 147</span> <spanclass="comment"> On 16-bit systems, the functions zalloc and zfree must be able to allocate</span></div>
<divclass="line"><aname="l00148"></a><spanclass="lineno"> 148</span> <spanclass="comment"> exactly 65536 bytes, but will not be required to allocate more than this if</span></div>
<divclass="line"><aname="l00149"></a><spanclass="lineno"> 149</span> <spanclass="comment"> the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS, pointers</span></div>
<divclass="line"><aname="l00150"></a><spanclass="lineno"> 150</span> <spanclass="comment"> returned by zalloc for objects of exactly 65536 bytes *must* have their</span></div>
<divclass="line"><aname="l00151"></a><spanclass="lineno"> 151</span> <spanclass="comment"> offset normalized to zero. The default allocation function provided by this</span></div>
<divclass="line"><aname="l00152"></a><spanclass="lineno"> 152</span> <spanclass="comment"> library ensures this (see zutil.c). To reduce memory requirements and avoid</span></div>
<divclass="line"><aname="l00153"></a><spanclass="lineno"> 153</span> <spanclass="comment"> any allocation of 64K objects, at the expense of compression ratio, compile</span></div>
<divclass="line"><aname="l00154"></a><spanclass="lineno"> 154</span> <spanclass="comment"> the library with -DMAX_WBITS=14 (see zconf.h).</span></div>
<divclass="line"><aname="l00156"></a><spanclass="lineno"> 156</span> <spanclass="comment"> The fields total_in and total_out can be used for statistics or progress</span></div>
<divclass="line"><aname="l00157"></a><spanclass="lineno"> 157</span> <spanclass="comment"> reports. After compression, total_in holds the total size of the</span></div>
<divclass="line"><aname="l00158"></a><spanclass="lineno"> 158</span> <spanclass="comment"> uncompressed data and may be saved for use in the decompressor (particularly</span></div>
<divclass="line"><aname="l00159"></a><spanclass="lineno"> 159</span> <spanclass="comment"> if the decompressor wants to decompress everything in a single step).</span></div>
<divclass="line"><aname="l00171"></a><spanclass="lineno"> 171</span> <spanclass="comment">/* Allowed flush values; see deflate() and inflate() below for details */</span></div>
<divclass="line"><aname="l00182"></a><spanclass="lineno"> 182</span> <spanclass="comment">/* Return codes for the compression/decompression functions. Negative values</span></div>
<divclass="line"><aname="l00183"></a><spanclass="lineno"> 183</span> <spanclass="comment"> * are errors, positive values are used for special but normal events.</span></div>
<divclass="line"><aname="l00197"></a><spanclass="lineno"> 197</span> <spanclass="comment">/* compression strategy; see deflateInit2() below for details */</span></div>
<divclass="line"><aname="l00201"></a><spanclass="lineno"><aclass="line"href="zlib_8h.html#a9a852d9163cdb10687403d4e79dda06e"> 201</a></span> <spanclass="preprocessor">#define Z_ASCII Z_TEXT </span><spanclass="comment">/* for compatibility with 1.2.2 and earlier */</span><spanclass="preprocessor"></span></div>
<divclass="line"><aname="l00203"></a><spanclass="lineno"> 203</span> <spanclass="comment">/* Possible values of the data_type field (though see inflate()) */</span></div>
<divclass="line"><aname="l00206"></a><spanclass="lineno"> 206</span> <spanclass="comment">/* The deflate compression method (the only one supported in this version) */</span></div>
<divclass="line"><aname="l00211"></a><spanclass="lineno"> 211</span> <spanclass="comment">/* for compatibility with versions < 1.0.2 */</span></div>
<divclass="line"><aname="l00217"></a><spanclass="lineno"> 217</span> <spanclass="comment">/* The application can compare zlibVersion and ZLIB_VERSION for consistency.</span></div>
<divclass="line"><aname="l00218"></a><spanclass="lineno"> 218</span> <spanclass="comment"> If the first character differs, the library code actually used is not</span></div>
<divclass="line"><aname="l00219"></a><spanclass="lineno"> 219</span> <spanclass="comment"> compatible with the zlib.h header file used by the application. This check</span></div>
<divclass="line"><aname="l00220"></a><spanclass="lineno"> 220</span> <spanclass="comment"> is automatically made by deflateInit and inflateInit.</span></div>
<divclass="line"><aname="l00224"></a><spanclass="lineno"> 224</span> <spanclass="comment">ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level));</span></div>
<divclass="line"><aname="l00226"></a><spanclass="lineno"> 226</span> <spanclass="comment"> Initializes the internal stream state for compression. The fields</span></div>
<divclass="line"><aname="l00227"></a><spanclass="lineno"> 227</span> <spanclass="comment"> zalloc, zfree and opaque must be initialized before by the caller. If</span></div>
<divclass="line"><aname="l00228"></a><spanclass="lineno"> 228</span> <spanclass="comment"> zalloc and zfree are set to Z_NULL, deflateInit updates them to use default</span></div>
<divclass="line"><aname="l00231"></a><spanclass="lineno"> 231</span> <spanclass="comment"> The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9:</span></div>
<divclass="line"><aname="l00232"></a><spanclass="lineno"> 232</span> <spanclass="comment"> 1 gives best speed, 9 gives best compression, 0 gives no compression at all</span></div>
<divclass="line"><aname="l00233"></a><spanclass="lineno"> 233</span> <spanclass="comment"> (the input data is simply copied a block at a time). Z_DEFAULT_COMPRESSION</span></div>
<divclass="line"><aname="l00234"></a><spanclass="lineno"> 234</span> <spanclass="comment"> requests a default compromise between speed and compression (currently</span></div>
<divclass="line"><aname="l00235"></a><spanclass="lineno"> 235</span> <spanclass="comment"> equivalent to level 6).</span></div>
<divclass="line"><aname="l00237"></a><spanclass="lineno"> 237</span> <spanclass="comment"> deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough</span></div>
<divclass="line"><aname="l00238"></a><spanclass="lineno"> 238</span> <spanclass="comment"> memory, Z_STREAM_ERROR if level is not a valid compression level, or</span></div>
<divclass="line"><aname="l00239"></a><spanclass="lineno"> 239</span> <spanclass="comment"> Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible</span></div>
<divclass="line"><aname="l00240"></a><spanclass="lineno"> 240</span> <spanclass="comment"> with the version assumed by the caller (ZLIB_VERSION). msg is set to null</span></div>
<divclass="line"><aname="l00241"></a><spanclass="lineno"> 241</span> <spanclass="comment"> if there is no error message. deflateInit does not perform any compression:</span></div>
<divclass="line"><aname="l00242"></a><spanclass="lineno"> 242</span> <spanclass="comment"> this will be done by deflate().</span></div>
<divclass="line"><aname="l00248"></a><spanclass="lineno"> 248</span> <spanclass="comment"> deflate compresses as much data as possible, and stops when the input</span></div>
<divclass="line"><aname="l00249"></a><spanclass="lineno"> 249</span> <spanclass="comment"> buffer becomes empty or the output buffer becomes full. It may introduce</span></div>
<divclass="line"><aname="l00250"></a><spanclass="lineno"> 250</span> <spanclass="comment"> some output latency (reading input without producing any output) except when</span></div>
<divclass="line"><aname="l00251"></a><spanclass="lineno"> 251</span> <spanclass="comment"> forced to flush.</span></div>
<divclass="line"><aname="l00253"></a><spanclass="lineno"> 253</span> <spanclass="comment"> The detailed semantics are as follows. deflate performs one or both of the</span></div>
<divclass="line"><aname="l00254"></a><spanclass="lineno"> 254</span> <spanclass="comment"> following actions:</span></div>
<divclass="line"><aname="l00256"></a><spanclass="lineno"> 256</span> <spanclass="comment"> - Compress more input starting at next_in and update next_in and avail_in</span></div>
<divclass="line"><aname="l00257"></a><spanclass="lineno"> 257</span> <spanclass="comment"> accordingly. If not all input can be processed (because there is not</span></div>
<divclass="line"><aname="l00258"></a><spanclass="lineno"> 258</span> <spanclass="comment"> enough room in the output buffer), next_in and avail_in are updated and</span></div>
<divclass="line"><aname="l00259"></a><spanclass="lineno"> 259</span> <spanclass="comment"> processing will resume at this point for the next call of deflate().</span></div>
<divclass="line"><aname="l00261"></a><spanclass="lineno"> 261</span> <spanclass="comment"> - Provide more output starting at next_out and update next_out and avail_out</span></div>
<divclass="line"><aname="l00262"></a><spanclass="lineno"> 262</span> <spanclass="comment"> accordingly. This action is forced if the parameter flush is non zero.</span></div>
<divclass="line"><aname="l00263"></a><spanclass="lineno"> 263</span> <spanclass="comment"> Forcing flush frequently degrades the compression ratio, so this parameter</span></div>
<divclass="line"><aname="l00264"></a><spanclass="lineno"> 264</span> <spanclass="comment"> should be set only when necessary (in interactive applications). Some</span></div>
<divclass="line"><aname="l00265"></a><spanclass="lineno"> 265</span> <spanclass="comment"> output may be provided even if flush is not set.</span></div>
<divclass="line"><aname="l00267"></a><spanclass="lineno"> 267</span> <spanclass="comment"> Before the call of deflate(), the application should ensure that at least</span></div>
<divclass="line"><aname="l00268"></a><spanclass="lineno"> 268</span> <spanclass="comment"> one of the actions is possible, by providing more input and/or consuming more</span></div>
<divclass="line"><aname="l00269"></a><spanclass="lineno"> 269</span> <spanclass="comment"> output, and updating avail_in or avail_out accordingly; avail_out should</span></div>
<divclass="line"><aname="l00270"></a><spanclass="lineno"> 270</span> <spanclass="comment"> never be zero before the call. The application can consume the compressed</span></div>
<divclass="line"><aname="l00271"></a><spanclass="lineno"> 271</span> <spanclass="comment"> output when it wants, for example when the output buffer is full (avail_out</span></div>
<divclass="line"><aname="l00272"></a><spanclass="lineno"> 272</span> <spanclass="comment"> == 0), or after each call of deflate(). If deflate returns Z_OK and with</span></div>
<divclass="line"><aname="l00273"></a><spanclass="lineno"> 273</span> <spanclass="comment"> zero avail_out, it must be called again after making room in the output</span></div>
<divclass="line"><aname="l00274"></a><spanclass="lineno"> 274</span> <spanclass="comment"> buffer because there might be more output pending.</span></div>
<divclass="line"><aname="l00276"></a><spanclass="lineno"> 276</span> <spanclass="comment"> Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to</span></div>
<divclass="line"><aname="l00277"></a><spanclass="lineno"> 277</span> <spanclass="comment"> decide how much data to accumulate before producing output, in order to</span></div>
<divclass="line"><aname="l00280"></a><spanclass="lineno"> 280</span> <spanclass="comment"> If the parameter flush is set to Z_SYNC_FLUSH, all pending output is</span></div>
<divclass="line"><aname="l00281"></a><spanclass="lineno"> 281</span> <spanclass="comment"> flushed to the output buffer and the output is aligned on a byte boundary, so</span></div>
<divclass="line"><aname="l00282"></a><spanclass="lineno"> 282</span> <spanclass="comment"> that the decompressor can get all input data available so far. (In</span></div>
<divclass="line"><aname="l00283"></a><spanclass="lineno"> 283</span> <spanclass="comment"> particular avail_in is zero after the call if enough output space has been</span></div>
<divclass="line"><aname="l00284"></a><spanclass="lineno"> 284</span> <spanclass="comment"> provided before the call.) Flushing may degrade compression for some</span></div>
<divclass="line"><aname="l00285"></a><spanclass="lineno"> 285</span> <spanclass="comment"> compression algorithms and so it should be used only when necessary. This</span></div>
<divclass="line"><aname="l00286"></a><spanclass="lineno"> 286</span> <spanclass="comment"> completes the current deflate block and follows it with an empty stored block</span></div>
<divclass="line"><aname="l00287"></a><spanclass="lineno"> 287</span> <spanclass="comment"> that is three bits plus filler bits to the next byte, followed by four bytes</span></div>
<divclass="line"><aname="l00290"></a><spanclass="lineno"> 290</span> <spanclass="comment"> If flush is set to Z_PARTIAL_FLUSH, all pending output is flushed to the</span></div>
<divclass="line"><aname="l00291"></a><spanclass="lineno"> 291</span> <spanclass="comment"> output buffer, but the output is not aligned to a byte boundary. All of the</span></div>
<divclass="line"><aname="l00292"></a><spanclass="lineno"> 292</span> <spanclass="comment"> input data so far will be available to the decompressor, as for Z_SYNC_FLUSH.</span></div>
<divclass="line"><aname="l00293"></a><spanclass="lineno"> 293</span> <spanclass="comment"> This completes the current deflate block and follows it with an empty fixed</span></div>
<divclass="line"><aname="l00294"></a><spanclass="lineno"> 294</span> <spanclass="comment"> codes block that is 10 bits long. This assures that enough bytes are output</span></div>
<divclass="line"><aname="l00295"></a><spanclass="lineno"> 295</span> <spanclass="comment"> in order for the decompressor to finish the block before the empty fixed code</span></div>
<divclass="line"><aname="l00298"></a><spanclass="lineno"> 298</span> <spanclass="comment"> If flush is set to Z_BLOCK, a deflate block is completed and emitted, as</span></div>
<divclass="line"><aname="l00299"></a><spanclass="lineno"> 299</span> <spanclass="comment"> for Z_SYNC_FLUSH, but the output is not aligned on a byte boundary, and up to</span></div>
<divclass="line"><aname="l00300"></a><spanclass="lineno"> 300</span> <spanclass="comment"> seven bits of the current block are held to be written as the next byte after</span></div>
<divclass="line"><aname="l00301"></a><spanclass="lineno"> 301</span> <spanclass="comment"> the next deflate block is completed. In this case, the decompressor may not</span></div>
<divclass="line"><aname="l00302"></a><spanclass="lineno"> 302</span> <spanclass="comment"> be provided enough bits at this point in order to complete decompression of</span></div>
<divclass="line"><aname="l00303"></a><spanclass="lineno"> 303</span> <spanclass="comment"> the data provided so far to the compressor. It may need to wait for the next</span></div>
<divclass="line"><aname="l00304"></a><spanclass="lineno"> 304</span> <spanclass="comment"> block to be emitted. This is for advanced applications that need to control</span></div>
<divclass="line"><aname="l00305"></a><spanclass="lineno"> 305</span> <spanclass="comment"> the emission of deflate blocks.</span></div>
<divclass="line"><aname="l00307"></a><spanclass="lineno"> 307</span> <spanclass="comment"> If flush is set to Z_FULL_FLUSH, all output is flushed as with</span></div>
<divclass="line"><aname="l00308"></a><spanclass="lineno"> 308</span> <spanclass="comment"> Z_SYNC_FLUSH, and the compression state is reset so that decompression can</span></div>
<divclass="line"><aname="l00309"></a><spanclass="lineno"> 309</span> <spanclass="comment"> restart from this point if previous compressed data has been damaged or if</span></div>
<divclass="line"><aname="l00310"></a><spanclass="lineno"> 310</span> <spanclass="comment"> random access is desired. Using Z_FULL_FLUSH too often can seriously degrade</span></div>
<divclass="line"><aname="l00313"></a><spanclass="lineno"> 313</span> <spanclass="comment"> If deflate returns with avail_out == 0, this function must be called again</span></div>
<divclass="line"><aname="l00314"></a><spanclass="lineno"> 314</span> <spanclass="comment"> with the same value of the flush parameter and more output space (updated</span></div>
<divclass="line"><aname="l00315"></a><spanclass="lineno"> 315</span> <spanclass="comment"> avail_out), until the flush is complete (deflate returns with non-zero</span></div>
<divclass="line"><aname="l00316"></a><spanclass="lineno"> 316</span> <spanclass="comment"> avail_out). In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that</span></div>
<divclass="line"><aname="l00317"></a><spanclass="lineno"> 317</span> <spanclass="comment"> avail_out is greater than six to avoid repeated flush markers due to</span></div>
<divclass="line"><aname="l00318"></a><spanclass="lineno"> 318</span> <spanclass="comment"> avail_out == 0 on return.</span></div>
<divclass="line"><aname="l00320"></a><spanclass="lineno"> 320</span> <spanclass="comment"> If the parameter flush is set to Z_FINISH, pending input is processed,</span></div>
<divclass="line"><aname="l00321"></a><spanclass="lineno"> 321</span> <spanclass="comment"> pending output is flushed and deflate returns with Z_STREAM_END if there was</span></div>
<divclass="line"><aname="l00322"></a><spanclass="lineno"> 322</span> <spanclass="comment"> enough output space; if deflate returns with Z_OK, this function must be</span></div>
<divclass="line"><aname="l00323"></a><spanclass="lineno"> 323</span> <spanclass="comment"> called again with Z_FINISH and more output space (updated avail_out) but no</span></div>
<divclass="line"><aname="l00324"></a><spanclass="lineno"> 324</span> <spanclass="comment"> more input data, until it returns with Z_STREAM_END or an error. After</span></div>
<divclass="line"><aname="l00325"></a><spanclass="lineno"> 325</span> <spanclass="comment"> deflate has returned Z_STREAM_END, the only possible operations on the stream</span></div>
<divclass="line"><aname="l00326"></a><spanclass="lineno"> 326</span> <spanclass="comment"> are deflateReset or deflateEnd.</span></div>
<divclass="line"><aname="l00328"></a><spanclass="lineno"> 328</span> <spanclass="comment"> Z_FINISH can be used immediately after deflateInit if all the compression</span></div>
<divclass="line"><aname="l00329"></a><spanclass="lineno"> 329</span> <spanclass="comment"> is to be done in a single step. In this case, avail_out must be at least the</span></div>
<divclass="line"><aname="l00330"></a><spanclass="lineno"> 330</span> <spanclass="comment"> value returned by deflateBound (see below). If deflate does not return</span></div>
<divclass="line"><aname="l00331"></a><spanclass="lineno"> 331</span> <spanclass="comment"> Z_STREAM_END, then it must be called again as described above.</span></div>
<divclass="line"><aname="l00333"></a><spanclass="lineno"> 333</span> <spanclass="comment"> deflate() sets strm->adler to the adler32 checksum of all input read</span></div>
<divclass="line"><aname="l00334"></a><spanclass="lineno"> 334</span> <spanclass="comment"> so far (that is, total_in bytes).</span></div>
<divclass="line"><aname="l00336"></a><spanclass="lineno"> 336</span> <spanclass="comment"> deflate() may update strm->data_type if it can make a good guess about</span></div>
<divclass="line"><aname="l00337"></a><spanclass="lineno"> 337</span> <spanclass="comment"> the input data type (Z_BINARY or Z_TEXT). In doubt, the data is considered</span></div>
<divclass="line"><aname="l00338"></a><spanclass="lineno"> 338</span> <spanclass="comment"> binary. This field is only for information purposes and does not affect the</span></div>
<divclass="line"><aname="l00339"></a><spanclass="lineno"> 339</span> <spanclass="comment"> compression algorithm in any manner.</span></div>
<divclass="line"><aname="l00341"></a><spanclass="lineno"> 341</span> <spanclass="comment"> deflate() returns Z_OK if some progress has been made (more input</span></div>
<divclass="line"><aname="l00342"></a><spanclass="lineno"> 342</span> <spanclass="comment"> processed or more output produced), Z_STREAM_END if all input has been</span></div>
<divclass="line"><aname="l00343"></a><spanclass="lineno"> 343</span> <spanclass="comment"> consumed and all output has been produced (only when flush is set to</span></div>
<divclass="line"><aname="l00344"></a><spanclass="lineno"> 344</span> <spanclass="comment"> Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example</span></div>
<divclass="line"><aname="l00345"></a><spanclass="lineno"> 345</span> <spanclass="comment"> if next_in or next_out was Z_NULL), Z_BUF_ERROR if no progress is possible</span></div>
<divclass="line"><aname="l00346"></a><spanclass="lineno"> 346</span> <spanclass="comment"> (for example avail_in or avail_out was zero). Note that Z_BUF_ERROR is not</span></div>
<divclass="line"><aname="l00347"></a><spanclass="lineno"> 347</span> <spanclass="comment"> fatal, and deflate() can be called again with more input and more output</span></div>
<divclass="line"><aname="l00348"></a><spanclass="lineno"> 348</span> <spanclass="comment"> space to continue compressing.</span></div>
<divclass="line"><aname="l00354"></a><spanclass="lineno"> 354</span> <spanclass="comment"> All dynamically allocated data structures for this stream are freed.</span></div>
<divclass="line"><aname="l00355"></a><spanclass="lineno"> 355</span> <spanclass="comment"> This function discards any unprocessed input and does not flush any pending</span></div>
<divclass="line"><aname="l00358"></a><spanclass="lineno"> 358</span> <spanclass="comment"> deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the</span></div>
<divclass="line"><aname="l00359"></a><spanclass="lineno"> 359</span> <spanclass="comment"> stream state was inconsistent, Z_DATA_ERROR if the stream was freed</span></div>
<divclass="line"><aname="l00360"></a><spanclass="lineno"> 360</span> <spanclass="comment"> prematurely (some input or output was discarded). In the error case, msg</span></div>
<divclass="line"><aname="l00361"></a><spanclass="lineno"> 361</span> <spanclass="comment"> may be set but then points to a static string (which must not be</span></div>
<divclass="line"><aname="l00369"></a><spanclass="lineno"> 369</span> <spanclass="comment"> Initializes the internal stream state for decompression. The fields</span></div>
<divclass="line"><aname="l00370"></a><spanclass="lineno"> 370</span> <spanclass="comment"> next_in, avail_in, zalloc, zfree and opaque must be initialized before by</span></div>
<divclass="line"><aname="l00371"></a><spanclass="lineno"> 371</span> <spanclass="comment"> the caller. If next_in is not Z_NULL and avail_in is large enough (the</span></div>
<divclass="line"><aname="l00372"></a><spanclass="lineno"> 372</span> <spanclass="comment"> exact value depends on the compression method), inflateInit determines the</span></div>
<divclass="line"><aname="l00373"></a><spanclass="lineno"> 373</span> <spanclass="comment"> compression method from the zlib header and allocates all data structures</span></div>
<divclass="line"><aname="l00374"></a><spanclass="lineno"> 374</span> <spanclass="comment"> accordingly; otherwise the allocation will be deferred to the first call of</span></div>
<divclass="line"><aname="l00375"></a><spanclass="lineno"> 375</span> <spanclass="comment"> inflate. If zalloc and zfree are set to Z_NULL, inflateInit updates them to</span></div>
<divclass="line"><aname="l00376"></a><spanclass="lineno"> 376</span> <spanclass="comment"> use default allocation functions.</span></div>
<divclass="line"><aname="l00378"></a><spanclass="lineno"> 378</span> <spanclass="comment"> inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough</span></div>
<divclass="line"><aname="l00379"></a><spanclass="lineno"> 379</span> <spanclass="comment"> memory, Z_VERSION_ERROR if the zlib library version is incompatible with the</span></div>
<divclass="line"><aname="l00380"></a><spanclass="lineno"> 380</span> <spanclass="comment"> version assumed by the caller, or Z_STREAM_ERROR if the parameters are</span></div>
<divclass="line"><aname="l00381"></a><spanclass="lineno"> 381</span> <spanclass="comment"> invalid, such as a null pointer to the structure. msg is set to null if</span></div>
<divclass="line"><aname="l00382"></a><spanclass="lineno"> 382</span> <spanclass="comment"> there is no error message. inflateInit does not perform any decompression</span></div>
<divclass="line"><aname="l00383"></a><spanclass="lineno"> 383</span> <spanclass="comment"> apart from possibly reading the zlib header if present: actual decompression</span></div>
<divclass="line"><aname="l00384"></a><spanclass="lineno"> 384</span> <spanclass="comment"> will be done by inflate(). (So next_in and avail_in may be modified, but</span></div>
<divclass="line"><aname="l00385"></a><spanclass="lineno"> 385</span> <spanclass="comment"> next_out and avail_out are unused and unchanged.) The current implementation</span></div>
<divclass="line"><aname="l00386"></a><spanclass="lineno"> 386</span> <spanclass="comment"> of inflateInit() does not process any header information -- that is deferred</span></div>
<divclass="line"><aname="l00387"></a><spanclass="lineno"> 387</span> <spanclass="comment"> until inflate() is called.</span></div>
<divclass="line"><aname="l00393"></a><spanclass="lineno"> 393</span> <spanclass="comment"> inflate decompresses as much data as possible, and stops when the input</span></div>
<divclass="line"><aname="l00394"></a><spanclass="lineno"> 394</span> <spanclass="comment"> buffer becomes empty or the output buffer becomes full. It may introduce</span></div>
<divclass="line"><aname="l00395"></a><spanclass="lineno"> 395</span> <spanclass="comment"> some output latency (reading input without producing any output) except when</span></div>
<divclass="line"><aname="l00396"></a><spanclass="lineno"> 396</span> <spanclass="comment"> forced to flush.</span></div>
<divclass="line"><aname="l00398"></a><spanclass="lineno"> 398</span> <spanclass="comment"> The detailed semantics are as follows. inflate performs one or both of the</span></div>
<divclass="line"><aname="l00399"></a><spanclass="lineno"> 399</span> <spanclass="comment"> following actions:</span></div>
<divclass="line"><aname="l00401"></a><spanclass="lineno"> 401</span> <spanclass="comment"> - Decompress more input starting at next_in and update next_in and avail_in</span></div>
<divclass="line"><aname="l00402"></a><spanclass="lineno"> 402</span> <spanclass="comment"> accordingly. If not all input can be processed (because there is not</span></div>
<divclass="line"><aname="l00403"></a><spanclass="lineno"> 403</span> <spanclass="comment"> enough room in the output buffer), next_in is updated and processing will</span></div>
<divclass="line"><aname="l00404"></a><spanclass="lineno"> 404</span> <spanclass="comment"> resume at this point for the next call of inflate().</span></div>
<divclass="line"><aname="l00406"></a><spanclass="lineno"> 406</span> <spanclass="comment"> - Provide more output starting at next_out and update next_out and avail_out</span></div>
<divclass="line"><aname="l00407"></a><spanclass="lineno"> 407</span> <spanclass="comment"> accordingly. inflate() provides as much output as possible, until there is</span></div>
<divclass="line"><aname="l00408"></a><spanclass="lineno"> 408</span> <spanclass="comment"> no more input data or no more space in the output buffer (see below about</span></div>
<divclass="line"><aname="l00409"></a><spanclass="lineno"> 409</span> <spanclass="comment"> the flush parameter).</span></div>
<divclass="line"><aname="l00411"></a><spanclass="lineno"> 411</span> <spanclass="comment"> Before the call of inflate(), the application should ensure that at least</span></div>
<divclass="line"><aname="l00412"></a><spanclass="lineno"> 412</span> <spanclass="comment"> one of the actions is possible, by providing more input and/or consuming more</span></div>
<divclass="line"><aname="l00413"></a><spanclass="lineno"> 413</span> <spanclass="comment"> output, and updating the next_* and avail_* values accordingly. The</span></div>
<divclass="line"><aname="l00414"></a><spanclass="lineno"> 414</span> <spanclass="comment"> application can consume the uncompressed output when it wants, for example</span></div>
<divclass="line"><aname="l00415"></a><spanclass="lineno"> 415</span> <spanclass="comment"> when the output buffer is full (avail_out == 0), or after each call of</span></div>
<divclass="line"><aname="l00416"></a><spanclass="lineno"> 416</span> <spanclass="comment"> inflate(). If inflate returns Z_OK and with zero avail_out, it must be</span></div>
<divclass="line"><aname="l00417"></a><spanclass="lineno"> 417</span> <spanclass="comment"> called again after making room in the output buffer because there might be</span></div>
<divclass="line"><aname="l00418"></a><spanclass="lineno"> 418</span> <spanclass="comment"> more output pending.</span></div>
<divclass="line"><aname="l00420"></a><spanclass="lineno"> 420</span> <spanclass="comment"> The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH, Z_FINISH,</span></div>
<divclass="line"><aname="l00421"></a><spanclass="lineno"> 421</span> <spanclass="comment"> Z_BLOCK, or Z_TREES. Z_SYNC_FLUSH requests that inflate() flush as much</span></div>
<divclass="line"><aname="l00422"></a><spanclass="lineno"> 422</span> <spanclass="comment"> output as possible to the output buffer. Z_BLOCK requests that inflate()</span></div>
<divclass="line"><aname="l00423"></a><spanclass="lineno"> 423</span> <spanclass="comment"> stop if and when it gets to the next deflate block boundary. When decoding</span></div>
<divclass="line"><aname="l00424"></a><spanclass="lineno"> 424</span> <spanclass="comment"> the zlib or gzip format, this will cause inflate() to return immediately</span></div>
<divclass="line"><aname="l00425"></a><spanclass="lineno"> 425</span> <spanclass="comment"> after the header and before the first block. When doing a raw inflate,</span></div>
<divclass="line"><aname="l00426"></a><spanclass="lineno"> 426</span> <spanclass="comment"> inflate() will go ahead and process the first block, and will return when it</span></div>
<divclass="line"><aname="l00427"></a><spanclass="lineno"> 427</span> <spanclass="comment"> gets to the end of that block, or when it runs out of data.</span></div>
<divclass="line"><aname="l00429"></a><spanclass="lineno"> 429</span> <spanclass="comment"> The Z_BLOCK option assists in appending to or combining deflate streams.</span></div>
<divclass="line"><aname="l00430"></a><spanclass="lineno"> 430</span> <spanclass="comment"> Also to assist in this, on return inflate() will set strm->data_type to the</span></div>
<divclass="line"><aname="l00431"></a><spanclass="lineno"> 431</span> <spanclass="comment"> number of unused bits in the last byte taken from strm->next_in, plus 64 if</span></div>
<divclass="line"><aname="l00432"></a><spanclass="lineno"> 432</span> <spanclass="comment"> inflate() is currently decoding the last block in the deflate stream, plus</span></div>
<divclass="line"><aname="l00433"></a><spanclass="lineno"> 433</span> <spanclass="comment"> 128 if inflate() returned immediately after decoding an end-of-block code or</span></div>
<divclass="line"><aname="l00434"></a><spanclass="lineno"> 434</span> <spanclass="comment"> decoding the complete header up to just before the first byte of the deflate</span></div>
<divclass="line"><aname="l00435"></a><spanclass="lineno"> 435</span> <spanclass="comment"> stream. The end-of-block will not be indicated until all of the uncompressed</span></div>
<divclass="line"><aname="l00436"></a><spanclass="lineno"> 436</span> <spanclass="comment"> data from that block has been written to strm->next_out. The number of</span></div>
<divclass="line"><aname="l00437"></a><spanclass="lineno"> 437</span> <spanclass="comment"> unused bits may in general be greater than seven, except when bit 7 of</span></div>
<divclass="line"><aname="l00438"></a><spanclass="lineno"> 438</span> <spanclass="comment"> data_type is set, in which case the number of unused bits will be less than</span></div>
<divclass="line"><aname="l00439"></a><spanclass="lineno"> 439</span> <spanclass="comment"> eight. data_type is set as noted here every time inflate() returns for all</span></div>
<divclass="line"><aname="l00440"></a><spanclass="lineno"> 440</span> <spanclass="comment"> flush options, and so can be used to determine the amount of currently</span></div>
<divclass="line"><aname="l00441"></a><spanclass="lineno"> 441</span> <spanclass="comment"> consumed input in bits.</span></div>
<divclass="line"><aname="l00443"></a><spanclass="lineno"> 443</span> <spanclass="comment"> The Z_TREES option behaves as Z_BLOCK does, but it also returns when the</span></div>
<divclass="line"><aname="l00444"></a><spanclass="lineno"> 444</span> <spanclass="comment"> end of each deflate block header is reached, before any actual data in that</span></div>
<divclass="line"><aname="l00445"></a><spanclass="lineno"> 445</span> <spanclass="comment"> block is decoded. This allows the caller to determine the length of the</span></div>
<divclass="line"><aname="l00446"></a><spanclass="lineno"> 446</span> <spanclass="comment"> deflate block header for later use in random access within a deflate block.</span></div>
<divclass="line"><aname="l00447"></a><spanclass="lineno"> 447</span> <spanclass="comment"> 256 is added to the value of strm->data_type when inflate() returns</span></div>
<divclass="line"><aname="l00448"></a><spanclass="lineno"> 448</span> <spanclass="comment"> immediately after reaching the end of the deflate block header.</span></div>
<divclass="line"><aname="l00450"></a><spanclass="lineno"> 450</span> <spanclass="comment"> inflate() should normally be called until it returns Z_STREAM_END or an</span></div>
<divclass="line"><aname="l00451"></a><spanclass="lineno"> 451</span> <spanclass="comment"> error. However if all decompression is to be performed in a single step (a</span></div>
<divclass="line"><aname="l00452"></a><spanclass="lineno"> 452</span> <spanclass="comment"> single call of inflate), the parameter flush should be set to Z_FINISH. In</span></div>
<divclass="line"><aname="l00453"></a><spanclass="lineno"> 453</span> <spanclass="comment"> this case all pending input is processed and all pending output is flushed;</span></div>
<divclass="line"><aname="l00454"></a><spanclass="lineno"> 454</span> <spanclass="comment"> avail_out must be large enough to hold all the uncompressed data. (The size</span></div>
<divclass="line"><aname="l00455"></a><spanclass="lineno"> 455</span> <spanclass="comment"> of the uncompressed data may have been saved by the compressor for this</span></div>
<divclass="line"><aname="l00456"></a><spanclass="lineno"> 456</span> <spanclass="comment"> purpose.) The next operation on this stream must be inflateEnd to deallocate</span></div>
<divclass="line"><aname="l00457"></a><spanclass="lineno"> 457</span> <spanclass="comment"> the decompression state. The use of Z_FINISH is never required, but can be</span></div>
<divclass="line"><aname="l00458"></a><spanclass="lineno"> 458</span> <spanclass="comment"> used to inform inflate that a faster approach may be used for the single</span></div>
<divclass="line"><aname="l00461"></a><spanclass="lineno"> 461</span> <spanclass="comment"> In this implementation, inflate() always flushes as much output as</span></div>
<divclass="line"><aname="l00462"></a><spanclass="lineno"> 462</span> <spanclass="comment"> possible to the output buffer, and always uses the faster approach on the</span></div>
<divclass="line"><aname="l00463"></a><spanclass="lineno"> 463</span> <spanclass="comment"> first call. So the only effect of the flush parameter in this implementation</span></div>
<divclass="line"><aname="l00464"></a><spanclass="lineno"> 464</span> <spanclass="comment"> is on the return value of inflate(), as noted below, or when it returns early</span></div>
<divclass="line"><aname="l00465"></a><spanclass="lineno"> 465</span> <spanclass="comment"> because Z_BLOCK or Z_TREES is used.</span></div>
<divclass="line"><aname="l00467"></a><spanclass="lineno"> 467</span> <spanclass="comment"> If a preset dictionary is needed after this call (see inflateSetDictionary</span></div>
<divclass="line"><aname="l00468"></a><spanclass="lineno"> 468</span> <spanclass="comment"> below), inflate sets strm->adler to the adler32 checksum of the dictionary</span></div>
<divclass="line"><aname="l00469"></a><spanclass="lineno"> 469</span> <spanclass="comment"> chosen by the compressor and returns Z_NEED_DICT; otherwise it sets</span></div>
<divclass="line"><aname="l00470"></a><spanclass="lineno"> 470</span> <spanclass="comment"> strm->adler to the adler32 checksum of all output produced so far (that is,</span></div>
<divclass="line"><aname="l00471"></a><spanclass="lineno"> 471</span> <spanclass="comment"> total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described</span></div>
<divclass="line"><aname="l00472"></a><spanclass="lineno"> 472</span> <spanclass="comment"> below. At the end of the stream, inflate() checks that its computed adler32</span></div>
<divclass="line"><aname="l00473"></a><spanclass="lineno"> 473</span> <spanclass="comment"> checksum is equal to that saved by the compressor and returns Z_STREAM_END</span></div>
<divclass="line"><aname="l00474"></a><spanclass="lineno"> 474</span> <spanclass="comment"> only if the checksum is correct.</span></div>
<divclass="line"><aname="l00476"></a><spanclass="lineno"> 476</span> <spanclass="comment"> inflate() can decompress and check either zlib-wrapped or gzip-wrapped</span></div>
<divclass="line"><aname="l00477"></a><spanclass="lineno"> 477</span> <spanclass="comment"> deflate data. The header type is detected automatically, if requested when</span></div>
<divclass="line"><aname="l00478"></a><spanclass="lineno"> 478</span> <spanclass="comment"> initializing with inflateInit2(). Any information contained in the gzip</span></div>
<divclass="line"><aname="l00479"></a><spanclass="lineno"> 479</span> <spanclass="comment"> header is not retained, so applications that need that information should</span></div>
<divclass="line"><aname="l00480"></a><spanclass="lineno"> 480</span> <spanclass="comment"> instead use raw inflate, see inflateInit2() below, or inflateBack() and</span></div>
<divclass="line"><aname="l00481"></a><spanclass="lineno"> 481</span> <spanclass="comment"> perform their own processing of the gzip header and trailer.</span></div>
<divclass="line"><aname="l00483"></a><spanclass="lineno"> 483</span> <spanclass="comment"> inflate() returns Z_OK if some progress has been made (more input processed</span></div>
<divclass="line"><aname="l00484"></a><spanclass="lineno"> 484</span> <spanclass="comment"> or more output produced), Z_STREAM_END if the end of the compressed data has</span></div>
<divclass="line"><aname="l00485"></a><spanclass="lineno"> 485</span> <spanclass="comment"> been reached and all uncompressed output has been produced, Z_NEED_DICT if a</span></div>
<divclass="line"><aname="l00486"></a><spanclass="lineno"> 486</span> <spanclass="comment"> preset dictionary is needed at this point, Z_DATA_ERROR if the input data was</span></div>
<divclass="line"><aname="l00487"></a><spanclass="lineno"> 487</span> <spanclass="comment"> corrupted (input stream not conforming to the zlib format or incorrect check</span></div>
<divclass="line"><aname="l00488"></a><spanclass="lineno"> 488</span> <spanclass="comment"> value), Z_STREAM_ERROR if the stream structure was inconsistent (for example</span></div>
<divclass="line"><aname="l00489"></a><spanclass="lineno"> 489</span> <spanclass="comment"> next_in or next_out was Z_NULL), Z_MEM_ERROR if there was not enough memory,</span></div>
<divclass="line"><aname="l00490"></a><spanclass="lineno"> 490</span> <spanclass="comment"> Z_BUF_ERROR if no progress is possible or if there was not enough room in the</span></div>
<divclass="line"><aname="l00491"></a><spanclass="lineno"> 491</span> <spanclass="comment"> output buffer when Z_FINISH is used. Note that Z_BUF_ERROR is not fatal, and</span></div>
<divclass="line"><aname="l00492"></a><spanclass="lineno"> 492</span> <spanclass="comment"> inflate() can be called again with more input and more output space to</span></div>
<divclass="line"><aname="l00493"></a><spanclass="lineno"> 493</span> <spanclass="comment"> continue decompressing. If Z_DATA_ERROR is returned, the application may</span></div>
<divclass="line"><aname="l00494"></a><spanclass="lineno"> 494</span> <spanclass="comment"> then call inflateSync() to look for a good compression block if a partial</span></div>
<divclass="line"><aname="l00495"></a><spanclass="lineno"> 495</span> <spanclass="comment"> recovery of the data is desired.</span></div>
<divclass="line"><aname="l00501"></a><spanclass="lineno"> 501</span> <spanclass="comment"> All dynamically allocated data structures for this stream are freed.</span></div>
<divclass="line"><aname="l00502"></a><spanclass="lineno"> 502</span> <spanclass="comment"> This function discards any unprocessed input and does not flush any pending</span></div>
<divclass="line"><aname="l00505"></a><spanclass="lineno"> 505</span> <spanclass="comment"> inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state</span></div>
<divclass="line"><aname="l00506"></a><spanclass="lineno"> 506</span> <spanclass="comment"> was inconsistent. In the error case, msg may be set but then points to a</span></div>
<divclass="line"><aname="l00507"></a><spanclass="lineno"> 507</span> <spanclass="comment"> static string (which must not be deallocated).</span></div>
<divclass="line"><aname="l00514"></a><spanclass="lineno"> 514</span> <spanclass="comment"> The following functions are needed only in some special applications.</span></div>
<divclass="line"><aname="l00525"></a><spanclass="lineno"> 525</span> <spanclass="comment"> This is another version of deflateInit with more compression options. The</span></div>
<divclass="line"><aname="l00526"></a><spanclass="lineno"> 526</span> <spanclass="comment"> fields next_in, zalloc, zfree and opaque must be initialized before by the</span></div>
<divclass="line"><aname="l00529"></a><spanclass="lineno"> 529</span> <spanclass="comment"> The method parameter is the compression method. It must be Z_DEFLATED in</span></div>
<divclass="line"><aname="l00530"></a><spanclass="lineno"> 530</span> <spanclass="comment"> this version of the library.</span></div>
<divclass="line"><aname="l00532"></a><spanclass="lineno"> 532</span> <spanclass="comment"> The windowBits parameter is the base two logarithm of the window size</span></div>
<divclass="line"><aname="l00533"></a><spanclass="lineno"> 533</span> <spanclass="comment"> (the size of the history buffer). It should be in the range 8..15 for this</span></div>
<divclass="line"><aname="l00534"></a><spanclass="lineno"> 534</span> <spanclass="comment"> version of the library. Larger values of this parameter result in better</span></div>
<divclass="line"><aname="l00535"></a><spanclass="lineno"> 535</span> <spanclass="comment"> compression at the expense of memory usage. The default value is 15 if</span></div>
<divclass="line"><aname="l00536"></a><spanclass="lineno"> 536</span> <spanclass="comment"> deflateInit is used instead.</span></div>
<divclass="line"><aname="l00538"></a><spanclass="lineno"> 538</span> <spanclass="comment"> windowBits can also be -8..-15 for raw deflate. In this case, -windowBits</span></div>
<divclass="line"><aname="l00539"></a><spanclass="lineno"> 539</span> <spanclass="comment"> determines the window size. deflate() will then generate raw deflate data</span></div>
<divclass="line"><aname="l00540"></a><spanclass="lineno"> 540</span> <spanclass="comment"> with no zlib header or trailer, and will not compute an adler32 check value.</span></div>
<divclass="line"><aname="l00542"></a><spanclass="lineno"> 542</span> <spanclass="comment"> windowBits can also be greater than 15 for optional gzip encoding. Add</span></div>
<divclass="line"><aname="l00543"></a><spanclass="lineno"> 543</span> <spanclass="comment"> 16 to windowBits to write a simple gzip header and trailer around the</span></div>
<divclass="line"><aname="l00544"></a><spanclass="lineno"> 544</span> <spanclass="comment"> compressed data instead of a zlib wrapper. The gzip header will have no</span></div>
<divclass="line"><aname="l00545"></a><spanclass="lineno"> 545</span> <spanclass="comment"> file name, no extra data, no comment, no modification time (set to zero), no</span></div>
<divclass="line"><aname="l00546"></a><spanclass="lineno"> 546</span> <spanclass="comment"> header crc, and the operating system will be set to 255 (unknown). If a</span></div>
<divclass="line"><aname="l00547"></a><spanclass="lineno"> 547</span> <spanclass="comment"> gzip stream is being written, strm->adler is a crc32 instead of an adler32.</span></div>
<divclass="line"><aname="l00549"></a><spanclass="lineno"> 549</span> <spanclass="comment"> The memLevel parameter specifies how much memory should be allocated</span></div>
<divclass="line"><aname="l00550"></a><spanclass="lineno"> 550</span> <spanclass="comment"> for the internal compression state. memLevel=1 uses minimum memory but is</span></div>
<divclass="line"><aname="l00551"></a><spanclass="lineno"> 551</span> <spanclass="comment"> slow and reduces compression ratio; memLevel=9 uses maximum memory for</span></div>
<divclass="line"><aname="l00552"></a><spanclass="lineno"> 552</span> <spanclass="comment"> optimal speed. The default value is 8. See zconf.h for total memory usage</span></div>
<divclass="line"><aname="l00553"></a><spanclass="lineno"> 553</span> <spanclass="comment"> as a function of windowBits and memLevel.</span></div>
<divclass="line"><aname="l00555"></a><spanclass="lineno"> 555</span> <spanclass="comment"> The strategy parameter is used to tune the compression algorithm. Use the</span></div>
<divclass="line"><aname="l00556"></a><spanclass="lineno"> 556</span> <spanclass="comment"> value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a</span></div>
<divclass="line"><aname="l00557"></a><spanclass="lineno"> 557</span> <spanclass="comment"> filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no</span></div>
<divclass="line"><aname="l00558"></a><spanclass="lineno"> 558</span> <spanclass="comment"> string match), or Z_RLE to limit match distances to one (run-length</span></div>
<divclass="line"><aname="l00559"></a><spanclass="lineno"> 559</span> <spanclass="comment"> encoding). Filtered data consists mostly of small values with a somewhat</span></div>
<divclass="line"><aname="l00560"></a><spanclass="lineno"> 560</span> <spanclass="comment"> random distribution. In this case, the compression algorithm is tuned to</span></div>
<divclass="line"><aname="l00561"></a><spanclass="lineno"> 561</span> <spanclass="comment"> compress them better. The effect of Z_FILTERED is to force more Huffman</span></div>
<divclass="line"><aname="l00562"></a><spanclass="lineno"> 562</span> <spanclass="comment"> coding and less string matching; it is somewhat intermediate between</span></div>
<divclass="line"><aname="l00563"></a><spanclass="lineno"> 563</span> <spanclass="comment"> Z_DEFAULT_STRATEGY and Z_HUFFMAN_ONLY. Z_RLE is designed to be almost as</span></div>
<divclass="line"><aname="l00564"></a><spanclass="lineno"> 564</span> <spanclass="comment"> fast as Z_HUFFMAN_ONLY, but give better compression for PNG image data. The</span></div>
<divclass="line"><aname="l00565"></a><spanclass="lineno"> 565</span> <spanclass="comment"> strategy parameter only affects the compression ratio but not the</span></div>
<divclass="line"><aname="l00566"></a><spanclass="lineno"> 566</span> <spanclass="comment"> correctness of the compressed output even if it is not set appropriately.</span></div>
<divclass="line"><aname="l00567"></a><spanclass="lineno"> 567</span> <spanclass="comment"> Z_FIXED prevents the use of dynamic Huffman codes, allowing for a simpler</span></div>
<divclass="line"><aname="l00568"></a><spanclass="lineno"> 568</span> <spanclass="comment"> decoder for special applications.</span></div>
<divclass="line"><aname="l00570"></a><spanclass="lineno"> 570</span> <spanclass="comment"> deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough</span></div>
<divclass="line"><aname="l00571"></a><spanclass="lineno"> 571</span> <spanclass="comment"> memory, Z_STREAM_ERROR if any parameter is invalid (such as an invalid</span></div>
<divclass="line"><aname="l00572"></a><spanclass="lineno"> 572</span> <spanclass="comment"> method), or Z_VERSION_ERROR if the zlib library version (zlib_version) is</span></div>
<divclass="line"><aname="l00573"></a><spanclass="lineno"> 573</span> <spanclass="comment"> incompatible with the version assumed by the caller (ZLIB_VERSION). msg is</span></div>
<divclass="line"><aname="l00574"></a><spanclass="lineno"> 574</span> <spanclass="comment"> set to null if there is no error message. deflateInit2 does not perform any</span></div>
<divclass="line"><aname="l00575"></a><spanclass="lineno"> 575</span> <spanclass="comment"> compression: this will be done by deflate().</span></div>
<divclass="line"><aname="l00582"></a><spanclass="lineno"> 582</span> <spanclass="comment"> Initializes the compression dictionary from the given byte sequence</span></div>
<divclass="line"><aname="l00583"></a><spanclass="lineno"> 583</span> <spanclass="comment"> without producing any compressed output. This function must be called</span></div>
<divclass="line"><aname="l00584"></a><spanclass="lineno"> 584</span> <spanclass="comment"> immediately after deflateInit, deflateInit2 or deflateReset, before any call</span></div>
<divclass="line"><aname="l00585"></a><spanclass="lineno"> 585</span> <spanclass="comment"> of deflate. The compressor and decompressor must use exactly the same</span></div>
<divclass="line"><aname="l00586"></a><spanclass="lineno"> 586</span> <spanclass="comment"> dictionary (see inflateSetDictionary).</span></div>
<divclass="line"><aname="l00588"></a><spanclass="lineno"> 588</span> <spanclass="comment"> The dictionary should consist of strings (byte sequences) that are likely</span></div>
<divclass="line"><aname="l00589"></a><spanclass="lineno"> 589</span> <spanclass="comment"> to be encountered later in the data to be compressed, with the most commonly</span></div>
<divclass="line"><aname="l00590"></a><spanclass="lineno"> 590</span> <spanclass="comment"> used strings preferably put towards the end of the dictionary. Using a</span></div>
<divclass="line"><aname="l00591"></a><spanclass="lineno"> 591</span> <spanclass="comment"> dictionary is most useful when the data to be compressed is short and can be</span></div>
<divclass="line"><aname="l00592"></a><spanclass="lineno"> 592</span> <spanclass="comment"> predicted with good accuracy; the data can then be compressed better than</span></div>
<divclass="line"><aname="l00593"></a><spanclass="lineno"> 593</span> <spanclass="comment"> with the default empty dictionary.</span></div>
<divclass="line"><aname="l00595"></a><spanclass="lineno"> 595</span> <spanclass="comment"> Depending on the size of the compression data structures selected by</span></div>
<divclass="line"><aname="l00596"></a><spanclass="lineno"> 596</span> <spanclass="comment"> deflateInit or deflateInit2, a part of the dictionary may in effect be</span></div>
<divclass="line"><aname="l00597"></a><spanclass="lineno"> 597</span> <spanclass="comment"> discarded, for example if the dictionary is larger than the window size</span></div>
<divclass="line"><aname="l00598"></a><spanclass="lineno"> 598</span> <spanclass="comment"> provided in deflateInit or deflateInit2. Thus the strings most likely to be</span></div>
<divclass="line"><aname="l00599"></a><spanclass="lineno"> 599</span> <spanclass="comment"> useful should be put at the end of the dictionary, not at the front. In</span></div>
<divclass="line"><aname="l00600"></a><spanclass="lineno"> 600</span> <spanclass="comment"> addition, the current implementation of deflate will use at most the window</span></div>
<divclass="line"><aname="l00601"></a><spanclass="lineno"> 601</span> <spanclass="comment"> size minus 262 bytes of the provided dictionary.</span></div>
<divclass="line"><aname="l00603"></a><spanclass="lineno"> 603</span> <spanclass="comment"> Upon return of this function, strm->adler is set to the adler32 value</span></div>
<divclass="line"><aname="l00604"></a><spanclass="lineno"> 604</span> <spanclass="comment"> of the dictionary; the decompressor may later use this value to determine</span></div>
<divclass="line"><aname="l00605"></a><spanclass="lineno"> 605</span> <spanclass="comment"> which dictionary has been used by the compressor. (The adler32 value</span></div>
<divclass="line"><aname="l00606"></a><spanclass="lineno"> 606</span> <spanclass="comment"> applies to the whole dictionary even if only a subset of the dictionary is</span></div>
<divclass="line"><aname="l00607"></a><spanclass="lineno"> 607</span> <spanclass="comment"> actually used by the compressor.) If a raw deflate was requested, then the</span></div>
<divclass="line"><aname="l00608"></a><spanclass="lineno"> 608</span> <spanclass="comment"> adler32 value is not computed and strm->adler is not set.</span></div>
<divclass="line"><aname="l00610"></a><spanclass="lineno"> 610</span> <spanclass="comment"> deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a</span></div>
<divclass="line"><aname="l00611"></a><spanclass="lineno"> 611</span> <spanclass="comment"> parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is</span></div>
<divclass="line"><aname="l00612"></a><spanclass="lineno"> 612</span> <spanclass="comment"> inconsistent (for example if deflate has already been called for this stream</span></div>
<divclass="line"><aname="l00613"></a><spanclass="lineno"> 613</span> <spanclass="comment"> or if the compression method is bsort). deflateSetDictionary does not</span></div>
<divclass="line"><aname="l00614"></a><spanclass="lineno"> 614</span> <spanclass="comment"> perform any compression: this will be done by deflate().</span></div>
<divclass="line"><aname="l00620"></a><spanclass="lineno"> 620</span> <spanclass="comment"> Sets the destination stream as a complete copy of the source stream.</span></div>
<divclass="line"><aname="l00622"></a><spanclass="lineno"> 622</span> <spanclass="comment"> This function can be useful when several compression strategies will be</span></div>
<divclass="line"><aname="l00623"></a><spanclass="lineno"> 623</span> <spanclass="comment"> tried, for example when there are several ways of pre-processing the input</span></div>
<divclass="line"><aname="l00624"></a><spanclass="lineno"> 624</span> <spanclass="comment"> data with a filter. The streams that will be discarded should then be freed</span></div>
<divclass="line"><aname="l00625"></a><spanclass="lineno"> 625</span> <spanclass="comment"> by calling deflateEnd. Note that deflateCopy duplicates the internal</span></div>
<divclass="line"><aname="l00626"></a><spanclass="lineno"> 626</span> <spanclass="comment"> compression state which can be quite large, so this strategy is slow and can</span></div>
<divclass="line"><aname="l00627"></a><spanclass="lineno"> 627</span> <spanclass="comment"> consume lots of memory.</span></div>
<divclass="line"><aname="l00629"></a><spanclass="lineno"> 629</span> <spanclass="comment"> deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not</span></div>
<divclass="line"><aname="l00630"></a><spanclass="lineno"> 630</span> <spanclass="comment"> enough memory, Z_STREAM_ERROR if the source stream state was inconsistent</span></div>
<divclass="line"><aname="l00631"></a><spanclass="lineno"> 631</span> <spanclass="comment"> (such as zalloc being Z_NULL). msg is left unchanged in both source and</span></div>
<divclass="line"><aname="l00637"></a><spanclass="lineno"> 637</span> <spanclass="comment"> This function is equivalent to deflateEnd followed by deflateInit,</span></div>
<divclass="line"><aname="l00638"></a><spanclass="lineno"> 638</span> <spanclass="comment"> but does not free and reallocate all the internal compression state. The</span></div>
<divclass="line"><aname="l00639"></a><spanclass="lineno"> 639</span> <spanclass="comment"> stream will keep the same compression level and any other attributes that</span></div>
<divclass="line"><aname="l00640"></a><spanclass="lineno"> 640</span> <spanclass="comment"> may have been set by deflateInit2.</span></div>
<divclass="line"><aname="l00642"></a><spanclass="lineno"> 642</span> <spanclass="comment"> deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source</span></div>
<divclass="line"><aname="l00643"></a><spanclass="lineno"> 643</span> <spanclass="comment"> stream state was inconsistent (such as zalloc or state being Z_NULL).</span></div>
<divclass="line"><aname="l00650"></a><spanclass="lineno"> 650</span> <spanclass="comment"> Dynamically update the compression level and compression strategy. The</span></div>
<divclass="line"><aname="l00651"></a><spanclass="lineno"> 651</span> <spanclass="comment"> interpretation of level and strategy is as in deflateInit2. This can be</span></div>
<divclass="line"><aname="l00652"></a><spanclass="lineno"> 652</span> <spanclass="comment"> used to switch between compression and straight copy of the input data, or</span></div>
<divclass="line"><aname="l00653"></a><spanclass="lineno"> 653</span> <spanclass="comment"> to switch to a different kind of input data requiring a different strategy.</span></div>
<divclass="line"><aname="l00654"></a><spanclass="lineno"> 654</span> <spanclass="comment"> If the compression level is changed, the input available so far is</span></div>
<divclass="line"><aname="l00655"></a><spanclass="lineno"> 655</span> <spanclass="comment"> compressed with the old level (and may be flushed); the new level will take</span></div>
<divclass="line"><aname="l00656"></a><spanclass="lineno"> 656</span> <spanclass="comment"> effect only at the next call of deflate().</span></div>
<divclass="line"><aname="l00658"></a><spanclass="lineno"> 658</span> <spanclass="comment"> Before the call of deflateParams, the stream state must be set as for</span></div>
<divclass="line"><aname="l00659"></a><spanclass="lineno"> 659</span> <spanclass="comment"> a call of deflate(), since the currently available input may have to be</span></div>
<divclass="line"><aname="l00660"></a><spanclass="lineno"> 660</span> <spanclass="comment"> compressed and flushed. In particular, strm->avail_out must be non-zero.</span></div>
<divclass="line"><aname="l00662"></a><spanclass="lineno"> 662</span> <spanclass="comment"> deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source</span></div>
<divclass="line"><aname="l00663"></a><spanclass="lineno"> 663</span> <spanclass="comment"> stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR if</span></div>
<divclass="line"><aname="l00664"></a><spanclass="lineno"> 664</span> <spanclass="comment"> strm->avail_out was zero.</span></div>
<divclass="line"><aname="l00673"></a><spanclass="lineno"> 673</span> <spanclass="comment"> Fine tune deflate's internal compression parameters. This should only be</span></div>
<divclass="line"><aname="l00674"></a><spanclass="lineno"> 674</span> <spanclass="comment"> used by someone who understands the algorithm used by zlib's deflate for</span></div>
<divclass="line"><aname="l00675"></a><spanclass="lineno"> 675</span> <spanclass="comment"> searching for the best matching string, and even then only by the most</span></div>
<divclass="line"><aname="l00676"></a><spanclass="lineno"> 676</span> <spanclass="comment"> fanatic optimizer trying to squeeze out the last compressed bit for their</span></div>
<divclass="line"><aname="l00677"></a><spanclass="lineno"> 677</span> <spanclass="comment"> specific input data. Read the deflate.c source code for the meaning of the</span></div>
<divclass="line"><aname="l00678"></a><spanclass="lineno"> 678</span> <spanclass="comment"> max_lazy, good_length, nice_length, and max_chain parameters.</span></div>
<divclass="line"><aname="l00680"></a><spanclass="lineno"> 680</span> <spanclass="comment"> deflateTune() can be called after deflateInit() or deflateInit2(), and</span></div>
<divclass="line"><aname="l00681"></a><spanclass="lineno"> 681</span> <spanclass="comment"> returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream.</span></div>
<divclass="line"><aname="l00687"></a><spanclass="lineno"> 687</span> <spanclass="comment"> deflateBound() returns an upper bound on the compressed size after</span></div>
<divclass="line"><aname="l00688"></a><spanclass="lineno"> 688</span> <spanclass="comment"> deflation of sourceLen bytes. It must be called after deflateInit() or</span></div>
<divclass="line"><aname="l00689"></a><spanclass="lineno"> 689</span> <spanclass="comment"> deflateInit2(), and after deflateSetHeader(), if used. This would be used</span></div>
<divclass="line"><aname="l00690"></a><spanclass="lineno"> 690</span> <spanclass="comment"> to allocate an output buffer for deflation in a single pass, and so would be</span></div>
<divclass="line"><aname="l00691"></a><spanclass="lineno"> 691</span> <spanclass="comment"> called before deflate().</span></div>
<divclass="line"><aname="l00698"></a><spanclass="lineno"> 698</span> <spanclass="comment"> deflatePrime() inserts bits in the deflate output stream. The intent</span></div>
<divclass="line"><aname="l00699"></a><spanclass="lineno"> 699</span> <spanclass="comment"> is that this function is used to start off the deflate output with the bits</span></div>
<divclass="line"><aname="l00700"></a><spanclass="lineno"> 700</span> <spanclass="comment"> leftover from a previous deflate stream when appending to it. As such, this</span></div>
<divclass="line"><aname="l00701"></a><spanclass="lineno"> 701</span> <spanclass="comment"> function can only be used for raw deflate, and must be used before the first</span></div>
<divclass="line"><aname="l00702"></a><spanclass="lineno"> 702</span> <spanclass="comment"> deflate() call after a deflateInit2() or deflateReset(). bits must be less</span></div>
<divclass="line"><aname="l00703"></a><spanclass="lineno"> 703</span> <spanclass="comment"> than or equal to 16, and that many of the least significant bits of value</span></div>
<divclass="line"><aname="l00704"></a><spanclass="lineno"> 704</span> <spanclass="comment"> will be inserted in the output.</span></div>
<divclass="line"><aname="l00706"></a><spanclass="lineno"> 706</span> <spanclass="comment"> deflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source</span></div>
<divclass="line"><aname="l00707"></a><spanclass="lineno"> 707</span> <spanclass="comment"> stream state was inconsistent.</span></div>
<divclass="line"><aname="l00713"></a><spanclass="lineno"> 713</span> <spanclass="comment"> deflateSetHeader() provides gzip header information for when a gzip</span></div>
<divclass="line"><aname="l00714"></a><spanclass="lineno"> 714</span> <spanclass="comment"> stream is requested by deflateInit2(). deflateSetHeader() may be called</span></div>
<divclass="line"><aname="l00715"></a><spanclass="lineno"> 715</span> <spanclass="comment"> after deflateInit2() or deflateReset() and before the first call of</span></div>
<divclass="line"><aname="l00716"></a><spanclass="lineno"> 716</span> <spanclass="comment"> deflate(). The text, time, os, extra field, name, and comment information</span></div>
<divclass="line"><aname="l00717"></a><spanclass="lineno"> 717</span> <spanclass="comment"> in the provided gz_header structure are written to the gzip header (xflag is</span></div>
<divclass="line"><aname="l00718"></a><spanclass="lineno"> 718</span> <spanclass="comment"> ignored -- the extra flags are set according to the compression level). The</span></div>
<divclass="line"><aname="l00719"></a><spanclass="lineno"> 719</span> <spanclass="comment"> caller must assure that, if not Z_NULL, name and comment are terminated with</span></div>
<divclass="line"><aname="l00720"></a><spanclass="lineno"> 720</span> <spanclass="comment"> a zero byte, and that if extra is not Z_NULL, that extra_len bytes are</span></div>
<divclass="line"><aname="l00721"></a><spanclass="lineno"> 721</span> <spanclass="comment"> available there. If hcrc is true, a gzip header crc is included. Note that</span></div>
<divclass="line"><aname="l00722"></a><spanclass="lineno"> 722</span> <spanclass="comment"> the current versions of the command-line version of gzip (up through version</span></div>
<divclass="line"><aname="l00723"></a><spanclass="lineno"> 723</span> <spanclass="comment"> 1.3.x) do not support header crc's, and will report that it is a "multi-part</span></div>
<divclass="line"><aname="l00724"></a><spanclass="lineno"> 724</span> <spanclass="comment"> gzip file" and give up.</span></div>
<divclass="line"><aname="l00726"></a><spanclass="lineno"> 726</span> <spanclass="comment"> If deflateSetHeader is not used, the default gzip header has text false,</span></div>
<divclass="line"><aname="l00727"></a><spanclass="lineno"> 727</span> <spanclass="comment"> the time set to zero, and os set to 255, with no extra, name, or comment</span></div>
<divclass="line"><aname="l00728"></a><spanclass="lineno"> 728</span> <spanclass="comment"> fields. The gzip header is returned to the default state by deflateReset().</span></div>
<divclass="line"><aname="l00730"></a><spanclass="lineno"> 730</span> <spanclass="comment"> deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source</span></div>
<divclass="line"><aname="l00731"></a><spanclass="lineno"> 731</span> <spanclass="comment"> stream state was inconsistent.</span></div>
<divclass="line"><aname="l00738"></a><spanclass="lineno"> 738</span> <spanclass="comment"> This is another version of inflateInit with an extra parameter. The</span></div>
<divclass="line"><aname="l00739"></a><spanclass="lineno"> 739</span> <spanclass="comment"> fields next_in, avail_in, zalloc, zfree and opaque must be initialized</span></div>
<divclass="line"><aname="l00740"></a><spanclass="lineno"> 740</span> <spanclass="comment"> before by the caller.</span></div>
<divclass="line"><aname="l00742"></a><spanclass="lineno"> 742</span> <spanclass="comment"> The windowBits parameter is the base two logarithm of the maximum window</span></div>
<divclass="line"><aname="l00743"></a><spanclass="lineno"> 743</span> <spanclass="comment"> size (the size of the history buffer). It should be in the range 8..15 for</span></div>
<divclass="line"><aname="l00744"></a><spanclass="lineno"> 744</span> <spanclass="comment"> this version of the library. The default value is 15 if inflateInit is used</span></div>
<divclass="line"><aname="l00745"></a><spanclass="lineno"> 745</span> <spanclass="comment"> instead. windowBits must be greater than or equal to the windowBits value</span></div>
<divclass="line"><aname="l00746"></a><spanclass="lineno"> 746</span> <spanclass="comment"> provided to deflateInit2() while compressing, or it must be equal to 15 if</span></div>
<divclass="line"><aname="l00747"></a><spanclass="lineno"> 747</span> <spanclass="comment"> deflateInit2() was not used. If a compressed stream with a larger window</span></div>
<divclass="line"><aname="l00748"></a><spanclass="lineno"> 748</span> <spanclass="comment"> size is given as input, inflate() will return with the error code</span></div>
<divclass="line"><aname="l00749"></a><spanclass="lineno"> 749</span> <spanclass="comment"> Z_DATA_ERROR instead of trying to allocate a larger window.</span></div>
<divclass="line"><aname="l00751"></a><spanclass="lineno"> 751</span> <spanclass="comment"> windowBits can also be zero to request that inflate use the window size in</span></div>
<divclass="line"><aname="l00752"></a><spanclass="lineno"> 752</span> <spanclass="comment"> the zlib header of the compressed stream.</span></div>
<divclass="line"><aname="l00754"></a><spanclass="lineno"> 754</span> <spanclass="comment"> windowBits can also be -8..-15 for raw inflate. In this case, -windowBits</span></div>
<divclass="line"><aname="l00755"></a><spanclass="lineno"> 755</span> <spanclass="comment"> determines the window size. inflate() will then process raw deflate data,</span></div>
<divclass="line"><aname="l00756"></a><spanclass="lineno"> 756</span> <spanclass="comment"> not looking for a zlib or gzip header, not generating a check value, and not</span></div>
<divclass="line"><aname="l00757"></a><spanclass="lineno"> 757</span> <spanclass="comment"> looking for any check values for comparison at the end of the stream. This</span></div>
<divclass="line"><aname="l00758"></a><spanclass="lineno"> 758</span> <spanclass="comment"> is for use with other formats that use the deflate compressed data format</span></div>
<divclass="line"><aname="l00759"></a><spanclass="lineno"> 759</span> <spanclass="comment"> such as zip. Those formats provide their own check values. If a custom</span></div>
<divclass="line"><aname="l00760"></a><spanclass="lineno"> 760</span> <spanclass="comment"> format is developed using the raw deflate format for compressed data, it is</span></div>
<divclass="line"><aname="l00761"></a><spanclass="lineno"> 761</span> <spanclass="comment"> recommended that a check value such as an adler32 or a crc32 be applied to</span></div>
<divclass="line"><aname="l00762"></a><spanclass="lineno"> 762</span> <spanclass="comment"> the uncompressed data as is done in the zlib, gzip, and zip formats. For</span></div>
<divclass="line"><aname="l00763"></a><spanclass="lineno"> 763</span> <spanclass="comment"> most applications, the zlib format should be used as is. Note that comments</span></div>
<divclass="line"><aname="l00764"></a><spanclass="lineno"> 764</span> <spanclass="comment"> above on the use in deflateInit2() applies to the magnitude of windowBits.</span></div>
<divclass="line"><aname="l00766"></a><spanclass="lineno"> 766</span> <spanclass="comment"> windowBits can also be greater than 15 for optional gzip decoding. Add</span></div>
<divclass="line"><aname="l00767"></a><spanclass="lineno"> 767</span> <spanclass="comment"> 32 to windowBits to enable zlib and gzip decoding with automatic header</span></div>
<divclass="line"><aname="l00768"></a><spanclass="lineno"> 768</span> <spanclass="comment"> detection, or add 16 to decode only the gzip format (the zlib format will</span></div>
<divclass="line"><aname="l00769"></a><spanclass="lineno"> 769</span> <spanclass="comment"> return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler is a</span></div>
<divclass="line"><aname="l00770"></a><spanclass="lineno"> 770</span> <spanclass="comment"> crc32 instead of an adler32.</span></div>
<divclass="line"><aname="l00772"></a><spanclass="lineno"> 772</span> <spanclass="comment"> inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough</span></div>
<divclass="line"><aname="l00773"></a><spanclass="lineno"> 773</span> <spanclass="comment"> memory, Z_VERSION_ERROR if the zlib library version is incompatible with the</span></div>
<divclass="line"><aname="l00774"></a><spanclass="lineno"> 774</span> <spanclass="comment"> version assumed by the caller, or Z_STREAM_ERROR if the parameters are</span></div>
<divclass="line"><aname="l00775"></a><spanclass="lineno"> 775</span> <spanclass="comment"> invalid, such as a null pointer to the structure. msg is set to null if</span></div>
<divclass="line"><aname="l00776"></a><spanclass="lineno"> 776</span> <spanclass="comment"> there is no error message. inflateInit2 does not perform any decompression</span></div>
<divclass="line"><aname="l00777"></a><spanclass="lineno"> 777</span> <spanclass="comment"> apart from possibly reading the zlib header if present: actual decompression</span></div>
<divclass="line"><aname="l00778"></a><spanclass="lineno"> 778</span> <spanclass="comment"> will be done by inflate(). (So next_in and avail_in may be modified, but</span></div>
<divclass="line"><aname="l00779"></a><spanclass="lineno"> 779</span> <spanclass="comment"> next_out and avail_out are unused and unchanged.) The current implementation</span></div>
<divclass="line"><aname="l00780"></a><spanclass="lineno"> 780</span> <spanclass="comment"> of inflateInit2() does not process any header information -- that is</span></div>
<divclass="line"><aname="l00781"></a><spanclass="lineno"> 781</span> <spanclass="comment"> deferred until inflate() is called.</span></div>
<divclass="line"><aname="l00788"></a><spanclass="lineno"> 788</span> <spanclass="comment"> Initializes the decompression dictionary from the given uncompressed byte</span></div>
<divclass="line"><aname="l00789"></a><spanclass="lineno"> 789</span> <spanclass="comment"> sequence. This function must be called immediately after a call of inflate,</span></div>
<divclass="line"><aname="l00790"></a><spanclass="lineno"> 790</span> <spanclass="comment"> if that call returned Z_NEED_DICT. The dictionary chosen by the compressor</span></div>
<divclass="line"><aname="l00791"></a><spanclass="lineno"> 791</span> <spanclass="comment"> can be determined from the adler32 value returned by that call of inflate.</span></div>
<divclass="line"><aname="l00792"></a><spanclass="lineno"> 792</span> <spanclass="comment"> The compressor and decompressor must use exactly the same dictionary (see</span></div>
<divclass="line"><aname="l00793"></a><spanclass="lineno"> 793</span> <spanclass="comment"> deflateSetDictionary). For raw inflate, this function can be called</span></div>
<divclass="line"><aname="l00794"></a><spanclass="lineno"> 794</span> <spanclass="comment"> immediately after inflateInit2() or inflateReset() and before any call of</span></div>
<divclass="line"><aname="l00795"></a><spanclass="lineno"> 795</span> <spanclass="comment"> inflate() to set the dictionary. The application must insure that the</span></div>
<divclass="line"><aname="l00796"></a><spanclass="lineno"> 796</span> <spanclass="comment"> dictionary that was used for compression is provided.</span></div>
<divclass="line"><aname="l00798"></a><spanclass="lineno"> 798</span> <spanclass="comment"> inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a</span></div>
<divclass="line"><aname="l00799"></a><spanclass="lineno"> 799</span> <spanclass="comment"> parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is</span></div>
<divclass="line"><aname="l00800"></a><spanclass="lineno"> 800</span> <spanclass="comment"> inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the</span></div>
<divclass="line"><aname="l00801"></a><spanclass="lineno"> 801</span> <spanclass="comment"> expected one (incorrect adler32 value). inflateSetDictionary does not</span></div>
<divclass="line"><aname="l00802"></a><spanclass="lineno"> 802</span> <spanclass="comment"> perform any decompression: this will be done by subsequent calls of</span></div>
<divclass="line"><aname="l00808"></a><spanclass="lineno"> 808</span> <spanclass="comment"> Skips invalid compressed data until a full flush point (see above the</span></div>
<divclass="line"><aname="l00809"></a><spanclass="lineno"> 809</span> <spanclass="comment"> description of deflate with Z_FULL_FLUSH) can be found, or until all</span></div>
<divclass="line"><aname="l00810"></a><spanclass="lineno"> 810</span> <spanclass="comment"> available input is skipped. No output is provided.</span></div>
<divclass="line"><aname="l00812"></a><spanclass="lineno"> 812</span> <spanclass="comment"> inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR</span></div>
<divclass="line"><aname="l00813"></a><spanclass="lineno"> 813</span> <spanclass="comment"> if no more input was provided, Z_DATA_ERROR if no flush point has been</span></div>
<divclass="line"><aname="l00814"></a><spanclass="lineno"> 814</span> <spanclass="comment"> found, or Z_STREAM_ERROR if the stream structure was inconsistent. In the</span></div>
<divclass="line"><aname="l00815"></a><spanclass="lineno"> 815</span> <spanclass="comment"> success case, the application may save the current current value of total_in</span></div>
<divclass="line"><aname="l00816"></a><spanclass="lineno"> 816</span> <spanclass="comment"> which indicates where valid compressed data was found. In the error case,</span></div>
<divclass="line"><aname="l00817"></a><spanclass="lineno"> 817</span> <spanclass="comment"> the application may repeatedly call inflateSync, providing more input each</span></div>
<divclass="line"><aname="l00818"></a><spanclass="lineno"> 818</span> <spanclass="comment"> time, until success or end of the input data.</span></div>
<divclass="line"><aname="l00824"></a><spanclass="lineno"> 824</span> <spanclass="comment"> Sets the destination stream as a complete copy of the source stream.</span></div>
<divclass="line"><aname="l00826"></a><spanclass="lineno"> 826</span> <spanclass="comment"> This function can be useful when randomly accessing a large stream. The</span></div>
<divclass="line"><aname="l00827"></a><spanclass="lineno"> 827</span> <spanclass="comment"> first pass through the stream can periodically record the inflate state,</span></div>
<divclass="line"><aname="l00828"></a><spanclass="lineno"> 828</span> <spanclass="comment"> allowing restarting inflate at those points when randomly accessing the</span></div>
<divclass="line"><aname="l00831"></a><spanclass="lineno"> 831</span> <spanclass="comment"> inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not</span></div>
<divclass="line"><aname="l00832"></a><spanclass="lineno"> 832</span> <spanclass="comment"> enough memory, Z_STREAM_ERROR if the source stream state was inconsistent</span></div>
<divclass="line"><aname="l00833"></a><spanclass="lineno"> 833</span> <spanclass="comment"> (such as zalloc being Z_NULL). msg is left unchanged in both source and</span></div>
<divclass="line"><aname="l00839"></a><spanclass="lineno"> 839</span> <spanclass="comment"> This function is equivalent to inflateEnd followed by inflateInit,</span></div>
<divclass="line"><aname="l00840"></a><spanclass="lineno"> 840</span> <spanclass="comment"> but does not free and reallocate all the internal decompression state. The</span></div>
<divclass="line"><aname="l00841"></a><spanclass="lineno"> 841</span> <spanclass="comment"> stream will keep attributes that may have been set by inflateInit2.</span></div>
<divclass="line"><aname="l00843"></a><spanclass="lineno"> 843</span> <spanclass="comment"> inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source</span></div>
<divclass="line"><aname="l00844"></a><spanclass="lineno"> 844</span> <spanclass="comment"> stream state was inconsistent (such as zalloc or state being Z_NULL).</span></div>
<divclass="line"><aname="l00850"></a><spanclass="lineno"> 850</span> <spanclass="comment"> This function is the same as inflateReset, but it also permits changing</span></div>
<divclass="line"><aname="l00851"></a><spanclass="lineno"> 851</span> <spanclass="comment"> the wrap and window size requests. The windowBits parameter is interpreted</span></div>
<divclass="line"><aname="l00852"></a><spanclass="lineno"> 852</span> <spanclass="comment"> the same as it is for inflateInit2.</span></div>
<divclass="line"><aname="l00854"></a><spanclass="lineno"> 854</span> <spanclass="comment"> inflateReset2 returns Z_OK if success, or Z_STREAM_ERROR if the source</span></div>
<divclass="line"><aname="l00855"></a><spanclass="lineno"> 855</span> <spanclass="comment"> stream state was inconsistent (such as zalloc or state being Z_NULL), or if</span></div>
<divclass="line"><aname="l00856"></a><spanclass="lineno"> 856</span> <spanclass="comment"> the windowBits parameter is invalid.</span></div>
<divclass="line"><aname="l00863"></a><spanclass="lineno"> 863</span> <spanclass="comment"> This function inserts bits in the inflate input stream. The intent is</span></div>
<divclass="line"><aname="l00864"></a><spanclass="lineno"> 864</span> <spanclass="comment"> that this function is used to start inflating at a bit position in the</span></div>
<divclass="line"><aname="l00865"></a><spanclass="lineno"> 865</span> <spanclass="comment"> middle of a byte. The provided bits will be used before any bytes are used</span></div>
<divclass="line"><aname="l00866"></a><spanclass="lineno"> 866</span> <spanclass="comment"> from next_in. This function should only be used with raw inflate, and</span></div>
<divclass="line"><aname="l00867"></a><spanclass="lineno"> 867</span> <spanclass="comment"> should be used before the first inflate() call after inflateInit2() or</span></div>
<divclass="line"><aname="l00868"></a><spanclass="lineno"> 868</span> <spanclass="comment"> inflateReset(). bits must be less than or equal to 16, and that many of the</span></div>
<divclass="line"><aname="l00869"></a><spanclass="lineno"> 869</span> <spanclass="comment"> least significant bits of value will be inserted in the input.</span></div>
<divclass="line"><aname="l00871"></a><spanclass="lineno"> 871</span> <spanclass="comment"> If bits is negative, then the input stream bit buffer is emptied. Then</span></div>
<divclass="line"><aname="l00872"></a><spanclass="lineno"> 872</span> <spanclass="comment"> inflatePrime() can be called again to put bits in the buffer. This is used</span></div>
<divclass="line"><aname="l00873"></a><spanclass="lineno"> 873</span> <spanclass="comment"> to clear out bits leftover after feeding inflate a block description prior</span></div>
<divclass="line"><aname="l00874"></a><spanclass="lineno"> 874</span> <spanclass="comment"> to feeding inflate codes.</span></div>
<divclass="line"><aname="l00876"></a><spanclass="lineno"> 876</span> <spanclass="comment"> inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source</span></div>
<divclass="line"><aname="l00877"></a><spanclass="lineno"> 877</span> <spanclass="comment"> stream state was inconsistent.</span></div>
<divclass="line"><aname="l00882"></a><spanclass="lineno"> 882</span> <spanclass="comment"> This function returns two values, one in the lower 16 bits of the return</span></div>
<divclass="line"><aname="l00883"></a><spanclass="lineno"> 883</span> <spanclass="comment"> value, and the other in the remaining upper bits, obtained by shifting the</span></div>
<divclass="line"><aname="l00884"></a><spanclass="lineno"> 884</span> <spanclass="comment"> return value down 16 bits. If the upper value is -1 and the lower value is</span></div>
<divclass="line"><aname="l00885"></a><spanclass="lineno"> 885</span> <spanclass="comment"> zero, then inflate() is currently decoding information outside of a block.</span></div>
<divclass="line"><aname="l00886"></a><spanclass="lineno"> 886</span> <spanclass="comment"> If the upper value is -1 and the lower value is non-zero, then inflate is in</span></div>
<divclass="line"><aname="l00887"></a><spanclass="lineno"> 887</span> <spanclass="comment"> the middle of a stored block, with the lower value equaling the number of</span></div>
<divclass="line"><aname="l00888"></a><spanclass="lineno"> 888</span> <spanclass="comment"> bytes from the input remaining to copy. If the upper value is not -1, then</span></div>
<divclass="line"><aname="l00889"></a><spanclass="lineno"> 889</span> <spanclass="comment"> it is the number of bits back from the current bit position in the input of</span></div>
<divclass="line"><aname="l00890"></a><spanclass="lineno"> 890</span> <spanclass="comment"> the code (literal or length/distance pair) currently being processed. In</span></div>
<divclass="line"><aname="l00891"></a><spanclass="lineno"> 891</span> <spanclass="comment"> that case the lower value is the number of bytes already emitted for that</span></div>
<divclass="line"><aname="l00894"></a><spanclass="lineno"> 894</span> <spanclass="comment"> A code is being processed if inflate is waiting for more input to complete</span></div>
<divclass="line"><aname="l00895"></a><spanclass="lineno"> 895</span> <spanclass="comment"> decoding of the code, or if it has completed decoding but is waiting for</span></div>
<divclass="line"><aname="l00896"></a><spanclass="lineno"> 896</span> <spanclass="comment"> more output space to write the literal or match data.</span></div>
<divclass="line"><aname="l00898"></a><spanclass="lineno"> 898</span> <spanclass="comment"> inflateMark() is used to mark locations in the input data for random</span></div>
<divclass="line"><aname="l00899"></a><spanclass="lineno"> 899</span> <spanclass="comment"> access, which may be at bit positions, and to note those cases where the</span></div>
<divclass="line"><aname="l00900"></a><spanclass="lineno"> 900</span> <spanclass="comment"> output of a code may span boundaries of random access blocks. The current</span></div>
<divclass="line"><aname="l00901"></a><spanclass="lineno"> 901</span> <spanclass="comment"> location in the input stream can be determined from avail_in and data_type</span></div>
<divclass="line"><aname="l00902"></a><spanclass="lineno"> 902</span> <spanclass="comment"> as noted in the description for the Z_BLOCK flush parameter for inflate.</span></div>
<divclass="line"><aname="l00904"></a><spanclass="lineno"> 904</span> <spanclass="comment"> inflateMark returns the value noted above or -1 << 16 if the provided</span></div>
<divclass="line"><aname="l00905"></a><spanclass="lineno"> 905</span> <spanclass="comment"> source stream state was inconsistent.</span></div>
<divclass="line"><aname="l00911"></a><spanclass="lineno"> 911</span> <spanclass="comment"> inflateGetHeader() requests that gzip header information be stored in the</span></div>
<divclass="line"><aname="l00912"></a><spanclass="lineno"> 912</span> <spanclass="comment"> provided gz_header structure. inflateGetHeader() may be called after</span></div>
<divclass="line"><aname="l00913"></a><spanclass="lineno"> 913</span> <spanclass="comment"> inflateInit2() or inflateReset(), and before the first call of inflate().</span></div>
<divclass="line"><aname="l00914"></a><spanclass="lineno"> 914</span> <spanclass="comment"> As inflate() processes the gzip stream, head->done is zero until the header</span></div>
<divclass="line"><aname="l00915"></a><spanclass="lineno"> 915</span> <spanclass="comment"> is completed, at which time head->done is set to one. If a zlib stream is</span></div>
<divclass="line"><aname="l00916"></a><spanclass="lineno"> 916</span> <spanclass="comment"> being decoded, then head->done is set to -1 to indicate that there will be</span></div>
<divclass="line"><aname="l00917"></a><spanclass="lineno"> 917</span> <spanclass="comment"> no gzip header information forthcoming. Note that Z_BLOCK or Z_TREES can be</span></div>
<divclass="line"><aname="l00918"></a><spanclass="lineno"> 918</span> <spanclass="comment"> used to force inflate() to return immediately after header processing is</span></div>
<divclass="line"><aname="l00919"></a><spanclass="lineno"> 919</span> <spanclass="comment"> complete and before any actual data is decompressed.</span></div>
<divclass="line"><aname="l00921"></a><spanclass="lineno"> 921</span> <spanclass="comment"> The text, time, xflags, and os fields are filled in with the gzip header</span></div>
<divclass="line"><aname="l00922"></a><spanclass="lineno"> 922</span> <spanclass="comment"> contents. hcrc is set to true if there is a header CRC. (The header CRC</span></div>
<divclass="line"><aname="l00923"></a><spanclass="lineno"> 923</span> <spanclass="comment"> was valid if done is set to one.) If extra is not Z_NULL, then extra_max</span></div>
<divclass="line"><aname="l00924"></a><spanclass="lineno"> 924</span> <spanclass="comment"> contains the maximum number of bytes to write to extra. Once done is true,</span></div>
<divclass="line"><aname="l00925"></a><spanclass="lineno"> 925</span> <spanclass="comment"> extra_len contains the actual extra field length, and extra contains the</span></div>
<divclass="line"><aname="l00926"></a><spanclass="lineno"> 926</span> <spanclass="comment"> extra field, or that field truncated if extra_max is less than extra_len.</span></div>
<divclass="line"><aname="l00927"></a><spanclass="lineno"> 927</span> <spanclass="comment"> If name is not Z_NULL, then up to name_max characters are written there,</span></div>
<divclass="line"><aname="l00928"></a><spanclass="lineno"> 928</span> <spanclass="comment"> terminated with a zero unless the length is greater than name_max. If</span></div>
<divclass="line"><aname="l00929"></a><spanclass="lineno"> 929</span> <spanclass="comment"> comment is not Z_NULL, then up to comm_max characters are written there,</span></div>
<divclass="line"><aname="l00930"></a><spanclass="lineno"> 930</span> <spanclass="comment"> terminated with a zero unless the length is greater than comm_max. When any</span></div>
<divclass="line"><aname="l00931"></a><spanclass="lineno"> 931</span> <spanclass="comment"> of extra, name, or comment are not Z_NULL and the respective field is not</span></div>
<divclass="line"><aname="l00932"></a><spanclass="lineno"> 932</span> <spanclass="comment"> present in the header, then that field is set to Z_NULL to signal its</span></div>
<divclass="line"><aname="l00933"></a><spanclass="lineno"> 933</span> <spanclass="comment"> absence. This allows the use of deflateSetHeader() with the returned</span></div>
<divclass="line"><aname="l00934"></a><spanclass="lineno"> 934</span> <spanclass="comment"> structure to duplicate the header. However if those fields are set to</span></div>
<divclass="line"><aname="l00935"></a><spanclass="lineno"> 935</span> <spanclass="comment"> allocated memory, then the application will need to save those pointers</span></div>
<divclass="line"><aname="l00936"></a><spanclass="lineno"> 936</span> <spanclass="comment"> elsewhere so that they can be eventually freed.</span></div>
<divclass="line"><aname="l00938"></a><spanclass="lineno"> 938</span> <spanclass="comment"> If inflateGetHeader is not used, then the header information is simply</span></div>
<divclass="line"><aname="l00939"></a><spanclass="lineno"> 939</span> <spanclass="comment"> discarded. The header is always checked for validity, including the header</span></div>
<divclass="line"><aname="l00940"></a><spanclass="lineno"> 940</span> <spanclass="comment"> CRC if present. inflateReset() will reset the process to discard the header</span></div>
<divclass="line"><aname="l00941"></a><spanclass="lineno"> 941</span> <spanclass="comment"> information. The application would need to call inflateGetHeader() again to</span></div>
<divclass="line"><aname="l00942"></a><spanclass="lineno"> 942</span> <spanclass="comment"> retrieve the header from the next gzip stream.</span></div>
<divclass="line"><aname="l00944"></a><spanclass="lineno"> 944</span> <spanclass="comment"> inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source</span></div>
<divclass="line"><aname="l00945"></a><spanclass="lineno"> 945</span> <spanclass="comment"> stream state was inconsistent.</span></div>
<divclass="line"><aname="l00949"></a><spanclass="lineno"> 949</span> <spanclass="comment">ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits,</span></div>
<divclass="line"><aname="l00950"></a><spanclass="lineno"> 950</span> <spanclass="comment"> unsigned char FAR *window));</span></div>
<divclass="line"><aname="l00952"></a><spanclass="lineno"> 952</span> <spanclass="comment"> Initialize the internal stream state for decompression using inflateBack()</span></div>
<divclass="line"><aname="l00953"></a><spanclass="lineno"> 953</span> <spanclass="comment"> calls. The fields zalloc, zfree and opaque in strm must be initialized</span></div>
<divclass="line"><aname="l00954"></a><spanclass="lineno"> 954</span> <spanclass="comment"> before the call. If zalloc and zfree are Z_NULL, then the default library-</span></div>
<divclass="line"><aname="l00955"></a><spanclass="lineno"> 955</span> <spanclass="comment"> derived memory allocation routines are used. windowBits is the base two</span></div>
<divclass="line"><aname="l00956"></a><spanclass="lineno"> 956</span> <spanclass="comment"> logarithm of the window size, in the range 8..15. window is a caller</span></div>
<divclass="line"><aname="l00957"></a><spanclass="lineno"> 957</span> <spanclass="comment"> supplied buffer of that size. Except for special applications where it is</span></div>
<divclass="line"><aname="l00958"></a><spanclass="lineno"> 958</span> <spanclass="comment"> assured that deflate was used with small window sizes, windowBits must be 15</span></div>
<divclass="line"><aname="l00959"></a><spanclass="lineno"> 959</span> <spanclass="comment"> and a 32K byte window must be supplied to be able to decompress general</span></div>
<divclass="line"><aname="l00962"></a><spanclass="lineno"> 962</span> <spanclass="comment"> See inflateBack() for the usage of these routines.</span></div>
<divclass="line"><aname="l00964"></a><spanclass="lineno"> 964</span> <spanclass="comment"> inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of</span></div>
<divclass="line"><aname="l00965"></a><spanclass="lineno"> 965</span> <spanclass="comment"> the paramaters are invalid, Z_MEM_ERROR if the internal state could not be</span></div>
<divclass="line"><aname="l00966"></a><spanclass="lineno"> 966</span> <spanclass="comment"> allocated, or Z_VERSION_ERROR if the version of the library does not match</span></div>
<divclass="line"><aname="l00967"></a><spanclass="lineno"> 967</span> <spanclass="comment"> the version of the header file.</span></div>
<divclass="line"><aname="l00977"></a><spanclass="lineno"> 977</span> <spanclass="comment"> inflateBack() does a raw inflate with a single call using a call-back</span></div>
<divclass="line"><aname="l00978"></a><spanclass="lineno"> 978</span> <spanclass="comment"> interface for input and output. This is more efficient than inflate() for</span></div>
<divclass="line"><aname="l00979"></a><spanclass="lineno"> 979</span> <spanclass="comment"> file i/o applications in that it avoids copying between the output and the</span></div>
<divclass="line"><aname="l00980"></a><spanclass="lineno"> 980</span> <spanclass="comment"> sliding window by simply making the window itself the output buffer. This</span></div>
<divclass="line"><aname="l00981"></a><spanclass="lineno"> 981</span> <spanclass="comment"> function trusts the application to not change the output buffer passed by</span></div>
<divclass="line"><aname="l00982"></a><spanclass="lineno"> 982</span> <spanclass="comment"> the output function, at least until inflateBack() returns.</span></div>
<divclass="line"><aname="l00984"></a><spanclass="lineno"> 984</span> <spanclass="comment"> inflateBackInit() must be called first to allocate the internal state</span></div>
<divclass="line"><aname="l00985"></a><spanclass="lineno"> 985</span> <spanclass="comment"> and to initialize the state with the user-provided window buffer.</span></div>
<divclass="line"><aname="l00986"></a><spanclass="lineno"> 986</span> <spanclass="comment"> inflateBack() may then be used multiple times to inflate a complete, raw</span></div>
<divclass="line"><aname="l00987"></a><spanclass="lineno"> 987</span> <spanclass="comment"> deflate stream with each call. inflateBackEnd() is then called to free the</span></div>
<divclass="line"><aname="l00990"></a><spanclass="lineno"> 990</span> <spanclass="comment"> A raw deflate stream is one with no zlib or gzip header or trailer.</span></div>
<divclass="line"><aname="l00991"></a><spanclass="lineno"> 991</span> <spanclass="comment"> This routine would normally be used in a utility that reads zip or gzip</span></div>
<divclass="line"><aname="l00992"></a><spanclass="lineno"> 992</span> <spanclass="comment"> files and writes out uncompressed files. The utility would decode the</span></div>
<divclass="line"><aname="l00993"></a><spanclass="lineno"> 993</span> <spanclass="comment"> header and process the trailer on its own, hence this routine expects only</span></div>
<divclass="line"><aname="l00994"></a><spanclass="lineno"> 994</span> <spanclass="comment"> the raw deflate stream to decompress. This is different from the normal</span></div>
<divclass="line"><aname="l00995"></a><spanclass="lineno"> 995</span> <spanclass="comment"> behavior of inflate(), which expects either a zlib or gzip header and</span></div>
<divclass="line"><aname="l00996"></a><spanclass="lineno"> 996</span> <spanclass="comment"> trailer around the deflate stream.</span></div>
<divclass="line"><aname="l00998"></a><spanclass="lineno"> 998</span> <spanclass="comment"> inflateBack() uses two subroutines supplied by the caller that are then</span></div>
<divclass="line"><aname="l00999"></a><spanclass="lineno"> 999</span> <spanclass="comment"> called by inflateBack() for input and output. inflateBack() calls those</span></div>
<divclass="line"><aname="l01000"></a><spanclass="lineno"> 1000</span> <spanclass="comment"> routines until it reads a complete deflate stream and writes out all of the</span></div>
<divclass="line"><aname="l01001"></a><spanclass="lineno"> 1001</span> <spanclass="comment"> uncompressed data, or until it encounters an error. The function's</span></div>
<divclass="line"><aname="l01002"></a><spanclass="lineno"> 1002</span> <spanclass="comment"> parameters and return types are defined above in the in_func and out_func</span></div>
<divclass="line"><aname="l01003"></a><spanclass="lineno"> 1003</span> <spanclass="comment"> typedefs. inflateBack() will call in(in_desc, &buf) which should return the</span></div>
<divclass="line"><aname="l01004"></a><spanclass="lineno"> 1004</span> <spanclass="comment"> number of bytes of provided input, and a pointer to that input in buf. If</span></div>
<divclass="line"><aname="l01005"></a><spanclass="lineno"> 1005</span> <spanclass="comment"> there is no input available, in() must return zero--buf is ignored in that</span></div>
<divclass="line"><aname="l01006"></a><spanclass="lineno"> 1006</span> <spanclass="comment"> case--and inflateBack() will return a buffer error. inflateBack() will call</span></div>
<divclass="line"><aname="l01007"></a><spanclass="lineno"> 1007</span> <spanclass="comment"> out(out_desc, buf, len) to write the uncompressed data buf[0..len-1]. out()</span></div>
<divclass="line"><aname="l01008"></a><spanclass="lineno"> 1008</span> <spanclass="comment"> should return zero on success, or non-zero on failure. If out() returns</span></div>
<divclass="line"><aname="l01009"></a><spanclass="lineno"> 1009</span> <spanclass="comment"> non-zero, inflateBack() will return with an error. Neither in() nor out()</span></div>
<divclass="line"><aname="l01010"></a><spanclass="lineno"> 1010</span> <spanclass="comment"> are permitted to change the contents of the window provided to</span></div>
<divclass="line"><aname="l01011"></a><spanclass="lineno"> 1011</span> <spanclass="comment"> inflateBackInit(), which is also the buffer that out() uses to write from.</span></div>
<divclass="line"><aname="l01012"></a><spanclass="lineno"> 1012</span> <spanclass="comment"> The length written by out() will be at most the window size. Any non-zero</span></div>
<divclass="line"><aname="l01013"></a><spanclass="lineno"> 1013</span> <spanclass="comment"> amount of input may be provided by in().</span></div>
<divclass="line"><aname="l01015"></a><spanclass="lineno"> 1015</span> <spanclass="comment"> For convenience, inflateBack() can be provided input on the first call by</span></div>
<divclass="line"><aname="l01016"></a><spanclass="lineno"> 1016</span> <spanclass="comment"> setting strm->next_in and strm->avail_in. If that input is exhausted, then</span></div>
<divclass="line"><aname="l01017"></a><spanclass="lineno"> 1017</span> <spanclass="comment"> in() will be called. Therefore strm->next_in must be initialized before</span></div>
<divclass="line"><aname="l01018"></a><spanclass="lineno"> 1018</span> <spanclass="comment"> calling inflateBack(). If strm->next_in is Z_NULL, then in() will be called</span></div>
<divclass="line"><aname="l01019"></a><spanclass="lineno"> 1019</span> <spanclass="comment"> immediately for input. If strm->next_in is not Z_NULL, then strm->avail_in</span></div>
<divclass="line"><aname="l01020"></a><spanclass="lineno"> 1020</span> <spanclass="comment"> must also be initialized, and then if strm->avail_in is not zero, input will</span></div>
<divclass="line"><aname="l01021"></a><spanclass="lineno"> 1021</span> <spanclass="comment"> initially be taken from strm->next_in[0 .. strm->avail_in - 1].</span></div>
<divclass="line"><aname="l01023"></a><spanclass="lineno"> 1023</span> <spanclass="comment"> The in_desc and out_desc parameters of inflateBack() is passed as the</span></div>
<divclass="line"><aname="l01024"></a><spanclass="lineno"> 1024</span> <spanclass="comment"> first parameter of in() and out() respectively when they are called. These</span></div>
<divclass="line"><aname="l01025"></a><spanclass="lineno"> 1025</span> <spanclass="comment"> descriptors can be optionally used to pass any information that the caller-</span></div>
<divclass="line"><aname="l01026"></a><spanclass="lineno"> 1026</span> <spanclass="comment"> supplied in() and out() functions need to do their job.</span></div>
<divclass="line"><aname="l01028"></a><spanclass="lineno"> 1028</span> <spanclass="comment"> On return, inflateBack() will set strm->next_in and strm->avail_in to</span></div>
<divclass="line"><aname="l01029"></a><spanclass="lineno"> 1029</span> <spanclass="comment"> pass back any unused input that was provided by the last in() call. The</span></div>
<divclass="line"><aname="l01030"></a><spanclass="lineno"> 1030</span> <spanclass="comment"> return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR</span></div>
<divclass="line"><aname="l01031"></a><spanclass="lineno"> 1031</span> <spanclass="comment"> if in() or out() returned an error, Z_DATA_ERROR if there was a format error</span></div>
<divclass="line"><aname="l01032"></a><spanclass="lineno"> 1032</span> <spanclass="comment"> in the deflate stream (in which case strm->msg is set to indicate the nature</span></div>
<divclass="line"><aname="l01033"></a><spanclass="lineno"> 1033</span> <spanclass="comment"> of the error), or Z_STREAM_ERROR if the stream was not properly initialized.</span></div>
<divclass="line"><aname="l01034"></a><spanclass="lineno"> 1034</span> <spanclass="comment"> In the case of Z_BUF_ERROR, an input or output error can be distinguished</span></div>
<divclass="line"><aname="l01035"></a><spanclass="lineno"> 1035</span> <spanclass="comment"> using strm->next_in which will be Z_NULL only if in() returned an error. If</span></div>
<divclass="line"><aname="l01036"></a><spanclass="lineno"> 1036</span> <spanclass="comment"> strm->next_in is not Z_NULL, then the Z_BUF_ERROR was due to out() returning</span></div>
<divclass="line"><aname="l01037"></a><spanclass="lineno"> 1037</span> <spanclass="comment"> non-zero. (in() will always be called before out(), so strm->next_in is</span></div>
<divclass="line"><aname="l01038"></a><spanclass="lineno"> 1038</span> <spanclass="comment"> assured to be defined if out() returns non-zero.) Note that inflateBack()</span></div>
<divclass="line"><aname="l01044"></a><spanclass="lineno"> 1044</span> <spanclass="comment"> All memory allocated by inflateBackInit() is freed.</span></div>
<divclass="line"><aname="l01046"></a><spanclass="lineno"> 1046</span> <spanclass="comment"> inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream</span></div>
<divclass="line"><aname="l01047"></a><spanclass="lineno"> 1047</span> <spanclass="comment"> state was inconsistent.</span></div>
<divclass="line"><aname="l01065"></a><spanclass="lineno"> 1065</span> <spanclass="comment"> One-time table building (smaller code, but not thread-safe if true):</span></div>
<divclass="line"><aname="l01082"></a><spanclass="lineno"> 1082</span> <spanclass="comment"> The sprintf variant used by gzprintf (zero is best):</span></div>
<divclass="line"><aname="l01083"></a><spanclass="lineno"> 1083</span> <spanclass="comment"> 24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format</span></div>
<divclass="line"><aname="l01084"></a><spanclass="lineno"> 1084</span> <spanclass="comment"> 25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure!</span></div>
<divclass="line"><aname="l01095"></a><spanclass="lineno"> 1095</span> <spanclass="comment"> The following utility functions are implemented on top of the basic</span></div>
<divclass="line"><aname="l01096"></a><spanclass="lineno"> 1096</span> <spanclass="comment"> stream-oriented functions. To simplify the interface, some default options</span></div>
<divclass="line"><aname="l01097"></a><spanclass="lineno"> 1097</span> <spanclass="comment"> are assumed (compression level and memory usage, standard memory allocation</span></div>
<divclass="line"><aname="l01098"></a><spanclass="lineno"> 1098</span> <spanclass="comment"> functions). The source code of these utility functions can be modified if</span></div>
<divclass="line"><aname="l01099"></a><spanclass="lineno"> 1099</span> <spanclass="comment"> you need special options.</span></div>
<divclass="line"><aname="l01105"></a><spanclass="lineno"> 1105</span> <spanclass="comment"> Compresses the source buffer into the destination buffer. sourceLen is</span></div>
<divclass="line"><aname="l01106"></a><spanclass="lineno"> 1106</span> <spanclass="comment"> the byte length of the source buffer. Upon entry, destLen is the total size</span></div>
<divclass="line"><aname="l01107"></a><spanclass="lineno"> 1107</span> <spanclass="comment"> of the destination buffer, which must be at least the value returned by</span></div>
<divclass="line"><aname="l01108"></a><spanclass="lineno"> 1108</span> <spanclass="comment"> compressBound(sourceLen). Upon exit, destLen is the actual size of the</span></div>
<divclass="line"><aname="l01111"></a><spanclass="lineno"> 1111</span> <spanclass="comment"> compress returns Z_OK if success, Z_MEM_ERROR if there was not</span></div>
<divclass="line"><aname="l01112"></a><spanclass="lineno"> 1112</span> <spanclass="comment"> enough memory, Z_BUF_ERROR if there was not enough room in the output</span></div>
<divclass="line"><aname="l01120"></a><spanclass="lineno"> 1120</span> <spanclass="comment"> Compresses the source buffer into the destination buffer. The level</span></div>
<divclass="line"><aname="l01121"></a><spanclass="lineno"> 1121</span> <spanclass="comment"> parameter has the same meaning as in deflateInit. sourceLen is the byte</span></div>
<divclass="line"><aname="l01122"></a><spanclass="lineno"> 1122</span> <spanclass="comment"> length of the source buffer. Upon entry, destLen is the total size of the</span></div>
<divclass="line"><aname="l01123"></a><spanclass="lineno"> 1123</span> <spanclass="comment"> destination buffer, which must be at least the value returned by</span></div>
<divclass="line"><aname="l01124"></a><spanclass="lineno"> 1124</span> <spanclass="comment"> compressBound(sourceLen). Upon exit, destLen is the actual size of the</span></div>
<divclass="line"><aname="l01127"></a><spanclass="lineno"> 1127</span> <spanclass="comment"> compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough</span></div>
<divclass="line"><aname="l01128"></a><spanclass="lineno"> 1128</span> <spanclass="comment"> memory, Z_BUF_ERROR if there was not enough room in the output buffer,</span></div>
<divclass="line"><aname="l01129"></a><spanclass="lineno"> 1129</span> <spanclass="comment"> Z_STREAM_ERROR if the level parameter is invalid.</span></div>
<divclass="line"><aname="l01134"></a><spanclass="lineno"> 1134</span> <spanclass="comment"> compressBound() returns an upper bound on the compressed size after</span></div>
<divclass="line"><aname="l01135"></a><spanclass="lineno"> 1135</span> <spanclass="comment"> compress() or compress2() on sourceLen bytes. It would be used before a</span></div>
<divclass="line"><aname="l01136"></a><spanclass="lineno"> 1136</span> <spanclass="comment"> compress() or compress2() call to allocate the destination buffer.</span></div>
<divclass="line"><aname="l01142"></a><spanclass="lineno"> 1142</span> <spanclass="comment"> Decompresses the source buffer into the destination buffer. sourceLen is</span></div>
<divclass="line"><aname="l01143"></a><spanclass="lineno"> 1143</span> <spanclass="comment"> the byte length of the source buffer. Upon entry, destLen is the total size</span></div>
<divclass="line"><aname="l01144"></a><spanclass="lineno"> 1144</span> <spanclass="comment"> of the destination buffer, which must be large enough to hold the entire</span></div>
<divclass="line"><aname="l01145"></a><spanclass="lineno"> 1145</span> <spanclass="comment"> uncompressed data. (The size of the uncompressed data must have been saved</span></div>
<divclass="line"><aname="l01146"></a><spanclass="lineno"> 1146</span> <spanclass="comment"> previously by the compressor and transmitted to the decompressor by some</span></div>
<divclass="line"><aname="l01147"></a><spanclass="lineno"> 1147</span> <spanclass="comment"> mechanism outside the scope of this compression library.) Upon exit, destLen</span></div>
<divclass="line"><aname="l01148"></a><spanclass="lineno"> 1148</span> <spanclass="comment"> is the actual size of the uncompressed buffer.</span></div>
<divclass="line"><aname="l01150"></a><spanclass="lineno"> 1150</span> <spanclass="comment"> uncompress returns Z_OK if success, Z_MEM_ERROR if there was not</span></div>
<divclass="line"><aname="l01151"></a><spanclass="lineno"> 1151</span> <spanclass="comment"> enough memory, Z_BUF_ERROR if there was not enough room in the output</span></div>
<divclass="line"><aname="l01152"></a><spanclass="lineno"> 1152</span> <spanclass="comment"> buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete.</span></div>
<divclass="line"><aname="l01159"></a><spanclass="lineno"> 1159</span> <spanclass="comment"> This library supports reading and writing files in gzip (.gz) format with</span></div>
<divclass="line"><aname="l01160"></a><spanclass="lineno"> 1160</span> <spanclass="comment"> an interface similar to that of stdio, using the functions that start with</span></div>
<divclass="line"><aname="l01161"></a><spanclass="lineno"> 1161</span> <spanclass="comment">"gz". The gzip format is different from the zlib format. gzip is a gzip</span></div>
<divclass="line"><aname="l01162"></a><spanclass="lineno"> 1162</span> <spanclass="comment"> wrapper, documented in RFC 1952, wrapped around a deflate stream.</span></div>
<divclass="line"><aname="l01170"></a><spanclass="lineno"> 1170</span> <spanclass="comment"> Opens a gzip (.gz) file for reading or writing. The mode parameter is as</span></div>
<divclass="line"><aname="l01171"></a><spanclass="lineno"> 1171</span> <spanclass="comment"> in fopen ("rb" or "wb") but can also include a compression level ("wb9") or</span></div>
<divclass="line"><aname="l01172"></a><spanclass="lineno"> 1172</span> <spanclass="comment"> a strategy: 'f' for filtered data as in "wb6f", 'h' for Huffman-only</span></div>
<divclass="line"><aname="l01173"></a><spanclass="lineno"> 1173</span> <spanclass="comment"> compression as in "wb1h", 'R' for run-length encoding as in "wb1R", or 'F'</span></div>
<divclass="line"><aname="l01174"></a><spanclass="lineno"> 1174</span> <spanclass="comment"> for fixed code compression as in "wb9F". (See the description of</span></div>
<divclass="line"><aname="l01175"></a><spanclass="lineno"> 1175</span> <spanclass="comment"> deflateInit2 for more information about the strategy parameter.) Also "a"</span></div>
<divclass="line"><aname="l01176"></a><spanclass="lineno"> 1176</span> <spanclass="comment"> can be used instead of "w" to request that the gzip stream that will be</span></div>
<divclass="line"><aname="l01177"></a><spanclass="lineno"> 1177</span> <spanclass="comment"> written be appended to the file. "+" will result in an error, since reading</span></div>
<divclass="line"><aname="l01178"></a><spanclass="lineno"> 1178</span> <spanclass="comment"> and writing to the same gzip file is not supported.</span></div>
<divclass="line"><aname="l01180"></a><spanclass="lineno"> 1180</span> <spanclass="comment"> gzopen can be used to read a file which is not in gzip format; in this</span></div>
<divclass="line"><aname="l01181"></a><spanclass="lineno"> 1181</span> <spanclass="comment"> case gzread will directly read from the file without decompression.</span></div>
<divclass="line"><aname="l01183"></a><spanclass="lineno"> 1183</span> <spanclass="comment"> gzopen returns NULL if the file could not be opened, if there was</span></div>
<divclass="line"><aname="l01184"></a><spanclass="lineno"> 1184</span> <spanclass="comment"> insufficient memory to allocate the gzFile state, or if an invalid mode was</span></div>
<divclass="line"><aname="l01185"></a><spanclass="lineno"> 1185</span> <spanclass="comment"> specified (an 'r', 'w', or 'a' was not provided, or '+' was provided).</span></div>
<divclass="line"><aname="l01186"></a><spanclass="lineno"> 1186</span> <spanclass="comment"> errno can be checked to determine if the reason gzopen failed was that the</span></div>
<divclass="line"><aname="l01187"></a><spanclass="lineno"> 1187</span> <spanclass="comment"> file could not be opened.</span></div>
<divclass="line"><aname="l01192"></a><spanclass="lineno"> 1192</span> <spanclass="comment"> gzdopen associates a gzFile with the file descriptor fd. File descriptors</span></div>
<divclass="line"><aname="l01193"></a><spanclass="lineno"> 1193</span> <spanclass="comment"> are obtained from calls like open, dup, creat, pipe or fileno (if the file</span></div>
<divclass="line"><aname="l01194"></a><spanclass="lineno"> 1194</span> <spanclass="comment"> has been previously opened with fopen). The mode parameter is as in gzopen.</span></div>
<divclass="line"><aname="l01196"></a><spanclass="lineno"> 1196</span> <spanclass="comment"> The next call of gzclose on the returned gzFile will also close the file</span></div>
<divclass="line"><aname="l01197"></a><spanclass="lineno"> 1197</span> <spanclass="comment"> descriptor fd, just like fclose(fdopen(fd, mode)) closes the file descriptor</span></div>
<divclass="line"><aname="l01198"></a><spanclass="lineno"> 1198</span> <spanclass="comment"> fd. If you want to keep fd open, use fd = dup(fd_keep); gz = gzdopen(fd,</span></div>
<divclass="line"><aname="l01199"></a><spanclass="lineno"> 1199</span> <spanclass="comment"> mode);. The duplicated descriptor should be saved to avoid a leak, since</span></div>
<divclass="line"><aname="l01200"></a><spanclass="lineno"> 1200</span> <spanclass="comment"> gzdopen does not close fd if it fails.</span></div>
<divclass="line"><aname="l01202"></a><spanclass="lineno"> 1202</span> <spanclass="comment"> gzdopen returns NULL if there was insufficient memory to allocate the</span></div>
<divclass="line"><aname="l01203"></a><spanclass="lineno"> 1203</span> <spanclass="comment"> gzFile state, if an invalid mode was specified (an 'r', 'w', or 'a' was not</span></div>
<divclass="line"><aname="l01204"></a><spanclass="lineno"> 1204</span> <spanclass="comment"> provided, or '+' was provided), or if fd is -1. The file descriptor is not</span></div>
<divclass="line"><aname="l01205"></a><spanclass="lineno"> 1205</span> <spanclass="comment"> used until the next gz* read, write, seek, or close operation, so gzdopen</span></div>
<divclass="line"><aname="l01206"></a><spanclass="lineno"> 1206</span> <spanclass="comment"> will not detect if fd is invalid (unless fd is -1).</span></div>
<divclass="line"><aname="l01211"></a><spanclass="lineno"> 1211</span> <spanclass="comment"> Set the internal buffer size used by this library's functions. The</span></div>
<divclass="line"><aname="l01212"></a><spanclass="lineno"> 1212</span> <spanclass="comment"> default buffer size is 8192 bytes. This function must be called after</span></div>
<divclass="line"><aname="l01213"></a><spanclass="lineno"> 1213</span> <spanclass="comment"> gzopen() or gzdopen(), and before any other calls that read or write the</span></div>
<divclass="line"><aname="l01214"></a><spanclass="lineno"> 1214</span> <spanclass="comment"> file. The buffer memory allocation is always deferred to the first read or</span></div>
<divclass="line"><aname="l01215"></a><spanclass="lineno"> 1215</span> <spanclass="comment"> write. Two buffers are allocated, either both of the specified size when</span></div>
<divclass="line"><aname="l01216"></a><spanclass="lineno"> 1216</span> <spanclass="comment"> writing, or one of the specified size and the other twice that size when</span></div>
<divclass="line"><aname="l01217"></a><spanclass="lineno"> 1217</span> <spanclass="comment"> reading. A larger buffer size of, for example, 64K or 128K bytes will</span></div>
<divclass="line"><aname="l01218"></a><spanclass="lineno"> 1218</span> <spanclass="comment"> noticeably increase the speed of decompression (reading).</span></div>
<divclass="line"><aname="l01220"></a><spanclass="lineno"> 1220</span> <spanclass="comment"> The new buffer size also affects the maximum length for gzprintf().</span></div>
<divclass="line"><aname="l01222"></a><spanclass="lineno"> 1222</span> <spanclass="comment"> gzbuffer() returns 0 on success, or -1 on failure, such as being called</span></div>
<divclass="line"><aname="l01223"></a><spanclass="lineno"> 1223</span> <spanclass="comment"> too late.</span></div>
<divclass="line"><aname="l01228"></a><spanclass="lineno"> 1228</span> <spanclass="comment"> Dynamically update the compression level or strategy. See the description</span></div>
<divclass="line"><aname="l01229"></a><spanclass="lineno"> 1229</span> <spanclass="comment"> of deflateInit2 for the meaning of these parameters.</span></div>
<divclass="line"><aname="l01231"></a><spanclass="lineno"> 1231</span> <spanclass="comment"> gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not</span></div>
<divclass="line"><aname="l01232"></a><spanclass="lineno"> 1232</span> <spanclass="comment"> opened for writing.</span></div>
<divclass="line"><aname="l01237"></a><spanclass="lineno"> 1237</span> <spanclass="comment"> Reads the given number of uncompressed bytes from the compressed file. If</span></div>
<divclass="line"><aname="l01238"></a><spanclass="lineno"> 1238</span> <spanclass="comment"> the input file was not in gzip format, gzread copies the given number of</span></div>
<divclass="line"><aname="l01239"></a><spanclass="lineno"> 1239</span> <spanclass="comment"> bytes into the buffer.</span></div>
<divclass="line"><aname="l01241"></a><spanclass="lineno"> 1241</span> <spanclass="comment"> After reaching the end of a gzip stream in the input, gzread will continue</span></div>
<divclass="line"><aname="l01242"></a><spanclass="lineno"> 1242</span> <spanclass="comment"> to read, looking for another gzip stream, or failing that, reading the rest</span></div>
<divclass="line"><aname="l01243"></a><spanclass="lineno"> 1243</span> <spanclass="comment"> of the input file directly without decompression. The entire input file</span></div>
<divclass="line"><aname="l01244"></a><spanclass="lineno"> 1244</span> <spanclass="comment"> will be read if gzread is called until it returns less than the requested</span></div>
<divclass="line"><aname="l01247"></a><spanclass="lineno"> 1247</span> <spanclass="comment"> gzread returns the number of uncompressed bytes actually read, less than</span></div>
<divclass="line"><aname="l01248"></a><spanclass="lineno"> 1248</span> <spanclass="comment"> len for end of file, or -1 for error.</span></div>
<divclass="line"><aname="l01254"></a><spanclass="lineno"> 1254</span> <spanclass="comment"> Writes the given number of uncompressed bytes into the compressed file.</span></div>
<divclass="line"><aname="l01255"></a><spanclass="lineno"> 1255</span> <spanclass="comment"> gzwrite returns the number of uncompressed bytes written or 0 in case of</span></div>
<divclass="line"><aname="l01261"></a><spanclass="lineno"> 1261</span> <spanclass="comment"> Converts, formats, and writes the arguments to the compressed file under</span></div>
<divclass="line"><aname="l01262"></a><spanclass="lineno"> 1262</span> <spanclass="comment"> control of the format string, as in fprintf. gzprintf returns the number of</span></div>
<divclass="line"><aname="l01263"></a><spanclass="lineno"> 1263</span> <spanclass="comment"> uncompressed bytes actually written, or 0 in case of error. The number of</span></div>
<divclass="line"><aname="l01264"></a><spanclass="lineno"> 1264</span> <spanclass="comment"> uncompressed bytes written is limited to 8191, or one less than the buffer</span></div>
<divclass="line"><aname="l01265"></a><spanclass="lineno"> 1265</span> <spanclass="comment"> size given to gzbuffer(). The caller should assure that this limit is not</span></div>
<divclass="line"><aname="l01266"></a><spanclass="lineno"> 1266</span> <spanclass="comment"> exceeded. If it is exceeded, then gzprintf() will return an error (0) with</span></div>
<divclass="line"><aname="l01267"></a><spanclass="lineno"> 1267</span> <spanclass="comment"> nothing written. In this case, there may also be a buffer overflow with</span></div>
<divclass="line"><aname="l01268"></a><spanclass="lineno"> 1268</span> <spanclass="comment"> unpredictable consequences, which is possible only if zlib was compiled with</span></div>
<divclass="line"><aname="l01269"></a><spanclass="lineno"> 1269</span> <spanclass="comment"> the insecure functions sprintf() or vsprintf() because the secure snprintf()</span></div>
<divclass="line"><aname="l01270"></a><spanclass="lineno"> 1270</span> <spanclass="comment"> or vsnprintf() functions were not available. This can be determined using</span></div>
<divclass="line"><aname="l01276"></a><spanclass="lineno"> 1276</span> <spanclass="comment"> Writes the given null-terminated string to the compressed file, excluding</span></div>
<divclass="line"><aname="l01277"></a><spanclass="lineno"> 1277</span> <spanclass="comment"> the terminating null character.</span></div>
<divclass="line"><aname="l01279"></a><spanclass="lineno"> 1279</span> <spanclass="comment"> gzputs returns the number of characters written, or -1 in case of error.</span></div>
<divclass="line"><aname="l01284"></a><spanclass="lineno"> 1284</span> <spanclass="comment"> Reads bytes from the compressed file until len-1 characters are read, or a</span></div>
<divclass="line"><aname="l01285"></a><spanclass="lineno"> 1285</span> <spanclass="comment"> newline character is read and transferred to buf, or an end-of-file</span></div>
<divclass="line"><aname="l01286"></a><spanclass="lineno"> 1286</span> <spanclass="comment"> condition is encountered. If any characters are read or if len == 1, the</span></div>
<divclass="line"><aname="l01287"></a><spanclass="lineno"> 1287</span> <spanclass="comment"> string is terminated with a null character. If no characters are read due</span></div>
<divclass="line"><aname="l01288"></a><spanclass="lineno"> 1288</span> <spanclass="comment"> to an end-of-file or len < 1, then the buffer is left untouched.</span></div>
<divclass="line"><aname="l01290"></a><spanclass="lineno"> 1290</span> <spanclass="comment"> gzgets returns buf which is a null-terminated string, or it returns NULL</span></div>
<divclass="line"><aname="l01291"></a><spanclass="lineno"> 1291</span> <spanclass="comment"> for end-of-file or in case of error. If there was an error, the contents at</span></div>
<divclass="line"><aname="l01292"></a><spanclass="lineno"> 1292</span> <spanclass="comment"> buf are indeterminate.</span></div>
<divclass="line"><aname="l01297"></a><spanclass="lineno"> 1297</span> <spanclass="comment"> Writes c, converted to an unsigned char, into the compressed file. gzputc</span></div>
<divclass="line"><aname="l01298"></a><spanclass="lineno"> 1298</span> <spanclass="comment"> returns the value that was written, or -1 in case of error.</span></div>
<divclass="line"><aname="l01303"></a><spanclass="lineno"> 1303</span> <spanclass="comment"> Reads one byte from the compressed file. gzgetc returns this byte or -1</span></div>
<divclass="line"><aname="l01304"></a><spanclass="lineno"> 1304</span> <spanclass="comment"> in case of end of file or error.</span></div>
<divclass="line"><aname="l01309"></a><spanclass="lineno"> 1309</span> <spanclass="comment"> Push one character back onto the stream to be read as the first character</span></div>
<divclass="line"><aname="l01310"></a><spanclass="lineno"> 1310</span> <spanclass="comment"> on the next read. At least one character of push-back is allowed.</span></div>
<divclass="line"><aname="l01311"></a><spanclass="lineno"> 1311</span> <spanclass="comment"> gzungetc() returns the character pushed, or -1 on failure. gzungetc() will</span></div>
<divclass="line"><aname="l01312"></a><spanclass="lineno"> 1312</span> <spanclass="comment"> fail if c is -1, and may fail if a character has been pushed but not read</span></div>
<divclass="line"><aname="l01313"></a><spanclass="lineno"> 1313</span> <spanclass="comment"> yet. If gzungetc is used immediately after gzopen or gzdopen, at least the</span></div>
<divclass="line"><aname="l01314"></a><spanclass="lineno"> 1314</span> <spanclass="comment"> output buffer size of pushed characters is allowed. (See gzbuffer above.)</span></div>
<divclass="line"><aname="l01315"></a><spanclass="lineno"> 1315</span> <spanclass="comment"> The pushed character will be discarded if the stream is repositioned with</span></div>
<divclass="line"><aname="l01316"></a><spanclass="lineno"> 1316</span> <spanclass="comment"> gzseek() or gzrewind().</span></div>
<divclass="line"><aname="l01321"></a><spanclass="lineno"> 1321</span> <spanclass="comment"> Flushes all pending output into the compressed file. The parameter flush</span></div>
<divclass="line"><aname="l01322"></a><spanclass="lineno"> 1322</span> <spanclass="comment"> is as in the deflate() function. The return value is the zlib error number</span></div>
<divclass="line"><aname="l01323"></a><spanclass="lineno"> 1323</span> <spanclass="comment"> (see function gzerror below). gzflush is only permitted when writing.</span></div>
<divclass="line"><aname="l01325"></a><spanclass="lineno"> 1325</span> <spanclass="comment"> If the flush parameter is Z_FINISH, the remaining data is written and the</span></div>
<divclass="line"><aname="l01326"></a><spanclass="lineno"> 1326</span> <spanclass="comment"> gzip stream is completed in the output. If gzwrite() is called again, a new</span></div>
<divclass="line"><aname="l01327"></a><spanclass="lineno"> 1327</span> <spanclass="comment"> gzip stream will be started in the output. gzread() is able to read such</span></div>
<divclass="line"><aname="l01330"></a><spanclass="lineno"> 1330</span> <spanclass="comment"> gzflush should be called only when strictly necessary because it will</span></div>
<divclass="line"><aname="l01331"></a><spanclass="lineno"> 1331</span> <spanclass="comment"> degrade compression if called too often.</span></div>
<divclass="line"><aname="l01338"></a><spanclass="lineno"> 1338</span> <spanclass="comment"> Sets the starting position for the next gzread or gzwrite on the given</span></div>
<divclass="line"><aname="l01339"></a><spanclass="lineno"> 1339</span> <spanclass="comment"> compressed file. The offset represents a number of bytes in the</span></div>
<divclass="line"><aname="l01340"></a><spanclass="lineno"> 1340</span> <spanclass="comment"> uncompressed data stream. The whence parameter is defined as in lseek(2);</span></div>
<divclass="line"><aname="l01341"></a><spanclass="lineno"> 1341</span> <spanclass="comment"> the value SEEK_END is not supported.</span></div>
<divclass="line"><aname="l01343"></a><spanclass="lineno"> 1343</span> <spanclass="comment"> If the file is opened for reading, this function is emulated but can be</span></div>
<divclass="line"><aname="l01344"></a><spanclass="lineno"> 1344</span> <spanclass="comment"> extremely slow. If the file is opened for writing, only forward seeks are</span></div>
<divclass="line"><aname="l01345"></a><spanclass="lineno"> 1345</span> <spanclass="comment"> supported; gzseek then compresses a sequence of zeroes up to the new</span></div>
<divclass="line"><aname="l01348"></a><spanclass="lineno"> 1348</span> <spanclass="comment"> gzseek returns the resulting offset location as measured in bytes from</span></div>
<divclass="line"><aname="l01349"></a><spanclass="lineno"> 1349</span> <spanclass="comment"> the beginning of the uncompressed stream, or -1 in case of error, in</span></div>
<divclass="line"><aname="l01350"></a><spanclass="lineno"> 1350</span> <spanclass="comment"> particular if the file is opened for writing and the new starting position</span></div>
<divclass="line"><aname="l01351"></a><spanclass="lineno"> 1351</span> <spanclass="comment"> would be before the current position.</span></div>
<divclass="line"><aname="l01356"></a><spanclass="lineno"> 1356</span> <spanclass="comment"> Rewinds the given file. This function is supported only for reading.</span></div>
<divclass="line"><aname="l01358"></a><spanclass="lineno"> 1358</span> <spanclass="comment"> gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET)</span></div>
<divclass="line"><aname="l01364"></a><spanclass="lineno"> 1364</span> <spanclass="comment"> Returns the starting position for the next gzread or gzwrite on the given</span></div>
<divclass="line"><aname="l01365"></a><spanclass="lineno"> 1365</span> <spanclass="comment"> compressed file. This position represents a number of bytes in the</span></div>
<divclass="line"><aname="l01366"></a><spanclass="lineno"> 1366</span> <spanclass="comment"> uncompressed data stream, and is zero when starting, even if appending or</span></div>
<divclass="line"><aname="l01367"></a><spanclass="lineno"> 1367</span> <spanclass="comment"> reading a gzip stream from the middle of a file using gzdopen().</span></div>
<divclass="line"><aname="l01369"></a><spanclass="lineno"> 1369</span> <spanclass="comment"> gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR)</span></div>
<divclass="line"><aname="l01375"></a><spanclass="lineno"> 1375</span> <spanclass="comment"> Returns the current offset in the file being read or written. This offset</span></div>
<divclass="line"><aname="l01376"></a><spanclass="lineno"> 1376</span> <spanclass="comment"> includes the count of bytes that precede the gzip stream, for example when</span></div>
<divclass="line"><aname="l01377"></a><spanclass="lineno"> 1377</span> <spanclass="comment"> appending or when using gzdopen() for reading. When reading, the offset</span></div>
<divclass="line"><aname="l01378"></a><spanclass="lineno"> 1378</span> <spanclass="comment"> does not include as yet unused buffered input. This information can be used</span></div>
<divclass="line"><aname="l01379"></a><spanclass="lineno"> 1379</span> <spanclass="comment"> for a progress indicator. On error, gzoffset() returns -1.</span></div>
<divclass="line"><aname="l01384"></a><spanclass="lineno"> 1384</span> <spanclass="comment"> Returns true (1) if the end-of-file indicator has been set while reading,</span></div>
<divclass="line"><aname="l01385"></a><spanclass="lineno"> 1385</span> <spanclass="comment"> false (0) otherwise. Note that the end-of-file indicator is set only if the</span></div>
<divclass="line"><aname="l01386"></a><spanclass="lineno"> 1386</span> <spanclass="comment"> read tried to go past the end of the input, but came up short. Therefore,</span></div>
<divclass="line"><aname="l01387"></a><spanclass="lineno"> 1387</span> <spanclass="comment"> just like feof(), gzeof() may return false even if there is no more data to</span></div>
<divclass="line"><aname="l01388"></a><spanclass="lineno"> 1388</span> <spanclass="comment"> read, in the event that the last read request was for the exact number of</span></div>
<divclass="line"><aname="l01389"></a><spanclass="lineno"> 1389</span> <spanclass="comment"> bytes remaining in the input file. This will happen if the input file size</span></div>
<divclass="line"><aname="l01390"></a><spanclass="lineno"> 1390</span> <spanclass="comment"> is an exact multiple of the buffer size.</span></div>
<divclass="line"><aname="l01392"></a><spanclass="lineno"> 1392</span> <spanclass="comment"> If gzeof() returns true, then the read functions will return no more data,</span></div>
<divclass="line"><aname="l01393"></a><spanclass="lineno"> 1393</span> <spanclass="comment"> unless the end-of-file indicator is reset by gzclearerr() and the input file</span></div>
<divclass="line"><aname="l01394"></a><spanclass="lineno"> 1394</span> <spanclass="comment"> has grown since the previous end of file was detected.</span></div>
<divclass="line"><aname="l01399"></a><spanclass="lineno"> 1399</span> <spanclass="comment"> Returns true (1) if file is being copied directly while reading, or false</span></div>
<divclass="line"><aname="l01400"></a><spanclass="lineno"> 1400</span> <spanclass="comment"> (0) if file is a gzip stream being decompressed. This state can change from</span></div>
<divclass="line"><aname="l01401"></a><spanclass="lineno"> 1401</span> <spanclass="comment"> false to true while reading the input file if the end of a gzip stream is</span></div>
<divclass="line"><aname="l01402"></a><spanclass="lineno"> 1402</span> <spanclass="comment"> reached, but is followed by data that is not another gzip stream.</span></div>
<divclass="line"><aname="l01404"></a><spanclass="lineno"> 1404</span> <spanclass="comment"> If the input file is empty, gzdirect() will return true, since the input</span></div>
<divclass="line"><aname="l01405"></a><spanclass="lineno"> 1405</span> <spanclass="comment"> does not contain a gzip stream.</span></div>
<divclass="line"><aname="l01407"></a><spanclass="lineno"> 1407</span> <spanclass="comment"> If gzdirect() is used immediately after gzopen() or gzdopen() it will</span></div>
<divclass="line"><aname="l01408"></a><spanclass="lineno"> 1408</span> <spanclass="comment"> cause buffers to be allocated to allow reading the file to determine if it</span></div>
<divclass="line"><aname="l01409"></a><spanclass="lineno"> 1409</span> <spanclass="comment"> is a gzip file. Therefore if gzbuffer() is used, it should be called before</span></div>
<divclass="line"><aname="l01415"></a><spanclass="lineno"> 1415</span> <spanclass="comment"> Flushes all pending output if necessary, closes the compressed file and</span></div>
<divclass="line"><aname="l01416"></a><spanclass="lineno"> 1416</span> <spanclass="comment"> deallocates the (de)compression state. Note that once file is closed, you</span></div>
<divclass="line"><aname="l01417"></a><spanclass="lineno"> 1417</span> <spanclass="comment"> cannot call gzerror with file, since its structures have been deallocated.</span></div>
<divclass="line"><aname="l01418"></a><spanclass="lineno"> 1418</span> <spanclass="comment"> gzclose must not be called more than once on the same file, just as free</span></div>
<divclass="line"><aname="l01419"></a><spanclass="lineno"> 1419</span> <spanclass="comment"> must not be called more than once on the same allocation.</span></div>
<divclass="line"><aname="l01421"></a><spanclass="lineno"> 1421</span> <spanclass="comment"> gzclose will return Z_STREAM_ERROR if file is not valid, Z_ERRNO on a</span></div>
<divclass="line"><aname="l01422"></a><spanclass="lineno"> 1422</span> <spanclass="comment"> file operation error, or Z_OK on success.</span></div>
<divclass="line"><aname="l01428"></a><spanclass="lineno"> 1428</span> <spanclass="comment"> Same as gzclose(), but gzclose_r() is only for use when reading, and</span></div>
<divclass="line"><aname="l01429"></a><spanclass="lineno"> 1429</span> <spanclass="comment"> gzclose_w() is only for use when writing or appending. The advantage to</span></div>
<divclass="line"><aname="l01430"></a><spanclass="lineno"> 1430</span> <spanclass="comment"> using these instead of gzclose() is that they avoid linking in zlib</span></div>
<divclass="line"><aname="l01431"></a><spanclass="lineno"> 1431</span> <spanclass="comment"> compression or decompression code that is not used when only reading or only</span></div>
<divclass="line"><aname="l01432"></a><spanclass="lineno"> 1432</span> <spanclass="comment"> writing respectively. If gzclose() is used, then both compression and</span></div>
<divclass="line"><aname="l01433"></a><spanclass="lineno"> 1433</span> <spanclass="comment"> decompression code will be included the application when linking to a static</span></div>
<divclass="line"><aname="l01439"></a><spanclass="lineno"> 1439</span> <spanclass="comment"> Returns the error message for the last error which occurred on the given</span></div>
<divclass="line"><aname="l01440"></a><spanclass="lineno"> 1440</span> <spanclass="comment"> compressed file. errnum is set to zlib error number. If an error occurred</span></div>
<divclass="line"><aname="l01441"></a><spanclass="lineno"> 1441</span> <spanclass="comment"> in the file system and not in the compression library, errnum is set to</span></div>
<divclass="line"><aname="l01442"></a><spanclass="lineno"> 1442</span> <spanclass="comment"> Z_ERRNO and the application may consult errno to get the exact error code.</span></div>
<divclass="line"><aname="l01444"></a><spanclass="lineno"> 1444</span> <spanclass="comment"> The application must not modify the returned string. Future calls to</span></div>
<divclass="line"><aname="l01445"></a><spanclass="lineno"> 1445</span> <spanclass="comment"> this function may invalidate the previously returned string. If file is</span></div>
<divclass="line"><aname="l01446"></a><spanclass="lineno"> 1446</span> <spanclass="comment"> closed, then the string previously returned by gzerror will no longer be</span></div>
<divclass="line"><aname="l01449"></a><spanclass="lineno"> 1449</span> <spanclass="comment"> gzerror() should be used to distinguish errors from end-of-file for those</span></div>
<divclass="line"><aname="l01450"></a><spanclass="lineno"> 1450</span> <spanclass="comment"> functions above that do not distinguish those cases in their return values.</span></div>
<divclass="line"><aname="l01455"></a><spanclass="lineno"> 1455</span> <spanclass="comment"> Clears the error and end-of-file flags for file. This is analogous to the</span></div>
<divclass="line"><aname="l01456"></a><spanclass="lineno"> 1456</span> <spanclass="comment"> clearerr() function in stdio. This is useful for continuing to read a gzip</span></div>
<divclass="line"><aname="l01457"></a><spanclass="lineno"> 1457</span> <spanclass="comment"> file that is being written concurrently.</span></div>
<divclass="line"><aname="l01464"></a><spanclass="lineno"> 1464</span> <spanclass="comment"> These functions are not related to compression but are exported</span></div>
<divclass="line"><aname="l01465"></a><spanclass="lineno"> 1465</span> <spanclass="comment"> anyway because they might be useful in applications using the compression</span></div>
<divclass="line"><aname="l01471"></a><spanclass="lineno"> 1471</span> <spanclass="comment"> Update a running Adler-32 checksum with the bytes buf[0..len-1] and</span></div>
<divclass="line"><aname="l01472"></a><spanclass="lineno"> 1472</span> <spanclass="comment"> return the updated checksum. If buf is Z_NULL, this function returns the</span></div>
<divclass="line"><aname="l01473"></a><spanclass="lineno"> 1473</span> <spanclass="comment"> required initial value for the checksum.</span></div>
<divclass="line"><aname="l01475"></a><spanclass="lineno"> 1475</span> <spanclass="comment"> An Adler-32 checksum is almost as reliable as a CRC32 but can be computed</span></div>
<divclass="line"><aname="l01476"></a><spanclass="lineno"> 1476</span> <spanclass="comment"> much faster.</span></div>
<divclass="line"><aname="l01492"></a><spanclass="lineno"> 1492</span> <spanclass="comment"> Combine two Adler-32 checksums into one. For two sequences of bytes, seq1</span></div>
<divclass="line"><aname="l01493"></a><spanclass="lineno"> 1493</span> <spanclass="comment"> and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for</span></div>
<divclass="line"><aname="l01494"></a><spanclass="lineno"> 1494</span> <spanclass="comment"> each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of</span></div>
<divclass="line"><aname="l01495"></a><spanclass="lineno"> 1495</span> <spanclass="comment"> seq1 and seq2 concatenated, requiring only adler1, adler2, and len2.</span></div>
<divclass="line"><aname="l01500"></a><spanclass="lineno"> 1500</span> <spanclass="comment"> Update a running CRC-32 with the bytes buf[0..len-1] and return the</span></div>
<divclass="line"><aname="l01501"></a><spanclass="lineno"> 1501</span> <spanclass="comment"> updated CRC-32. If buf is Z_NULL, this function returns the required</span></div>
<divclass="line"><aname="l01502"></a><spanclass="lineno"> 1502</span> <spanclass="comment"> initial value for the for the crc. Pre- and post-conditioning (one's</span></div>
<divclass="line"><aname="l01503"></a><spanclass="lineno"> 1503</span> <spanclass="comment"> complement) is performed within this function so it shouldn't be done by the</span></div>
<divclass="line"><aname="l01519"></a><spanclass="lineno"> 1519</span> <spanclass="comment"> Combine two CRC-32 check values into one. For two sequences of bytes,</span></div>
<divclass="line"><aname="l01520"></a><spanclass="lineno"> 1520</span> <spanclass="comment"> seq1 and seq2 with lengths len1 and len2, CRC-32 check values were</span></div>
<divclass="line"><aname="l01521"></a><spanclass="lineno"> 1521</span> <spanclass="comment"> calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32</span></div>
<divclass="line"><aname="l01522"></a><spanclass="lineno"> 1522</span> <spanclass="comment"> check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and</span></div>
<divclass="line"><aname="l01529"></a><spanclass="lineno"> 1529</span> <spanclass="comment">/* deflateInit and inflateInit are macros to allow checking the zlib version</span></div>
<divclass="line"><aname="l01530"></a><spanclass="lineno"> 1530</span> <spanclass="comment"> * and the compiler's view of z_stream:</span></div>
<divclass="line"><aname="l01559"></a><spanclass="lineno"> 1559</span> <spanclass="comment">/* provide 64-bit offset functions if _LARGEFILE64_SOURCE defined, and/or</span></div>
<divclass="line"><aname="l01560"></a><spanclass="lineno"> 1560</span> <spanclass="comment"> * change the regular functions to 64 bits if _FILE_OFFSET_BITS is 64 (if</span></div>
<divclass="line"><aname="l01561"></a><spanclass="lineno"> 1561</span> <spanclass="comment"> * both are true, the application gets the *64 functions, and the regular</span></div>
<divclass="line"><aname="l01562"></a><spanclass="lineno"> 1562</span> <spanclass="comment"> * functions are changed to 64 bits) -- in case these are set on systems</span></div>
<divclass="line"><aname="l01563"></a><spanclass="lineno"> 1563</span> <spanclass="comment"> * without large file support, _LFS64_LARGEFILE must also be true</span></div>
<divclass="ttc"id="azconf_8h_html_aeb722a888064be47e12d05f692e0f407"><divclass="ttname"><ahref="zconf_8h.html#aeb722a888064be47e12d05f692e0f407">Bytef</a></div><divclass="ttdeci">Byte FAR Bytef</div><divclass="ttdef"><b>Definition:</b><ahref="zconf_8h_source.html#l00342">zconf.h:342</a></div></div>
<divclass="ttc"id="azlib_8h_html_ac21f94cab4411ce1c77771033cff040a"><divclass="ttname"><ahref="zlib_8h.html#ac21f94cab4411ce1c77771033cff040a">z_stream_s::state</a></div><divclass="ttdeci">struct internal_state FAR * state</div><divclass="ttdef"><b>Definition:</b><ahref="zlib_8h_source.html#l00095">zlib.h:95</a></div></div>
<divclass="ttc"id="azconf_8h_html_a2de3690ae41712f1488ce8b89b07141a"><divclass="ttname"><ahref="zconf_8h.html#a2de3690ae41712f1488ce8b89b07141a">voidpf</a></div><divclass="ttdeci">void FAR * voidpf</div><divclass="ttdef"><b>Definition:</b><ahref="zconf_8h_source.html#l00351">zconf.h:351</a></div></div>
<divclass="ttc"id="azconf_8h_html_acd2a5701a3aecf6700d2c66c606ecb40"><divclass="ttname"><ahref="zconf_8h.html#acd2a5701a3aecf6700d2c66c606ecb40">uLong</a></div><divclass="ttdeci">unsigned long uLong</div><divclass="ttdef"><b>Definition:</b><ahref="zconf_8h_source.html#l00336">zconf.h:336</a></div></div>
<divclass="ttc"id="azlib_8h_html_a40e9dcc294796d99b25e98fb06477fc8"><divclass="ttname"><ahref="zlib_8h.html#a40e9dcc294796d99b25e98fb06477fc8">gz_headerp</a></div><divclass="ttdeci">gz_header FAR * gz_headerp</div><divclass="ttdef"><b>Definition:</b><ahref="zlib_8h_source.html#l00129">zlib.h:129</a></div></div>
<divclass="ttc"id="azlib_8h_html_a6ede25c84d3c9f8632305866acffb1d6"><divclass="ttname"><ahref="zlib_8h.html#a6ede25c84d3c9f8632305866acffb1d6">z_streamp</a></div><divclass="ttdeci">z_stream FAR * z_streamp</div><divclass="ttdef"><b>Definition:</b><ahref="zlib_8h_source.html#l00106">zlib.h:106</a></div></div>
<divclass="ttc"id="azconf_8h_html_a0426a5a0ed418ec4ae15af8281c64254"><divclass="ttname"><ahref="zconf_8h.html#a0426a5a0ed418ec4ae15af8281c64254">uLongf</a></div><divclass="ttdeci">uLong FAR uLongf</div><divclass="ttdef"><b>Definition:</b><ahref="zconf_8h_source.html#l00347">zconf.h:347</a></div></div>
<divclass="ttc"id="azconf_8h_html_a87d141052bcd5ec8a80812a565c70369"><divclass="ttname"><ahref="zconf_8h.html#a87d141052bcd5ec8a80812a565c70369">uInt</a></div><divclass="ttdeci">unsigned int uInt</div><divclass="ttdef"><b>Definition:</b><ahref="zconf_8h_source.html#l00335">zconf.h:335</a></div></div>