compress::raw::zlib.3
来自「视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.」· 3 代码 · 共 753 行 · 第 1/3 页
3
753 行
\&\f(CW\*(C`$d\->dict_adler()\*(C'\fR..SpThe default is no dictionary..IP "\fB\-Bufsize\fR" 5.IX Item "-Bufsize"Sets the initial size for the output buffer used by the \f(CW\*(C`$d\->deflate\*(C'\fRand \f(CW\*(C`$d\->flush\*(C'\fR methods. If the buffer has to bereallocated to increase the size, it will grow in increments of\&\f(CW\*(C`Bufsize\*(C'\fR..SpThe default buffer size is 4096..IP "\fB\-AppendOutput\fR" 5.IX Item "-AppendOutput"This option controls how data is written to the output buffer by the\&\f(CW\*(C`$d\->deflate\*(C'\fR and \f(CW\*(C`$d\->flush\*(C'\fR methods..SpIf the \f(CW\*(C`AppendOutput\*(C'\fR option is set to false, the output buffers in the\&\f(CW\*(C`$d\->deflate\*(C'\fR and \f(CW\*(C`$d\->flush\*(C'\fR methods will be truncated beforeuncompressed data is written to them..SpIf the option is set to true, uncompressed data will be appended to theoutput buffer in the \f(CW\*(C`$d\->deflate\*(C'\fR and \f(CW\*(C`$d\->flush\*(C'\fR methods..SpThis option defaults to false..IP "\fB\-CRC32\fR" 5.IX Item "-CRC32"If set to true, a crc32 checksum of the uncompressed data will becalculated. Use the \f(CW\*(C`$d\->crc32\*(C'\fR method to retrieve this value..SpThis option defaults to false..IP "\fB\-ADLER32\fR" 5.IX Item "-ADLER32"If set to true, an adler32 checksum of the uncompressed data will becalculated. Use the \f(CW\*(C`$d\->adler32\*(C'\fR method to retrieve this value..SpThis option defaults to false..PPHere is an example of using the \f(CW\*(C`Compress::Raw::Zlib::Deflate\*(C'\fR optionalparameter list to override the default buffer size and compressionlevel. All other options will take their default values..PP.Vb 2\& my $d = new Compress::Raw::Zlib::Deflate ( \-Bufsize => 300, \& \-Level => Z_BEST_SPEED ) ;.Ve.ie n .Sh "\fB\fP\fB$status\fP\fB = \fP\f(BI$d\fP\fB\->deflate($input, \fP\f(CB$output\fP\fB)\fP".el .Sh "\fB\fP\f(CB$status\fP\fB = \fP\f(CB$d\fP\fB\->deflate($input, \fP\f(CB$output\fP\fB)\fP".IX Subsection "$status = $d->deflate($input, $output)"Deflates the contents of \f(CW$input\fR and writes the compressed data to\&\f(CW$output\fR..PPThe \f(CW$input\fR and \f(CW$output\fR parameters can be either scalars or scalarreferences..PPWhen finished, \f(CW$input\fR will be completely processed (assuming therewere no errors). If the deflation was successful it writes the deflateddata to \f(CW$output\fR and returns a status value of \f(CW\*(C`Z_OK\*(C'\fR..PPOn error, it returns a \fIzlib\fR error code..PPIf the \f(CW\*(C`AppendOutput\*(C'\fR option is set to true in the constructor forthe \f(CW$d\fR object, the compressed data will be appended to \f(CW$output\fR. Ifit is false, \f(CW$output\fR will be truncated before any compressed data iswritten to it..PP\&\fBNote\fR: This method will not necessarily write compressed data to\&\f(CW$output\fR every time it is called. So do not assume that there has beenan error if the contents of \f(CW$output\fR is empty on returning fromthis method. As long as the return code from the method is \f(CW\*(C`Z_OK\*(C'\fR,the deflate has succeeded..ie n .Sh "\fB\fP\fB$status\fP\fB = \fP\f(BI$d\fP\fB\->flush($output [, \fP\f(CB$flush_type\fP\fB]) \fP".el .Sh "\fB\fP\f(CB$status\fP\fB = \fP\f(CB$d\fP\fB\->flush($output [, \fP\f(CB$flush_type\fP\fB]) \fP".IX Subsection "$status = $d->flush($output [, $flush_type]) "Typically used to finish the deflation. Any pending output will bewritten to \f(CW$output\fR..PPReturns \f(CW\*(C`Z_OK\*(C'\fR if successful..PPNote that flushing can seriously degrade the compression ratio, so itshould only be used to terminate a decompression (using \f(CW\*(C`Z_FINISH\*(C'\fR) orwhen you want to create a \fIfull flush point\fR (using \f(CW\*(C`Z_FULL_FLUSH\*(C'\fR)..PPBy default the \f(CW\*(C`flush_type\*(C'\fR used is \f(CW\*(C`Z_FINISH\*(C'\fR. Other valid valuesfor \f(CW\*(C`flush_type\*(C'\fR are \f(CW\*(C`Z_NO_FLUSH\*(C'\fR, \f(CW\*(C`Z_PARTIAL_FLUSH\*(C'\fR, \f(CW\*(C`Z_SYNC_FLUSH\*(C'\fRand \f(CW\*(C`Z_FULL_FLUSH\*(C'\fR. It is strongly recommended that you only set the\&\f(CW\*(C`flush_type\*(C'\fR parameter if you fully understand the implications ofwhat it does. See the \f(CW\*(C`zlib\*(C'\fR documentation for details..PPIf the \f(CW\*(C`AppendOutput\*(C'\fR option is set to true in the constructor forthe \f(CW$d\fR object, the compressed data will be appended to \f(CW$output\fR. Ifit is false, \f(CW$output\fR will be truncated before any compressed data iswritten to it..ie n .Sh "\fB\fP\fB$status\fP\fB = \fP\f(BI$d\fP\fB\->deflateParams([\s-1OPT\s0])\fP".el .Sh "\fB\fP\f(CB$status\fP\fB = \fP\f(CB$d\fP\fB\->deflateParams([\s-1OPT\s0])\fP".IX Subsection "$status = $d->deflateParams([OPT])"Change settings for the deflate object \f(CW$d\fR..PPThe list of the valid options is shown below. Options not specifiedwill remain unchanged..IP "\fB\-Level\fR" 5.IX Item "-Level"Defines the compression level. Valid values are 0 through 9,\&\f(CW\*(C`Z_NO_COMPRESSION\*(C'\fR, \f(CW\*(C`Z_BEST_SPEED\*(C'\fR, \f(CW\*(C`Z_BEST_COMPRESSION\*(C'\fR, and\&\f(CW\*(C`Z_DEFAULT_COMPRESSION\*(C'\fR..IP "\fB\-Strategy\fR" 5.IX Item "-Strategy"Defines the strategy used to tune the compression. The valid values are\&\f(CW\*(C`Z_DEFAULT_STRATEGY\*(C'\fR, \f(CW\*(C`Z_FILTERED\*(C'\fR and \f(CW\*(C`Z_HUFFMAN_ONLY\*(C'\fR..IP "\fB\-BufSize\fR" 5.IX Item "-BufSize"Sets the initial size for the output buffer used by the \f(CW\*(C`$d\->deflate\*(C'\fRand \f(CW\*(C`$d\->flush\*(C'\fR methods. If the buffer has to bereallocated to increase the size, it will grow in increments of\&\f(CW\*(C`Bufsize\*(C'\fR..ie n .Sh "\fB\fP\fB$status\fP\fB = \fP\f(BI$d\fP\fB\->deflateTune($good_length, \fP\f(CB$max_lazy\fP\fB, \fP\f(CB$nice_length\fP\fB, \fP\f(CB$max_chain\fP\fB)\fP".el .Sh "\fB\fP\f(CB$status\fP\fB = \fP\f(CB$d\fP\fB\->deflateTune($good_length, \fP\f(CB$max_lazy\fP\fB, \fP\f(CB$nice_length\fP\fB, \fP\f(CB$max_chain\fP\fB)\fP".IX Subsection "$status = $d->deflateTune($good_length, $max_lazy, $nice_length, $max_chain)"Tune the internal settings for the deflate object \f(CW$d\fR. This option isonly available if you are running zlib 1.2.2.3 or better..PPRefer to the documentation in zlib.h for instructions on how to fly\&\f(CW\*(C`deflateTune\*(C'\fR..ie n .Sh "\fB\fP\fB$d\fP\fB\->\fP\f(BIdict_adler()\fP\fB\fP".el .Sh "\fB\fP\f(CB$d\fP\fB\->\fP\f(BIdict_adler()\fP\fB\fP".IX Subsection "$d->dict_adler()"Returns the adler32 value for the dictionary..ie n .Sh "\fB\fP\fB$d\fP\fB\->\fP\f(BIcrc32()\fP\fB\fP".el .Sh "\fB\fP\f(CB$d\fP\fB\->\fP\f(BIcrc32()\fP\fB\fP".IX Subsection "$d->crc32()"Returns the crc32 value for the uncompressed data to date..PPIf the \f(CW\*(C`CRC32\*(C'\fR option is not enabled in the constructor for this object,this method will always return 0;.ie n .Sh "\fB\fP\fB$d\fP\fB\->\fP\f(BIadler32()\fP\fB\fP".el .Sh "\fB\fP\f(CB$d\fP\fB\->\fP\f(BIadler32()\fP\fB\fP".IX Subsection "$d->adler32()"Returns the adler32 value for the uncompressed data to date..ie n .Sh "\fB\fP\fB$d\fP\fB\->\fP\f(BImsg()\fP\fB\fP".el .Sh "\fB\fP\f(CB$d\fP\fB\->\fP\f(BImsg()\fP\fB\fP".IX Subsection "$d->msg()"Returns the last error message generated by zlib..ie n .Sh "\fB\fP\fB$d\fP\fB\->\fP\f(BItotal_in()\fP\fB\fP".el .Sh "\fB\fP\f(CB$d\fP\fB\->\fP\f(BItotal_in()\fP\fB\fP".IX Subsection "$d->total_in()"Returns the total number of bytes uncompressed bytes input to deflate..ie n .Sh "\fB\fP\fB$d\fP\fB\->\fP\f(BItotal_out()\fP\fB\fP".el .Sh "\fB\fP\f(CB$d\fP\fB\->\fP\f(BItotal_out()\fP\fB\fP".IX Subsection "$d->total_out()"Returns the total number of compressed bytes output from deflate..ie n .Sh "\fB\fP\fB$d\fP\fB\->\fP\f(BIget_Strategy()\fP\fB\fP".el .Sh "\fB\fP\f(CB$d\fP\fB\->\fP\f(BIget_Strategy()\fP\fB\fP".IX Subsection "$d->get_Strategy()"Returns the deflation strategy currently used. Valid values are\&\f(CW\*(C`Z_DEFAULT_STRATEGY\*(C'\fR, \f(CW\*(C`Z_FILTERED\*(C'\fR and \f(CW\*(C`Z_HUFFMAN_ONLY\*(C'\fR..ie n .Sh "\fB\fP\fB$d\fP\fB\->\fP\f(BIget_Level()\fP\fB\fP".el .Sh "\fB\fP\f(CB$d\fP\fB\->\fP\f(BIget_Level()\fP\fB\fP".IX Subsection "$d->get_Level()"Returns the compression level being used..ie n .Sh "\fB\fP\fB$d\fP\fB\->\fP\f(BIget_BufSize()\fP\fB\fP".el .Sh "\fB\fP\f(CB$d\fP\fB\->\fP\f(BIget_BufSize()\fP\fB\fP".IX Subsection "$d->get_BufSize()"Returns the buffer size used to carry out the compression..Sh "Example".IX Subsection "Example"Here is a trivial example of using \f(CW\*(C`deflate\*(C'\fR. It simply reads standardinput, deflates it and writes it to standard output..PP.Vb 2\& 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\en" ;\&\& my ($output, $status) ;\& while (<>)\& {\& $status = $x\->deflate($_, $output) ;\& \& $status == Z_OK\& or die "deflation failed\en" ;\& \& print $output ;\& }\& \& $status = $x\->flush($output) ;\& \& $status == Z_OK\& or die "deflation failed\en" ;\& \& print $output ;.Ve.SH "Compress::Raw::Zlib::Inflate".IX Header "Compress::Raw::Zlib::Inflate"This section defines an interface that allows in-memory uncompression usingthe \fIinflate\fR interface provided by zlib..PPHere is a definition of the interface:.ie n .Sh "\fB ($i, \fP\fB$status\fP\fB) = new Compress::Raw::Zlib::Inflate( [\s-1OPT\s0] ) \fP".el .Sh "\fB ($i, \fP\f(CB$status\fP\fB) = new Compress::Raw::Zlib::Inflate( [\s-1OPT\s0] ) \fP".IX Subsection " ($i, $status) = new Compress::Raw::Zlib::Inflate( [OPT] ) "Initialises an inflation object..PPIn a list context it returns the inflation object, \f(CW$i\fR, and the\&\fIzlib\fR status code (\f(CW$status\fR). In a scalar context it returns theinflation object only..PPIf successful, \f(CW$i\fR will hold the inflation object and \f(CW$status\fR willbe \f(CW\*(C`Z_OK\*(C'\fR..PPIf not successful, \f(CW$i\fR will be \fIundef\fR and \f(CW$status\fR will hold the\&\fIzlib\fR error code..PPThe function optionally takes a number of named options specified as\&\f(CW\*(C`\-Name => value\*(C'\fR pairs. This allows individual options to betailored without having to specify them all in the parameter list..PPFor backward compatibility, it is also possible to pass the parametersas a reference to a hash containing the \f(CW\*(C`name=>value\*(C'\fR pairs..PPHere is a list of the valid options:.IP "\fB\-WindowBits\fR" 5.IX Item "-WindowBits"To uncompress an \s-1RFC\s0 1950 data stream, set \f(CW\*(C`WindowBits\*(C'\fR to a positivenumber..SpTo uncompress an \s-1RFC\s0 1951 data stream, set \f(CW\*(C`WindowBits\*(C'\fR to \f(CW\*(C`\-MAX_WBITS\*(C'\fR..SpFor a full definition of the meaning and valid values for \f(CW\*(C`WindowBits\*(C'\fRrefer to the \fIzlib\fR documentation for \fIinflateInit2\fR..SpDefaults to \s-1MAX_WBITS\s0..IP "\fB\-Bufsize\fR" 5.IX Item "-Bufsize"Sets the initial size for the output buffer used by the \f(CW\*(C`$i\->inflate\*(C'\fRmethod. If the output buffer in this method has to be reallocated toincrease the size, it will grow in increments of \f(CW\*(C`Bufsize\*(C'\fR..SpDefault is 4096..IP "\fB\-Dictionary\fR" 5.IX Item "-Dictionary"The default is no dictionary..IP "\fB\-AppendOutput\fR" 5.IX Item "-AppendOutput"This option controls how data is written to the output buffer by the\&\f(CW\*(C`$i\->inflate\*(C'\fR method..Sp
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?