line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package PerlIO::via::Base64; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# be as strict and verbose as possible |
4
|
1
|
|
|
1
|
|
25248
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
43
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
55
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# which version are we? |
8
|
|
|
|
|
|
|
our $VERSION= '0.08'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# get the logic we need |
11
|
1
|
|
|
1
|
|
966
|
use MIME::Base64 qw( encode_base64 ); |
|
1
|
|
|
|
|
843
|
|
|
1
|
|
|
|
|
378
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# default setting for the end of line character |
14
|
|
|
|
|
|
|
my $eol= "\n"; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# satisfy -require- |
17
|
|
|
|
|
|
|
1; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# Class methods |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
24
|
|
|
|
|
|
|
# IN: 1 class (ignored) |
25
|
|
|
|
|
|
|
# 2 new setting for eol (default: no change) |
26
|
|
|
|
|
|
|
# OUT: 1 current setting for eol |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub eol { |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# set new value if one specified |
31
|
3
|
100
|
|
3
|
1
|
961
|
$eol= $_[1] if @_ >1; |
32
|
|
|
|
|
|
|
|
33
|
3
|
|
|
|
|
23
|
return $eol; |
34
|
|
|
|
|
|
|
} #eol |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# Methods for standard Perl features |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
41
|
|
|
|
|
|
|
# IN: 1 class |
42
|
|
|
|
|
|
|
# 2 mode string (ignored) |
43
|
|
|
|
|
|
|
# 3 file handle of PerlIO layer below (ignored) |
44
|
|
|
|
|
|
|
# OUT: 1 blessed object |
45
|
|
|
|
|
|
|
|
46
|
4
|
|
|
4
|
0
|
3499
|
sub PUSHED { bless [ '', $eol ], $_[0] } #PUSHED |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
49
|
|
|
|
|
|
|
# IN: 1 instantiated object (ignored) |
50
|
|
|
|
|
|
|
# 2 handle to read from |
51
|
|
|
|
|
|
|
# OUT: 1 decoded string |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub FILL { |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
# slurp everything we can |
56
|
6
|
|
|
6
|
0
|
20
|
local $/; |
57
|
6
|
|
|
|
|
99
|
my $line= readline $_[1]; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# decode if there is something decode or signal eof |
60
|
6
|
100
|
|
|
|
67
|
return defined $line ? MIME::Base64::decode_base64( $line ) : undef; |
61
|
|
|
|
|
|
|
} #FILL |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
64
|
|
|
|
|
|
|
# IN: 1 instantiated object (reference to buffer) |
65
|
|
|
|
|
|
|
# 2 buffer to be written |
66
|
|
|
|
|
|
|
# 3 handle to write to (ignored) |
67
|
|
|
|
|
|
|
# OUT: 1 number of bytes "written" |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub WRITE { |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
# add to the buffer (encoding will take place on FLUSH) |
72
|
2
|
|
|
2
|
|
12
|
$_[0]->[0] .= $_[1]; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
# indicate we read the entire buffer |
75
|
2
|
|
|
|
|
17
|
return length $_[1]; |
76
|
|
|
|
|
|
|
} #WRITE |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
79
|
|
|
|
|
|
|
# IN: 1 instantiated object (reference to buffer) |
80
|
|
|
|
|
|
|
# 2 handle to write to |
81
|
|
|
|
|
|
|
# OUT: 1 flag indicating error |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub FLUSH { |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
# flush buffer |
86
|
4
|
100
|
|
4
|
0
|
24
|
if ( $_[0]->[0] ) { |
87
|
2
|
50
|
|
|
|
5
|
return -1 if !print { $_[1] } encode_base64( $_[0]->[0], $_[0]->[1] ); |
|
2
|
|
|
|
|
49
|
|
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
# reset buffer |
90
|
2
|
|
|
|
|
7
|
$_[0]->[0]= ''; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
# indicate success |
94
|
4
|
|
|
|
|
206
|
return 0; |
95
|
|
|
|
|
|
|
} #FLUSH |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
98
|
|
|
|
|
|
|
# IN: 1 class for which to import |
99
|
|
|
|
|
|
|
# 2..N parameters passed in -use- |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub import { |
102
|
2
|
|
|
2
|
|
142
|
my ( $class, %param )= @_; |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
# store parameters using mutators |
105
|
2
|
|
|
|
|
22
|
$class->$_( $param{$_} ) foreach keys %param; |
106
|
|
|
|
|
|
|
} #import |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
__END__ |