home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / xampp / xampp-perl-addon-1.4.9-installer.exe / Binary.pm < prev    next >
Encoding:
Perl POD Document  |  2002-06-14  |  1.9 KB  |  86 lines

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