+ die "Did not reach end of stream\n" if $code == LZMA_OK;
+ die "Error decoding LZMA2: $code\n" if $code != LZMA_STREAM_END;
+ $output
+ },
+
+ 'bz2' => sub {
+ my ($input) = @_;
+ my ($bz2, $code, $output);
+ ($bz2, $code)= Compress::Raw::Bunzip2->new;
+ die "Error creating Bunzip2: $code\n" unless $code == Z_OK;
+
+ $code = $bz2->bzinflate($input, $output);
+ die "Did not reach end of stream\n" if $code == BZ_OK;
+ die "Error decoding Bzip2: $code\n" if $code != BZ_STREAM_END;
+
+ $output
+ },
+
+ 'zlib' => sub {
+ my ($input) = @_;
+ my ($zlib, $code, $output);
+ ($zlib, $code) = Compress::Raw::Zlib::Inflate->new(
+ -WindowBits => WANT_GZIP_OR_ZLIB
+ );
+ die "Error creating Zlib inflate: $code\n" unless $code == Z_OK;
+
+ $code = $zlib->inflate($input, \$output, 1);
+ die "Did not reach end of stream\n" if $code == Z_OK;
+ die "Error inflating zlib: $code\n" if $code != Z_STREAM_END;