{
    "content": [
        {
            "type": "text",
            "text": "# Compress::Zlib (perldoc)\n\n## NAME\n\nCompress::Zlib - Interface to zlib compression library\n\n## SYNOPSIS\n\nuse Compress::Zlib ;\n($d, $status) = deflateInit( [OPT] ) ;\n$status = $d->deflate($input, $output) ;\n$status = $d->flush([$flushtype]) ;\n$d->deflateParams(OPTS) ;\n$d->deflateTune(OPTS) ;\n$d->dictadler() ;\n$d->crc32() ;\n$d->adler32() ;\n$d->totalin() ;\n$d->totalout() ;\n$d->msg() ;\n$d->getStrategy();\n$d->getLevel();\n$d->getBufSize();\n($i, $status) = inflateInit( [OPT] ) ;\n$status = $i->inflate($input, $output [, $eof]) ;\n$status = $i->inflateSync($input) ;\n$i->dictadler() ;\n$d->crc32() ;\n$d->adler32() ;\n$i->totalin() ;\n$i->totalout() ;\n$i->msg() ;\n$d->getBufSize();\n$dest = compress($source) ;\n$dest = uncompress($source) ;\n$gz = gzopen($filename or filehandle, $mode) ;\n$bytesread = $gz->gzread($buffer [,$size]) ;\n$bytesread = $gz->gzreadline($line) ;\n$byteswritten = $gz->gzwrite($buffer) ;\n$status = $gz->gzflush($flush) ;\n$offset = $gz->gztell() ;\n$status = $gz->gzseek($offset, $whence) ;\n$status = $gz->gzclose() ;\n$status = $gz->gzeof() ;\n$status = $gz->gzsetparams($level, $strategy) ;\n$errstring = $gz->gzerror() ;\n$gzerrno\n$dest = Compress::Zlib::memGzip($buffer) ;\n$dest = Compress::Zlib::memGunzip($buffer) ;\n$crc = adler32($buffer [,$crc]) ;\n$crc = crc32($buffer [,$crc]) ;\n$crc = crc32combine($crc1, $crc2, $len2);\n$adler = adler32combine($adler1, $adler2, $len2);\nmy $version = Compress::Raw::Zlib::zlibversion();\n\n## DESCRIPTION\n\nThe *Compress::Zlib* module provides a Perl interface to the *zlib* compression library (see\n\"AUTHOR\" for details about where to get *zlib*).\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION** (1 subsections)\n- **GZIP INTERFACE** (3 subsections)\n- **COMPRESS/UNCOMPRESS**\n- **Deflate Interface** (10 subsections)\n- **Inflate Interface** (4 subsections)\n- **CHECKSUM FUNCTIONS**\n- **Misc**\n- **CONSTANTS**\n- **SUPPORT**\n- **SEE ALSO**\n- **AUTHOR**\n- **MODIFICATION HISTORY**\n- **COPYRIGHT AND LICENSE**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "Compress::Zlib",
        "section": "",
        "mode": "perldoc",
        "summary": "Compress::Zlib - Interface to zlib compression library",
        "synopsis": "use Compress::Zlib ;\n($d, $status) = deflateInit( [OPT] ) ;\n$status = $d->deflate($input, $output) ;\n$status = $d->flush([$flushtype]) ;\n$d->deflateParams(OPTS) ;\n$d->deflateTune(OPTS) ;\n$d->dictadler() ;\n$d->crc32() ;\n$d->adler32() ;\n$d->totalin() ;\n$d->totalout() ;\n$d->msg() ;\n$d->getStrategy();\n$d->getLevel();\n$d->getBufSize();\n($i, $status) = inflateInit( [OPT] ) ;\n$status = $i->inflate($input, $output [, $eof]) ;\n$status = $i->inflateSync($input) ;\n$i->dictadler() ;\n$d->crc32() ;\n$d->adler32() ;\n$i->totalin() ;\n$i->totalout() ;\n$i->msg() ;\n$d->getBufSize();\n$dest = compress($source) ;\n$dest = uncompress($source) ;\n$gz = gzopen($filename or filehandle, $mode) ;\n$bytesread = $gz->gzread($buffer [,$size]) ;\n$bytesread = $gz->gzreadline($line) ;\n$byteswritten = $gz->gzwrite($buffer) ;\n$status = $gz->gzflush($flush) ;\n$offset = $gz->gztell() ;\n$status = $gz->gzseek($offset, $whence) ;\n$status = $gz->gzclose() ;\n$status = $gz->gzeof() ;\n$status = $gz->gzsetparams($level, $strategy) ;\n$errstring = $gz->gzerror() ;\n$gzerrno\n$dest = Compress::Zlib::memGzip($buffer) ;\n$dest = Compress::Zlib::memGunzip($buffer) ;\n$crc = adler32($buffer [,$crc]) ;\n$crc = crc32($buffer [,$crc]) ;\n$crc = crc32combine($crc1, $crc2, $len2);\n$adler = adler32combine($adler1, $adler2, $len2);\nmy $version = Compress::Raw::Zlib::zlibversion();",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 55,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 9,
                "subsections": [
                    {
                        "name": "Notes for users of Compress::Zlib version 1",
                        "lines": 16
                    }
                ]
            },
            {
                "name": "GZIP INTERFACE",
                "lines": 164,
                "subsections": [
                    {
                        "name": "Examples",
                        "lines": 74
                    },
                    {
                        "name": "Compress::Zlib::memGzip",
                        "lines": 13
                    },
                    {
                        "name": "Compress::Zlib::memGunzip",
                        "lines": 17
                    }
                ]
            },
            {
                "name": "COMPRESS/UNCOMPRESS",
                "lines": 25,
                "subsections": []
            },
            {
                "name": "Deflate Interface",
                "lines": 29,
                "subsections": [
                    {
                        "name": "-Level",
                        "lines": 5
                    },
                    {
                        "name": "-Method",
                        "lines": 3
                    },
                    {
                        "name": "-WindowBits",
                        "lines": 9
                    },
                    {
                        "name": "-MemLevel",
                        "lines": 5
                    },
                    {
                        "name": "-Strategy",
                        "lines": 5
                    },
                    {
                        "name": "-Dictionary",
                        "lines": 6
                    },
                    {
                        "name": "-Bufsize",
                        "lines": 44
                    },
                    {
                        "name": "-Level",
                        "lines": 3
                    },
                    {
                        "name": "-Strategy",
                        "lines": 15
                    },
                    {
                        "name": "Example",
                        "lines": 31
                    }
                ]
            },
            {
                "name": "Inflate Interface",
                "lines": 27,
                "subsections": [
                    {
                        "name": "-WindowBits",
                        "lines": 9
                    },
                    {
                        "name": "-Bufsize",
                        "lines": 5
                    },
                    {
                        "name": "-Dictionary",
                        "lines": 44
                    },
                    {
                        "name": "Example",
                        "lines": 28
                    }
                ]
            },
            {
                "name": "CHECKSUM FUNCTIONS",
                "lines": 20,
                "subsections": []
            },
            {
                "name": "Misc",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "CONSTANTS",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SUPPORT",
                "lines": 4,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 21,
                "subsections": []
            },
            {
                "name": "AUTHOR",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "MODIFICATION HISTORY",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "COPYRIGHT AND LICENSE",
                "lines": 5,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "Compress::Zlib - Interface to zlib compression library\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "use Compress::Zlib ;\n\n($d, $status) = deflateInit( [OPT] ) ;\n$status = $d->deflate($input, $output) ;\n$status = $d->flush([$flushtype]) ;\n$d->deflateParams(OPTS) ;\n$d->deflateTune(OPTS) ;\n$d->dictadler() ;\n$d->crc32() ;\n$d->adler32() ;\n$d->totalin() ;\n$d->totalout() ;\n$d->msg() ;\n$d->getStrategy();\n$d->getLevel();\n$d->getBufSize();\n\n($i, $status) = inflateInit( [OPT] ) ;\n$status = $i->inflate($input, $output [, $eof]) ;\n$status = $i->inflateSync($input) ;\n$i->dictadler() ;\n$d->crc32() ;\n$d->adler32() ;\n$i->totalin() ;\n$i->totalout() ;\n$i->msg() ;\n$d->getBufSize();\n\n$dest = compress($source) ;\n$dest = uncompress($source) ;\n\n$gz = gzopen($filename or filehandle, $mode) ;\n$bytesread = $gz->gzread($buffer [,$size]) ;\n$bytesread = $gz->gzreadline($line) ;\n$byteswritten = $gz->gzwrite($buffer) ;\n$status = $gz->gzflush($flush) ;\n$offset = $gz->gztell() ;\n$status = $gz->gzseek($offset, $whence) ;\n$status = $gz->gzclose() ;\n$status = $gz->gzeof() ;\n$status = $gz->gzsetparams($level, $strategy) ;\n$errstring = $gz->gzerror() ;\n$gzerrno\n\n$dest = Compress::Zlib::memGzip($buffer) ;\n$dest = Compress::Zlib::memGunzip($buffer) ;\n\n$crc = adler32($buffer [,$crc]) ;\n$crc = crc32($buffer [,$crc]) ;\n\n$crc = crc32combine($crc1, $crc2, $len2);\n$adler = adler32combine($adler1, $adler2, $len2);\n\nmy $version = Compress::Raw::Zlib::zlibversion();\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "The *Compress::Zlib* module provides a Perl interface to the *zlib* compression library (see\n\"AUTHOR\" for details about where to get *zlib*).\n\nThe \"Compress::Zlib\" module can be split into two general areas of functionality, namely a\nsimple read/write interface to *gzip* files and a low-level in-memory compression/decompression\ninterface.\n\nEach of these areas will be discussed in the following sections.\n",
                "subsections": [
                    {
                        "name": "Notes for users of Compress::Zlib version 1",
                        "content": "The main change in \"Compress::Zlib\" version 2.x is that it does not now interface directly to\nthe zlib library. Instead it uses the \"IO::Compress::Gzip\" and \"IO::Uncompress::Gunzip\" modules\nfor reading/writing gzip files, and the \"Compress::Raw::Zlib\" module for some low-level zlib\naccess.\n\nThe interface provided by version 2 of this module should be 100% backward compatible with\nversion 1. If you find a difference in the expected behaviour please contact the author (See\n\"AUTHOR\"). See \"GZIP INTERFACE\"\n\nWith the creation of the \"IO::Compress\" and \"IO::Uncompress\" modules no new features are planned\nfor \"Compress::Zlib\" - the new modules do everything that \"Compress::Zlib\" does and then some.\nDevelopment on \"Compress::Zlib\" will be limited to bug fixes only.\n\nIf you are writing new code, your first port of call should be one of the new \"IO::Compress\" or\n\"IO::Uncompress\" modules.\n"
                    }
                ]
            },
            "GZIP INTERFACE": {
                "content": "A number of functions are supplied in *zlib* for reading and writing *gzip* files that conform\nto RFC 1952. This module provides an interface to most of them.\n\nIf you have previously used \"Compress::Zlib\" 1.x, the following enhancements/changes have been\nmade to the \"gzopen\" interface:\n\n1    If you want to open either STDIN or STDOUT with \"gzopen\", you can now optionally use the\nspecial filename \"\"-\"\" as a synonym for \"\\*STDIN\" and \"\\*STDOUT\".\n\n2    In \"Compress::Zlib\" version 1.x, \"gzopen\" used the zlib library to open the underlying\nfile. This made things especially tricky when a Perl filehandle was passed to \"gzopen\".\nBehind the scenes the numeric C file descriptor had to be extracted from the Perl\nfilehandle and this passed to the zlib library.\n\nApart from being non-portable to some operating systems, this made it difficult to use\n\"gzopen\" in situations where you wanted to extract/create a gzip data stream that is\nembedded in a larger file, without having to resort to opening and closing the file\nmultiple times.\n\nIt also made it impossible to pass a perl filehandle that wasn't associated with a real\nfilesystem file, like, say, an \"IO::String\".\n\nIn \"Compress::Zlib\" version 2.x, the \"gzopen\" interface has been completely rewritten to\nuse the IO::Compress::Gzip for writing gzip files and IO::Uncompress::Gunzip for reading\ngzip files. None of the limitations mentioned above apply.\n\n3    Addition of \"gzseek\" to provide a restricted \"seek\" interface.\n\n4.   Added \"gztell\".\n\nA more complete and flexible interface for reading/writing gzip files/buffers is included with\nthe module \"IO-Compress-Zlib\". See IO::Compress::Gzip and IO::Uncompress::Gunzip for more\ndetails.\n\n$gz = gzopen($filename, $mode)\n$gz = gzopen($filehandle, $mode)\nThis function opens either the *gzip* file $filename for reading or writing or attaches to\nthe opened filehandle, $filehandle. It returns an object on success and \"undef\" on failure.\n\nWhen writing a gzip file this interface will *always* create the smallest possible gzip\nheader (exactly 10 bytes). If you want greater control over what gets stored in the gzip\nheader (like the original filename or a comment) use IO::Compress::Gzip instead. Similarly\nif you want to read the contents of the gzip header use IO::Uncompress::Gunzip.\n\nThe second parameter, $mode, is used to specify whether the file is opened for reading or\nwriting and to optionally specify a compression level and compression strategy when\nwriting. The format of the $mode parameter is similar to the mode parameter to the 'C'\nfunction \"fopen\", so \"rb\" is used to open for reading, \"wb\" for writing and \"ab\" for\nappending (writing at the end of the file).\n\nTo specify a compression level when writing, append a digit between 0 and 9 to the mode\nstring -- 0 means no compression and 9 means maximum compression. If no compression level\nis specified ZDEFAULTCOMPRESSION is used.\n\nTo specify the compression strategy when writing, append 'f' for filtered data, 'h' for\nHuffman only compression, or 'R' for run-length encoding. If no strategy is specified\nZDEFAULTSTRATEGY is used.\n\nSo, for example, \"wb9\" means open for writing with the maximum compression using the\ndefault strategy and \"wb4R\" means open for writing with compression level 4 and run-length\nencoding.\n\nRefer to the *zlib* documentation for the exact format of the $mode parameter.\n\n$bytesread = $gz->gzread($buffer [, $size]) ;\nReads $size bytes from the compressed file into $buffer. If $size is not specified, it will\ndefault to 4096. If the scalar $buffer is not large enough, it will be extended\nautomatically.\n\nReturns the number of bytes actually read. On EOF it returns 0 and in the case of an error,\n-1.\n\n$bytesread = $gz->gzreadline($line) ;\nReads the next line from the compressed file into $line.\n\nReturns the number of bytes actually read. On EOF it returns 0 and in the case of an error,\n-1.\n\nIt is legal to intermix calls to \"gzread\" and \"gzreadline\".\n\nTo maintain backward compatibility with version 1.x of this module \"gzreadline\" ignores the\n$/ variable - it *always* uses the string \"\\n\" as the line delimiter.\n\nIf you want to read a gzip file a line at a time and have it respect the $/ variable (or\n$INPUTRECORDSEPARATOR, or $RS when \"English\" is in use) see IO::Uncompress::Gunzip.\n\n$byteswritten = $gz->gzwrite($buffer) ;\nWrites the contents of $buffer to the compressed file. Returns the number of bytes actually\nwritten, or 0 on error.\n\n$status = $gz->gzflush($flushtype) ;\nFlushes all pending output into the compressed file.\n\nThis method takes an optional parameter, $flushtype, that controls how the flushing will\nbe carried out. By default the $flushtype used is \"ZFINISH\". Other valid values for\n$flushtype are \"ZNOFLUSH\", \"ZSYNCFLUSH\", \"ZFULLFLUSH\" and \"ZBLOCK\". It is strongly\nrecommended that you only set the \"flushtype\" parameter if you fully understand the\nimplications of what it does - overuse of \"flush\" can seriously degrade the level of\ncompression achieved. See the \"zlib\" documentation for details.\n\nReturns 0 on success.\n\n$offset = $gz->gztell() ;\nReturns the uncompressed file offset.\n\n$status = $gz->gzseek($offset, $whence) ;\nProvides a sub-set of the \"seek\" functionality, with the restriction that it is only legal\nto seek forward in the compressed file. It is a fatal error to attempt to seek backward.\n\nWhen opened for writing, empty parts of the file will have NULL (0x00) bytes written to\nthem.\n\nThe $whence parameter should be one of SEEKSET, SEEKCUR or SEEKEND.\n\nReturns 1 on success, 0 on failure.\n\n$gz->gzclose\nCloses the compressed file. Any pending data is flushed to the file before it is closed.\n\nReturns 0 on success.\n\n$gz->gzsetparams($level, $strategy\nChange settings for the deflate stream $gz.\n\nThe list of the valid options is shown below. Options not specified will remain unchanged.\n\nNote: This method is only available if you are running zlib 1.0.6 or better.\n\n$level\nDefines the compression level. Valid values are 0 through 9, \"ZNOCOMPRESSION\",\n\"ZBESTSPEED\", \"ZBESTCOMPRESSION\", and \"ZDEFAULTCOMPRESSION\".\n\n$strategy\nDefines the strategy used to tune the compression. The valid values are\n\"ZDEFAULTSTRATEGY\", \"ZFILTERED\" and \"ZHUFFMANONLY\".\n\n$gz->gzerror\nReturns the *zlib* error message or number for the last operation associated with $gz. The\nreturn value will be the *zlib* error number when used in a numeric context and the *zlib*\nerror message when used in a string context. The *zlib* error number constants, shown\nbelow, are available for use.\n\nZOK\nZSTREAMEND\nZERRNO\nZSTREAMERROR\nZDATAERROR\nZMEMERROR\nZBUFERROR\n\n$gzerrno\nThe $gzerrno scalar holds the error code associated with the most recent *gzip* routine.\nNote that unlike \"gzerror()\", the error is *not* associated with a particular file.\n\nAs with \"gzerror()\" it returns an error number in numeric context and an error message in\nstring context. Unlike \"gzerror()\" though, the error message will correspond to the *zlib*\nmessage when the error is associated with *zlib* itself, or the UNIX error message when it\nis not (i.e. *zlib* returned \"ZERRORNO\").\n\nAs there is an overlap between the error numbers used by *zlib* and UNIX, $gzerrno should\nonly be used to check for the presence of *an* error in numeric context. Use \"gzerror()\" to\ncheck for specific *zlib* errors. The *gzcat* example below shows how the variable can be\nused safely.\n",
                "subsections": [
                    {
                        "name": "Examples",
                        "content": "Here is an example script which uses the interface. It implements a *gzcat* function.\n\nuse strict ;\nuse warnings ;\n\nuse Compress::Zlib ;\n\n# use stdin if no files supplied\n@ARGV = '-' unless @ARGV ;\n\nforeach my $file (@ARGV) {\nmy $buffer ;\n\nmy $gz = gzopen($file, \"rb\")\nor die \"Cannot open $file: $gzerrno\\n\" ;\n\nprint $buffer while $gz->gzread($buffer) > 0 ;\n\ndie \"Error reading from $file: $gzerrno\" . ($gzerrno+0) . \"\\n\"\nif $gzerrno != ZSTREAMEND ;\n\n$gz->gzclose() ;\n}\n\nBelow is a script which makes use of \"gzreadline\". It implements a very simple *grep* like\nscript.\n\nuse strict ;\nuse warnings ;\n\nuse Compress::Zlib ;\n\ndie \"Usage: gzgrep pattern [file...]\\n\"\nunless @ARGV >= 1;\n\nmy $pattern = shift ;\n\n# use stdin if no files supplied\n@ARGV = '-' unless @ARGV ;\n\nforeach my $file (@ARGV) {\nmy $gz = gzopen($file, \"rb\")\nor die \"Cannot open $file: $gzerrno\\n\" ;\n\nwhile ($gz->gzreadline($) > 0) {\nprint if /$pattern/ ;\n}\n\ndie \"Error reading from $file: $gzerrno\\n\"\nif $gzerrno != ZSTREAMEND ;\n\n$gz->gzclose() ;\n}\n\nThis script, *gzstream*, does the opposite of the *gzcat* script above. It reads from standard\ninput and writes a gzip data stream to standard output.\n\nuse strict ;\nuse warnings ;\n\nuse Compress::Zlib ;\n\nbinmode STDOUT;  # gzopen only sets it on the fd\n\nmy $gz = gzopen(\\*STDOUT, \"wb\")\nor die \"Cannot open stdout: $gzerrno\\n\" ;\n\nwhile (<>) {\n$gz->gzwrite($)\nor die \"error writing: $gzerrno\\n\" ;\n}\n\n$gz->gzclose ;\n"
                    },
                    {
                        "name": "Compress::Zlib::memGzip",
                        "content": "This function is used to create an in-memory gzip file with the minimum possible gzip header\n(exactly 10 bytes).\n\n$dest = Compress::Zlib::memGzip($buffer)\nor die \"Cannot compress: $gzerrno\\n\";\n\nIf successful, it returns the in-memory gzip file. Otherwise it returns \"undef\" and the $gzerrno\nvariable will store the zlib error code.\n\nThe $buffer parameter can either be a scalar or a scalar reference.\n\nSee IO::Compress::Gzip for an alternative way to carry out in-memory gzip compression.\n"
                    },
                    {
                        "name": "Compress::Zlib::memGunzip",
                        "content": "This function is used to uncompress an in-memory gzip file.\n\n$dest = Compress::Zlib::memGunzip($buffer)\nor die \"Cannot uncompress: $gzerrno\\n\";\n\nIf successful, it returns the uncompressed gzip file. Otherwise it returns \"undef\" and the\n$gzerrno variable will store the zlib error code.\n\nThe $buffer parameter can either be a scalar or a scalar reference. The contents of the $buffer\nparameter are destroyed after calling this function.\n\nIf $buffer consists of multiple concatenated gzip data streams only the first will be\nuncompressed. Use \"gunzip\" with the \"MultiStream\" option in the \"IO::Uncompress::Gunzip\" module\nif you need to deal with concatenated data streams.\n\nSee IO::Uncompress::Gunzip for an alternative way to carry out in-memory gzip uncompression.\n"
                    }
                ]
            },
            "COMPRESS/UNCOMPRESS": {
                "content": "Two functions are provided to perform in-memory compression/uncompression of RFC 1950 data\nstreams. They are called \"compress\" and \"uncompress\".\n\n$dest = compress($source [, $level] ) ;\nCompresses $source. If successful it returns the compressed data. Otherwise it returns\n*undef*.\n\nThe source buffer, $source, can either be a scalar or a scalar reference.\n\nThe $level parameter defines the compression level. Valid values are 0 through 9,\n\"ZNOCOMPRESSION\", \"ZBESTSPEED\", \"ZBESTCOMPRESSION\", and \"ZDEFAULTCOMPRESSION\". If\n$level is not specified \"ZDEFAULTCOMPRESSION\" will be used.\n\n$dest = uncompress($source) ;\nUncompresses $source. If successful it returns the uncompressed data. Otherwise it returns\n*undef*.\n\nThe source buffer can either be a scalar or a scalar reference.\n\nPlease note: the two functions defined above are *not* compatible with the Unix commands of the\nsame name.\n\nSee IO::Deflate and IO::Inflate included with this distribution for an alternative interface for\nreading/writing RFC 1950 files/buffers.\n",
                "subsections": []
            },
            "Deflate Interface": {
                "content": "This section defines an interface that allows in-memory compression using the *deflate*\ninterface provided by zlib.\n\nHere is a definition of the interface available:\n\n($d, $status) = deflateInit( [OPT] )\nInitialises a deflation stream.\n\nIt combines the features of the *zlib* functions \"deflateInit\", \"deflateInit2\" and\n\"deflateSetDictionary\".\n\nIf successful, it will return the initialised deflation stream, $d and $status of \"ZOK\" in a\nlist context. In scalar context it returns the deflation stream, $d, only.\n\nIf not successful, the returned deflation stream ($d) will be *undef* and $status will hold the\nexact *zlib* error code.\n\nThe function optionally takes a number of named options specified as \"-Name=>value\" pairs. This\nallows individual options to be tailored without having to specify them all in the parameter\nlist.\n\nFor backward compatibility, it is also possible to pass the parameters as a reference to a hash\ncontaining the name=>value pairs.\n\nThe function takes one optional parameter, a reference to a hash. The contents of the hash allow\nthe deflation interface to be tailored.\n\nHere is a list of the valid options:\n",
                "subsections": [
                    {
                        "name": "-Level",
                        "content": "Defines the compression level. Valid values are 0 through 9, \"ZNOCOMPRESSION\",\n\"ZBESTSPEED\", \"ZBESTCOMPRESSION\", and \"ZDEFAULTCOMPRESSION\".\n\nThe default is ZDEFAULTCOMPRESSION.\n"
                    },
                    {
                        "name": "-Method",
                        "content": "Defines the compression method. The only valid value at present (and the default) is\nZDEFLATED.\n"
                    },
                    {
                        "name": "-WindowBits",
                        "content": "To create an RFC 1950 data stream, set \"WindowBits\" to a positive number.\n\nTo create an RFC 1951 data stream, set \"WindowBits\" to \"-MAXWBITS\".\n\nFor a full definition of the meaning and valid values for \"WindowBits\" refer to the *zlib*\ndocumentation for *deflateInit2*.\n\nDefaults to MAXWBITS.\n"
                    },
                    {
                        "name": "-MemLevel",
                        "content": "For a definition of the meaning and valid values for \"MemLevel\" refer to the *zlib*\ndocumentation for *deflateInit2*.\n\nDefaults to MAXMEMLEVEL.\n"
                    },
                    {
                        "name": "-Strategy",
                        "content": "Defines the strategy used to tune the compression. The valid values are\n\"ZDEFAULTSTRATEGY\", \"ZFILTERED\" and \"ZHUFFMANONLY\".\n\nThe default is ZDEFAULTSTRATEGY.\n"
                    },
                    {
                        "name": "-Dictionary",
                        "content": "When a dictionary is specified *Compress::Zlib* will automatically call\n\"deflateSetDictionary\" directly after calling \"deflateInit\". The Adler32 value for the\ndictionary can be obtained by calling the method \"$d->dictadler()\".\n\nThe default is no dictionary.\n"
                    },
                    {
                        "name": "-Bufsize",
                        "content": "Sets the initial size for the deflation buffer. If the buffer has to be reallocated to\nincrease the size, it will grow in increments of \"Bufsize\".\n\nThe default is 4096.\n\nHere is an example of using the \"deflateInit\" optional parameter list to override the default\nbuffer size and compression level. All other options will take their default values.\n\ndeflateInit( -Bufsize => 300,\n-Level => ZBESTSPEED  ) ;\n\n($out, $status) = $d->deflate($buffer)\nDeflates the contents of $buffer. The buffer can either be a scalar or a scalar reference. When\nfinished, $buffer will be completely processed (assuming there were no errors). If the deflation\nwas successful it returns the deflated output, $out, and a status value, $status, of \"ZOK\".\n\nOn error, $out will be *undef* and $status will contain the *zlib* error code.\n\nIn a scalar context \"deflate\" will return $out only.\n\nAs with the *deflate* function in *zlib*, it is not necessarily the case that any output will be\nproduced by this method. So don't rely on the fact that $out is empty for an error test.\n\n($out, $status) = $d->flush()\n=head2 ($out, $status) = $d->flush($flushtype)\nTypically used to finish the deflation. Any pending output will be returned via $out. $status\nwill have a value \"ZOK\" if successful.\n\nIn a scalar context \"flush\" will return $out only.\n\nNote that flushing can seriously degrade the compression ratio, so it should only be used to\nterminate a decompression (using \"ZFINISH\") or when you want to create a *full flush point*\n(using \"ZFULLFLUSH\").\n\nBy default the \"flushtype\" used is \"ZFINISH\". Other valid values for \"flushtype\" are\n\"ZNOFLUSH\", \"ZPARTIALFLUSH\", \"ZSYNCFLUSH\" and \"ZFULLFLUSH\". It is strongly recommended\nthat you only set the \"flushtype\" parameter if you fully understand the implications of what it\ndoes. See the \"zlib\" documentation for details.\n\n$status = $d->deflateParams([OPT])\nChange settings for the deflate stream $d.\n\nThe list of the valid options is shown below. Options not specified will remain unchanged.\n"
                    },
                    {
                        "name": "-Level",
                        "content": "Defines the compression level. Valid values are 0 through 9, \"ZNOCOMPRESSION\",\n\"ZBESTSPEED\", \"ZBESTCOMPRESSION\", and \"ZDEFAULTCOMPRESSION\".\n"
                    },
                    {
                        "name": "-Strategy",
                        "content": "Defines the strategy used to tune the compression. The valid values are\n\"ZDEFAULTSTRATEGY\", \"ZFILTERED\" and \"ZHUFFMANONLY\".\n\n$d->dictadler()\nReturns the adler32 value for the dictionary.\n\n$d->msg()\nReturns the last error message generated by zlib.\n\n$d->totalin()\nReturns the total number of bytes uncompressed bytes input to deflate.\n\n$d->totalout()\nReturns the total number of compressed bytes output from deflate.\n"
                    },
                    {
                        "name": "Example",
                        "content": "Here is a trivial example of using \"deflate\". It simply reads standard input, deflates it and\nwrites it to standard output.\n\nuse strict ;\nuse warnings ;\n\nuse Compress::Zlib ;\n\nbinmode STDIN;\nbinmode STDOUT;\nmy $x = deflateInit()\nor die \"Cannot create a deflation stream\\n\" ;\n\nmy ($output, $status) ;\nwhile (<>)\n{\n($output, $status) = $x->deflate($) ;\n\n$status == ZOK\nor die \"deflation failed\\n\" ;\n\nprint $output ;\n}\n\n($output, $status) = $x->flush() ;\n\n$status == ZOK\nor die \"deflation failed\\n\" ;\n\nprint $output ;\n"
                    }
                ]
            },
            "Inflate Interface": {
                "content": "This section defines the interface available that allows in-memory uncompression using the\n*deflate* interface provided by zlib.\n\nHere is a definition of the interface:\n\n($i, $status) = inflateInit()\nInitialises an inflation stream.\n\nIn a list context it returns the inflation stream, $i, and the *zlib* status code in $status. In\na scalar context it returns the inflation stream only.\n\nIf successful, $i will hold the inflation stream and $status will be \"ZOK\".\n\nIf not successful, $i will be *undef* and $status will hold the *zlib* error code.\n\nThe function optionally takes a number of named options specified as \"-Name=>value\" pairs. This\nallows individual options to be tailored without having to specify them all in the parameter\nlist.\n\nFor backward compatibility, it is also possible to pass the parameters as a reference to a hash\ncontaining the name=>value pairs.\n\nThe function takes one optional parameter, a reference to a hash. The contents of the hash allow\nthe deflation interface to be tailored.\n\nHere is a list of the valid options:\n",
                "subsections": [
                    {
                        "name": "-WindowBits",
                        "content": "To uncompress an RFC 1950 data stream, set \"WindowBits\" to a positive number.\n\nTo uncompress an RFC 1951 data stream, set \"WindowBits\" to \"-MAXWBITS\".\n\nFor a full definition of the meaning and valid values for \"WindowBits\" refer to the *zlib*\ndocumentation for *inflateInit2*.\n\nDefaults to MAXWBITS.\n"
                    },
                    {
                        "name": "-Bufsize",
                        "content": "Sets the initial size for the inflation buffer. If the buffer has to be reallocated to\nincrease the size, it will grow in increments of \"Bufsize\".\n\nDefault is 4096.\n"
                    },
                    {
                        "name": "-Dictionary",
                        "content": "The default is no dictionary.\n\nHere is an example of using the \"inflateInit\" optional parameter to override the default buffer\nsize.\n\ninflateInit( -Bufsize => 300 ) ;\n\n($out, $status) = $i->inflate($buffer)\nInflates the complete contents of $buffer. The buffer can either be a scalar or a scalar\nreference.\n\nReturns \"ZOK\" if successful and \"ZSTREAMEND\" if the end of the compressed data has been\nsuccessfully reached. If not successful, $out will be *undef* and $status will hold the *zlib*\nerror code.\n\nThe $buffer parameter is modified by \"inflate\". On completion it will contain what remains of\nthe input buffer after inflation. This means that $buffer will be an empty string when the\nreturn status is \"ZOK\". When the return status is \"ZSTREAMEND\" the $buffer parameter will\ncontains what (if anything) was stored in the input buffer after the deflated data stream.\n\nThis feature is useful when processing a file format that encapsulates a compressed data stream\n(e.g. gzip, zip).\n\n$status = $i->inflateSync($buffer)\nScans $buffer until it reaches either a *full flush point* or the end of the buffer.\n\nIf a *full flush point* is found, \"ZOK\" is returned and $buffer will be have all data up to the\nflush point removed. This can then be passed to the \"deflate\" method.\n\nAny other return code means that a flush point was not found. If more data is available,\n\"inflateSync\" can be called repeatedly with more compressed data until the flush point is found.\n\n$i->dictadler()\nReturns the adler32 value for the dictionary.\n\n$i->msg()\nReturns the last error message generated by zlib.\n\n$i->totalin()\nReturns the total number of bytes compressed bytes input to inflate.\n\n$i->totalout()\nReturns the total number of uncompressed bytes output from inflate.\n"
                    },
                    {
                        "name": "Example",
                        "content": "Here is an example of using \"inflate\".\n\nuse strict ;\nuse warnings ;\n\nuse Compress::Zlib ;\n\nmy $x = inflateInit()\nor die \"Cannot create a inflation stream\\n\" ;\n\nmy $input = '' ;\nbinmode STDIN;\nbinmode STDOUT;\n\nmy ($output, $status) ;\nwhile (read(STDIN, $input, 4096))\n{\n($output, $status) = $x->inflate(\\$input) ;\n\nprint $output\nif $status == ZOK or $status == ZSTREAMEND ;\n\nlast if $status != ZOK ;\n}\n\ndie \"inflation failed\\n\"\nunless $status == ZSTREAMEND ;\n"
                    }
                ]
            },
            "CHECKSUM FUNCTIONS": {
                "content": "Two functions are provided by *zlib* to calculate checksums. For the Perl interface, the order\nof the two parameters in both functions has been reversed. This allows both running checksums\nand one off calculations to be done.\n\n$crc = adler32($buffer [,$crc]) ;\n$crc = crc32($buffer [,$crc]) ;\n\nThe buffer parameters can either be a scalar or a scalar reference.\n\nIf the $crc parameters is \"undef\", the crc value will be reset.\n\nIf you have built this module with zlib 1.2.3 or better, two more CRC-related functions are\navailable.\n\n$crc = crc32combine($crc1, $crc2, $len2);\n$adler = adler32combine($adler1, $adler2, $len2);\n\nThese functions allow checksums to be merged. Refer to the *zlib* documentation for more\ndetails.\n",
                "subsections": []
            },
            "Misc": {
                "content": "my $version = Compress::Zlib::zlibversion();\nReturns the version of the zlib library.\n",
                "subsections": []
            },
            "CONSTANTS": {
                "content": "All the *zlib* constants are automatically imported when you make use of *Compress::Zlib*.\n",
                "subsections": []
            },
            "SUPPORT": {
                "content": "General feedback/questions/bug reports should be sent to\n<https://github.com/pmqs/IO-Compress/issues> (preferred) or\n<https://rt.cpan.org/Public/Dist/Display.html?Name=IO-Compress>.\n",
                "subsections": []
            },
            "SEE ALSO": {
                "content": "IO::Compress::Gzip, IO::Uncompress::Gunzip, IO::Compress::Deflate, IO::Uncompress::Inflate,\nIO::Compress::RawDeflate, IO::Uncompress::RawInflate, IO::Compress::Bzip2,\nIO::Uncompress::Bunzip2, IO::Compress::Lzma, IO::Uncompress::UnLzma, IO::Compress::Xz,\nIO::Uncompress::UnXz, IO::Compress::Lzip, IO::Uncompress::UnLzip, IO::Compress::Lzop,\nIO::Uncompress::UnLzop, IO::Compress::Lzf, IO::Uncompress::UnLzf, IO::Compress::Zstd,\nIO::Uncompress::UnZstd, IO::Uncompress::AnyInflate, IO::Uncompress::AnyUncompress\n\nIO::Compress::FAQ\n\nFile::GlobMapper, Archive::Zip, Archive::Tar, IO::Zlib\n\nFor RFC 1950, 1951 and 1952 see <http://www.faqs.org/rfcs/rfc1950.html>,\n<http://www.faqs.org/rfcs/rfc1951.html> and <http://www.faqs.org/rfcs/rfc1952.html>\n\nThe *zlib* compression library was written by Jean-loup Gailly \"gzip@prep.ai.mit.edu\" and Mark\nAdler \"madler@alumni.caltech.edu\".\n\nThe primary site for the *zlib* compression library is <http://www.zlib.org>.\n\nThe primary site for gzip is <http://www.gzip.org>.\n",
                "subsections": []
            },
            "AUTHOR": {
                "content": "This module was written by Paul Marquess, \"pmqs@cpan.org\".\n",
                "subsections": []
            },
            "MODIFICATION HISTORY": {
                "content": "See the Changes file.\n",
                "subsections": []
            },
            "COPYRIGHT AND LICENSE": {
                "content": "Copyright (c) 1995-2021 Paul Marquess. All rights reserved.\n\nThis program is free software; you can redistribute it and/or modify it under the same terms as\nPerl itself.\n",
                "subsections": []
            }
        }
    }
}