line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package POE::Filter::ErrorProof; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
671
|
use 5.000; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
39
|
|
4
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
32
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
5
|
use vars qw($VERSION @ISA); |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
1046
|
|
7
|
|
|
|
|
|
|
$VERSION = '0.01'; |
8
|
|
|
|
|
|
|
@ISA = qw(POE::Filter); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new { |
11
|
0
|
|
|
0
|
1
|
|
my ($type, $filter, $errorsock) = @_; |
12
|
0
|
0
|
|
|
|
|
if(!defined($filter)) { |
13
|
0
|
|
|
|
|
|
$filter = new POE::Filter::Stream; |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
0
|
|
|
|
|
|
my $outputErrors; |
17
|
0
|
0
|
|
|
|
|
if(!defined($errorsock)) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
18
|
0
|
|
|
|
|
|
$outputErrors = 0; |
19
|
|
|
|
|
|
|
} elsif(ref($errorsock) eq "GLOB") { |
20
|
0
|
|
|
|
|
|
$outputErrors = 1; |
21
|
|
|
|
|
|
|
} elsif(ref($errorsock) eq "POE::Wheel::ReadWrite") { |
22
|
0
|
|
|
|
|
|
$outputErrors = 2; |
23
|
|
|
|
|
|
|
} elsif($errorsock == 1) { |
24
|
0
|
|
|
|
|
|
$outputErrors = 1; |
25
|
0
|
|
|
|
|
|
$errorsock = \*STDERR; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
0
|
0
|
|
|
|
|
$type = ref($type) if ref($type); |
29
|
|
|
|
|
|
|
my $self = { |
30
|
|
|
|
|
|
|
filter => $filter, |
31
|
|
|
|
|
|
|
outputErrors => $outputErrors, |
32
|
|
|
|
|
|
|
errorsock => $errorsock, |
33
|
|
|
|
|
|
|
output => sub { |
34
|
0
|
|
|
0
|
|
|
my $self = shift; my $error = shift; |
|
0
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
|
my $oe = $self->{outputErrors}; |
36
|
0
|
0
|
|
|
|
|
if($oe == 1) { |
|
|
0
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
my $sock = $self->{errorsock}; |
38
|
0
|
|
|
|
|
|
print $sock $error; |
39
|
|
|
|
|
|
|
} elsif($oe == 2) { |
40
|
0
|
|
|
|
|
|
$self->{errorsock}->put($error); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
}, |
43
|
0
|
|
|
|
|
|
}; |
44
|
0
|
|
|
|
|
|
bless $self, $type; |
45
|
0
|
|
|
|
|
|
return $self; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub clone { |
49
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
50
|
0
|
|
|
|
|
|
my $filter; |
51
|
0
|
|
|
|
|
|
eval { |
52
|
0
|
0
|
|
|
|
|
if($self->{filter}->can('clone')) { |
53
|
0
|
|
|
|
|
|
$filter = $self->{filter}->clone(); |
54
|
|
|
|
|
|
|
} else { |
55
|
0
|
|
|
|
|
|
$filter = $self->{filter}; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
}; |
58
|
0
|
0
|
|
|
|
|
if($@) { |
59
|
0
|
|
|
|
|
|
$self->{output}->($self, $@); |
60
|
0
|
|
|
|
|
|
return undef; |
61
|
|
|
|
|
|
|
} |
62
|
0
|
|
|
|
|
|
my $clone = { |
63
|
|
|
|
|
|
|
filter => $filter, |
64
|
|
|
|
|
|
|
}; |
65
|
0
|
|
|
|
|
|
bless $clone, ref $self; |
66
|
0
|
|
|
|
|
|
return $clone; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub DESTROY { |
70
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
71
|
0
|
|
|
|
|
|
my $outp; |
72
|
0
|
|
|
|
|
|
eval { |
73
|
0
|
0
|
|
|
|
|
$outp = $self->{filter}->DESTROY() if($self->{filter}->can('DESTROY')); |
74
|
|
|
|
|
|
|
}; |
75
|
0
|
0
|
|
|
|
|
if($@) { |
76
|
0
|
|
|
|
|
|
$self->{output}->($self, $@); |
77
|
0
|
|
|
|
|
|
return undef; |
78
|
|
|
|
|
|
|
} |
79
|
0
|
|
|
|
|
|
return $outp; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub reset { |
83
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
84
|
0
|
|
|
|
|
|
my $outp; |
85
|
0
|
|
|
|
|
|
eval { |
86
|
0
|
0
|
|
|
|
|
$outp = $self->{filter}->reset() if($self->{filter}->can('reset')); |
87
|
|
|
|
|
|
|
}; |
88
|
0
|
0
|
|
|
|
|
if($@) { |
89
|
0
|
|
|
|
|
|
$self->{output}->($self, $@); |
90
|
0
|
|
|
|
|
|
return undef; |
91
|
|
|
|
|
|
|
} |
92
|
0
|
|
|
|
|
|
return $outp; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub get_one_start { |
96
|
0
|
|
|
0
|
1
|
|
my ($self, $stream) = @_; |
97
|
0
|
|
|
|
|
|
my $outp; |
98
|
0
|
|
|
|
|
|
eval { |
99
|
0
|
|
|
|
|
|
$outp = $self->{filter}->get_one_start($stream); |
100
|
|
|
|
|
|
|
}; |
101
|
0
|
0
|
|
|
|
|
if($@) { |
102
|
0
|
|
|
|
|
|
$self->{output}->($self, $@); |
103
|
0
|
|
|
|
|
|
return undef; |
104
|
|
|
|
|
|
|
} |
105
|
0
|
|
|
|
|
|
return $outp; |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub get_one { |
109
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
110
|
0
|
|
|
|
|
|
my $outp; |
111
|
0
|
|
|
|
|
|
eval { |
112
|
0
|
|
|
|
|
|
$outp = $self->{filter}->get_one(); |
113
|
|
|
|
|
|
|
}; |
114
|
0
|
0
|
|
|
|
|
if($@) { |
115
|
0
|
|
|
|
|
|
$self->{output}->($self, $@); |
116
|
0
|
|
|
|
|
|
return []; |
117
|
|
|
|
|
|
|
} |
118
|
0
|
|
|
|
|
|
return $outp; |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
sub put { |
122
|
0
|
|
|
0
|
1
|
|
my ($self, $chunks) = @_; |
123
|
0
|
|
|
|
|
|
my $outp; |
124
|
0
|
|
|
|
|
|
eval { |
125
|
0
|
|
|
|
|
|
$outp = $self->{filter}->put(); |
126
|
|
|
|
|
|
|
}; |
127
|
0
|
0
|
|
|
|
|
if($@) { |
128
|
0
|
|
|
|
|
|
$self->{output}->($self, $@); |
129
|
0
|
|
|
|
|
|
return []; |
130
|
|
|
|
|
|
|
} |
131
|
0
|
|
|
|
|
|
return $outp; |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
sub get_pending { |
135
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
136
|
0
|
|
|
|
|
|
my $outp; |
137
|
0
|
|
|
|
|
|
eval { |
138
|
0
|
|
|
|
|
|
$outp = $self->{filter}->get_pending(); |
139
|
|
|
|
|
|
|
}; |
140
|
0
|
0
|
|
|
|
|
if($@) { |
141
|
0
|
|
|
|
|
|
$self->{output}->($self, $@); |
142
|
0
|
|
|
|
|
|
return undef; |
143
|
|
|
|
|
|
|
} |
144
|
0
|
|
|
|
|
|
return $outp; |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
1; |
150
|
|
|
|
|
|
|
__END__ |