use warnings;
use strict;
-use Compress::Zlib qw/Z_OK Z_FULL_FLUSH Z_SYNC_FLUSH MAX_WBITS/;
+use Compress::Zlib qw/Z_FULL_FLUSH Z_SYNC_FLUSH MAX_WBITS/;
use Config::Tiny ();
use Errno 'EWOULDBLOCK';
use IO::Select ();
$self->panic($IMAP_text) unless $r eq 'OK';
if ($algo eq 'DEFLATE') {
- my ($status, $d, $i);
my %args = ( -WindowBits => 0 - MAX_WBITS );
- ($d, $status) = Compress::Zlib::deflateInit(%args);
- $self->panic("Can't create deflation stream: ", $d->msg())
- unless defined $d and $status == Z_OK;
-
- ($i, $status) = Compress::Zlib::inflateInit(%args);
- $self->panic("Can't create inflation stream: ", $i->msg())
- unless defined $i and $status == Z_OK;
- @$self{qw/_Z_DEFLATE _Z_INFLATE/} = ($d, $i);
+ $self->{_Z_DEFLATE} = Compress::Zlib::deflateInit(%args) //
+ $self->panic("Can't create deflation stream");
+ $self->{_Z_INFLATE} = Compress::Zlib::inflateInit(%args) //
+ $self->panic("Can't create inflation stream");
}
else {
$self->fail("Unsupported compression algorithm: $algo");
$self->{_OUTRAWCOUNT} += $n;
if (defined (my $i = $self->{_Z_INFLATE})) {
- my ($out, $status) = $i->inflate($buf);
- $self->panic("Inflation failed: ", $i->msg()) unless $status == Z_OK;
- $buf = $out;
+ $buf = $i->inflate($buf) // $self->panic("Inflation failed: ", $i->msg());
}
$self->{_OUTBUF} = $buf;
}
sub _z_flush($;$) {
my ($self,$t) = @_;
my $d = $self->{_Z_DEFLATE} // return;
- my ($out, $status) = $d->flush($t);
- $self->panic("Can't flush deflation stream: ", $d->msg()) unless $status == Z_OK;
- $self->_write($out);
+ $self->_write( $d->flush($t) // $self->panic("Can't flush deflation stream: ", $d->msg()) );
}
else {
for (my $i = 0; $i <= $#data; $i++) {
$self->_z_flush(Z_FULL_FLUSH) if $i == 0 and $z_flush;
-
- my ($out, $status) = $d->deflate($data[$i]);
- $self->panic("Deflation failed: ", $d->msg()) unless $status == Z_OK;
- $self->_write($out);
-
+ $self->_write( $d->deflate($data[$i]) // $self->panic("Deflation failed: ", $d->msg()) );
$self->_z_flush(Z_FULL_FLUSH) if $i == 0 and $z_flush;
}
}