| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Convert::UU; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
2854
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
32
|
|
|
4
|
1
|
|
|
1
|
|
45
|
BEGIN {require 5.004} # m//gc |
|
5
|
1
|
|
|
1
|
|
4
|
use vars qw($VERSION @ISA @EXPORT_OK); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
209
|
|
|
6
|
1
|
|
|
1
|
|
7
|
use Carp 'croak'; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
1601
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
require Exporter; |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
@ISA = qw(Exporter); |
|
11
|
|
|
|
|
|
|
# Items to export into callers namespace by default. Note: do not export |
|
12
|
|
|
|
|
|
|
# names by default without a very good reason. Use EXPORT_OK instead. |
|
13
|
|
|
|
|
|
|
# Do not simply export all your public functions/methods/constants. |
|
14
|
|
|
|
|
|
|
@EXPORT_OK = qw( |
|
15
|
|
|
|
|
|
|
uudecode uuencode |
|
16
|
|
|
|
|
|
|
); |
|
17
|
|
|
|
|
|
|
$VERSION = '0.5201'; |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# |
|
20
|
|
|
|
|
|
|
# From comp.lang.perl 3/1/95. |
|
21
|
|
|
|
|
|
|
# Posted by Hans Mulder (hansm@wsinti05.win.tue.nl) |
|
22
|
|
|
|
|
|
|
# |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub uuencode { |
|
25
|
3
|
50
|
33
|
3
|
0
|
3809
|
croak("Usage: uuencode( {string|filehandle} [,filename] [, mode] )") |
|
26
|
|
|
|
|
|
|
unless(@_ >= 1 && @_ <= 3); |
|
27
|
|
|
|
|
|
|
|
|
28
|
3
|
|
|
|
|
9
|
my($in,$file,$mode) = @_; |
|
29
|
3
|
|
100
|
|
|
16
|
$mode ||= "644"; |
|
30
|
3
|
|
100
|
|
|
11
|
$file ||= "uuencode.uu"; |
|
31
|
|
|
|
|
|
|
|
|
32
|
3
|
|
|
|
|
4
|
my($chunk,@result,$r); |
|
33
|
3
|
50
|
66
|
|
|
66
|
if ( |
|
|
|
|
66
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
34
|
|
|
|
|
|
|
UNIVERSAL::isa( $in, 'IO::Handle' ) or |
|
35
|
|
|
|
|
|
|
ref(\$in) eq "GLOB" or |
|
36
|
|
|
|
|
|
|
ref($in) eq "GLOB" or |
|
37
|
|
|
|
|
|
|
ref($in) eq 'FileHandle' |
|
38
|
|
|
|
|
|
|
) { |
|
39
|
|
|
|
|
|
|
# local $^W = 0; # Why did I get use of undefined value here ? |
|
40
|
1
|
|
|
|
|
3
|
binmode($in); |
|
41
|
1
|
|
|
|
|
4
|
local $/; |
|
42
|
1
|
|
|
|
|
20
|
$in = <$in>; |
|
43
|
|
|
|
|
|
|
} |
|
44
|
3
|
|
|
|
|
11
|
pos($in)=0; |
|
45
|
3
|
|
|
|
|
16
|
while ($in =~ m/\G(.{1,45})/sgc) { |
|
46
|
74
|
|
|
|
|
204
|
push @result, _uuencode_chunk($1); |
|
47
|
|
|
|
|
|
|
} |
|
48
|
3
|
|
|
|
|
6
|
push @result, "`\n"; |
|
49
|
3
|
|
|
|
|
37
|
join "", "begin $mode $file\n", @result, "end\n"; |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub _uuencode_chunk { |
|
53
|
74
|
|
|
74
|
|
128
|
my($string) = shift; |
|
54
|
|
|
|
|
|
|
# for the Mac? |
|
55
|
|
|
|
|
|
|
# my($mod3) = length($string) % 3; |
|
56
|
|
|
|
|
|
|
# $string .= "\0", $mod3 -= 3 if $mod3; |
|
57
|
74
|
|
|
|
|
163
|
my $encoded_string = pack("u", $string); # unix uuencode |
|
58
|
|
|
|
|
|
|
# for the Mac? |
|
59
|
|
|
|
|
|
|
# $encoded_string =~ s/.//; # remove length byte |
|
60
|
|
|
|
|
|
|
# chop($encoded_string); # remove trailing \n |
|
61
|
|
|
|
|
|
|
# $encoded_string =~ tr#`!-_#A-Za-z0-9+/#; # tr to mime alphabet |
|
62
|
|
|
|
|
|
|
# substr($encoded_string, $mod3) =~ tr/A/=/; # adjust padding |
|
63
|
74
|
|
|
|
|
300
|
$encoded_string; |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub uudecode { |
|
67
|
6
|
50
|
|
6
|
0
|
37
|
croak("Usage: uudecode( {string|filehandle|array ref}) ") |
|
68
|
|
|
|
|
|
|
unless(@_ == 1); |
|
69
|
6
|
|
|
|
|
9
|
my($in) = @_; |
|
70
|
|
|
|
|
|
|
|
|
71
|
6
|
|
|
|
|
7
|
my(@result,$file,$mode); |
|
72
|
6
|
|
|
|
|
10
|
$mode = $file = ""; |
|
73
|
6
|
50
|
33
|
|
|
126
|
if ( |
|
|
|
100
|
33
|
|
|
|
|
|
|
|
50
|
33
|
|
|
|
|
|
74
|
|
|
|
|
|
|
UNIVERSAL::isa( $in, 'IO::Handle' ) or |
|
75
|
|
|
|
|
|
|
ref(\$in) eq "GLOB" or |
|
76
|
|
|
|
|
|
|
ref($in) eq "GLOB" or |
|
77
|
|
|
|
|
|
|
ref($in) eq 'FileHandle' |
|
78
|
|
|
|
|
|
|
) { |
|
79
|
0
|
|
|
|
|
0
|
local($\) = "\n"; |
|
80
|
0
|
|
|
|
|
0
|
binmode($in); |
|
81
|
0
|
|
|
|
|
0
|
while (<$in>) { |
|
82
|
0
|
0
|
0
|
|
|
0
|
if ($file eq "" and !$mode){ |
|
83
|
0
|
0
|
|
|
|
0
|
($mode,$file) = ($1, $2) if /^begin\s+(\d+)\s+(.+)$/ ; |
|
84
|
0
|
|
|
|
|
0
|
next; |
|
85
|
|
|
|
|
|
|
} |
|
86
|
0
|
0
|
|
|
|
0
|
last if /^end/; |
|
87
|
0
|
|
|
|
|
0
|
push @result, _uudecode_chunk($_); |
|
88
|
|
|
|
|
|
|
} |
|
89
|
|
|
|
|
|
|
} elsif (ref(\$in) eq "SCALAR") { |
|
90
|
5
|
|
|
|
|
31
|
while ($in =~ m/\G(.*?(\n|\r|\r\n|\n\r))/gc) { |
|
91
|
93
|
|
|
|
|
143
|
my $line = $1; |
|
92
|
93
|
100
|
66
|
|
|
215
|
if ($file eq "" and !$mode){ |
|
93
|
5
|
|
|
|
|
27
|
($mode,$file) = $line =~ /^begin\s+(\d+)\s+(.+)$/ ; |
|
94
|
5
|
|
|
|
|
36
|
next; |
|
95
|
|
|
|
|
|
|
} |
|
96
|
88
|
50
|
33
|
|
|
185
|
next if $file eq "" and !$mode; |
|
97
|
88
|
100
|
|
|
|
172
|
last if $line =~ /^end/; |
|
98
|
83
|
|
|
|
|
136
|
push @result, _uudecode_chunk($line); |
|
99
|
|
|
|
|
|
|
} |
|
100
|
|
|
|
|
|
|
} elsif (ref($in) eq "ARRAY") { |
|
101
|
1
|
|
|
|
|
1
|
my $line; |
|
102
|
1
|
|
|
|
|
3
|
foreach $line (@$in) { |
|
103
|
3
|
100
|
66
|
|
|
12
|
if ($file eq "" and !$mode){ |
|
104
|
1
|
|
|
|
|
6
|
($mode,$file) = $line =~ /^begin\s+(\d+)\s+(.+)$/ ; |
|
105
|
1
|
|
|
|
|
2
|
next; |
|
106
|
|
|
|
|
|
|
} |
|
107
|
2
|
50
|
33
|
|
|
7
|
next if $file eq "" and !$mode; |
|
108
|
2
|
100
|
|
|
|
9
|
last if $line =~ /^end/; |
|
109
|
1
|
|
|
|
|
19
|
push @result, _uudecode_chunk($line); |
|
110
|
|
|
|
|
|
|
} |
|
111
|
|
|
|
|
|
|
} |
|
112
|
6
|
50
|
|
|
|
54
|
wantarray ? (join("",@result),$file,$mode) : join("",@result); |
|
113
|
|
|
|
|
|
|
} |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub _uudecode_chunk { |
|
116
|
84
|
|
|
84
|
|
97
|
my($chunk) = @_; |
|
117
|
|
|
|
|
|
|
# return "" if $chunk =~ /^(--|\#|CREATED)/; # the "#" was an evil |
|
118
|
|
|
|
|
|
|
# bug: a "#" in column |
|
119
|
|
|
|
|
|
|
# one is legal! |
|
120
|
84
|
50
|
|
|
|
218
|
return "" if $chunk =~ /^(?:--|CREATED)/; |
|
121
|
84
|
|
|
|
|
254
|
my $string = substr($chunk,0,int((((ord($chunk) - 32) & 077) + 2) / 3)*4+1); |
|
122
|
|
|
|
|
|
|
# warn "DEBUG: string [$string]"; |
|
123
|
|
|
|
|
|
|
# my $return = unpack("u", $string); |
|
124
|
|
|
|
|
|
|
# warn "DEBUG: return [$return]"; |
|
125
|
|
|
|
|
|
|
# $return; |
|
126
|
|
|
|
|
|
|
|
|
127
|
84
|
|
|
|
|
358
|
my $ret = unpack("u", $string); |
|
128
|
84
|
100
|
|
|
|
761
|
defined $ret ? $ret : ""; |
|
129
|
|
|
|
|
|
|
} |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
1; |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
__END__ |