Update documentation with &share() non prototype checking version.
[p5sagit/p5-mst-13.2.git] / lib / PerlIO / via / QuotedPrint.pm
1 package PerlIO::via::QuotedPrint;
2
3 # Make sure we do things by the book
4 # Set the version info
5
6 use strict;
7 $PerlIO::via::QuotedPrint::VERSION = 0.01;
8
9 # Make sure the encoding/decoding stuff is available
10
11 use MIME::QuotedPrint (); # no need to pollute this namespace
12
13 #-----------------------------------------------------------------------
14 #  IN: 1 class to bless with
15 #      2 mode string (ignored)
16 #      3 file handle of PerlIO layer below (ignored)
17 # OUT: 1 blessed object
18
19 sub PUSHED { bless [],$_[0] } #PUSHED
20
21 #-----------------------------------------------------------------------
22 #  IN: 1 instantiated object (ignored)
23 #      2 handle to read from
24 # OUT: 1 decoded string
25
26 sub FILL {
27
28 # Read the line from the handle
29 # Decode if there is something decode and return result or signal eof
30
31     my $line = readline( $_[1] );
32     (defined $line) ? MIME::QuotedPrint::decode_qp( $line ) : undef;
33 } #FILL
34
35 #-----------------------------------------------------------------------
36 #  IN: 1 instantiated object (ignored)
37 #      2 buffer to be written
38 #      3 handle to write to
39 # OUT: 1 number of bytes written
40
41 sub WRITE {
42
43 # Encode whatever needs to be encoded and write to handle: indicate result
44
45     (print {$_[2]} MIME::QuotedPrint::encode_qp($_[1])) ? length($_[1]) : -1;
46 } #WRITE
47
48 # Satisfy -require-
49
50 1;
51
52 __END__
53
54 =head1 NAME
55
56 PerlIO::via::QuotedPrint - PerlIO layer for quoted-printable strings
57
58 =head1 SYNOPSIS
59
60  use PerlIO::via::QuotedPrint;
61
62  open( my $in,'<Via(PerlIO::via::QuotedPrint)','file.qp' )
63   or die "Can't open file.qp for reading: $!\n";
64  
65  open( my $out,'>Via(PerlIO::via::QuotedPrint)','file.qp' )
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
74 =head1 SEE ALSO
75
76 L<PerlIO::via>, L<MIME::QuotedPrint>, L<PerlIO::via::Base64>, L<PerlIO::via::MD5>,
77 L<PerlIO::via::StripHTML>.
78
79 =head1 COPYRIGHT
80
81 Copyright (c) 2002 Elizabeth Mattijsen.  Based on example that was initially
82 added to MIME::QuotedPrint.pm for the 5.8.0 distribution of Perl.
83
84 This library is free software; you can redistribute it and/or
85 modify it under the same terms as Perl itself.
86
87 =cut