{
    "content": [
        {
            "type": "text",
            "text": "# Compress::Raw::Bzip2 (perldoc)\n\n**Summary:** Compress::Raw::Bzip2 - Low-Level Interface to bzip2 compression library\n\n**Synopsis:** use Compress::Raw::Bzip2 ;\nmy ($bz, $status) = new Compress::Raw::Bzip2 [OPTS]\nor die \"Cannot create bzip2 object: $bzerno\\n\";\n$status = $bz->bzdeflate($input, $output);\n$status = $bz->bzflush($output);\n$status = $bz->bzclose($output);\nmy ($bz, $status) = new Compress::Raw::Bunzip2 [OPTS]\nor die \"Cannot create bunzip2 object: $bzerno\\n\";\n$status = $bz->bzinflate($input, $output);\nmy $version = Compress::Raw::Bzip2::bzlibversion();\n\n## Section Outline\n\n- **NAME** (2 lines)\n- **SYNOPSIS** (16 lines)\n- **DESCRIPTION** (7 lines)\n- **Compression** (70 lines) — 1 subsections\n  - Example (1 lines)\n- **Uncompression** (62 lines)\n- **Misc** (3 lines)\n- **Constants** (21 lines)\n- **SUPPORT** (4 lines)\n- **SEE ALSO** (16 lines)\n- **AUTHOR** (2 lines)\n- **MODIFICATION HISTORY** (2 lines)\n- **COPYRIGHT AND LICENSE** (5 lines)\n\n## Full Content\n\n### NAME\n\nCompress::Raw::Bzip2 - Low-Level Interface to bzip2 compression library\n\n### SYNOPSIS\n\nuse Compress::Raw::Bzip2 ;\n\nmy ($bz, $status) = new Compress::Raw::Bzip2 [OPTS]\nor die \"Cannot create bzip2 object: $bzerno\\n\";\n\n$status = $bz->bzdeflate($input, $output);\n$status = $bz->bzflush($output);\n$status = $bz->bzclose($output);\n\nmy ($bz, $status) = new Compress::Raw::Bunzip2 [OPTS]\nor die \"Cannot create bunzip2 object: $bzerno\\n\";\n\n$status = $bz->bzinflate($input, $output);\n\nmy $version = Compress::Raw::Bzip2::bzlibversion();\n\n### DESCRIPTION\n\n\"Compress::Raw::Bzip2\" provides an interface to the in-memory compression/uncompression\nfunctions from the bzip2 compression library.\n\nAlthough the primary purpose for the existence of \"Compress::Raw::Bzip2\" is for use by the\n\"IO::Compress::Bzip2\" and \"IO::Compress::Bunzip2\" modules, it can be used on its own for simple\ncompression/uncompression tasks.\n\n### Compression\n\n($z, $status) = new Compress::Raw::Bzip2 $appendOutput, $blockSize100k, $workfactor;\nCreates a new compression object.\n\nIf successful, it will return the initialised compression object, $z and a $status of \"BZOK\" in\na list context. In scalar context it returns the deflation object, $z, only.\n\nIf not successful, the returned compression object, $z, will be *undef* and $status will hold\nthe a *bzip2* error code.\n\nBelow is a list of the valid options:\n\n$appendOutput\nControls whether the compressed data is appended to the output buffer in the \"bzdeflate\",\n\"bzflush\" and \"bzclose\" methods.\n\nDefaults to 1.\n\n$blockSize100k\nTo quote the bzip2 documentation\n\nblockSize100k specifies the block size to be used for compression. It\nshould be a value between 1 and 9 inclusive, and the actual block size\nused is 100000 x this figure. 9 gives the best compression but takes\nmost memory.\n\nDefaults to 1.\n\n$workfactor\nTo quote the bzip2 documentation\n\nThis parameter controls how the compression phase behaves when\npresented with worst case, highly repetitive, input data. If\ncompression runs into difficulties caused by repetitive data, the\nlibrary switches from the standard sorting algorithm to a fallback\nalgorithm. The fallback is slower than the standard algorithm by\nperhaps a factor of three, but always behaves reasonably, no matter how\nbad the input.\n\nLower values of workFactor reduce the amount of effort the standard\nalgorithm will expend before resorting to the fallback. You should set\nthis parameter carefully; too low, and many inputs will be handled by\nthe fallback algorithm and so compress rather slowly, too high, and\nyour average-to-worst case compression times can become very large. The\ndefault value of 30 gives reasonable behaviour over a wide range of\ncircumstances.\n\nAllowable values range from 0 to 250 inclusive. 0 is a special case,\nequivalent to using the default value of 30.\n\nDefaults to 0.\n\n$status = $bz->bzdeflate($input, $output);\nReads the contents of $input, compresses it and writes the compressed data to $output.\n\nReturns \"BZRUNOK\" on success and a \"bzip2\" error code on failure.\n\nIf \"appendOutput\" is enabled in the constructor for the bzip2 object, the compressed data will\nbe appended to $output. If not enabled, $output will be truncated before the compressed data is\nwritten to it.\n\n$status = $bz->bzflush($output);\nFlushes any pending compressed data to $output.\n\nReturns \"BZRUNOK\" on success and a \"bzip2\" error code on failure.\n\n$status = $bz->bzclose($output);\nTerminates the compressed data stream and flushes any pending compressed data to $output.\n\nReturns \"BZSTREAMEND\" on success and a \"bzip2\" error code on failure.\n\n#### Example\n\n### Uncompression\n\n($z, $status) = new Compress::Raw::Bunzip2 $appendOutput, $consumeInput, $small, $verbosity, $limitOutput;\nIf successful, it will return the initialised uncompression object, $z and a $status of \"BZOK\"\nin a list context. In scalar context it returns the deflation object, $z, only.\n\nIf not successful, the returned uncompression object, $z, will be *undef* and $status will hold\nthe a *bzip2* error code.\n\nBelow is a list of the valid options:\n\n$appendOutput\nControls whether the compressed data is appended to the output buffer in the \"bzinflate\",\n\"bzflush\" and \"bzclose\" methods.\n\nDefaults to 1.\n\n$consumeInput\n$small\nTo quote the bzip2 documentation\n\nIf small is nonzero, the library will use an alternative decompression\nalgorithm which uses less memory but at the cost of decompressing more\nslowly (roughly speaking, half the speed, but the maximum memory\nrequirement drops to around 2300k).\n\nDefaults to 0.\n\n$limitOutput\nThe \"LimitOutput\" option changes the behavior of the \"$i->bzinflate\" method so that the\namount of memory used by the output buffer can be limited.\n\nWhen \"LimitOutput\" is used the size of the output buffer used will either be the 16k or the\namount of memory already allocated to $output, whichever is larger. Predicting the output\nsize available is tricky, so don't rely on getting an exact output buffer size.\n\nWhen \"LimitOutout\" is not specified \"$i->bzinflate\" will use as much memory as it takes to\nwrite all the uncompressed data it creates by uncompressing the input buffer.\n\nIf \"LimitOutput\" is enabled, the \"ConsumeInput\" option will also be enabled.\n\nThis option defaults to false.\n\n$verbosity\nThis parameter is ignored.\n\nDefaults to 0.\n\n$status = $z->bzinflate($input, $output);\nUncompresses $input and writes the uncompressed data to $output.\n\nReturns \"BZOK\" if the uncompression was successful, but the end of the compressed data stream\nhas not been reached. Returns \"BZSTREAMEND\" on successful uncompression and the end of the\ncompression stream has been reached.\n\nIf \"consumeInput\" is enabled in the constructor for the bunzip2 object, $input will have all\ncompressed data removed from it after uncompression. On \"BZOK\" return this will mean that\n$input will be an empty string; when \"BZSTREAMEND\" $input will either be an empty string or\nwill contain whatever data immediately followed the compressed data stream.\n\nIf \"appendOutput\" is enabled in the constructor for the bunzip2 object, the uncompressed data\nwill be appended to $output. If not enabled, $output will be truncated before the uncompressed\ndata is written to it.\n\n### Misc\n\nmy $version = Compress::Raw::Bzip2::bzlibversion();\nReturns the version of the underlying bzip2 library.\n\n### Constants\n\nThe following bzip2 constants are exported by this module\n\nBZRUN\nBZFLUSH\nBZFINISH\n\nBZOK\nBZRUNOK\nBZFLUSHOK\nBZFINISHOK\nBZSTREAMEND\nBZSEQUENCEERROR\nBZPARAMERROR\nBZMEMERROR\nBZDATAERROR\nBZDATAERRORMAGIC\nBZIOERROR\nBZUNEXPECTEDEOF\nBZOUTBUFFFULL\nBZCONFIGERROR\n\n### SUPPORT\n\nGeneral feedback/questions/bug reports should be sent to\n<https://github.com/pmqs/Compress-Raw-Bzip2/issues> (preferred) or\n<https://rt.cpan.org/Public/Dist/Display.html?Name=Compress-Raw-Bzip2>.\n\n### SEE ALSO\n\nCompress::Zlib, IO::Compress::Gzip, IO::Uncompress::Gunzip, IO::Compress::Deflate,\nIO::Uncompress::Inflate, IO::Compress::RawDeflate, IO::Uncompress::RawInflate,\nIO::Compress::Bzip2, IO::Uncompress::Bunzip2, IO::Compress::Lzma, IO::Uncompress::UnLzma,\nIO::Compress::Xz, IO::Uncompress::UnXz, IO::Compress::Lzip, IO::Uncompress::UnLzip,\nIO::Compress::Lzop, IO::Uncompress::UnLzop, IO::Compress::Lzf, IO::Uncompress::UnLzf,\nIO::Compress::Zstd, IO::Uncompress::UnZstd, IO::Uncompress::AnyInflate,\nIO::Uncompress::AnyUncompress\n\nIO::Compress::FAQ\n\nFile::GlobMapper, Archive::Zip, Archive::Tar, IO::Zlib\n\nThe primary site for the bzip2 program is <https://sourceware.org/bzip2/>.\n\nSee the module Compress::Bzip2\n\n### AUTHOR\n\nThis module was written by Paul Marquess, \"pmqs@cpan.org\".\n\n### MODIFICATION HISTORY\n\nSee the Changes file.\n\n### COPYRIGHT AND LICENSE\n\nCopyright (c) 2005-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\n"
        }
    ],
    "structuredContent": {
        "command": "Compress::Raw::Bzip2",
        "section": "",
        "mode": "perldoc",
        "summary": "Compress::Raw::Bzip2 - Low-Level Interface to bzip2 compression library",
        "synopsis": "use Compress::Raw::Bzip2 ;\nmy ($bz, $status) = new Compress::Raw::Bzip2 [OPTS]\nor die \"Cannot create bzip2 object: $bzerno\\n\";\n$status = $bz->bzdeflate($input, $output);\n$status = $bz->bzflush($output);\n$status = $bz->bzclose($output);\nmy ($bz, $status) = new Compress::Raw::Bunzip2 [OPTS]\nor die \"Cannot create bunzip2 object: $bzerno\\n\";\n$status = $bz->bzinflate($input, $output);\nmy $version = Compress::Raw::Bzip2::bzlibversion();",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 16,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 7,
                "subsections": []
            },
            {
                "name": "Compression",
                "lines": 70,
                "subsections": [
                    {
                        "name": "Example",
                        "lines": 1
                    }
                ]
            },
            {
                "name": "Uncompression",
                "lines": 62,
                "subsections": []
            },
            {
                "name": "Misc",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "Constants",
                "lines": 21,
                "subsections": []
            },
            {
                "name": "SUPPORT",
                "lines": 4,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 16,
                "subsections": []
            },
            {
                "name": "AUTHOR",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "MODIFICATION HISTORY",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "COPYRIGHT AND LICENSE",
                "lines": 5,
                "subsections": []
            }
        ]
    }
}