line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Parse::AFP::Base; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
4
|
1
|
|
|
1
|
|
1113
|
use Parse::Binary; |
|
1
|
|
|
|
|
12838
|
|
|
1
|
|
|
|
|
31
|
|
5
|
1
|
|
|
1
|
|
11
|
use base 'Parse::Binary'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
119
|
|
6
|
1
|
|
|
1
|
|
6
|
use constant BASE_CLASS => 'Parse::AFP'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
69
|
|
7
|
1
|
|
|
1
|
|
6
|
use constant DEFAULT_ARGS => ( Length => 0 ); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
916
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub padding { |
10
|
110
|
|
|
110
|
0
|
75060
|
my ($self, $field) = @_; |
11
|
110
|
|
|
|
|
573
|
my $padding = $self->PADDING; |
12
|
110
|
50
|
|
|
|
259
|
return $padding if defined($padding); |
13
|
110
|
|
|
|
|
455
|
return "\xFF" x $self->member_length_bytes; |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub member_length_bytes { |
17
|
126
|
|
|
126
|
0
|
173
|
my ($self) = @_; |
18
|
126
|
100
|
|
|
|
378
|
my ($field) = $self->member_fields or return 0; |
19
|
30
|
50
|
|
|
|
194
|
$self->field_format($field) =~ m{(\S+)/} or return 0; |
20
|
30
|
|
|
|
|
393
|
return length(pack($1, 0)); |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub refresh_length { |
24
|
10
|
|
|
10
|
0
|
19
|
my ($self) = @_; |
25
|
10
|
100
|
|
|
|
47
|
if ($self->has_field('Length')) { |
26
|
5
|
|
|
|
|
39
|
my $length = length($self->dump); |
27
|
5
|
|
|
|
|
61
|
foreach my $field ($self->fields) { |
28
|
9
|
100
|
|
|
|
56
|
last if $field eq 'Length'; |
29
|
4
|
|
|
|
|
16
|
$length -= $self->field_length($field); |
30
|
|
|
|
|
|
|
} |
31
|
5
|
|
|
|
|
20
|
$self->SetLength($length); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub refresh_parent { |
36
|
10
|
|
|
10
|
0
|
211
|
my ($self) = @_; |
37
|
10
|
|
|
|
|
44
|
$self->refresh_length; |
38
|
10
|
|
|
|
|
85
|
$self->SUPER::refresh_parent; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub load_size { |
42
|
101
|
|
|
101
|
0
|
13242
|
my ($self, $data) = @_; |
43
|
101
|
|
|
|
|
317
|
$self->SUPER::load_size($data); |
44
|
101
|
100
|
|
|
|
683
|
if ($self->has_field('Length')) { |
45
|
100
|
|
|
|
|
609
|
$self->SetLength( $self->Length + $self->field_length('Length') ); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub dump { |
50
|
198
|
|
|
198
|
0
|
84122
|
my ($self) = @_; |
51
|
|
|
|
|
|
|
|
52
|
198
|
|
|
0
|
|
1035
|
local $SIG{__WARN__} = sub {}; |
|
0
|
|
|
|
|
0
|
|
53
|
198
|
100
|
|
|
|
832
|
return $self->SUPER::dump unless $self->has_members; |
54
|
|
|
|
|
|
|
|
55
|
16
|
|
|
|
|
77
|
my $out = ''; |
56
|
16
|
|
|
|
|
73
|
foreach my $field ($self->fields) { |
57
|
95
|
50
|
|
|
|
3226
|
my $packer = $self->field_packer($field) or die "No packer for $field\n"; |
58
|
|
|
|
|
|
|
|
59
|
95
|
100
|
|
|
|
570
|
if ($self->member_class($field)) { |
60
|
16
|
|
|
|
|
89
|
my $format = $packer->{Format}[0]; |
61
|
16
|
50
|
|
|
|
115
|
my $prefix = ($format =~ m{\((.*?)/}) ? $1 : ''; |
62
|
16
|
|
|
|
|
50
|
my $length = $self->member_length_bytes; |
63
|
|
|
|
|
|
|
|
64
|
16
|
|
|
|
|
25
|
foreach my $member (@{$self->field($field)}) { |
|
16
|
|
|
|
|
61
|
|
65
|
146
|
|
|
|
|
647
|
my $rv = $packer->format({ $field => $member }); |
66
|
146
|
50
|
|
|
|
3953
|
if ($prefix) { |
67
|
146
|
|
|
|
|
361
|
my @leading = unpack($prefix, $rv); |
68
|
146
|
|
|
|
|
200
|
$leading[-1] += $length; |
69
|
146
|
|
|
|
|
276
|
my $leading = pack($prefix, @leading); |
70
|
146
|
|
|
|
|
358
|
substr($rv, 0, length($leading), $leading); |
71
|
|
|
|
|
|
|
} |
72
|
146
|
|
|
|
|
303
|
$out .= $rv; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
else { |
76
|
79
|
|
|
|
|
414
|
$out .= $packer->format($self->struct); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
16
|
|
|
|
|
85
|
$self->set_size(length($out)); |
81
|
16
|
|
|
|
|
170
|
return $out; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub set_field_arrayref { |
85
|
0
|
|
|
0
|
0
|
0
|
my ($self, $field, $data) = @_; |
86
|
0
|
0
|
0
|
|
|
0
|
@{$self->struct->{$field}||=[]} = @{$data||[]}; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub validate_memberdata { |
90
|
14
|
|
|
14
|
0
|
2413
|
my ($self, $field) = @_; |
91
|
14
|
100
|
|
|
|
92
|
$field = $self->field($field) or return; |
92
|
822
|
50
|
|
|
|
3450
|
@$field = grep { |
93
|
5
|
|
|
|
|
46
|
ref($_) eq 'CODE' or $self->valid_memberdata($field, $_) |
94
|
|
|
|
|
|
|
} @$field; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub spawn_obj { |
98
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
99
|
0
|
|
|
|
|
|
my $obj = $self->spawn(CC => '5a', @_); |
100
|
0
|
|
|
|
|
|
@{$obj}{qw( lazy output )} = @{$self}{qw( lazy output )}; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
101
|
0
|
|
|
|
|
|
$obj->refresh; |
102
|
0
|
|
|
|
|
|
return $obj; |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
1; |