line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/perl |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Tie::FTP; |
4
|
|
|
|
|
|
|
|
5
|
3
|
|
|
3
|
|
109667
|
use strict; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
133
|
|
6
|
3
|
|
|
3
|
|
18
|
use warnings; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
97
|
|
7
|
|
|
|
|
|
|
|
8
|
3
|
|
|
3
|
|
4288
|
use File::Temp (); |
|
3
|
|
|
|
|
104817
|
|
|
3
|
|
|
|
|
139
|
|
9
|
3
|
|
|
3
|
|
3256
|
use URI; |
|
3
|
|
|
|
|
18983
|
|
|
3
|
|
|
|
|
117
|
|
10
|
3
|
|
|
3
|
|
6086
|
use Net::FTP; |
|
3
|
|
|
|
|
249444
|
|
|
3
|
|
|
|
|
2820
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = 0.02; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub TIEHANDLE { # uri object || uri || netftp object, path |
15
|
2
|
|
50
|
2
|
|
398807
|
my $pkg = shift || return undef; |
16
|
|
|
|
|
|
|
|
17
|
2
|
|
|
|
|
15
|
my ($tmpfh,$tmpnm) = File::Temp::tmpnam(); |
18
|
|
|
|
|
|
|
|
19
|
2
|
|
|
|
|
648541
|
my $self = bless { tmpfile => $tmpnm, tmpfh => $tmpfh},$pkg; |
20
|
|
|
|
|
|
|
|
21
|
2
|
|
|
|
|
15
|
$self; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub OPEN { |
25
|
2
|
|
|
2
|
|
28
|
my $self = shift; |
26
|
|
|
|
|
|
|
|
27
|
2
|
100
|
|
|
|
16
|
if (scalar @_ > 1){ |
28
|
1
|
|
|
|
|
11
|
$self->ftp(shift); |
29
|
1
|
|
|
|
|
6
|
$self->path(shift); |
30
|
|
|
|
|
|
|
} else { # uri or uri object |
31
|
1
|
|
|
|
|
3
|
my $uri = shift; |
32
|
1
|
50
|
|
|
|
14
|
$uri = URI->new($uri) unless ref $uri; |
33
|
1
|
50
|
|
|
|
26851
|
return undef unless $uri->scheme eq 'ftp'; |
34
|
|
|
|
|
|
|
|
35
|
1
|
|
|
|
|
467
|
$self->ftp(Net::FTP->new($uri->host)); |
36
|
1
|
|
|
|
|
8
|
$self->ftp->login(split(':',$uri->userinfo)); |
37
|
1
|
|
|
|
|
381676
|
$self->path(substr($uri->path,1)); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
2
|
|
|
|
|
23
|
$self->ftp->get($self->path,$self->tmpfile); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub tmpfile { # set to use a tempfile instead of writing and reading via net. overrides cache |
44
|
2
|
|
|
2
|
0
|
5
|
my $self = shift; |
45
|
2
|
50
|
|
|
|
11
|
$self->{tmpfile} = shift if @_; |
46
|
2
|
|
|
|
|
74
|
$self->{tmpfile}; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub tmpfh { |
50
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
51
|
0
|
0
|
|
|
|
0
|
$self->{tmpfh} = shift if @_; |
52
|
0
|
|
|
|
|
0
|
$self->{tmpfh}; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub ftp { |
56
|
5
|
|
|
5
|
0
|
45755
|
my $self = shift; |
57
|
5
|
100
|
|
|
|
38
|
$self->{ftp} = shift if @_; |
58
|
5
|
|
|
|
|
37
|
$self->{ftp}; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub path { |
62
|
4
|
|
|
4
|
0
|
57
|
my $self = shift; |
63
|
4
|
100
|
|
|
|
23
|
$self->{path} = shift if @_; |
64
|
4
|
|
|
|
|
615
|
$self->{path}; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub taint { |
68
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
69
|
0
|
|
|
|
|
0
|
$self->{tainted} = 1; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub tainted { |
73
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
74
|
0
|
|
|
|
|
0
|
$self->{tainted}; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub CLOSE { |
78
|
2
|
|
|
2
|
|
1776
|
goto &UNTIE; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
2
|
|
|
2
|
|
16
|
sub UNTIE { } |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub DESTROY { |
84
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
85
|
0
|
|
|
|
|
0
|
close $self->tmpfh; |
86
|
0
|
0
|
|
|
|
0
|
$self->ftp->put($self->tmpfile,$self->path) if $self->tainted; |
87
|
0
|
|
|
|
|
0
|
unlink $self->tmpfile; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
|
91
|
0
|
|
|
0
|
|
0
|
sub WRITE { $_[0]->taint; my $fh = $_[0]{tmpfh}; print $fh substr($_[1],$_[3],$_[2]) } |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
92
|
0
|
|
|
0
|
|
0
|
sub PRINT { $_[0]->taint; my $fh = shift->{tmpfh}; print $fh @_ } |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
93
|
0
|
|
|
0
|
|
0
|
sub PRINTF { $_[0]->taint; my $fh = shift->{tmpfh}; printf $fh @_ } |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
94
|
0
|
|
|
0
|
|
0
|
sub READ { read *{$_[0]{tmpfh}},$_[1],$_[2],$_[3] } |
|
0
|
|
|
|
|
0
|
|
95
|
2
|
|
|
2
|
|
250456
|
sub READLINE { readline $_[0]{tmpfh} } |
96
|
0
|
|
|
0
|
|
|
sub GETC { getc *{$_[0]{tmpfh}} } |
|
0
|
|
|
|
|
|
|
97
|
0
|
|
|
0
|
|
|
sub BINMODE{ binmode *{$_[0]{tmpfh}} } |
|
0
|
|
|
|
|
|
|
98
|
0
|
|
|
0
|
|
|
sub EOF { eof *{$_[0]{tmpfh}} } |
|
0
|
|
|
|
|
|
|
99
|
0
|
|
|
0
|
|
|
sub TELL { tell *{$_[0]{tmpfh}} } |
|
0
|
|
|
|
|
|
|
100
|
0
|
|
|
0
|
|
|
sub SEEK { seek *{$_[0]{tmpfh}},$_[1],$_[2] } |
|
0
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
1; # Keep your mother happy. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
__END__ |