Netconf/Access.pm untested

filter: Statementstmt 0.0% 0 / 45 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 6 Subroutinesub 0.0% 0 / 10 Podpod 0.0% 0 / 7 totaltotal 0.0% 0 / 82 CC 8 SCAR 22.8
CC
8
Cov
0%
recv
20.0
new
12.0
send
12.0
CRAP 9.8
1 package Net::Netconf::Access;
2  
3 use strict;
4 use Net::Netconf::Trace;
5 use Carp;
6 our $VERSION ='1.00';
7  
8 sub new
9 {
10 my($class, $args) = @_;
11 my %args = %$args;
12 my $self = { %args };
13 $self->{'netconf_device'} = $args;
14  
15 $class = ref $class || $class;
16 my $access = $args{'access'};
17 if ($args{'access'}) {
18 $access =~ s/-/_/g;
19 }
20  
21 $class .= '::' . $access if $access;
22  
23 bless $self, $class;
24 $self;
25 }
26  
27 sub start
28 {
29 my($self) = @_;
30 $self->{'netconf_device'}->report_error(1,
31 'no ' . ref $self . '::start defined');
32 undef;
33 }
34  
35 sub connect
36 {
37 my($self, %args) = @_;
38 $self->start(%args);
39 }
40  
41 sub disconnect
42 {
43 my($self) = @_;
44 undef;
45 }
46  
47 sub send
48 {
49 my($self, @data) = @_;
50 my $data = join("", @data);
51 return if (!$self->{'OUTPUT'});
52 my $rc = syswrite($self->{'OUTPUT'}, $data, length($data));
53 $self->{'seen_eof'} = 1 if $rc <= 0;
54 $rc;
55 }
56  
57 sub recv
58 {
59 my($self, $timeout) = @_;
60 my $data;
61 return if (!$self->{INPUT});
62 my $len = sysread($self->{INPUT}, $data, 0x2000);
63 $self->{seen_eof} = 1 if $len < 0;
64 $self->{seen_eof} = 1 if $len == 0 && eof($self->{INPUT});
65 $data;
66 }
67  
68 #
69 # Have we hit end-of-file yet?
70 #
71 sub eof
72 {
73 my($self) = @_;
74 $self->{'seen_eof'};
75 }
76  
77 1;
78  
79  
80 __END__