1eac174f2Safresh1# Copyright (C) 2002-2004, 2012 Elizabeth Mattijsen. All rights reserved. 2eac174f2Safresh1# Copyright (C) 2015 Steve Hay. All rights reserved. 3eac174f2Safresh1 4eac174f2Safresh1# This module is free software; you can redistribute it and/or modify it under 5eac174f2Safresh1# the same terms as Perl itself, i.e. under the terms of either the GNU General 6eac174f2Safresh1# Public License or the Artistic License, as specified in the F<LICENCE> file. 7eac174f2Safresh1 8b39c5158Smillertpackage PerlIO::via::QuotedPrint; 9b39c5158Smillert 10eac174f2Safresh1use 5.008001; 11b39c5158Smillert 1291f110e0Safresh1# be as strict as possible 13b39c5158Smillertuse strict; 14b39c5158Smillert 15*e0680481Safresh1our $VERSION = '0.10'; 16eac174f2Safresh1 1791f110e0Safresh1# modules that we need 18b39c5158Smillertuse MIME::QuotedPrint (); # no need to pollute this namespace 19b39c5158Smillert 2091f110e0Safresh1# satisfy -require- 21b39c5158Smillert1; 22b39c5158Smillert 2391f110e0Safresh1#------------------------------------------------------------------------------- 2491f110e0Safresh1# 2591f110e0Safresh1# Standard Perl features 2691f110e0Safresh1# 2791f110e0Safresh1#------------------------------------------------------------------------------- 28b39c5158Smillert# IN: 1 class to bless with 29b39c5158Smillert# 2 mode string (ignored) 30b39c5158Smillert# 3 file handle of PerlIO layer below (ignored) 31b39c5158Smillert# OUT: 1 blessed object 32b39c5158Smillert 33b39c5158Smillertsub PUSHED { bless \*PUSHED,$_[0] } #PUSHED 34b39c5158Smillert 3591f110e0Safresh1#------------------------------------------------------------------------------- 36b39c5158Smillert# IN: 1 instantiated object (ignored) 37b39c5158Smillert# 2 handle to read from 38b39c5158Smillert# OUT: 1 decoded string 39b39c5158Smillert 40b39c5158Smillertsub FILL { 41b39c5158Smillert 4291f110e0Safresh1 # decode and return 43b39c5158Smillert my $line= readline( $_[1] ); 4491f110e0Safresh1 return ( defined $line ) 4591f110e0Safresh1 ? MIME::QuotedPrint::decode_qp($line) 4691f110e0Safresh1 : undef; 47b39c5158Smillert} #FILL 48b39c5158Smillert 4991f110e0Safresh1#------------------------------------------------------------------------------- 50b39c5158Smillert# IN: 1 instantiated object (ignored) 51b39c5158Smillert# 2 buffer to be written 52b39c5158Smillert# 3 handle to write to 53b39c5158Smillert# OUT: 1 number of bytes written 54b39c5158Smillert 55b39c5158Smillertsub WRITE { 56b39c5158Smillert 5791f110e0Safresh1 # encode and write to handle: indicate result 5891f110e0Safresh1 return ( print { $_[2] } MIME::QuotedPrint::encode_qp( $_[1] ) ) 5991f110e0Safresh1 ? length( $_[1] ) 6091f110e0Safresh1 : -1; 61b39c5158Smillert} #WRITE 62b39c5158Smillert 6391f110e0Safresh1#------------------------------------------------------------------------------- 6491f110e0Safresh1 65b39c5158Smillert__END__ 66b39c5158Smillert 67b39c5158Smillert=head1 NAME 68b39c5158Smillert 69b39c5158SmillertPerlIO::via::QuotedPrint - PerlIO layer for quoted-printable strings 70b39c5158Smillert 71b39c5158Smillert=head1 SYNOPSIS 72b39c5158Smillert 73b39c5158Smillert use PerlIO::via::QuotedPrint; 74b39c5158Smillert 75eac174f2Safresh1 open(my $in, '<:via(QuotedPrint)', 'file.qp') or 76eac174f2Safresh1 die "Can't open file.qp for reading: $!\n"; 77b39c5158Smillert 78eac174f2Safresh1 open(my $out, '>:via(QuotedPrint)', 'file.qp') or 79eac174f2Safresh1 die "Can't open file.qp for writing: $!\n"; 8091f110e0Safresh1 81b39c5158Smillert=head1 DESCRIPTION 82b39c5158Smillert 83b39c5158SmillertThis module implements a PerlIO layer that works on files encoded in the 84b39c5158Smillertquoted-printable format. It will decode from quoted-printable while reading 85b39c5158Smillertfrom a handle, and it will encode as quoted-printable while writing to a handle. 86b39c5158Smillert 87eac174f2Safresh1=head1 EXPORTS 88b39c5158Smillert 89eac174f2Safresh1I<None>. 90eac174f2Safresh1 91eac174f2Safresh1=head1 KNOWN BUGS 92eac174f2Safresh1 93eac174f2Safresh1I<None>. 94eac174f2Safresh1 95eac174f2Safresh1=head1 FEEDBACK 96eac174f2Safresh1 97eac174f2Safresh1Patches, bug reports, suggestions or any other feedback is welcome. 98eac174f2Safresh1 99eac174f2Safresh1Patches can be sent as GitHub pull requests at 100eac174f2Safresh1L<https://github.com/steve-m-hay/PerlIO-via-QuotedPrint/pulls>. 101eac174f2Safresh1 102eac174f2Safresh1Bug reports and suggestions can be made on the CPAN Request Tracker at 103eac174f2Safresh1L<https://rt.cpan.org/Public/Bug/Report.html?Queue=PerlIO-via-QuotedPrint>. 104eac174f2Safresh1 105eac174f2Safresh1Currently active requests on the CPAN Request Tracker can be viewed at 106eac174f2Safresh1L<https://rt.cpan.org/Public/Dist/Display.html?Status=Active;Queue=PerlIO-via-QuotedPrint>. 107eac174f2Safresh1 108eac174f2Safresh1Please test this distribution. See CPAN Testers Reports at 109eac174f2Safresh1L<https://www.cpantesters.org/> for details of how to get involved. 110eac174f2Safresh1 111eac174f2Safresh1Previous test results on CPAN Testers Reports can be viewed at 112eac174f2Safresh1L<https://www.cpantesters.org/distro/P/PerlIO-via-QuotedPrint.html>. 113eac174f2Safresh1 114eac174f2Safresh1Please rate this distribution on CPAN Ratings at 115eac174f2Safresh1L<https://cpanratings.perl.org/rate/?distribution=PerlIO-via-QuotedPrint>. 116b39c5158Smillert 117b39c5158Smillert=head1 SEE ALSO 118b39c5158Smillert 119eac174f2Safresh1L<PerlIO::via>, 120eac174f2Safresh1L<MIME::QuotedPrint>. 121b39c5158Smillert 122b39c5158Smillert=head1 ACKNOWLEDGEMENTS 123b39c5158Smillert 124eac174f2Safresh1Based on an example in the standard library module MIME::QuotedPrint in Perl 125eac174f2Safresh1(version 5.8.0). 126eac174f2Safresh1 127eac174f2Safresh1=head1 AVAILABILITY 128eac174f2Safresh1 129eac174f2Safresh1The latest version of this module is available from CPAN (see 130eac174f2Safresh1L<perlmodlib/"CPAN"> for details) at 131eac174f2Safresh1 132eac174f2Safresh1L<https://metacpan.org/release/PerlIO-via-QuotedPrint> or 133eac174f2Safresh1 134eac174f2Safresh1L<https://www.cpan.org/authors/id/S/SH/SHAY/> or 135eac174f2Safresh1 136eac174f2Safresh1L<https://www.cpan.org/modules/by-module/PerlIO/>. 137eac174f2Safresh1 138eac174f2Safresh1The latest source code is available from GitHub at 139eac174f2Safresh1L<https://github.com/steve-m-hay/PerlIO-via-QuotedPrint>. 140eac174f2Safresh1 141eac174f2Safresh1=head1 INSTALLATION 142eac174f2Safresh1 143eac174f2Safresh1See the F<INSTALL> file. 144eac174f2Safresh1 145eac174f2Safresh1=head1 AUTHOR 146eac174f2Safresh1 147eac174f2Safresh1Elizabeth Mattijsen E<lt>L<liz@dijkmat.nl|mailto:liz@dijkmat.nl>E<gt>. 148eac174f2Safresh1 149eac174f2Safresh1Steve Hay E<lt>L<shay@cpan.org|mailto:shay@cpan.org>E<gt> is now maintaining 150eac174f2Safresh1PerlIO::via::QuotedPrint as of version 0.08. 151b39c5158Smillert 152b39c5158Smillert=head1 COPYRIGHT 153b39c5158Smillert 154eac174f2Safresh1Copyright (C) 2002-2004, 2012 Elizabeth Mattijsen. All rights reserved. 155eac174f2Safresh1 156eac174f2Safresh1Copyright (C) 2015, 2020 Steve Hay. All rights reserved. 157eac174f2Safresh1 158eac174f2Safresh1=head1 LICENCE 159eac174f2Safresh1 160eac174f2Safresh1This module is free software; you can redistribute it and/or modify it under 161eac174f2Safresh1the same terms as Perl itself, i.e. under the terms of either the GNU General 162eac174f2Safresh1Public License or the Artistic License, as specified in the F<LICENCE> file. 163eac174f2Safresh1 164eac174f2Safresh1=head1 VERSION 165eac174f2Safresh1 166*e0680481Safresh1Version 0.10 167eac174f2Safresh1 168eac174f2Safresh1=head1 DATE 169eac174f2Safresh1 170*e0680481Safresh122 May 2022 171eac174f2Safresh1 172eac174f2Safresh1=head1 HISTORY 173eac174f2Safresh1 174eac174f2Safresh1See the F<Changes> file. 175b39c5158Smillert 176b39c5158Smillert=cut 177