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 / Gzip64.pm < prev    next >
Encoding:
Perl POD Document  |  2002-06-14  |  2.8 KB  |  113 lines

  1. package MIME::Decoder::Gzip64;
  2.  
  3.  
  4. =head1 NAME
  5.  
  6. MIME::Decoder::Gzip64 - decode a "base64" gzip stream
  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::Base64 subclass for a nonstandard encoding whereby
  17. data are gzipped, then the gzipped file is base64-encoded.
  18. Common non-standard MIME encodings for this:
  19.  
  20.     x-gzip64
  21.  
  22. Since this class relies on external programs which may not
  23. exist on your machine, MIME-tools does not "install" it by default.
  24. To use it, you need to say in your main program:
  25.  
  26.     install MIME::Decoder::Gzip64 'x-gzip64';
  27.  
  28. Note: if this class isn't working for you, you may need to change
  29. the commands it runs.  In your main program, you can do so
  30. by setting up the two commands which
  31.  
  32.     use MIME::Decoder::Gzip64;
  33.  
  34.     $MIME::Decoder::Gzip64::GZIP   = 'gzip -c';
  35.     $MIME::Decoder::Gzip64::GUNZIP = 'gzip -d -c';
  36.  
  37.  
  38. =head1 AUTHOR
  39.  
  40. Eryq (F<eryq@zeegee.com>), ZeeGee Software Inc (F<http://www.zeegee.com>).
  41.  
  42. All rights reserved.  This program is free software; you can redistribute
  43. it and/or modify it under the same terms as Perl itself.
  44.  
  45.  
  46. =head1 VERSION
  47.  
  48. $Revision: 5.403 $ $Date: 2000/11/04 19:54:48 $
  49.  
  50. =cut
  51.  
  52.  
  53. require 5.002;
  54. use vars qw(@ISA $VERSION $ZIP $UNZIP);
  55. use MIME::Decoder;
  56. use MIME::Base64;
  57. use MIME::Decoder::Base64;
  58. use MIME::Tools qw(tmpopen whine);
  59. use IO::Wrap;
  60.  
  61. # Inheritance:
  62. @ISA = qw(MIME::Decoder::Base64);
  63.  
  64. # The package version, both in 1.23 style *and* usable by MakeMaker:
  65. $VERSION = substr q$Revision: 5.403 $, 10;
  66.  
  67. # How to compress stdin to stdout:
  68. $GZIP   = "gzip -c";
  69.  
  70. # How to UNcompress stdin to stdout:
  71. $GUNZIP = "gzip -d -c";
  72.  
  73.  
  74. #------------------------------
  75. #
  76. # decode_it IN, OUT
  77. #
  78. sub decode_it {
  79.     my ($self, $in, $out) = @_;
  80.  
  81.     # Open a temp file (assume the worst, that this is a big stream):
  82.     my $tmp = wraphandle(tmpopen() || die "can't get temp file");
  83.  
  84.     # Stage 1: decode the base64'd stream into zipped data:
  85.     $self->SUPER::decode_it($in, $tmp)    or die "base64 decoding failed!";
  86.     
  87.     # Stage 2: un-zip the zipped data:
  88.     $tmp->seek(0, 0); 
  89.     $self->filter($tmp, $out, $GUNZIP)    or die "gzip decoding failed!";
  90. }
  91.  
  92. #------------------------------
  93. #
  94. # encode_it IN, OUT
  95. #
  96. sub encode_it {
  97.     my ($self, $in, $out) = @_;
  98.     whine "Encoding ", $self->encoding, " is not standard MIME!"; 
  99.     
  100.     # Open a temp file (assume the worst, that this is a big stream):
  101.     my $tmp = wraphandle(tmpopen() || die "can't get temp file");
  102.   
  103.     # Stage 1: zip the raw data:
  104.     $self->filter($in, $tmp, $GZIP)       or die "gzip encoding failed!";
  105.     
  106.     # Stage 2: encode the zipped data via base64:
  107.     $tmp->seek(0, 0);    
  108.     $self->SUPER::encode_it($tmp, $out)   or die "base64 encoding failed!";
  109. }
  110.  
  111. #------------------------------
  112. 1;
  113.