| 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
| |||||||||||
| 22 | return undef | ||||||||||
| 23 | 0 | ▶ | if read($self->{socket}, $$buffer, 2, length($$buffer)) == 0; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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
| |||||||||||
| 32 | return undef | ||||||||||
| 33 | 0 | ▶ | if read($self->{socket}, $$buffer, $len + 1 - length($$buffer), length($$buffer)) == 0; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 34 | } | ||||||||||
| 35 | |||||||||||
| 36 | 0 | ▶ | die "Short read" | ||||||||
|
Branch: 1 branch
| |||||||||||
| 37 | if length($$buffer) < $len + 1; | ||||||||||
| 38 | 0 | ▶ | die "Packat is not null-terminated" | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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; | |||||||||