NNTP.pm

filter: Statementstmt 79.0% 173 / 219 Branchbran 57.5% 46 / 80 Conditioncond 55.5% 15 / 27 MC/DCmcdc 31.2% 5 / 16 Subroutinesub 78.1% 25 / 32 Podpod 77.7% 7 / 9 totaltotal 70.7% 271 / 383 CC 59 SCAR 22.7
CC
59
Cov
72%
register
42.0
_unregister
42.0
spawn
10.2
CRAP 9.7
↑ Summary NNTP/Constants.pm »
1 package POE::Component::Server::NNTP;
2  
3 10 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 10 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 10 ▶use POE qw(Component::Client::NNTP Wheel::SocketFactory Wheel::ReadWrite Filter::Line);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 10 ▶use base qw(POE::Component::Pluggable);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 10 ▶use POE::Component::Pluggable::Constants qw(:ALL);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 10 ▶use Socket;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 10 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 10 $VERSION = '1.04';
12  
13 sub spawn {
14 8 ▶ my $package = shift;
Subroutine spawn: called CC=10 SCAR=23.3
Pod documented
15 8 my %opts = @_;
16 8 $opts{lc $_} = delete $opts{$_} for keys %opts;
17 8 my $options = delete $opts{options};
18 8 ▶ $opts{posting} = 1 unless defined $opts{posting} and !$opts{posting};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts{"posting"} and not $opts{"posting"} 7 1 8
Condition66%2/3
defined $opts{"posting"} and not $opts{"posting"}
!ll&&!rl&&r
701
MC/DC50%1/2
defined $opts{"posting"} and not $opts{"posting"}
defined $opts{"posting"} not $opts{"posting"}
Truth table66%2/3
A and not(B)
A= defined $opts{"posting"}B= not $opts{"posting"}
ABresult
0X0
100
111
19 8 ▶ $opts{handle_connects} = 1 unless defined $opts{handle_connects} and !$opts{handle_connects};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts{"handle_connects"} and not $opts{"handle_connects"} 6 2 8
Condition66%2/3
defined $opts{"handle_connects"} and not $opts{"handle_connects"}
!ll&&!rl&&r
602
MC/DC50%1/2
defined $opts{"handle_connects"} and not $opts{"handle_connects"}
defined $opts{"handle_connects"} not $opts{"handle_connects"}
Truth table66%2/3
A and not(B)
A= defined $opts{"handle_connects"}B= not $opts{"handle_connects"}
ABresult
0X0
100
111
20 8 ▶ $opts{extra_cmds} = [ ] unless defined $opts{extra_cmds} and ref $opts{extra_cmds} eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts{"extra_cmds"} and ref $opts{"extra_cmds"} eq "ARRAY" 7 1 8
Condition66%2/3
defined $opts{"extra_cmds"} and ref $opts{"extra_cmds"} eq "ARRAY"
!ll&&!rl&&r
701
MC/DC50%1/2
defined $opts{"extra_cmds"} and ref $opts{"extra_cmds"} eq "ARRAY"
defined $opts{"extra_cmds"} ref $opts{"extra_cmds"} eq "ARRAY"
Truth table66%2/3
A and B
A= defined $opts{"extra_cmds"}B= ref $opts{"extra_cmds"} eq "ARRAY"
ABresult
0X0
100
111
21 8 $_ = lc $_ for @{ $opts{extra_cmds} };
22 8 my $self = bless \%opts, $package;
23 8 $self->_pluggable_init( prefix => 'nntpd_', types => [ 'NNTPD', 'NNTPC' ] );
24 8 ▶ $self->{session_id} = POE::Session->create(
Branch: 1 branch
BranchTrueFalseTotal
ref $options eq 'HASH' ? : 8 0 8
25 object_states => [
26 $self => { shutdown => '_shutdown',
27 send_event => '__send_event',
28 send_to_client => '_send_to_client',
29 },
30 $self => [ qw(_start register unregister _accept_client _accept_failed _conn_input _conn_error _conn_flushed _conn_alarm _send_to_client __send_event) ],
31 ],
32 heap => $self,
33 ( ref($options) eq 'HASH' ? ( options => $options ) : () ),
34 )->ID();
35 8 return $self;
36 }
37  
38 sub session_id {
39 8 ▶ return $_[0]->{session_id};
Subroutine session_id: called CC=1 SCAR=0.0
Pod documented
40 }
41  
42 sub _conn_exists {
43 414 ▶ my ($self,$wheel_id) = @_;
Subroutine _conn_exists: called CC=3 SCAR=12.5
44 414 ▶ return 0 unless $wheel_id and defined $self->{clients}->{ $wheel_id };
Branch: 1 branch
BranchTrueFalseTotal
unless $wheel_id and defined $self->{"clients"}{$wheel_id} 0 414 414
Condition33%1/3
$wheel_id and defined $self->{"clients"}{$wheel_id}
!ll&&!rl&&r
00414
MC/DC0%0/2
$wheel_id and defined $self->{"clients"}{$wheel_id}
$wheel_id defined $self->{"clients"}{$wheel_id}
Truth table33%1/3
A and B
A= $wheel_idB= defined $self->{"clients"}{$wheel_id}
ABresult
0X0
100
111
45 414 return 1;
46 }
47  
48 sub _valid_cmd {
49 7 ▶ my $self = shift;
Subroutine _valid_cmd: called CC=3 SCAR=11.0
50 7 ▶ my $cmd = shift || return;
Condition50%1/2
shift() || (return)
l!l
70
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
51 7 $cmd = lc $cmd;
52 7 ▶ return 0 unless grep { $_ eq $cmd } @{ $self->{cmds} }, @{ $self->{extra_cmds} };
Branch: 1 branch
BranchTrueFalseTotal
unless grep {$_ eq $cmd;} @{$$self{"cmds"};}, @{$$self{"extra_cmds"};} 1 6 7
53 6 return 1;
54 }
55  
56 sub shutdown {
57 0 ▶ my $self = shift;
Subroutine shutdown: not called CC=1 SCAR=6.9
Pod documented
58 0 $poe_kernel->post( $self->{session_id}, 'shutdown' );
59 }
60  
61 sub _start {
62 8 ▶ my ($kernel,$self,$sender) = @_[KERNEL,OBJECT,SENDER];
Subroutine _start: called CC=5 SCAR=16.1
63 8 $self->{session_id} = $_[SESSION]->ID();
64 8 ▶ if ( $self->{alias} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'alias'}) { } 7 1 8
65 7 $kernel->alias_set( $self->{alias} );
66 }
67 else {
68 1 $kernel->refcount_increment( $self->{session_id} => __PACKAGE__ );
69 }
70 8 ▶ if ( $kernel != $sender ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kernel != $sender) 8 0 8
71 8 my $sender_id = $sender->ID;
72 8 $self->{events}->{'nntpd_all'}->{$sender_id} = $sender_id;
73 8 $self->{sessions}->{$sender_id}->{'ref'} = $sender_id;
74 8 $self->{sessions}->{$sender_id}->{'refcnt'}++;
75 8 $kernel->refcount_increment($sender_id, __PACKAGE__);
76 8 $kernel->post( $sender, 'nntpd_registered', $self );
77 8 $kernel->detach_myself();
78 }
79  
80 8 $self->{filter} = POE::Filter::Line->new();
81  
82 8 $self->{cmds} = [ qw(authinfo article body head stat group help ihave last list newgroups newnews next post quit slave) ];
83  
84 $self->{listener} = POE::Wheel::SocketFactory->new(
85 ( defined $self->{address} ? ( BindAddress => $self->{address} ) : () ),
86 8 ▶ ( defined $self->{port} ? ( BindPort => $self->{port} ) : ( BindPort => 119 ) ),
Branch: 2 branches
BranchTrueFalseTotal
defined $self->{'address'} ? : 7 1 8
defined $self->{'port'} ? : 8 0 8
87 SuccessEvent => '_accept_client',
88 FailureEvent => '_accept_failed',
89 SocketDomain => AF_INET, # Sets the socket() domain
90 SocketType => SOCK_STREAM, # Sets the socket() type
91 SocketProtocol => 'tcp', # Sets the socket() protocol
92 Reuse => 'on', # Lets the port be reused
93 );
94 8 return;
95 }
96  
97 sub _accept_client {
98 7 ▶ my ($kernel,$self,$socket,$peeraddr,$peerport) = @_[KERNEL,OBJECT,ARG0..ARG2];
Subroutine _accept_client: called CC=3 SCAR=11.0
99 7 my $sockaddr = inet_ntoa( ( unpack_sockaddr_in ( getsockname $socket ) )[1] );
100 7 my $sockport = ( unpack_sockaddr_in ( getsockname $socket ) )[0];
101 7 $peeraddr = inet_ntoa( $peeraddr );
102  
103 my $wheel = POE::Wheel::ReadWrite->new(
104 Handle => $socket,
105 Filter => $self->{filter},
106 7 InputEvent => '_conn_input',
107 ErrorEvent => '_conn_error',
108 FlushedEvent => '_conn_flushed',
109 );
110  
111 7 ▶ return unless $wheel;
Branch: 1 branch
BranchTrueFalseTotal
unless $wheel 0 7 7
112
113 7 my $id = $wheel->ID();
114 7 $self->{clients}->{ $id } =
115 {
116 wheel => $wheel,
117 peeraddr => $peeraddr,
118 peerport => $peerport,
119 sockaddr => $sockaddr,
120 sockport => $sockport,
121 };
122 7 $self->_send_event( 'nntpd_connection', $id, $peeraddr, $peerport, $sockaddr, $sockport );
123  
124 7 ▶ $self->{clients}->{ $id }->{alarm} = $kernel->delay_set( '_conn_alarm', $self->{time_out} || 300, $id );
Condition100%2/2
$self->{'time_out'} || 300
l!l
16
MC/DC100%1/1
$self->{'time_out'} || 300
$self->{'time_out'}
Truth table100%2/2
A
A= $self->{'time_out'}
Aresult
11
00
125 7 return;
126 }
127  
128  
129 sub _accept_failed {
130 0 ▶ my ($kernel,$self,$operation,$errnum,$errstr,$wheel_id) = @_[KERNEL,OBJECT,ARG0..ARG3];
Subroutine _accept_failed: not called CC=1 SCAR=6.9
131 0 warn "Wheel $wheel_id generated $operation error $errnum: $errstr\n";
132 0 delete $self->{listener};
133 0 $self->_send_event( 'nntpd_listener_failed', $operation, $errnum, $errstr );
134 0 return;
135 }
136  
137 sub _conn_input {
138 381 ▶ my ($kernel,$self,$input,$id) = @_[KERNEL,OBJECT,ARG0,ARG1];
Subroutine _conn_input: called CC=8 SCAR=20.8
139 381 ▶ return unless $self->_conn_exists( $id );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_conn_exists($id) 0 381 381
140 381 ▶ $kernel->delay_adjust( $self->{clients}->{ $id }->{alarm}, $self->{time_out} || 300 );
Condition50%1/2
$self->{'time_out'} || 300
l!l
0381
MC/DC0%0/1
$self->{'time_out'} || 300
$self->{'time_out'}
Truth table50%1/2
A
A= $self->{'time_out'}
Aresult
11
00
141 381 ▶ if ( $self->{clients}->{ $id }->{post_buffer} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"clients"}{$id}{"post_buffer"}) 374 7 381
142 374 ▶ if ( $input eq '.' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($input eq ".") 2 372 374
143 2 my $buffer = delete $self->{clients}->{ $id }->{post_buffer};
144 2 my $code = $self->{clients}->{ $id }->{post_code};
145 2 $self->_send_event( 'nntpd_posting', $id, $code, $buffer );
146 2 return;
147 }
148 372 $input =~ s/^\.\.$/./;
149 372 push @{ $self->{clients}->{ $id }->{post_buffer} }, $input;
150 372 return;
151 }
152 7 $input =~ s/^\s+//g;
153 7 $input =~ s/\s+$//g;
154 7 my @args = split /\s+/, $input;
155 7 my $cmd = shift @args;
156 7 ▶ return unless $cmd;
Branch: 1 branch
BranchTrueFalseTotal
unless $cmd 0 7 7
157 7 ▶ unless ( $self->_valid_cmd( $cmd ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->_valid_cmd($cmd)) 1 6 7
158 1 $self->send_to_client( $id, "500 command '$cmd' not recognized" );
159 1 return;
160 }
161 6 $cmd = lc $cmd;
162 6 ▶ if ( $cmd eq 'quit' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "quit") 3 3 6
163 3 $self->{clients}->{ $id }->{quit} = 1;
164 3 $self->send_to_client( $id, '205 closing connection - goodbye!' );
165 3 return;
166 }
167 3 $self->_send_event( 'nntpd_cmd_' . $cmd, $id, @args );
168 3 return;
169 }
170  
171 sub _conn_error {
172 0 ▶ my ($self,$errstr,$id) = @_[OBJECT,ARG2,ARG3];
Subroutine _conn_error: not called CC=2 SCAR=17.9
173 0 ▶ return unless $self->_conn_exists( $id );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_conn_exists($id) 0 0 0
174 0 delete $self->{clients}->{ $id };
175 0 $self->_send_event( 'nntpd_disconnected', $id );
176 0 return;
177 }
178  
179 sub _conn_flushed {
180 16 ▶ my ($self,$id) = @_[OBJECT,ARG0];
Subroutine _conn_flushed: called CC=3 SCAR=11.0
181 16 ▶ return unless $self->_conn_exists( $id );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_conn_exists($id) 0 16 16
182 16 ▶ return unless $self->{clients}->{ $id }->{quit};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"clients"}{$id}{"quit"} 13 3 16
183 3 delete $self->{clients}->{ $id };
184 3 $self->_send_event( 'nntpd_disconnected', $id );
185 3 return;
186 }
187  
188 sub _conn_alarm {
189 1 ▶ my ($kernel,$self,$id) = @_[KERNEL,OBJECT,ARG0];
Subroutine _conn_alarm: called CC=2 SCAR=7.0
190 1 ▶ return unless $self->_conn_exists( $id );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_conn_exists($id) 0 1 1
191 1 delete $self->{clients}->{ $id };
192 1 $self->_send_event( 'nntpd_disconnected', $id );
193 1 return;
194 }
195  
196 sub _shutdown {
197 8 ▶ my ($kernel,$self) = @_[KERNEL,OBJECT];
Subroutine _shutdown: called CC=3 SCAR=11.0
198 8 delete $self->{listener};
199 8 delete $self->{clients};
200 8 $kernel->alarm_remove_all();
201 8 $kernel->alias_remove( $_ ) for $kernel->alias_list();
202 8 ▶ $kernel->refcount_decrement( $self->{session_id} => __PACKAGE__ ) unless $self->{alias};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"alias"} 1 7 8
203 8 $self->_pluggable_destroy();
204 8 $self->_unregister_sessions();
205 8 undef;
206 }
207  
208 sub register {
209 0 ▶ my ($kernel, $self, $session, $sender, @events) =
Subroutine register: not called CC=6 SCAR=37.4
Pod documented
210 @_[KERNEL, OBJECT, SESSION, SENDER, ARG0 .. $#_];
211  
212 0 ▶ unless (@events) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@events) 0 0 0
213 0 warn "register: Not enough arguments";
214 0 return;
215 }
216  
217 0 my $sender_id = $sender->ID();
218  
219 0 foreach (@events) {
220 0 ▶ $_ = "nntpd_" . $_ unless /^_/;
Branch: 1 branch
BranchTrueFalseTotal
unless /^_/ 0 0 0
221 0 $self->{events}->{$_}->{$sender_id} = $sender_id;
222 0 $self->{sessions}->{$sender_id}->{'ref'} = $sender_id;
223 0 ▶ unless ($self->{sessions}->{$sender_id}->{refcnt}++ or $session == $sender) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"sessions"}{$sender_id}{"refcnt"}++ or $session == $sender) 0 0 0
Condition0%0/3
$self->{"sessions"}{$sender_id}{"refcnt"}++ or $session == $sender
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"sessions"}{$sender_id}{"refcnt"}++ or $session == $sender
$self->{"sessions"}{$sender_id}{"refcnt"}++ $session == $sender
Truth table0%0/3
A or B
A= $self->{"sessions"}{$sender_id}{"refcnt"}++B= $session == $sender
ABresult
1X1
011
000
224 0 $kernel->refcount_increment($sender_id, __PACKAGE__);
225 }
226 }
227  
228 0 $kernel->post( $sender, 'nntpd_registered', $self );
229 0 return;
230 }
231  
232 sub unregister {
233 0 ▶ my ($kernel, $self, $session, $sender, @events) =
Subroutine unregister: not called CC=2 SCAR=17.9
Pod documented
234 @_[KERNEL, OBJECT, SESSION, SENDER, ARG0 .. $#_];
235  
236 0 ▶ unless (@events) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@events) 0 0 0
237 0 warn "unregister: Not enough arguments";
238 0 return;
239 }
240  
241 0 $self->_unregister($session,$sender,@events);
242 0 undef;
243 }
244  
245 sub _unregister {
246 0 ▶ my ($self,$session,$sender) = splice @_,0,3;
Subroutine _unregister: not called CC=6 SCAR=37.4
247 0 my $sender_id = $sender->ID();
248  
249 0 foreach (@_) {
250 0 ▶ $_ = "nntpd_" . $_ unless /^_/;
Branch: 1 branch
BranchTrueFalseTotal
unless /^_/ 0 0 0
251 0 my $blah = delete $self->{events}->{$_}->{$sender_id};
252 0 ▶ unless ( $blah ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($blah) 0 0 0
253 0 warn "$sender_id hasn't registered for '$_' events\n";
254 0 next;
255 }
256 0 ▶ if (--$self->{sessions}->{$sender_id}->{refcnt} <= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (--$self->{"sessions"}{$sender_id}{"refcnt"} <= 0) 0 0 0
257 0 delete $self->{sessions}->{$sender_id};
258 0 ▶ unless ($session == $sender) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($session == $sender) 0 0 0
259 0 $poe_kernel->refcount_decrement($sender_id, __PACKAGE__);
260 }
261 }
262 }
263 0 undef;
264 }
265  
266 sub _unregister_sessions {
267 8 ▶ my $self = shift;
Subroutine _unregister_sessions: called CC=4 SCAR=14.1
268 8 my $nntpd_id = $self->session_id();
269 8 foreach my $session_id ( keys %{ $self->{sessions} } ) {
270 8 ▶ if (--$self->{sessions}->{$session_id}->{refcnt} <= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (--$self->{"sessions"}{$session_id}{"refcnt"} <= 0) 8 0 8
271 8 delete $self->{sessions}->{$session_id};
272 8 ▶ $poe_kernel->refcount_decrement($session_id, __PACKAGE__)
Branch: 1 branch
BranchTrueFalseTotal
unless $session_id eq $nntpd_id 8 0 8
273 unless ( $session_id eq $nntpd_id );
274 }
275 }
276 }
277  
278 sub __send_event {
279 8 ▶ my( $self, $event, @args ) = @_[ OBJECT, ARG0, ARG1 .. $#_ ];
Subroutine __send_event: called CC=1 SCAR=0.0
280 8 $self->_send_event( $event, @args );
281 8 return;
282 }
283  
284 sub _pluggable_event {
285 8 ▶ my $self = shift;
Subroutine _pluggable_event: called CC=1 SCAR=0.0
286 8 $poe_kernel->post( $self->{session_id}, '__send_event', @_ );
287 }
288  
289 sub send_event {
290 0 ▶ my $self = shift;
Subroutine send_event: not called CC=1 SCAR=6.9
Pod documented
291 0 $poe_kernel->post( $self->{session_id}, '__send_event', @_ );
292 }
293  
294 sub _send_event {
295 24 ▶ my $self = shift;
Subroutine _send_event: called CC=5 SCAR=16.2
296 24 my ($event, @args) = @_;
297 24 my $kernel = $POE::Kernel::poe_kernel;
298 24 my $session = $kernel->get_active_session()->ID();
299 24 my %sessions;
300  
301 my @extra_args;
302  
303 24 ▶ return 1 if $self->_pluggable_process( 'NNTPD', $event, \( @args ), \@extra_args ) == PLUGIN_EAT_ALL;
Branch: 1 branch
BranchTrueFalseTotal
if $self->_pluggable_process("NNTPD", $event, \(@args), \@extra_args) == 4 0 24 24
304  
305 24 ▶ push @args, @extra_args if scalar @extra_args;
Branch: 1 branch
BranchTrueFalseTotal
if scalar @extra_args 0 24 24
306  
307 24 $sessions{$_} = $_ for (values %{$self->{events}->{'nntpd_all'}}, values %{$self->{events}->{$event}});
308  
309 24 $kernel->post( $_ => $event => @args ) for values %sessions;
310 24 undef;
311 }
312  
313 sub send_to_client {
314 16 ▶ my $self = shift;
Subroutine send_to_client: called CC=1 SCAR=0.0
Pod documented
315 16 $poe_kernel->call( $self->{session_id}, '_send_to_client', @_ );
316 }
317  
318 sub _send_to_client {
319 16 ▶ my ($kernel,$self,$id,$output) = @_[KERNEL,OBJECT,ARG0..ARG1];
Subroutine _send_to_client: called CC=4 SCAR=14.5
320 16 ▶ return unless $self->_conn_exists( $id );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_conn_exists($id) 0 16 16
321 16 ▶ return unless $output;
Branch: 1 branch
BranchTrueFalseTotal
unless $output 0 16 16
322  
323 16 ▶ return 1 if $self->_pluggable_process( 'NNTPC', 'response', $id, \$output ) == PLUGIN_EAT_ALL;
Branch: 1 branch
BranchTrueFalseTotal
if $self->_pluggable_process("NNTPC", "response", $id, \$output) == 4 0 16 16
324  
325 16 $self->{clients}->{ $id }->{wheel}->put($output);
326 16 return 1;
327 }
328  
329 sub NNTPD_connection {
330 7 ▶ my ($self,$nntpd) = splice @_, 0, 2;
Subroutine NNTPD_connection: called CC=3 SCAR=11.0
Pod undocumented
331 7 my $id = ${ $_[0] };
332 7 ▶ return 1 unless $self->{handle_connects};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"handle_connects"} 2 5 7
333 5 ▶ if ( $self->{posting} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'posting'}) { } 4 1 5
334 4 $self->send_to_client( $id, '200 server ready - posting allowed' );
335 }
336 else {
337 1 $self->send_to_client( $id, '201 server ready - no posting allowed' );
338 }
339 5 return 1;
340 }
341  
342 sub NNTPC_response {
343 16 ▶ my ($self,$nntpd) = splice @_, 0, 2;
Subroutine NNTPC_response: called CC=4 SCAR=13.9
Pod undocumented
344 16 my $id = $_[0];
345 16 my $text = ${ $_[1] };
346 16 my ($code) = $text =~ /^\s*(\d{3,3})\s*/;
347 16 ▶ return 1 unless $code && ( $code eq '340' || $code eq '335' );
Branch: 1 branch
BranchTrueFalseTotal
unless $code and $code eq 340 || $code eq 335 14 2 16
Condition66%4/6
$code and $code eq 340 || $code eq 335
!ll&&!rl&&r
0142
$code eq 340 or $code eq 335
l!l&&r!l&&!r
0214
MC/DC33%1/3
$code and $code eq 340 || $code eq 335
$code $code eq 340 $code eq 335
Truth table50%2/4
A and B or C
A= $codeB= $code eq 340C= $code eq 335
ABCresult
0XX0
1000
11X1
1011
348 2 $self->{clients}->{ $id }->{post_code} = $code;
349 2 $self->{clients}->{ $id }->{post_buffer} = [ ];
350 2 return 1;
351 }
352  
353 10 1;
354 __END__
↑ Summary NNTP/Constants.pm »