1*0Sstevel@tonic-gatepackage PerlIO::via::QuotedPrint; 2*0Sstevel@tonic-gate 3*0Sstevel@tonic-gate# Set the version info 4*0Sstevel@tonic-gate# Make sure we do things by the book from now on 5*0Sstevel@tonic-gate 6*0Sstevel@tonic-gate$VERSION = '0.06'; 7*0Sstevel@tonic-gateuse strict; 8*0Sstevel@tonic-gate 9*0Sstevel@tonic-gate# Make sure the encoding/decoding stuff is available 10*0Sstevel@tonic-gate 11*0Sstevel@tonic-gateuse MIME::QuotedPrint (); # no need to pollute this namespace 12*0Sstevel@tonic-gate 13*0Sstevel@tonic-gate# Satisfy -require- 14*0Sstevel@tonic-gate 15*0Sstevel@tonic-gate1; 16*0Sstevel@tonic-gate 17*0Sstevel@tonic-gate#----------------------------------------------------------------------- 18*0Sstevel@tonic-gate# IN: 1 class to bless with 19*0Sstevel@tonic-gate# 2 mode string (ignored) 20*0Sstevel@tonic-gate# 3 file handle of PerlIO layer below (ignored) 21*0Sstevel@tonic-gate# OUT: 1 blessed object 22*0Sstevel@tonic-gate 23*0Sstevel@tonic-gatesub PUSHED { bless \*PUSHED,$_[0] } #PUSHED 24*0Sstevel@tonic-gate 25*0Sstevel@tonic-gate#----------------------------------------------------------------------- 26*0Sstevel@tonic-gate# IN: 1 instantiated object (ignored) 27*0Sstevel@tonic-gate# 2 handle to read from 28*0Sstevel@tonic-gate# OUT: 1 decoded string 29*0Sstevel@tonic-gate 30*0Sstevel@tonic-gatesub FILL { 31*0Sstevel@tonic-gate 32*0Sstevel@tonic-gate# Read the line from the handle 33*0Sstevel@tonic-gate# Decode if there is something decode and return result or signal eof 34*0Sstevel@tonic-gate 35*0Sstevel@tonic-gate my $line = readline( $_[1] ); 36*0Sstevel@tonic-gate (defined $line) ? MIME::QuotedPrint::decode_qp( $line ) : undef; 37*0Sstevel@tonic-gate} #FILL 38*0Sstevel@tonic-gate 39*0Sstevel@tonic-gate#----------------------------------------------------------------------- 40*0Sstevel@tonic-gate# IN: 1 instantiated object (ignored) 41*0Sstevel@tonic-gate# 2 buffer to be written 42*0Sstevel@tonic-gate# 3 handle to write to 43*0Sstevel@tonic-gate# OUT: 1 number of bytes written 44*0Sstevel@tonic-gate 45*0Sstevel@tonic-gatesub WRITE { 46*0Sstevel@tonic-gate 47*0Sstevel@tonic-gate# Encode whatever needs to be encoded and write to handle: indicate result 48*0Sstevel@tonic-gate 49*0Sstevel@tonic-gate (print {$_[2]} MIME::QuotedPrint::encode_qp($_[1])) ? length($_[1]) : -1; 50*0Sstevel@tonic-gate} #WRITE 51*0Sstevel@tonic-gate 52*0Sstevel@tonic-gate__END__ 53*0Sstevel@tonic-gate 54*0Sstevel@tonic-gate=head1 NAME 55*0Sstevel@tonic-gate 56*0Sstevel@tonic-gatePerlIO::via::QuotedPrint - PerlIO layer for quoted-printable strings 57*0Sstevel@tonic-gate 58*0Sstevel@tonic-gate=head1 SYNOPSIS 59*0Sstevel@tonic-gate 60*0Sstevel@tonic-gate use PerlIO::via::QuotedPrint; 61*0Sstevel@tonic-gate 62*0Sstevel@tonic-gate open( my $in,'<:via(QuotedPrint)','file.qp' ) 63*0Sstevel@tonic-gate or die "Can't open file.qp for reading: $!\n"; 64*0Sstevel@tonic-gate 65*0Sstevel@tonic-gate open( my $out,'>:via(QuotedPrint)','file.qp' ) 66*0Sstevel@tonic-gate or die "Can't open file.qp for writing: $!\n"; 67*0Sstevel@tonic-gate 68*0Sstevel@tonic-gate=head1 DESCRIPTION 69*0Sstevel@tonic-gate 70*0Sstevel@tonic-gateThis module implements a PerlIO layer that works on files encoded in the 71*0Sstevel@tonic-gatequoted-printable format. It will decode from quoted-printable while reading 72*0Sstevel@tonic-gatefrom a handle, and it will encode as quoted-printable while writing to a handle. 73*0Sstevel@tonic-gate 74*0Sstevel@tonic-gate=head1 REQUIRED MODULES 75*0Sstevel@tonic-gate 76*0Sstevel@tonic-gate MIME::QuotedPrint (any) 77*0Sstevel@tonic-gate 78*0Sstevel@tonic-gate=head1 SEE ALSO 79*0Sstevel@tonic-gate 80*0Sstevel@tonic-gateL<PerlIO::via>, L<MIME::QuotedPrint>, L<PerlIO::via::Base64>, 81*0Sstevel@tonic-gateL<PerlIO::via::MD5>, L<PerlIO::via::StripHTML>, L<PerlIO::via::Rotate>. 82*0Sstevel@tonic-gate 83*0Sstevel@tonic-gate=head1 ACKNOWLEDGEMENTS 84*0Sstevel@tonic-gate 85*0Sstevel@tonic-gateBased on example that was initially added to MIME::QuotedPrint.pm for the 86*0Sstevel@tonic-gate5.8.0 distribution of Perl. 87*0Sstevel@tonic-gate 88*0Sstevel@tonic-gate=head1 COPYRIGHT 89*0Sstevel@tonic-gate 90*0Sstevel@tonic-gateCopyright (c) 2002-2003 Elizabeth Mattijsen. All rights reserved. This 91*0Sstevel@tonic-gatelibrary is free software; you can redistribute it and/or modify it under 92*0Sstevel@tonic-gatethe same terms as Perl itself. 93*0Sstevel@tonic-gate 94*0Sstevel@tonic-gate=cut 95