MIME::Decoder::Binary - perform no encoding/decoding


MIME-tools documentation Contained in the MIME-tools distribution.

Index


Code Index:

NAME

Top

MIME::Decoder::Binary - perform no encoding/decoding

SYNOPSIS

Top

A generic decoder object; see MIME::Decoder for usage.

DESCRIPTION

Top

A MIME::Decoder subclass for the "binary" encoding (in other words, no encoding).

The "binary" decoder is a special case, since it's ill-advised to read the input line-by-line: after all, an uncompressed image file might conceivably have loooooooooong stretches of bytes without a "\n" among them, and we don't want to risk blowing out our core. So, we read-and-write fixed-size chunks.

Both the encoder and decoder do a simple pass-through of the data from input to output.

SEE ALSO

Top

MIME::Decoder

AUTHOR

Top

Eryq (eryq@zeegee.com), ZeeGee Software Inc (http://www.zeegee.com).

All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


MIME-tools documentation Contained in the MIME-tools distribution.

package MIME::Decoder::Binary;


use MIME::Decoder;
use vars qw(@ISA $VERSION);

@ISA = qw(MIME::Decoder);

### The package version, both in 1.23 style *and* usable by MakeMaker:
$VERSION = "5.502";

### Buffer length:
my $BUFLEN = 8192;

#------------------------------
#
# decode_it IN, OUT
#
sub decode_it {
    my ($self, $in, $out) = @_;

    my ($buf, $nread) = ('', 0);
    while ($nread = $in->read($buf, $BUFLEN)) {
	$out->print($buf);
    }
    defined($nread) or return undef;      ### check for error
    1;
}

#------------------------------
#
# encode_it IN, OUT
#
sub encode_it {
    my ($self, $in, $out) = @_;

    my ($buf, $nread) = ('', 0);
    while ($nread = $in->read($buf, $BUFLEN)) {
	$out->print($buf);
    }
    defined($nread) or return undef;      ### check for error
    1;
}

#------------------------------
1;