Client/Stream.pm

filter: Statementstmt 26.9% 7 / 26 Branchbran 0.0% 0 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 40.0% 2 / 5 Podpod 0.0% 0 / 3 totaltotal 19.5% 9 / 46 CC 7 SCAR 35.9
CC
7
Cov
18%
get_line
56.0
new
2.0
put_line
2.0
CRAP 36.2
↑ Summary Client/Response/Property.pm »
1 package DBGp::Client::Stream;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
Pod undocumented
7 0 my ($class, %args) = @_;
8 my $self = bless {
9 socket => $args{socket},
10 0 buffer => '',
11 }, $class;
12  
13 0 return $self;
14 }
15  
16 0 ▶sub get_line {
Subroutine get_line: not called CC=7 SCAR=40.3
Pod undocumented
17 0 my ($self) = @_;
18 0 my $buffer = \$self->{buffer};
19  
20 0 my $len_end = index($$buffer, "\x00");
21 0 ▶ while ($len_end == -1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($len_end == -1) 0 0 0
22 return undef
23 0 ▶ if read($self->{socket}, $$buffer, 2, length($$buffer)) == 0;
Branch: 1 branch
BranchTrueFalseTotal
if read($self->{"socket"}, $$buffer, 2, length $$buffer) == 0 0 0 0
24  
25 0 $len_end = index($$buffer, "\x00");
26 }
27  
28 0 my $len = substr $$buffer, 0, $len_end;
29 0 substr $$buffer, 0, $len_end + 1, '';
30  
31 0 ▶ if (length($$buffer) < $len + 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $$buffer < $len + 1) 0 0 0
32 return undef
33 0 ▶ if read($self->{socket}, $$buffer, $len + 1 - length($$buffer), length($$buffer)) == 0;
Branch: 1 branch
BranchTrueFalseTotal
if read($self->{"socket"}, $$buffer, $len + 1 - length($$buffer), length $$buffer) == 0 0 0 0
34 }
35  
36 0 ▶ die "Short read"
Branch: 1 branch
BranchTrueFalseTotal
if length $$buffer < $len + 1 0 0 0
37 if length($$buffer) < $len + 1;
38 0 ▶ die "Packat is not null-terminated"
Branch: 1 branch
BranchTrueFalseTotal
unless substr($$buffer, $len, 1, "") eq "\0" 0 0 0
39 unless substr($$buffer, $len, 1, '') eq "\x00";
40  
41 0 return substr $$buffer, 0, $len, '';
42 }
43  
44 0 ▶sub put_line {
Subroutine put_line: not called CC=1 SCAR=6.9
Pod undocumented
45 0 my ($self, @items) = @_;
46 0 my $cmd = join(" ", @items);
47  
48 0 syswrite $self->{socket}, $cmd . "\x00";
49 }
50  
51 2 1;
↑ Summary Client/Response/Property.pm »