| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package PerlIO::via::MD5; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
$VERSION= '0.07'; |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
# be as strict as possible |
|
6
|
1
|
|
|
1
|
|
71777
|
use strict; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
45
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# modules that we need |
|
9
|
1
|
|
|
1
|
|
7
|
use Digest::MD5 (); # no need to pollute this namespace |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
354
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# initializations |
|
12
|
|
|
|
|
|
|
my %allowed= ( digest => 1, hexdigest => 1, b64digest => 1 ); |
|
13
|
|
|
|
|
|
|
my $method= 'hexdigest'; |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# satisfy -require- |
|
16
|
|
|
|
|
|
|
1; |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
|
19
|
|
|
|
|
|
|
# |
|
20
|
|
|
|
|
|
|
# Methods for settings that will be used by the objects |
|
21
|
|
|
|
|
|
|
# |
|
22
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
|
23
|
|
|
|
|
|
|
# IN: 1 class (ignored) |
|
24
|
|
|
|
|
|
|
# 2 new setting for method |
|
25
|
|
|
|
|
|
|
# OUT: 1 current setting for eol |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub method { |
|
28
|
3
|
|
|
3
|
1
|
23
|
shift; |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# set new value if given |
|
31
|
3
|
100
|
|
|
|
13
|
if (@_) { |
|
32
|
2
|
50
|
|
|
|
11
|
die "Invalid digest method '$_[0]'" unless $allowed{$_[0]}; |
|
33
|
2
|
|
|
|
|
4
|
$method= shift; |
|
34
|
|
|
|
|
|
|
} |
|
35
|
|
|
|
|
|
|
|
|
36
|
3
|
|
|
|
|
19
|
return $method; |
|
37
|
|
|
|
|
|
|
} #method |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
|
40
|
|
|
|
|
|
|
# |
|
41
|
|
|
|
|
|
|
# Standard Perl features |
|
42
|
|
|
|
|
|
|
# |
|
43
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
|
44
|
|
|
|
|
|
|
# IN: 1 class |
|
45
|
|
|
|
|
|
|
# 2 mode string (ignored) |
|
46
|
|
|
|
|
|
|
# 3 file handle of PerlIO layer below (ignored) |
|
47
|
|
|
|
|
|
|
# OUT: 1 blessed object |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub PUSHED { |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
# not reading |
|
52
|
3
|
50
|
|
3
|
0
|
2807
|
return -1 if $_[1] ne 'r'; |
|
53
|
|
|
|
|
|
|
|
|
54
|
3
|
|
|
|
|
256
|
return bless [ Digest::MD5->new, $method ], $_[0]; |
|
55
|
|
|
|
|
|
|
} #PUSHED |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
|
58
|
|
|
|
|
|
|
# IN: 1 instantiated object |
|
59
|
|
|
|
|
|
|
# 2 handle to read from |
|
60
|
|
|
|
|
|
|
# OUT: 1 empty string (when still busy) or the digest string (when done) |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub FILL { |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
# still reading file |
|
65
|
51
|
|
|
51
|
0
|
152
|
my $line= readline( $_[1] ); |
|
66
|
51
|
100
|
|
|
|
106
|
if ( defined($line) ) { |
|
|
|
100
|
|
|
|
|
|
|
67
|
45
|
|
|
|
|
129
|
$_[0]->[0]->add($line); |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
# nothing to be returned yet |
|
70
|
45
|
|
|
|
|
116
|
return ''; |
|
71
|
|
|
|
|
|
|
} |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
# end of data reached, we have MD5 object still |
|
74
|
|
|
|
|
|
|
elsif ( $_[0]->[0] ) { |
|
75
|
3
|
|
|
|
|
6
|
my ( $object, $method )= @{ $_[0] }; |
|
|
3
|
|
|
|
|
8
|
|
|
76
|
3
|
|
|
|
|
10
|
$_[0]->[0]= ''; |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
# return result of digest |
|
79
|
3
|
|
|
|
|
105
|
return $object->$method; |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
# huh?, end of data without MD5 object, empty file? |
|
83
|
3
|
|
|
|
|
23
|
return undef; |
|
84
|
|
|
|
|
|
|
} #FILL |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
__END__ |