DBus/Authn/IO.pm untested

filter: Statementstmt 0.0% 0 / 23 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 3 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 38 SCAR 30.0
CC
4
Cov
0%
read_line_from_socket
20.0
BEGIN
2.0
BEGIN
2.0
CRAP 20.0
1 package Protocol::DBus::Authn::IO;
2  
3 use strict;
4 use warnings;
5  
6 use Socket ();
7  
8 use constant _BUFSIZE => 32768;
9  
10 sub read_line_from_socket {
11 my $from = recv( $_[0], my $buf, _BUFSIZE(), Socket::MSG_PEEK() );
12 if (!defined $from) {
13 die "recv($_[0], MSG_PEEK): $!";
14 }
15  
16 my $crlf_at = index $buf, "\r\n";
17  
18 my $line;
19  
20 if (-1 == $crlf_at) {
21 if (length($buf) == _BUFSIZE) {
22 die sprintf("No CRLF in %d bytes!", _BUFSIZE());
23 }
24 }
25 else {
26 sysread( $_[0], $line, 2 + $crlf_at ) or do {
27 die "read($_[0]): $!";
28 };
29 }
30  
31 return $line;
32 }
33  
34 1;