| 1 |
.\" -*- mode: troff; coding: utf-8 -*- |
| 2 |
.\" Automatically generated by Pod::Man 5.0102 (Pod::Simple 3.45) |
| 3 |
.\" |
| 4 |
.\" Standard preamble: |
| 5 |
.\" ======================================================================== |
| 6 |
.de Sp \" Vertical space (when we can't use .PP) |
| 7 |
.if t .sp .5v |
| 8 |
.if n .sp |
| 9 |
.. |
| 10 |
.de Vb \" Begin verbatim text |
| 11 |
.ft CW |
| 12 |
.nf |
| 13 |
.ne \\$1 |
| 14 |
.. |
| 15 |
.de Ve \" End verbatim text |
| 16 |
.ft R |
| 17 |
.fi |
| 18 |
.. |
| 19 |
.\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. |
| 20 |
.ie n \{\ |
| 21 |
. ds C` "" |
| 22 |
. ds C' "" |
| 23 |
'br\} |
| 24 |
.el\{\ |
| 25 |
. ds C` |
| 26 |
. ds C' |
| 27 |
'br\} |
| 28 |
.\" |
| 29 |
.\" Escape single quotes in literal strings from groff's Unicode transform. |
| 30 |
.ie \n(.g .ds Aq \(aq |
| 31 |
.el .ds Aq ' |
| 32 |
.\" |
| 33 |
.\" If the F register is >0, we'll generate index entries on stderr for |
| 34 |
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index |
| 35 |
.\" entries marked with X<> in POD. Of course, you'll have to process the |
| 36 |
.\" output yourself in some meaningful fashion. |
| 37 |
.\" |
| 38 |
.\" Avoid warning from groff about undefined register 'F'. |
| 39 |
.de IX |
| 40 |
.. |
| 41 |
.nr rF 0 |
| 42 |
.if \n(.g .if rF .nr rF 1 |
| 43 |
.if (\n(rF:(\n(.g==0)) \{\ |
| 44 |
. if \nF \{\ |
| 45 |
. de IX |
| 46 |
. tm Index:\\$1\t\\n%\t"\\$2" |
| 47 |
.. |
| 48 |
. if !\nF==2 \{\ |
| 49 |
. nr % 0 |
| 50 |
. nr F 2 |
| 51 |
. \} |
| 52 |
. \} |
| 53 |
.\} |
| 54 |
.rr rF |
| 55 |
.\" ======================================================================== |
| 56 |
.\" |
| 57 |
.IX Title "Compress::Raw::Bzip2 3perl" |
| 58 |
.TH Compress::Raw::Bzip2 3perl 2025-11-16 "perl v5.40.1" "Perl Programmers Reference Guide" |
| 59 |
.\" For nroff, turn off justification. Always turn off hyphenation; it makes |
| 60 |
.\" way too many mistakes in technical documents. |
| 61 |
.if n .ad l |
| 62 |
.nh |
| 63 |
.SH NAME |
| 64 |
Compress::Raw::Bzip2 \- Low\-Level Interface to bzip2 compression library |
| 65 |
.SH SYNOPSIS |
| 66 |
.IX Header "SYNOPSIS" |
| 67 |
.Vb 1 |
| 68 |
\& use Compress::Raw::Bzip2 ; |
| 69 |
\& |
| 70 |
\& my ($bz, $status) = new Compress::Raw::Bzip2 [OPTS] |
| 71 |
\& or die "Cannot create bzip2 object: $bzerno\en"; |
| 72 |
\& |
| 73 |
\& $status = $bz\->bzdeflate($input, $output); |
| 74 |
\& $status = $bz\->bzflush($output); |
| 75 |
\& $status = $bz\->bzclose($output); |
| 76 |
\& |
| 77 |
\& my ($bz, $status) = new Compress::Raw::Bunzip2 [OPTS] |
| 78 |
\& or die "Cannot create bunzip2 object: $bzerno\en"; |
| 79 |
\& |
| 80 |
\& $status = $bz\->bzinflate($input, $output); |
| 81 |
\& |
| 82 |
\& my $version = Compress::Raw::Bzip2::bzlibversion(); |
| 83 |
.Ve |
| 84 |
.SH DESCRIPTION |
| 85 |
.IX Header "DESCRIPTION" |
| 86 |
\&\f(CW\*(C`Compress::Raw::Bzip2\*(C'\fR provides an interface to the in-memory |
| 87 |
compression/uncompression functions from the bzip2 compression library. |
| 88 |
.PP |
| 89 |
Although the primary purpose for the existence of \f(CW\*(C`Compress::Raw::Bzip2\*(C'\fR |
| 90 |
is for use by the \f(CW\*(C`IO::Compress::Bzip2\*(C'\fR and \f(CW\*(C`IO::Compress::Bunzip2\*(C'\fR |
| 91 |
modules, it can be used on its own for simple compression/uncompression |
| 92 |
tasks. |
| 93 |
.SH Compression |
| 94 |
.IX Header "Compression" |
| 95 |
.ie n .SS "($z, $status) = new Compress::Raw::Bzip2 $appendOutput, $blockSize100k, $workfactor;" |
| 96 |
.el .SS "($z, \f(CW$status\fP) = new Compress::Raw::Bzip2 \f(CW$appendOutput\fP, \f(CW$blockSize100k\fP, \f(CW$workfactor\fP;" |
| 97 |
.IX Subsection "($z, $status) = new Compress::Raw::Bzip2 $appendOutput, $blockSize100k, $workfactor;" |
| 98 |
Creates a new compression object. |
| 99 |
.PP |
| 100 |
If successful, it will return the initialised compression object, \f(CW$z\fR |
| 101 |
and a \f(CW$status\fR of \f(CW\*(C`BZ_OK\*(C'\fR in a list context. In scalar context it |
| 102 |
returns the deflation object, \f(CW$z\fR, only. |
| 103 |
.PP |
| 104 |
If not successful, the returned compression object, \f(CW$z\fR, will be |
| 105 |
\&\fIundef\fR and \f(CW$status\fR will hold the a \fIbzip2\fR error code. |
| 106 |
.PP |
| 107 |
Below is a list of the valid options: |
| 108 |
.ie n .IP \fR\fB$appendOutput\fR\fB\fR 5 |
| 109 |
.el .IP \fR\f(CB$appendOutput\fR\fB\fR 5 |
| 110 |
.IX Item "$appendOutput" |
| 111 |
Controls whether the compressed data is appended to the output buffer in |
| 112 |
the \f(CW\*(C`bzdeflate\*(C'\fR, \f(CW\*(C`bzflush\*(C'\fR and \f(CW\*(C`bzclose\*(C'\fR methods. |
| 113 |
.Sp |
| 114 |
Defaults to 1. |
| 115 |
.ie n .IP \fR\fB$blockSize100k\fR\fB\fR 5 |
| 116 |
.el .IP \fR\f(CB$blockSize100k\fR\fB\fR 5 |
| 117 |
.IX Item "$blockSize100k" |
| 118 |
To quote the bzip2 documentation |
| 119 |
.Sp |
| 120 |
.Vb 4 |
| 121 |
\& blockSize100k specifies the block size to be used for compression. It |
| 122 |
\& should be a value between 1 and 9 inclusive, and the actual block size |
| 123 |
\& used is 100000 x this figure. 9 gives the best compression but takes |
| 124 |
\& most memory. |
| 125 |
.Ve |
| 126 |
.Sp |
| 127 |
Defaults to 1. |
| 128 |
.ie n .IP \fR\fB$workfactor\fR\fB\fR 5 |
| 129 |
.el .IP \fR\f(CB$workfactor\fR\fB\fR 5 |
| 130 |
.IX Item "$workfactor" |
| 131 |
To quote the bzip2 documentation |
| 132 |
.Sp |
| 133 |
.Vb 7 |
| 134 |
\& This parameter controls how the compression phase behaves when |
| 135 |
\& presented with worst case, highly repetitive, input data. If |
| 136 |
\& compression runs into difficulties caused by repetitive data, the |
| 137 |
\& library switches from the standard sorting algorithm to a fallback |
| 138 |
\& algorithm. The fallback is slower than the standard algorithm by |
| 139 |
\& perhaps a factor of three, but always behaves reasonably, no matter how |
| 140 |
\& bad the input. |
| 141 |
\& |
| 142 |
\& Lower values of workFactor reduce the amount of effort the standard |
| 143 |
\& algorithm will expend before resorting to the fallback. You should set |
| 144 |
\& this parameter carefully; too low, and many inputs will be handled by |
| 145 |
\& the fallback algorithm and so compress rather slowly, too high, and |
| 146 |
\& your average\-to\-worst case compression times can become very large. The |
| 147 |
\& default value of 30 gives reasonable behaviour over a wide range of |
| 148 |
\& circumstances. |
| 149 |
\& |
| 150 |
\& Allowable values range from 0 to 250 inclusive. 0 is a special case, |
| 151 |
\& equivalent to using the default value of 30. |
| 152 |
.Ve |
| 153 |
.Sp |
| 154 |
Defaults to 0. |
| 155 |
.ie n .SS "$status = $bz\->bzdeflate($input, $output);" |
| 156 |
.el .SS "\f(CW$status\fP = \f(CW$bz\fP\->bzdeflate($input, \f(CW$output\fP);" |
| 157 |
.IX Subsection "$status = $bz->bzdeflate($input, $output);" |
| 158 |
Reads the contents of \f(CW$input\fR, compresses it and writes the compressed |
| 159 |
data to \f(CW$output\fR. |
| 160 |
.PP |
| 161 |
Returns \f(CW\*(C`BZ_RUN_OK\*(C'\fR on success and a \f(CW\*(C`bzip2\*(C'\fR error code on failure. |
| 162 |
.PP |
| 163 |
If \f(CW\*(C`appendOutput\*(C'\fR is enabled in the constructor for the bzip2 object, the |
| 164 |
compressed data will be appended to \f(CW$output\fR. If not enabled, \f(CW$output\fR |
| 165 |
will be truncated before the compressed data is written to it. |
| 166 |
.ie n .SS "$status = $bz\->bzflush($output);" |
| 167 |
.el .SS "\f(CW$status\fP = \f(CW$bz\fP\->bzflush($output);" |
| 168 |
.IX Subsection "$status = $bz->bzflush($output);" |
| 169 |
Flushes any pending compressed data to \f(CW$output\fR. |
| 170 |
.PP |
| 171 |
Returns \f(CW\*(C`BZ_RUN_OK\*(C'\fR on success and a \f(CW\*(C`bzip2\*(C'\fR error code on failure. |
| 172 |
.ie n .SS "$status = $bz\->bzclose($output);" |
| 173 |
.el .SS "\f(CW$status\fP = \f(CW$bz\fP\->bzclose($output);" |
| 174 |
.IX Subsection "$status = $bz->bzclose($output);" |
| 175 |
Terminates the compressed data stream and flushes any pending compressed |
| 176 |
data to \f(CW$output\fR. |
| 177 |
.PP |
| 178 |
Returns \f(CW\*(C`BZ_STREAM_END\*(C'\fR on success and a \f(CW\*(C`bzip2\*(C'\fR error code on failure. |
| 179 |
.SS Example |
| 180 |
.IX Subsection "Example" |
| 181 |
.SH Uncompression |
| 182 |
.IX Header "Uncompression" |
| 183 |
.ie n .SS "($z, $status) = new Compress::Raw::Bunzip2 $appendOutput, $consumeInput, $small, $verbosity, $limitOutput;" |
| 184 |
.el .SS "($z, \f(CW$status\fP) = new Compress::Raw::Bunzip2 \f(CW$appendOutput\fP, \f(CW$consumeInput\fP, \f(CW$small\fP, \f(CW$verbosity\fP, \f(CW$limitOutput\fP;" |
| 185 |
.IX Subsection "($z, $status) = new Compress::Raw::Bunzip2 $appendOutput, $consumeInput, $small, $verbosity, $limitOutput;" |
| 186 |
If successful, it will return the initialised uncompression object, \f(CW$z\fR |
| 187 |
and a \f(CW$status\fR of \f(CW\*(C`BZ_OK\*(C'\fR in a list context. In scalar context it |
| 188 |
returns the deflation object, \f(CW$z\fR, only. |
| 189 |
.PP |
| 190 |
If not successful, the returned uncompression object, \f(CW$z\fR, will be |
| 191 |
\&\fIundef\fR and \f(CW$status\fR will hold the a \fIbzip2\fR error code. |
| 192 |
.PP |
| 193 |
Below is a list of the valid options: |
| 194 |
.ie n .IP \fR\fB$appendOutput\fR\fB\fR 5 |
| 195 |
.el .IP \fR\f(CB$appendOutput\fR\fB\fR 5 |
| 196 |
.IX Item "$appendOutput" |
| 197 |
Controls whether the compressed data is appended to the output buffer in the |
| 198 |
\&\f(CW\*(C`bzinflate\*(C'\fR, \f(CW\*(C`bzflush\*(C'\fR and \f(CW\*(C`bzclose\*(C'\fR methods. |
| 199 |
.Sp |
| 200 |
Defaults to 1. |
| 201 |
.ie n .IP \fR\fB$consumeInput\fR\fB\fR 5 |
| 202 |
.el .IP \fR\f(CB$consumeInput\fR\fB\fR 5 |
| 203 |
.IX Item "$consumeInput" |
| 204 |
.PD 0 |
| 205 |
.ie n .IP \fR\fB$small\fR\fB\fR 5 |
| 206 |
.el .IP \fR\f(CB$small\fR\fB\fR 5 |
| 207 |
.IX Item "$small" |
| 208 |
.PD |
| 209 |
To quote the bzip2 documentation |
| 210 |
.Sp |
| 211 |
.Vb 4 |
| 212 |
\& If small is nonzero, the library will use an alternative decompression |
| 213 |
\& algorithm which uses less memory but at the cost of decompressing more |
| 214 |
\& slowly (roughly speaking, half the speed, but the maximum memory |
| 215 |
\& requirement drops to around 2300k). |
| 216 |
.Ve |
| 217 |
.Sp |
| 218 |
Defaults to 0. |
| 219 |
.ie n .IP \fR\fB$limitOutput\fR\fB\fR 5 |
| 220 |
.el .IP \fR\f(CB$limitOutput\fR\fB\fR 5 |
| 221 |
.IX Item "$limitOutput" |
| 222 |
The \f(CW\*(C`LimitOutput\*(C'\fR option changes the behavior of the \f(CW\*(C`$i\->bzinflate\*(C'\fR |
| 223 |
method so that the amount of memory used by the output buffer can be |
| 224 |
limited. |
| 225 |
.Sp |
| 226 |
When \f(CW\*(C`LimitOutput\*(C'\fR is used the size of the output buffer used will either |
| 227 |
be the 16k or the amount of memory already allocated to \f(CW$output\fR, |
| 228 |
whichever is larger. Predicting the output size available is tricky, so |
| 229 |
don't rely on getting an exact output buffer size. |
| 230 |
.Sp |
| 231 |
When \f(CW\*(C`LimitOutout\*(C'\fR is not specified \f(CW\*(C`$i\->bzinflate\*(C'\fR will use as much |
| 232 |
memory as it takes to write all the uncompressed data it creates by |
| 233 |
uncompressing the input buffer. |
| 234 |
.Sp |
| 235 |
If \f(CW\*(C`LimitOutput\*(C'\fR is enabled, the \f(CW\*(C`ConsumeInput\*(C'\fR option will also be |
| 236 |
enabled. |
| 237 |
.Sp |
| 238 |
This option defaults to false. |
| 239 |
.ie n .IP \fR\fB$verbosity\fR\fB\fR 5 |
| 240 |
.el .IP \fR\f(CB$verbosity\fR\fB\fR 5 |
| 241 |
.IX Item "$verbosity" |
| 242 |
This parameter is ignored. |
| 243 |
.Sp |
| 244 |
Defaults to 0. |
| 245 |
.ie n .SS "$status = $z\->bzinflate($input, $output);" |
| 246 |
.el .SS "\f(CW$status\fP = \f(CW$z\fP\->bzinflate($input, \f(CW$output\fP);" |
| 247 |
.IX Subsection "$status = $z->bzinflate($input, $output);" |
| 248 |
Uncompresses \f(CW$input\fR and writes the uncompressed data to \f(CW$output\fR. |
| 249 |
.PP |
| 250 |
Returns \f(CW\*(C`BZ_OK\*(C'\fR if the uncompression was successful, but the end of the |
| 251 |
compressed data stream has not been reached. Returns \f(CW\*(C`BZ_STREAM_END\*(C'\fR on |
| 252 |
successful uncompression and the end of the compression stream has been |
| 253 |
reached. |
| 254 |
.PP |
| 255 |
If \f(CW\*(C`consumeInput\*(C'\fR is enabled in the constructor for the bunzip2 object, |
| 256 |
\&\f(CW$input\fR will have all compressed data removed from it after |
| 257 |
uncompression. On \f(CW\*(C`BZ_OK\*(C'\fR return this will mean that \f(CW$input\fR will be an |
| 258 |
empty string; when \f(CW\*(C`BZ_STREAM_END\*(C'\fR \f(CW$input\fR will either be an empty |
| 259 |
string or will contain whatever data immediately followed the compressed |
| 260 |
data stream. |
| 261 |
.PP |
| 262 |
If \f(CW\*(C`appendOutput\*(C'\fR is enabled in the constructor for the bunzip2 object, |
| 263 |
the uncompressed data will be appended to \f(CW$output\fR. If not enabled, |
| 264 |
\&\f(CW$output\fR will be truncated before the uncompressed data is written to it. |
| 265 |
.SH Misc |
| 266 |
.IX Header "Misc" |
| 267 |
.ie n .SS "my $version = \fBCompress::Raw::Bzip2::bzlibversion()\fP;" |
| 268 |
.el .SS "my \f(CW$version\fP = \fBCompress::Raw::Bzip2::bzlibversion()\fP;" |
| 269 |
.IX Subsection "my $version = Compress::Raw::Bzip2::bzlibversion();" |
| 270 |
Returns the version of the underlying bzip2 library. |
| 271 |
.SH Constants |
| 272 |
.IX Header "Constants" |
| 273 |
The following bzip2 constants are exported by this module |
| 274 |
.PP |
| 275 |
.Vb 3 |
| 276 |
\& BZ_RUN |
| 277 |
\& BZ_FLUSH |
| 278 |
\& BZ_FINISH |
| 279 |
\& |
| 280 |
\& BZ_OK |
| 281 |
\& BZ_RUN_OK |
| 282 |
\& BZ_FLUSH_OK |
| 283 |
\& BZ_FINISH_OK |
| 284 |
\& BZ_STREAM_END |
| 285 |
\& BZ_SEQUENCE_ERROR |
| 286 |
\& BZ_PARAM_ERROR |
| 287 |
\& BZ_MEM_ERROR |
| 288 |
\& BZ_DATA_ERROR |
| 289 |
\& BZ_DATA_ERROR_MAGIC |
| 290 |
\& BZ_IO_ERROR |
| 291 |
\& BZ_UNEXPECTED_EOF |
| 292 |
\& BZ_OUTBUFF_FULL |
| 293 |
\& BZ_CONFIG_ERROR |
| 294 |
.Ve |
| 295 |
.SH SUPPORT |
| 296 |
.IX Header "SUPPORT" |
| 297 |
General feedback/questions/bug reports should be sent to |
| 298 |
<https://github.com/pmqs/Compress\-Raw\-Bzip2/issues> (preferred) or |
| 299 |
<https://rt.cpan.org/Public/Dist/Display.html?Name=Compress\-Raw\-Bzip2>. |
| 300 |
.SH "SEE ALSO" |
| 301 |
.IX Header "SEE ALSO" |
| 302 |
Compress::Zlib, IO::Compress::Gzip, IO::Uncompress::Gunzip, IO::Compress::Deflate, IO::Uncompress::Inflate, IO::Compress::RawDeflate, IO::Uncompress::RawInflate, IO::Compress::Bzip2, IO::Uncompress::Bunzip2, IO::Compress::Lzma, IO::Uncompress::UnLzma, IO::Compress::Xz, IO::Uncompress::UnXz, IO::Compress::Lzip, IO::Uncompress::UnLzip, IO::Compress::Lzop, IO::Uncompress::UnLzop, IO::Compress::Lzf, IO::Uncompress::UnLzf, IO::Compress::Zstd, IO::Uncompress::UnZstd, IO::Uncompress::AnyInflate, IO::Uncompress::AnyUncompress |
| 303 |
.PP |
| 304 |
IO::Compress::FAQ |
| 305 |
.PP |
| 306 |
File::GlobMapper, Archive::Zip, |
| 307 |
Archive::Tar, |
| 308 |
IO::Zlib |
| 309 |
.PP |
| 310 |
The primary site for the bzip2 program is <https://sourceware.org/bzip2/>. |
| 311 |
.PP |
| 312 |
See the module Compress::Bzip2 |
| 313 |
.SH AUTHOR |
| 314 |
.IX Header "AUTHOR" |
| 315 |
This module was written by Paul Marquess, \f(CW\*(C`[email protected]\*(C'\fR. |
| 316 |
.SH "MODIFICATION HISTORY" |
| 317 |
.IX Header "MODIFICATION HISTORY" |
| 318 |
See the Changes file. |
| 319 |
.SH "COPYRIGHT AND LICENSE" |
| 320 |
.IX Header "COPYRIGHT AND LICENSE" |
| 321 |
Copyright (c) 2005\-2024 Paul Marquess. All rights reserved. |
| 322 |
.PP |
| 323 |
This program is free software; you can redistribute it and/or |
| 324 |
modify it under the same terms as Perl itself. |