⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 zlib.pm

📁 视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.
💻 PM
📖 第 1 页 / 共 3 页
字号:
=head2 B<$d-E<gt>msg()>Returns the last error message generated by zlib.=head2 B<$d-E<gt>total_in()>Returns the total number of bytes uncompressed bytes input to deflate.=head2 B<$d-E<gt>total_out()>Returns the total number of compressed bytes output from deflate.=head2 B<$d-E<gt>get_Strategy()>Returns the deflation strategy currently used. Valid values areC<Z_DEFAULT_STRATEGY>, C<Z_FILTERED> and C<Z_HUFFMAN_ONLY>. =head2 B<$d-E<gt>get_Level()>Returns the compression level being used. =head2 B<$d-E<gt>get_BufSize()>Returns the buffer size used to carry out the compression.=head2 ExampleHere is a trivial example of using C<deflate>. It simply reads standardinput, deflates it and writes it to standard output.    use strict ;    use warnings ;    use Compress::Raw::Zlib ;    binmode STDIN;    binmode STDOUT;    my $x = new Compress::Raw::Zlib::Deflate       or die "Cannot create a deflation stream\n" ;    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 ;=head1 Compress::Raw::Zlib::InflateThis section defines an interface that allows in-memory uncompression usingthe I<inflate> interface provided by zlib.Here is a definition of the interface:=head2 B< ($i, $status) = new Compress::Raw::Zlib::Inflate( [OPT] ) >Initialises an inflation object. In a list context it returns the inflation object, C<$i>, and theI<zlib> status code (C<$status>). In a scalar context it returns theinflation object only.If successful, C<$i> will hold the inflation object and C<$status> willbe C<Z_OK>.If not successful, C<$i> will be I<undef> and C<$status> will hold theI<zlib> error code.The function optionally takes a number of named options specified asC<< -Name => value >> pairs. This allows individual options to betailored without having to specify them all in the parameter list.For backward compatibility, it is also possible to pass the parametersas a reference to a hash containing the C<< name=>value >> pairs.Here is a list of the valid options:=over 5=item B<-WindowBits>To uncompress an RFC 1950 data stream, set C<WindowBits> to a positivenumber.To uncompress an RFC 1951 data stream, set C<WindowBits> to C<-MAX_WBITS>.For a full definition of the meaning and valid values for C<WindowBits>refer to the I<zlib> documentation for I<inflateInit2>.Defaults to MAX_WBITS.=item B<-Bufsize>Sets the initial size for the output buffer used by the C<$i-E<gt>inflate>method. If the output buffer in this method has to be reallocated toincrease the size, it will grow in increments of C<Bufsize>.Default is 4096.=item B<-Dictionary>The default is no dictionary.=item B<-AppendOutput>This option controls how data is written to the output buffer by theC<$i-E<gt>inflate> method.If the option is set to false, the output buffer in the C<$i-E<gt>inflate>method will be truncated before uncompressed data is written to it.If the option is set to true, uncompressed data will be appended to theoutput buffer by the C<$i-E<gt>inflate> method.This option defaults to false.=item B<-CRC32>If set to true, a crc32 checksum of the uncompressed data will becalculated. Use the C<$i-E<gt>crc32> method to retrieve this value.This option defaults to false.=item B<-ADLER32>If set to true, an adler32 checksum of the uncompressed data will becalculated. Use the C<$i-E<gt>adler32> method to retrieve this value.This option defaults to false.=item B<-ConsumeInput>If set to true, this option will remove compressed data from the inputbuffer of the the C< $i-E<gt>inflate > method as the inflate progresses.This option can be useful when you are processing compressed data that isembedded in another file/buffer. In this case the data that immediatelyfollows the compressed stream will be left in the input buffer.This option defaults to true.=backHere is an example of using an optional parameter to override the defaultbuffer size.    my ($i, $status) = new Compress::Raw::Zlib::Inflate( -Bufsize => 300 ) ;=head2 B< $status = $i-E<gt>inflate($input, $output [,$eof]) >Inflates the complete contents of C<$input> and writes the uncompresseddata to C<$output>. The C<$input> and C<$output> parameters can either bescalars or scalar references.Returns C<Z_OK> if successful and C<Z_STREAM_END> if the end of thecompressed data has been successfully reached. If not successful C<$status> will hold the I<zlib> error code.If the C<ConsumeInput> option has been set to true when theC<Compress::Raw::Zlib::Inflate> object is created, the C<$input> parameteris modified by C<inflate>. On completion it will contain what remainsof the input buffer after inflation. In practice, this means that whenthe return status is C<Z_OK> the C<$input> parameter will contain anempty string, and when the return status is C<Z_STREAM_END> the C<$input>parameter will contains what (if anything) was stored in the input bufferafter the deflated data stream.This feature is useful when processing a file format that encapsulatesa compressed data stream (e.g. gzip, zip) and there is useful dataimmediately after the deflation stream.If the C<AppendOutput> option is set to true in the constructor forthis object, the uncompressed data will be appended to C<$output>. Ifit is false, C<$output> will be truncated before any uncompressed datais written to it.The C<$eof> parameter needs a bit of explanation. Prior to version 1.2.0, zlib assumed that there was at least one trailingbyte immediately after the compressed data stream when it was carrying outdecompression. This normally isn't a problem because the majority of zlibapplications guarantee that there will be data directly after thecompressed data stream.  For example, both gzip (RFC 1950) and zip bothdefine trailing data that follows the compressed data stream.The C<$eof> parameter only needs to be used if B<all> of the followingconditions apply=over 5=item 1 You are either using a copy of zlib that is older than version 1.2.0 or youwant your application code to be able to run with as many differentversions of zlib as possible.=item 2You have set the C<WindowBits> parameter to C<-MAX_WBITS> in the constructorfor this object, i.e. you are uncompressing a raw deflated data stream(RFC 1951).=item 3There is no data immediately after the compressed data stream.=backIf B<all> of these are the case, then you need to set the C<$eof> parameterto true on the final call (and only the final call) to C<$i-E<gt>inflate>. If you have built this module with zlib >= 1.2.0, the C<$eof> parameter isignored. You can still set it if you want, but it won't be used behind thescenes.=head2 B<$status = $i-E<gt>inflateSync($input)>This method can be used to attempt to recover good data from a compresseddata stream that is partially corrupt.It scans C<$input> until it reaches either a I<full flush point> or theend of the buffer.If a I<full flush point> is found, C<Z_OK> is returned and C<$input>will be have all data up to the flush point removed. This data can then bepassed to the C<$i-E<gt>inflate> method to be uncompressed.Any other return code means that a flush point was not found. If moredata is available, C<inflateSync> can be called repeatedly with morecompressed data until the flush point is found.Note I<full flush points> are not present by default in compresseddata streams. They must have been added explicitly when the data streamwas created by calling C<Compress::Deflate::flush>  with C<Z_FULL_FLUSH>.=head2 B<$i-E<gt>dict_adler()>Returns the adler32 value for the dictionary.=head2 B<$i-E<gt>crc32()>Returns the crc32 value for the uncompressed data to date.If the C<CRC32> option is not enabled in the constructor for this object,this method will always return 0;=head2 B<$i-E<gt>adler32()>Returns the adler32 value for the uncompressed data to date.If the C<ADLER32> option is not enabled in the constructor for this object,this method will always return 0;=head2 B<$i-E<gt>msg()>Returns the last error message generated by zlib.=head2 B<$i-E<gt>total_in()>Returns the total number of bytes compressed bytes input to inflate.=head2 B<$i-E<gt>total_out()>Returns the total number of uncompressed bytes output from inflate.=head2 B<$d-E<gt>get_BufSize()>Returns the buffer size used to carry out the decompression.=head2 ExampleHere is an example of using C<inflate>.    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 ;=head1 CHECKSUM FUNCTIONSTwo functions are provided by I<zlib> to calculate checksums. For thePerl interface, the order of the two parameters in both functions hasbeen reversed. This allows both running checksums and one offcalculations to be done.    $crc = adler32($buffer [,$crc]) ;    $crc = crc32($buffer [,$crc]) ;The buffer parameters can either be a scalar or a scalar reference.If the $crc parameters is C<undef>, the crc value will be reset.If you have built this module with zlib 1.2.3 or better, two moreCRC-related functions are available.    $crc = adler32_combine($crc1, $crc2, $len2)l    $crc = crc32_combine($adler1, $adler2, $len2)These functions allow checksums to be merged.=head1 ACCESSING ZIP FILESAlthough it is possible (with some effort on your part) to use thismodule to access .zip files, there is a module on CPAN that will do allthe hard work for you. Check out the C<Archive::Zip> module on CPAN at    http://www.cpan.org/modules/by-module/Archive/Archive-Zip-*.tar.gz    =head1 CONSTANTSAll the I<zlib> constants are automatically imported when you make useof I<Compress::Raw::Zlib>.=head1 SEE ALSOL<Compress::Zlib>, L<IO::Compress::Gzip>, L<IO::Uncompress::Gunzip>, L<IO::Compress::Deflate>, L<IO::Uncompress::Inflate>, L<IO::Compress::RawDeflate>, L<IO::Uncompress::RawInflate>, L<IO::Compress::Bzip2>, L<IO::Uncompress::Bunzip2>, L<IO::Compress::Lzop>, L<IO::Uncompress::UnLzop>, L<IO::Compress::Lzf>, L<IO::Uncompress::UnLzf>, L<IO::Uncompress::AnyInflate>, L<IO::Uncompress::AnyUncompress>L<Compress::Zlib::FAQ|Compress::Zlib::FAQ>L<File::GlobMapper|File::GlobMapper>, L<Archive::Zip|Archive::Zip>,L<Archive::Tar|Archive::Tar>,L<IO::Zlib|IO::Zlib>For RFC 1950, 1951 and 1952 see F<http://www.faqs.org/rfcs/rfc1950.html>,F<http://www.faqs.org/rfcs/rfc1951.html> andF<http://www.faqs.org/rfcs/rfc1952.html>The I<zlib> compression library was written by Jean-loup GaillyF<gzip@prep.ai.mit.edu> and Mark Adler F<madler@alumni.caltech.edu>.The primary site for the I<zlib> compression library isF<http://www.zlib.org>.The primary site for gzip is F<http://www.gzip.org>.=head1 AUTHORThis module was written by Paul Marquess, F<pmqs@cpan.org>. =head1 MODIFICATION HISTORYSee the Changes file.=head1 COPYRIGHT AND LICENSECopyright (c) 2005-2007 Paul Marquess. All rights reserved.This program is free software; you can redistribute it and/ormodify it under the same terms as Perl itself.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -