# Compress::Raw::Zlib
📦 std
Low-level interface to the `zlib` compression library.
`Compress::Raw::Zlib` is the thin binding layer underneath
`Compress::Zlib` and the whole `IO::Compress::*` family. It exposes
zlib’s streaming `deflate`/`inflate` state machines directly, plus
the `crc32`/`adler32` checksums and the zlib manifest constants.
```perl
use Compress::Raw::Zlib;
my ($d, $status) = Compress::Raw::Zlib::Deflate->new();
$d->deflate($input, my $output);
$d->flush($output);
my ($i, $istatus) = Compress::Raw::Zlib::Inflate->new();
$i->inflate($output, my $roundtrip);
```
This is a 1:1 transliteration of `cpan/Compress-Raw-Zlib/Zlib.xs`
(upstream 2.222). The Perl half of `Compress/Raw/Zlib.pm` - the
`Parameters` option parser and the `Deflate`/`Inflate`/`InflateScan`
constructors - is embedded verbatim and injected with `eval_pv_boot`,
the same faithful-mirror technique `B.rs` uses for `B.pm`.
zlib itself is reached through `dlopen` (`libz.so.1`), exactly the
library the upstream XS links against. No DEFLATE implementation
lives here.
## Functions
### Other Functions
#### `ret_iv`
typemap `T_IV`: `sv_setiv(TARG, (IV)RETVAL); ST(0) = TARG;`
#### `ret_uv`
typemap `T_UV`: xsubpp emits `TARGu((IV)RETVAL, 1); ST(0) = TARG;`
#### `ret_pv`
typemap `T_PV`: `sv_setpv((SV*)TARG, RETVAL); ST(0) = TARG;` A NULL RETVAL sets undef - which is what `msg()` wants.
#### `ret_bool`
typemap `T_BOOL`: `ST(0) = boolSV(RETVAL);`
#### `ret_dual`
typemap `T_DUAL` (DualType): `SV * RETVALSV = sv_newmortal(); setDUALstatus(RETVALSV, RETVAL); ST(0) = RETVALSV;`