Edit D:\app\Administrator\product\11.2.0\dbhome_1\perl\html\lib\Compress\Raw\Zlib.html
<?xml version="1.0" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Compress::Raw::Zlib - Low-Level Interface to zlib compression library</title> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <link rev="made" href="mailto:" /> </head> <body style="background-color: white"> <table border="0" width="100%" cellspacing="0" cellpadding="3"> <tr><td class="block" style="background-color: #cccccc" valign="middle"> <big><strong><span class="block"> Compress::Raw::Zlib - Low-Level Interface to zlib compression library</span></strong></big> </td></tr> </table> <!-- INDEX BEGIN --> <div name="index"> <p><a name="__index__"></a></p> <ul> <li><a href="#name">NAME</a></li> <li><a href="#synopsis">SYNOPSIS</a></li> <li><a href="#description">DESCRIPTION</a></li> <li><a href="#compress__raw__zlib__deflate">Compress::Raw::Zlib::Deflate</a></li> <ul> <li><a href="#__d___status____new_compress__raw__zlib__deflate___opt___"><strong>($d, $status) = new Compress::Raw::Zlib::Deflate( [OPT] ) </strong></a></li> <li><a href="#_status____d__deflate__input___output_"><strong>$status = $d->deflate($input, $output)</strong></a></li> <li><a href="#_status____d__flush__output_____flush_type__"><strong>$status = $d->flush($output [, $flush_type]) </strong></a></li> <li><a href="#_status____d__deflateparams__opt__"><strong>$status = $d->deflateParams([OPT])</strong></a></li> <li><a href="#_status____d__deflatetune__good_length___max_lazy___nice_length___max_chain_"><strong>$status = $d->deflateTune($good_length, $max_lazy, $nice_length, $max_chain)</strong></a></li> <li><a href="#_d__dict_adler__"><strong>$d->dict_adler()</strong></a></li> <li><a href="#_d__crc32__"><strong>$d->crc32()</strong></a></li> <li><a href="#_d__adler32__"><strong>$d->adler32()</strong></a></li> <li><a href="#_d__msg__"><strong>$d->msg()</strong></a></li> <li><a href="#_d__total_in__"><strong>$d->total_in()</strong></a></li> <li><a href="#_d__total_out__"><strong>$d->total_out()</strong></a></li> <li><a href="#_d__get_strategy__"><strong>$d->get_Strategy()</strong></a></li> <li><a href="#_d__get_level__"><strong>$d->get_Level()</strong></a></li> <li><a href="#_d__get_bufsize__"><strong>$d->get_BufSize()</strong></a></li> <li><a href="#example">Example</a></li> </ul> <li><a href="#compress__raw__zlib__inflate">Compress::Raw::Zlib::Inflate</a></li> <ul> <li><a href="#__i___status____new_compress__raw__zlib__inflate___opt___"><strong> ($i, $status) = new Compress::Raw::Zlib::Inflate( [OPT] ) </strong></a></li> <li><a href="#_status____i__inflate__input___output____eof__"><strong> $status = $i->inflate($input, $output [,$eof]) </strong></a></li> <li><a href="#_status____i__inflatesync__input_"><strong>$status = $i->inflateSync($input)</strong></a></li> <li><a href="#_i__dict_adler__"><strong>$i->dict_adler()</strong></a></li> <li><a href="#_i__crc32__"><strong>$i->crc32()</strong></a></li> <li><a href="#_i__adler32__"><strong>$i->adler32()</strong></a></li> <li><a href="#_i__msg__"><strong>$i->msg()</strong></a></li> <li><a href="#_i__total_in__"><strong>$i->total_in()</strong></a></li> <li><a href="#_i__total_out__"><strong>$i->total_out()</strong></a></li> <li><a href="#_d__get_bufsize__"><strong>$d->get_BufSize()</strong></a></li> <li><a href="#example">Example</a></li> </ul> <li><a href="#checksum_functions">CHECKSUM FUNCTIONS</a></li> <li><a href="#accessing_zip_files">ACCESSING ZIP FILES</a></li> <li><a href="#constants">CONSTANTS</a></li> <li><a href="#see_also">SEE ALSO</a></li> <li><a href="#author">AUTHOR</a></li> <li><a href="#modification_history">MODIFICATION HISTORY</a></li> <li><a href="#copyright_and_license">COPYRIGHT AND LICENSE</a></li> </ul> <hr name="index" /> </div> <!-- INDEX END --> <p> </p> <h1><a name="name">NAME</a></h1> <p>Compress::Raw::Zlib - Low-Level Interface to zlib compression library</p> <p> </p> <hr /> <h1><a name="synopsis">SYNOPSIS</a></h1> <pre> use Compress::Raw::Zlib ;</pre> <pre> ($d, $status) = new Compress::Raw::Zlib::Deflate( [OPT] ) ; $status = $d->deflate($input, $output) ; $status = $d->flush($output [, $flush_type]) ; $d->deflateParams(OPTS) ; $d->deflateTune(OPTS) ; $d->dict_adler() ; $d->crc32() ; $d->adler32() ; $d->total_in() ; $d->total_out() ; $d->msg() ; $d->get_Strategy(); $d->get_Level(); $d->get_BufSize();</pre> <pre> ($i, $status) = new Compress::Raw::Zlib::Inflate( [OPT] ) ; $status = $i->inflate($input, $output [, $eof]) ; $status = $i->inflateSync($input) ; $i->dict_adler() ; $d->crc32() ; $d->adler32() ; $i->total_in() ; $i->total_out() ; $i->msg() ; $d->get_BufSize();</pre> <pre> $crc = adler32($buffer [,$crc]) ; $crc = crc32($buffer [,$crc]) ;</pre> <pre> $crc = adler32_combine($crc1, $crc2, $len2)l $crc = crc32_combine($adler1, $adler2, $len2)</pre> <pre> ZLIB_VERSION ZLIB_VERNUM</pre> <p> </p> <hr /> <h1><a name="description">DESCRIPTION</a></h1> <p>The <em>Compress::Raw::Zlib</em> module provides a Perl interface to the <em>zlib</em> compression library (see <a href="#author">AUTHOR</a> for details about where to get <em>zlib</em>).</p> <p> </p> <hr /> <h1><a name="compress__raw__zlib__deflate">Compress::Raw::Zlib::Deflate</a></h1> <p>This section defines an interface that allows in-memory compression using the <em>deflate</em> interface provided by zlib.</p> <p>Here is a definition of the interface available:</p> <p> </p> <h2><a name="__d___status____new_compress__raw__zlib__deflate___opt___"><strong>($d, $status) = new Compress::Raw::Zlib::Deflate( [OPT] ) </strong></a></h2> <p>Initialises a deflation object.</p> <p>If you are familiar with the <em>zlib</em> library, it combines the features of the <em>zlib</em> functions <code>deflateInit</code>, <code>deflateInit2</code> and <code>deflateSetDictionary</code>.</p> <p>If successful, it will return the initialised deflation object, <code>$d</code> and a <code>$status</code> of <code>Z_OK</code> in a list context. In scalar context it returns the deflation object, <code>$d</code>, only.</p> <p>If not successful, the returned deflation object, <code>$d</code>, will be <em>undef</em> and <code>$status</code> will hold the a <em>zlib</em> error code.</p> <p>The function optionally takes a number of named options specified as <code>Name => value</code> pairs. This allows individual options to be tailored without having to specify them all in the parameter list.</p> <p>For backward compatibility, it is also possible to pass the parameters as a reference to a hash containing the name=>value pairs.</p> <p>Below is a list of the valid options:</p> <dl> <dt><strong><a name="level" class="item"><strong>-Level</strong></a></strong> <dd> <p>Defines the compression level. Valid values are 0 through 9, <code>Z_NO_COMPRESSION</code>, <code>Z_BEST_SPEED</code>, <code>Z_BEST_COMPRESSION</code>, and <code>Z_DEFAULT_COMPRESSION</code>.</p> </dd> <dd> <p>The default is Z_DEFAULT_COMPRESSION.</p> </dd> </li> <dt><strong><a name="method" class="item"><strong>-Method</strong></a></strong> <dd> <p>Defines the compression method. The only valid value at present (and the default) is Z_DEFLATED.</p> </dd> </li> <dt><strong><a name="windowbits" class="item"><strong>-WindowBits</strong></a></strong> <dd> <p>For a definition of the meaning and valid values for <a href="#windowbits"><code>WindowBits</code></a> refer to the <em>zlib</em> documentation for <em>deflateInit2</em>.</p> </dd> <dd> <p>Defaults to MAX_WBITS.</p> </dd> </li> <dt><strong><a name="memlevel" class="item"><strong>-MemLevel</strong></a></strong> <dd> <p>For a definition of the meaning and valid values for <a href="#memlevel"><code>MemLevel</code></a> refer to the <em>zlib</em> documentation for <em>deflateInit2</em>.</p> </dd> <dd> <p>Defaults to MAX_MEM_LEVEL.</p> </dd> </li> <dt><strong><a name="strategy" class="item"><strong>-Strategy</strong></a></strong> <dd> <p>Defines the strategy used to tune the compression. The valid values are <code>Z_DEFAULT_STRATEGY</code>, <code>Z_FILTERED</code>, <code>Z_RLE</code>, <code>Z_FIXED</code> and <code>Z_HUFFMAN_ONLY</code>.</p> </dd> <dd> <p>The default is Z_DEFAULT_STRATEGY.</p> </dd> </li> <dt><strong><a name="dictionary" class="item"><strong>-Dictionary</strong></a></strong> <dd> <p>When a dictionary is specified <em>Compress::Raw::Zlib</em> will automatically call <code>deflateSetDictionary</code> directly after calling <code>deflateInit</code>. The Adler32 value for the dictionary can be obtained by calling the method <code>$d->dict_adler()</code>.</p> </dd> <dd> <p>The default is no dictionary.</p> </dd> </li> <dt><strong><a name="bufsize" class="item"><strong>-Bufsize</strong></a></strong> <dd> <p>Sets the initial size for the output buffer used by the <code>$d->deflate</code> and <code>$d->flush</code> methods. If the buffer has to be reallocated to increase the size, it will grow in increments of <a href="#bufsize"><code>Bufsize</code></a>.</p> </dd> <dd> <p>The default buffer size is 4096.</p> </dd> </li> <dt><strong><a name="appendoutput" class="item"><strong>-AppendOutput</strong></a></strong> <dd> <p>This option controls how data is written to the output buffer by the <code>$d->deflate</code> and <code>$d->flush</code> methods.</p> </dd> <dd> <p>If the <a href="#appendoutput"><code>AppendOutput</code></a> option is set to false, the output buffers in the <code>$d->deflate</code> and <code>$d->flush</code> methods will be truncated before uncompressed data is written to them.</p> </dd> <dd> <p>If the option is set to true, uncompressed data will be appended to the output buffer in the <code>$d->deflate</code> and <code>$d->flush</code> methods.</p> </dd> <dd> <p>This option defaults to false.</p> </dd> </li> <dt><strong><a name="crc32" class="item"><strong>-CRC32</strong></a></strong> <dd> <p>If set to true, a crc32 checksum of the uncompressed data will be calculated. Use the <code>$d->crc32</code> method to retrieve this value.</p> </dd> <dd> <p>This option defaults to false.</p> </dd> </li> <dt><strong><a name="adler32" class="item"><strong>-ADLER32</strong></a></strong> <dd> <p>If set to true, an adler32 checksum of the uncompressed data will be calculated. Use the <code>$d->adler32</code> method to retrieve this value.</p> </dd> <dd> <p>This option defaults to false.</p> </dd> </li> </dl> <p>Here is an example of using the <code>Compress::Raw::Zlib::Deflate</code> optional parameter list to override the default buffer size and compression level. All other options will take their default values.</p> <pre> my $d = new Compress::Raw::Zlib::Deflate ( -Bufsize => 300, -Level => Z_BEST_SPEED ) ;</pre> <p> </p> <h2><a name="_status____d__deflate__input___output_"><strong>$status = $d->deflate($input, $output)</strong></a></h2> <p>Deflates the contents of <code>$input</code> and writes the compressed data to <code>$output</code>.</p> <p>The <code>$input</code> and <code>$output</code> parameters can be either scalars or scalar references.</p> <p>When finished, <code>$input</code> will be completely processed (assuming there were no errors). If the deflation was successful it writes the deflated data to <code>$output</code> and returns a status value of <code>Z_OK</code>.</p> <p>On error, it returns a <em>zlib</em> error code.</p> <p>If the <a href="#appendoutput"><code>AppendOutput</code></a> option is set to true in the constructor for the <code>$d</code> object, the compressed data will be appended to <code>$output</code>. If it is false, <code>$output</code> will be truncated before any compressed data is written to it.</p> <p><strong>Note</strong>: This method will not necessarily write compressed data to <code>$output</code> every time it is called. So do not assume that there has been an error if the contents of <code>$output</code> is empty on returning from this method. As long as the return code from the method is <code>Z_OK</code>, the deflate has succeeded.</p> <p> </p> <h2><a name="_status____d__flush__output_____flush_type__"><strong>$status = $d->flush($output [, $flush_type]) </strong></a></h2> <p>Typically used to finish the deflation. Any pending output will be written to <code>$output</code>.</p> <p>Returns <code>Z_OK</code> if successful.</p> <p>Note that flushing can seriously degrade the compression ratio, so it should only be used to terminate a decompression (using <code>Z_FINISH</code>) or when you want to create a <em>full flush point</em> (using <code>Z_FULL_FLUSH</code>).</p> <p>By default the <code>flush_type</code> used is <code>Z_FINISH</code>. Other valid values for <code>flush_type</code> are <code>Z_NO_FLUSH</code>, <code>Z_PARTIAL_FLUSH</code>, <code>Z_SYNC_FLUSH</code> and <code>Z_FULL_FLUSH</code>. It is strongly recommended that you only set the <code>flush_type</code> parameter if you fully understand the implications of what it does. See the <code>zlib</code> documentation for details.</p> <p>If the <a href="#appendoutput"><code>AppendOutput</code></a> option is set to true in the constructor for the <code>$d</code> object, the compressed data will be appended to <code>$output</code>. If it is false, <code>$output</code> will be truncated before any compressed data is written to it.</p> <p> </p> <h2><a name="_status____d__deflateparams__opt__"><strong>$status = $d->deflateParams([OPT])</strong></a></h2> <p>Change settings for the deflate object <code>$d</code>.</p> <p>The list of the valid options is shown below. Options not specified will remain unchanged.</p> <dl> <dt><strong><a name="level2" class="item"><strong>-Level</strong></a></strong> <dd> <p>Defines the compression level. Valid values are 0 through 9, <code>Z_NO_COMPRESSION</code>, <code>Z_BEST_SPEED</code>, <code>Z_BEST_COMPRESSION</code>, and <code>Z_DEFAULT_COMPRESSION</code>.</p> </dd> </li> <dt><strong><a name="strategy2" class="item"><strong>-Strategy</strong></a></strong> <dd> <p>Defines the strategy used to tune the compression. The valid values are <code>Z_DEFAULT_STRATEGY</code>, <code>Z_FILTERED</code> and <code>Z_HUFFMAN_ONLY</code>.</p> </dd> </li> <dt><strong><a name="bufsize" class="item"><strong>-BufSize</strong></a></strong> <dd> <p>Sets the initial size for the output buffer used by the <code>$d->deflate</code> and <code>$d->flush</code> methods. If the buffer has to be reallocated to increase the size, it will grow in increments of <a href="#bufsize"><code>Bufsize</code></a>.</p> </dd> </li> </dl> <p> </p> <h2><a name="_status____d__deflatetune__good_length___max_lazy___nice_length___max_chain_"><strong>$status = $d->deflateTune($good_length, $max_lazy, $nice_length, $max_chain)</strong></a></h2> <p>Tune the internal settings for the deflate object <code>$d</code>. This option is only available if you are running zlib 1.2.2.3 or better.</p> <p>Refer to the documentation in zlib.h for instructions on how to fly <code>deflateTune</code>.</p> <p> </p> <h2><a name="_d__dict_adler__"><strong>$d->dict_adler()</strong></a></h2> <p>Returns the adler32 value for the dictionary.</p> <p> </p> <h2><a name="_d__crc32__"><strong>$d->crc32()</strong></a></h2> <p>Returns the crc32 value for the uncompressed data to date.</p> <p>If the <a href="#crc32"><code>CRC32</code></a> option is not enabled in the constructor for this object, this method will always return 0;</p> <p> </p> <h2><a name="_d__adler32__"><strong>$d->adler32()</strong></a></h2> <p>Returns the adler32 value for the uncompressed data to date.</p> <p> </p> <h2><a name="_d__msg__"><strong>$d->msg()</strong></a></h2> <p>Returns the last error message generated by zlib.</p> <p> </p> <h2><a name="_d__total_in__"><strong>$d->total_in()</strong></a></h2> <p>Returns the total number of bytes uncompressed bytes input to deflate.</p> <p> </p> <h2><a name="_d__total_out__"><strong>$d->total_out()</strong></a></h2> <p>Returns the total number of compressed bytes output from deflate.</p> <p> </p> <h2><a name="_d__get_strategy__"><strong>$d->get_Strategy()</strong></a></h2> <p>Returns the deflation strategy currently used. Valid values are <code>Z_DEFAULT_STRATEGY</code>, <code>Z_FILTERED</code> and <code>Z_HUFFMAN_ONLY</code>.</p> <p> </p> <h2><a name="_d__get_level__"><strong>$d->get_Level()</strong></a></h2> <p>Returns the compression level being used.</p> <p> </p> <h2><a name="_d__get_bufsize__"><strong>$d->get_BufSize()</strong></a></h2> <p>Returns the buffer size used to carry out the compression.</p> <p> </p> <h2><a name="example">Example</a></h2> <p>Here is a trivial example of using <code>deflate</code>. It simply reads standard input, deflates it and writes it to standard output.</p> <pre> use strict ; use warnings ;</pre> <pre> use Compress::Raw::Zlib ;</pre> <pre> binmode STDIN; binmode STDOUT; my $x = new Compress::Raw::Zlib::Deflate or die "Cannot create a deflation stream\n" ;</pre> <pre> my ($output, $status) ; while (<>) { $status = $x->deflate($_, $output) ; $status == Z_OK or die "deflation failed\n" ; print $output ; } $status = $x->flush($output) ; $status == Z_OK or die "deflation failed\n" ; print $output ;</pre> <p> </p> <hr /> <h1><a name="compress__raw__zlib__inflate">Compress::Raw::Zlib::Inflate</a></h1> <p>This section defines an interface that allows in-memory uncompression using the <em>inflate</em> interface provided by zlib.</p> <p>Here is a definition of the interface:</p> <p> </p> <h2><a name="__i___status____new_compress__raw__zlib__inflate___opt___"><strong> ($i, $status) = new Compress::Raw::Zlib::Inflate( [OPT] ) </strong></a></h2> <p>Initialises an inflation object.</p> <p>In a list context it returns the inflation object, <code>$i</code>, and the <em>zlib</em> status code (<code>$status</code>). In a scalar context it returns the inflation object only.</p> <p>If successful, <code>$i</code> will hold the inflation object and <code>$status</code> will be <code>Z_OK</code>.</p> <p>If not successful, <code>$i</code> will be <em>undef</em> and <code>$status</code> will hold the <em>zlib</em> error code.</p> <p>The function optionally takes a number of named options specified as <code>-Name => value</code> pairs. This allows individual options to be tailored without having to specify them all in the parameter list.</p> <p>For backward compatibility, it is also possible to pass the parameters as a reference to a hash containing the <code>name=>value</code> pairs.</p> <p>Here is a list of the valid options:</p> <dl> <dt><strong><a name="windowbits2" class="item"><strong>-WindowBits</strong></a></strong> <dd> <p>To uncompress an <a href="http://www.ietf.org/rfc/rfc1950.txt" class="rfc">RFC 1950</a> data stream, set <a href="#windowbits"><code>WindowBits</code></a> to a positive number.</p> </dd> <dd> <p>To uncompress an <a href="http://www.ietf.org/rfc/rfc1951.txt" class="rfc">RFC 1951</a> data stream, set <a href="#windowbits"><code>WindowBits</code></a> to <code>-MAX_WBITS</code>.</p> </dd> <dd> <p>For a full definition of the meaning and valid values for <a href="#windowbits"><code>WindowBits</code></a> refer to the <em>zlib</em> documentation for <em>inflateInit2</em>.</p> </dd> <dd> <p>Defaults to MAX_WBITS.</p> </dd> </li> <dt><strong><a name="bufsize2" class="item"><strong>-Bufsize</strong></a></strong> <dd> <p>Sets the initial size for the output buffer used by the <code>$i->inflate</code> method. If the output buffer in this method has to be reallocated to increase the size, it will grow in increments of <a href="#bufsize"><code>Bufsize</code></a>.</p> </dd> <dd> <p>Default is 4096.</p> </dd> </li> <dt><strong><a name="dictionary2" class="item"><strong>-Dictionary</strong></a></strong> <dd> <p>The default is no dictionary.</p> </dd> </li> <dt><strong><a name="appendoutput2" class="item"><strong>-AppendOutput</strong></a></strong> <dd> <p>This option controls how data is written to the output buffer by the <code>$i->inflate</code> method.</p> </dd> <dd> <p>If the option is set to false, the output buffer in the <code>$i->inflate</code> method will be truncated before uncompressed data is written to it.</p> </dd> <dd> <p>If the option is set to true, uncompressed data will be appended to the output buffer by the <code>$i->inflate</code> method.</p> </dd> <dd> <p>This option defaults to false.</p> </dd> </li> <dt><strong><a name="crc322" class="item"><strong>-CRC32</strong></a></strong> <dd> <p>If set to true, a crc32 checksum of the uncompressed data will be calculated. Use the <code>$i->crc32</code> method to retrieve this value.</p> </dd> <dd> <p>This option defaults to false.</p> </dd> </li> <dt><strong><a name="adler322" class="item"><strong>-ADLER32</strong></a></strong> <dd> <p>If set to true, an adler32 checksum of the uncompressed data will be calculated. Use the <code>$i->adler32</code> method to retrieve this value.</p> </dd> <dd> <p>This option defaults to false.</p> </dd> </li> <dt><strong><a name="consumeinput" class="item"><strong>-ConsumeInput</strong></a></strong> <dd> <p>If set to true, this option will remove compressed data from the input buffer of the the <code> $i->inflate </code> method as the inflate progresses.</p> </dd> <dd> <p>This option can be useful when you are processing compressed data that is embedded in another file/buffer. In this case the data that immediately follows the compressed stream will be left in the input buffer.</p> </dd> <dd> <p>This option defaults to true.</p> </dd> </li> </dl> <p>Here is an example of using an optional parameter to override the default buffer size.</p> <pre> my ($i, $status) = new Compress::Raw::Zlib::Inflate( -Bufsize => 300 ) ;</pre> <p> </p> <h2><a name="_status____i__inflate__input___output____eof__"><strong> $status = $i->inflate($input, $output [,$eof]) </strong></a></h2> <p>Inflates the complete contents of <code>$input</code> and writes the uncompressed data to <code>$output</code>. The <code>$input</code> and <code>$output</code> parameters can either be scalars or scalar references.</p> <p>Returns <code>Z_OK</code> if successful and <code>Z_STREAM_END</code> if the end of the compressed data has been successfully reached.</p> <p>If not successful <code>$status</code> will hold the <em>zlib</em> error code.</p> <p>If the <a href="#consumeinput"><code>ConsumeInput</code></a> option has been set to true when the <code>Compress::Raw::Zlib::Inflate</code> object is created, the <code>$input</code> parameter is modified by <code>inflate</code>. On completion it will contain what remains of the input buffer after inflation. In practice, this means that when the return status is <code>Z_OK</code> the <code>$input</code> parameter will contain an empty string, and when the return status is <code>Z_STREAM_END</code> the <code>$input</code> parameter will contains what (if anything) was stored in the input buffer after the deflated data stream.</p> <p>This feature is useful when processing a file format that encapsulates a compressed data stream (e.g. gzip, zip) and there is useful data immediately after the deflation stream.</p> <p>If the <a href="#appendoutput"><code>AppendOutput</code></a> option is set to true in the constructor for this object, the uncompressed data will be appended to <code>$output</code>. If it is false, <code>$output</code> will be truncated before any uncompressed data is written to it.</p> <p>The <code>$eof</code> parameter needs a bit of explanation.</p> <p>Prior to version 1.2.0, zlib assumed that there was at least one trailing byte immediately after the compressed data stream when it was carrying out decompression. This normally isn't a problem because the majority of zlib applications guarantee that there will be data directly after the compressed data stream. For example, both gzip (<a href="http://www.ietf.org/rfc/rfc1950.txt" class="rfc">RFC 1950</a>) and zip both define trailing data that follows the compressed data stream.</p> <p>The <code>$eof</code> parameter only needs to be used if <strong>all</strong> of the following conditions apply</p> <ol> <li> <p>You are either using a copy of zlib that is older than version 1.2.0 or you want your application code to be able to run with as many different versions of zlib as possible.</p> </li> <li> <p>You have set the <a href="#windowbits"><code>WindowBits</code></a> parameter to <code>-MAX_WBITS</code> in the constructor for this object, i.e. you are uncompressing a raw deflated data stream (<a href="http://www.ietf.org/rfc/rfc1951.txt" class="rfc">RFC 1951</a>).</p> </li> <li> <p>There is no data immediately after the compressed data stream.</p> </li> </ol> <p>If <strong>all</strong> of these are the case, then you need to set the <code>$eof</code> parameter to true on the final call (and only the final call) to <code>$i->inflate</code>.</p> <p>If you have built this module with zlib >= 1.2.0, the <code>$eof</code> parameter is ignored. You can still set it if you want, but it won't be used behind the scenes.</p> <p> </p> <h2><a name="_status____i__inflatesync__input_"><strong>$status = $i->inflateSync($input)</strong></a></h2> <p>This method can be used to attempt to recover good data from a compressed data stream that is partially corrupt. It scans <code>$input</code> until it reaches either a <em>full flush point</em> or the end of the buffer.</p> <p>If a <em>full flush point</em> is found, <code>Z_OK</code> is returned and <code>$input</code> will be have all data up to the flush point removed. This data can then be passed to the <code>$i->inflate</code> method to be uncompressed.</p> <p>Any other return code means that a flush point was not found. If more data is available, <code>inflateSync</code> can be called repeatedly with more compressed data until the flush point is found.</p> <p>Note <em>full flush points</em> are not present by default in compressed data streams. They must have been added explicitly when the data stream was created by calling <code>Compress::Deflate::flush</code> with <code>Z_FULL_FLUSH</code>.</p> <p> </p> <h2><a name="_i__dict_adler__"><strong>$i->dict_adler()</strong></a></h2> <p>Returns the adler32 value for the dictionary.</p> <p> </p> <h2><a name="_i__crc32__"><strong>$i->crc32()</strong></a></h2> <p>Returns the crc32 value for the uncompressed data to date.</p> <p>If the <a href="#crc32"><code>CRC32</code></a> option is not enabled in the constructor for this object, this method will always return 0;</p> <p> </p> <h2><a name="_i__adler32__"><strong>$i->adler32()</strong></a></h2> <p>Returns the adler32 value for the uncompressed data to date.</p> <p>If the <a href="#adler32"><code>ADLER32</code></a> option is not enabled in the constructor for this object, this method will always return 0;</p> <p> </p> <h2><a name="_i__msg__"><strong>$i->msg()</strong></a></h2> <p>Returns the last error message generated by zlib.</p> <p> </p> <h2><a name="_i__total_in__"><strong>$i->total_in()</strong></a></h2> <p>Returns the total number of bytes compressed bytes input to inflate.</p> <p> </p> <h2><a name="_i__total_out__"><strong>$i->total_out()</strong></a></h2> <p>Returns the total number of uncompressed bytes output from inflate.</p> <p> </p> <h2><a name="_d__get_bufsize__"><strong>$d->get_BufSize()</strong></a></h2> <p>Returns the buffer size used to carry out the decompression.</p> <p> </p> <h2><a name="example">Example</a></h2> <p>Here is an example of using <code>inflate</code>.</p> <pre> use strict ; use warnings ; use Compress::Raw::Zlib; my $x = new Compress::Raw::Zlib::Inflate() or die "Cannot create a inflation stream\n" ; my $input = '' ; binmode STDIN; binmode STDOUT; my ($output, $status) ; while (read(STDIN, $input, 4096)) { $status = $x->inflate(\$input, $output) ; print $output if $status == Z_OK or $status == Z_STREAM_END ; last if $status != Z_OK ; } die "inflation failed\n" unless $status == Z_STREAM_END ;</pre> <p> </p> <hr /> <h1><a name="checksum_functions">CHECKSUM FUNCTIONS</a></h1> <p>Two functions are provided by <em>zlib</em> to calculate checksums. For the Perl interface, the order of the two parameters in both functions has been reversed. This allows both running checksums and one off calculations to be done.</p> <pre> $crc = adler32($buffer [,$crc]) ; $crc = crc32($buffer [,$crc]) ;</pre> <p>The buffer parameters can either be a scalar or a scalar reference.</p> <p>If the $crc parameters is <a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/pod/perlfunc.html#undef"><code>undef</code></a>, the crc value will be reset.</p> <p>If you have built this module with zlib 1.2.3 or better, two more CRC-related functions are available.</p> <pre> $crc = adler32_combine($crc1, $crc2, $len2)l $crc = crc32_combine($adler1, $adler2, $len2)</pre> <p>These functions allow checksums to be merged.</p> <p> </p> <hr /> <h1><a name="accessing_zip_files">ACCESSING ZIP FILES</a></h1> <p>Although it is possible (with some effort on your part) to use this module to access .zip files, there is a module on CPAN that will do all the hard work for you. Check out the <code>Archive::Zip</code> module on CPAN at</p> <pre> <a href="http://www.cpan.org/modules/by-module/Archive/Archive-Zip">http://www.cpan.org/modules/by-module/Archive/Archive-Zip</a>-*.tar.gz</pre> <p> </p> <hr /> <h1><a name="constants">CONSTANTS</a></h1> <p>All the <em>zlib</em> constants are automatically imported when you make use of <em>Compress::Raw::Zlib</em>.</p> <p> </p> <hr /> <h1><a name="see_also">SEE ALSO</a></h1> <p><a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/lib/Compress/Zlib.html">the Compress::Zlib manpage</a>, <a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/lib/IO/Compress/Gzip.html">the IO::Compress::Gzip manpage</a>, <a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/lib/IO/Uncompress/Gunzip.html">the IO::Uncompress::Gunzip manpage</a>, <a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/lib/IO/Compress/Deflate.html">the IO::Compress::Deflate manpage</a>, <a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/lib/IO/Uncompress/Inflate.html">the IO::Uncompress::Inflate manpage</a>, <a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/lib/IO/Compress/RawDeflate.html">the IO::Compress::RawDeflate manpage</a>, <a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/lib/IO/Uncompress/RawInflate.html">the IO::Uncompress::RawInflate manpage</a>, <a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/IO/Compress/Bzip2.html">the IO::Compress::Bzip2 manpage</a>, <a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/IO/Uncompress/Bunzip2.html">the IO::Uncompress::Bunzip2 manpage</a>, <a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/IO/Compress/Lzop.html">the IO::Compress::Lzop manpage</a>, <a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/IO/Uncompress/UnLzop.html">the IO::Uncompress::UnLzop manpage</a>, <a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/IO/Compress/Lzf.html">the IO::Compress::Lzf manpage</a>, <a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/IO/Uncompress/UnLzf.html">the IO::Uncompress::UnLzf manpage</a>, <a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/lib/IO/Uncompress/AnyInflate.html">the IO::Uncompress::AnyInflate manpage</a>, <a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/lib/IO/Uncompress/AnyUncompress.html">the IO::Uncompress::AnyUncompress manpage</a></p> <p><a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/Compress/Zlib/FAQ.html">Compress::Zlib::FAQ</a></p> <p><a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/lib/File/GlobMapper.html">File::GlobMapper</a>, <a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/Archive/Zip.html">Archive::Zip</a>, <a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/lib/Archive/Tar.html">Archive::Tar</a>, <a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/lib/IO/Zlib.html">IO::Zlib</a></p> <p>For <a href="http://www.ietf.org/rfc/rfc1950.txt" class="rfc">RFC 1950</a>, 1951 and 1952 see <em class="file"><a href="http://www.faqs.org/rfcs/rfc1950.html">http://www.faqs.org/rfcs/rfc1950.html</a></em>, <em class="file"><a href="http://www.faqs.org/rfcs/rfc1951.html">http://www.faqs.org/rfcs/rfc1951.html</a></em> and <em class="file"><a href="http://www.faqs.org/rfcs/rfc1952.html">http://www.faqs.org/rfcs/rfc1952.html</a></em></p> <p>The <em>zlib</em> compression library was written by Jean-loup Gailly <em class="file"><a href="mailto:gzip@prep.ai.mit.edu">gzip@prep.ai.mit.edu</a></em> and Mark Adler <em class="file"><a href="mailto:madler@alumni.caltech.edu">madler@alumni.caltech.edu</a></em>.</p> <p>The primary site for the <em>zlib</em> compression library is <em class="file"><a href="http://www.zlib.org">http://www.zlib.org</a></em>.</p> <p>The primary site for gzip is <em class="file"><a href="http://www.gzip.org">http://www.gzip.org</a></em>.</p> <p> </p> <hr /> <h1><a name="author">AUTHOR</a></h1> <p>This module was written by Paul Marquess, <em class="file"><a href="mailto:pmqs@cpan.org">pmqs@cpan.org</a></em>.</p> <p> </p> <hr /> <h1><a name="modification_history">MODIFICATION HISTORY</a></h1> <p>See the Changes file.</p> <p> </p> <hr /> <h1><a name="copyright_and_license">COPYRIGHT AND LICENSE</a></h1> <p>Copyright (c) 2005-2007 Paul Marquess. All rights reserved.</p> <p>This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.</p> <table border="0" width="100%" cellspacing="0" cellpadding="3"> <tr><td class="block" style="background-color: #cccccc" valign="middle"> <big><strong><span class="block"> Compress::Raw::Zlib - Low-Level Interface to zlib compression library</span></strong></big> </td></tr> </table> </body> </html>
Ms-Dos/Windows
Unix
Write backup
jsp File Browser version 1.2 by
www.vonloesch.de