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