| 1 | package MIME::Decoder::Binary; | ||||||||||
| 2 | 7 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 7 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | |||||||||||
| 6 | =head1 NAME | ||||||||||
| 7 | |||||||||||
| 8 | MIME::Decoder::Binary - perform no encoding/decoding | ||||||||||
| 9 | |||||||||||
| 10 | |||||||||||
| 11 | =head1 SYNOPSIS | ||||||||||
| 12 | |||||||||||
| 13 | A generic decoder object; see L<MIME::Decoder> for usage. | ||||||||||
| 14 | |||||||||||
| 15 | |||||||||||
| 16 | =head1 DESCRIPTION | ||||||||||
| 17 | |||||||||||
| 18 | A MIME::Decoder subclass for the C<"binary"> encoding (in other words, | ||||||||||
| 19 | no encoding). | ||||||||||
| 20 | |||||||||||
| 21 | The C<"binary"> decoder is a special case, since it's ill-advised | ||||||||||
| 22 | to read the input line-by-line: after all, an uncompressed image file might | ||||||||||
| 23 | conceivably have loooooooooong stretches of bytes without a C<"\n"> among | ||||||||||
| 24 | them, and we don't want to risk blowing out our core. So, we | ||||||||||
| 25 | read-and-write fixed-size chunks. | ||||||||||
| 26 | |||||||||||
| 27 | Both the B<encoder> and B<decoder> do a simple pass-through of the data | ||||||||||
| 28 | from input to output. | ||||||||||
| 29 | |||||||||||
| 30 | =head1 SEE ALSO | ||||||||||
| 31 | |||||||||||
| 32 | L<MIME::Decoder> | ||||||||||
| 33 | |||||||||||
| 34 | |||||||||||
| 35 | =head1 AUTHOR | ||||||||||
| 36 | |||||||||||
| 37 | Eryq (F<eryq@zeegee.com>), ZeeGee Software Inc (F<http://www.zeegee.com>). | ||||||||||
| 38 | |||||||||||
| 39 | All rights reserved. This program is free software; you can redistribute | ||||||||||
| 40 | it and/or modify it under the same terms as Perl itself. | ||||||||||
| 41 | |||||||||||
| 42 | =cut | ||||||||||
| 43 | |||||||||||
| 44 | 7 | ▶ | use MIME::Decoder; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 45 | 7 | ▶ | use vars qw(@ISA $VERSION); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 46 | |||||||||||
| 47 | 7 | @ISA = qw(MIME::Decoder); | |||||||||
| 48 | |||||||||||
| 49 | ### The package version, both in 1.23 style *and* usable by MakeMaker: | ||||||||||
| 50 | 7 | $VERSION = "5.522"; | |||||||||
| 51 | |||||||||||
| 52 | ### Buffer length: | ||||||||||
| 53 | 7 | my $BUFLEN = 8192; | |||||||||
| 54 | |||||||||||
| 55 | #------------------------------ | ||||||||||
| 56 | # | ||||||||||
| 57 | # decode_it IN, OUT | ||||||||||
| 58 | # | ||||||||||
| 59 | 13 | ▶ | sub decode_it { | ||||||||
|
Subroutine
decode_it: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||
| 60 | 13 | my ($self, $in, $out) = @_; | |||||||||
| 61 | |||||||||||
| 62 | 13 | my ($buf, $nread) = ('', 0); | |||||||||
| 63 | 13 | ▶ | while ($nread = $in->read($buf, $BUFLEN)) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 64 | 13 | $out->print($buf); | |||||||||
| 65 | } | ||||||||||
| 66 | 13 | ▶ | defined($nread) or return undef; ### check for error | ||||||||
|
Branch: 1 branch
| |||||||||||
| 67 | 13 | 1; | |||||||||
| 68 | } | ||||||||||
| 69 | |||||||||||
| 70 | #------------------------------ | ||||||||||
| 71 | # | ||||||||||
| 72 | # encode_it IN, OUT | ||||||||||
| 73 | # | ||||||||||
| 74 | 21 | ▶ | sub encode_it { | ||||||||
|
Subroutine
encode_it: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||
| 75 | 21 | my ($self, $in, $out) = @_; | |||||||||
| 76 | |||||||||||
| 77 | 21 | my ($buf, $nread) = ('', 0); | |||||||||
| 78 | 21 | ▶ | while ($nread = $in->read($buf, $BUFLEN)) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 79 | 21 | $out->print($buf); | |||||||||
| 80 | } | ||||||||||
| 81 | 21 | ▶ | defined($nread) or return undef; ### check for error | ||||||||
|
Branch: 1 branch
| |||||||||||
| 82 | 21 | 1; | |||||||||
| 83 | } | ||||||||||
| 84 | |||||||||||
| 85 | #------------------------------ | ||||||||||
| 86 | 7 | 1; | |||||||||