1package PerlIO::via::QuotedPrint;
2
3$VERSION= '0.08';
4
5# be as strict as possible
6use strict;
7
8# modules that we need
9use MIME::QuotedPrint (); # no need to pollute this namespace
10
11# satisfy -require-
121;
13
14#-------------------------------------------------------------------------------
15#
16# Standard Perl features
17#
18#-------------------------------------------------------------------------------
19#  IN: 1 class to bless with
20#      2 mode string (ignored)
21#      3 file handle of PerlIO layer below (ignored)
22# OUT: 1 blessed object
23
24sub PUSHED { bless \*PUSHED,$_[0] } #PUSHED
25
26#-------------------------------------------------------------------------------
27#  IN: 1 instantiated object (ignored)
28#      2 handle to read from
29# OUT: 1 decoded string
30
31sub FILL {
32
33    # decode and return
34    my $line= readline( $_[1] );
35    return ( defined $line )
36      ? MIME::QuotedPrint::decode_qp($line)
37      : undef;
38} #FILL
39
40#-------------------------------------------------------------------------------
41#  IN: 1 instantiated object (ignored)
42#      2 buffer to be written
43#      3 handle to write to
44# OUT: 1 number of bytes written
45
46sub WRITE {
47
48    # encode and write to handle: indicate result
49    return ( print { $_[2] } MIME::QuotedPrint::encode_qp( $_[1] ) )
50      ? length( $_[1] )
51      : -1;
52} #WRITE
53
54#-------------------------------------------------------------------------------
55
56__END__
57
58=head1 NAME
59
60PerlIO::via::QuotedPrint - PerlIO layer for quoted-printable strings
61
62=head1 SYNOPSIS
63
64 use PerlIO::via::QuotedPrint;
65
66 open( my $in, '<:via(QuotedPrint)', 'file.qp' )
67   or die "Can't open file.qp for reading: $!\n";
68
69 open( my $out, '>:via(QuotedPrint)', 'file.qp' )
70   or die "Can't open file.qp for writing: $!\n";
71
72=head1 VERSION
73
74This documentation describes version 0.08.
75
76=head1 DESCRIPTION
77
78This module implements a PerlIO layer that works on files encoded in the
79quoted-printable format.  It will decode from quoted-printable while reading
80from a handle, and it will encode as quoted-printable while writing to a handle.
81
82=head1 REQUIRED MODULES
83
84 MIME::QuotedPrint (any)
85
86=head1 SEE ALSO
87
88L<PerlIO::via>, L<MIME::QuotedPrint>, L<PerlIO::via::Base64>,
89L<PerlIO::via::MD5>, L<PerlIO::via::StripHTML>, L<PerlIO::via::Rotate>.
90
91=head1 ACKNOWLEDGEMENTS
92
93Based on example that was initially added to MIME::QuotedPrint.pm for the
945.8.0 distribution of Perl.
95
96=head1 COPYRIGHT
97
98Copyright (c) 2002, 2003, 2004, 2012 Elizabeth Mattijsen.  All rights reserved.
99This library is free software; you can redistribute it and/or modify it under
100the same terms as Perl itself.
101
102=cut
103