SNPP.pm

filter: Statementstmt 25.6% 47 / 183 Branchbran 7.2% 8 / 110 Conditioncond 2.9% 2 / 68 MC/DCmcdc 0.0% 0 / 36 Subroutinesub 14.7% 9 / 61 Podpod 57.1% 16 / 28 totaltotal 16.8% 82 / 486 CC 78 SCAR 41.6
CC
78
Cov
16%
send
380.0
message_status
56.0
xwho
30.0
CRAP 63.8
« SNPP/Server.pm ↑ Summary SNPP/HylaFAX.pm »
1 # Net::SNPP.pm
2 #
3 # Copyright (c) 1995-2001 Graham Barr.
4 # Copyright (c) 2001 Derek J. Balling <dredd@megacity.org>.
5 # All rights reserved. This program is free software; you can
6 # redistribute it and/or modify it under the same terms as Perl itself.
7 #
8  
9 package Net::SNPP;
10  
11 4 require 5.001;
12  
13 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 4 ▶use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
Subroutine BEGIN: called CC=1 SCAR=0.0
15 4 ▶use Socket 1.3;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 4 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 4 ▶use IO::Socket;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 4 ▶use Net::Cmd;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 4 ▶use Net::Config;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 4 $VERSION = "1.17"; # $Id: SNPP.pm,v 1.9 2004/01/27 22:18:32 tobeya Exp $
22 4 @ISA = qw(Net::Cmd IO::Socket::INET);
23 4 @EXPORT = (qw(CMD_2WAYERROR CMD_2WAYOK CMD_2WAYQUEUED), @Net::Cmd::EXPORT);
24  
25 sub CMD_2WAYERROR () { 7 }
26 sub CMD_2WAYOK () { 8 }
27 sub CMD_2WAYQUEUED () { 9 }
28  
29 sub new
30 1 ▶{
Subroutine new: called CC=11 SCAR=26.5
Pod documented
31 1 my $self = shift;
32 1 ▶ my $type = ref($self) || $self;
Condition33%1/3
ref $self || $self
l!l&&r!l&&!r
010
MC/DC0%0/2
ref $self || $self
ref $self $self
Truth table33%1/3
A || B
A= ref $selfB= $self
ABresult
1X1
011
000
33 1 ▶ my $host = shift if @_ % 2;
Branch: 1 branch
BranchTrueFalseTotal
if @_ % 2 1 0 1
34 1 my %arg = @_;
35 1 ▶ my $hosts = defined $host ? [ $host ] : $NetConfig{snpp_hosts};
Branch: 1 branch
BranchTrueFalseTotal
defined $host ? : 1 0 1
36 1 my $obj;
37  
38 my $h;
39 1 foreach $h (@{$hosts})
40 {
41 $obj = $type->SUPER::new(PeerAddr => ($host = $h),
42 PeerPort => $arg{Port} || 'snpp(444)',
43 Proto => 'tcp',
44 Timeout => defined $arg{Timeout}
45 ? $arg{Timeout}
46 1 ▶ : 120
Branch: 2 branches
BranchTrueFalseTotal
$obj = $type->SUPER::new("PeerAddr", $host = $h, "PeerPort", $arg{"Port"} || "snpp(444)", "Proto", "tcp", "Timeout", defined $arg{"Timeout"} ? $arg{"Timeout"} : 120) and last 1 0 1
defined $arg{'Timeout'} ? : 0 1 1
Condition50%1/2
$arg{'Port'} || 'snpp(444)'
l!l
10
MC/DC0%0/1
$arg{'Port'} || 'snpp(444)'
$arg{'Port'}
Truth table50%1/2
A
A= $arg{'Port'}
Aresult
11
00
47 ) and last;
48 }
49  
50 return undef
51 1 ▶ unless defined $obj;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $obj 0 1 1
52  
53 1 ${*$obj}{'net_snpp_host'} = $host;
54  
55 1 $obj->autoflush(1);
56  
57 1 ▶ $obj->debug(exists $arg{Debug} ? $arg{Debug} : undef);
Branch: 1 branch
BranchTrueFalseTotal
exists $arg{'Debug'} ? : 0 1 1
58  
59 1 ▶ unless ($obj->response() == CMD_OK)
Branch: 1 branch
BranchTrueFalseTotal
unless ($obj->response == 2) 1 0 1
60 {
61 1 $obj->close();
62 1 return undef;
63 }
64  
65 0 $obj;
66 }
67  
68 ##
69 ## User interface methods
70 ##
71  
72 sub pager_id
73 0 ▶{
Subroutine pager_id: not called CC=2 SCAR=17.9
Pod undocumented
74 0 ▶ @_ == 2 or croak 'usage: $snpp->pager_id( PAGER_ID )';
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or croak("usage: \$snpp->pager_id( PAGER_ID )") 0 0 0
75 0 shift->_PAGE(@_);
76 }
77  
78 sub content
79 0 ▶{
Subroutine content: not called CC=2 SCAR=17.9
Pod undocumented
80 0 ▶ @_ == 2 or croak 'usage: $snpp->content( MESSAGE )';
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or croak("usage: \$snpp->content( MESSAGE )") 0 0 0
81 0 shift->_MESS(@_);
82 }
83  
84 sub send
85 0 ▶{
Subroutine send: not called CC=19 SCAR=59.4
Pod documented
86 0 my $me = shift;
87  
88 0 ▶ if(@_)
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
89 {
90 0 my %arg = @_;
91  
92 0 ▶ if(exists $arg{Pager})
Branch: 1 branch
BranchTrueFalseTotal
if (exists $arg{"Pager"}) 0 0 0
93 {
94 0 ▶ my $pagers = ref($arg{Pager}) ? $arg{Pager} : [ $arg{Pager} ];
Branch: 1 branch
BranchTrueFalseTotal
ref $arg{'Pager'} ? : 0 0 0
95 0 my $pager;
96 0 foreach $pager (@$pagers)
97 {
98 0 ▶ $me->_PAGE($pager) || return 0
Branch: 1 branch
BranchTrueFalseTotal
$me->_PAGE($pager) or return 0 0 0 0
99 }
100 }
101 $me->_MESS($arg{Message}) || return 0
102 0 ▶ if(exists $arg{Message});
Branch: 1 branch
BranchTrueFalseTotal
if exists $arg{"Message"} 0 0 0
Condition0%0/5
exists $arg{'Message'} && ($me->_MESS($arg{'Message'}) || (return 0))
!ll&&!rl&&r
000
$me->_MESS($arg{"Message"}) or return 0
l!l
00
MC/DC0%0/2
exists $arg{'Message'} && ($me->_MESS($arg{'Message'}) || (return 0))
exists $arg{'Message'} $me->_MESS($arg{"Message"})
Truth table0%0/3
A && B
A= exists $arg{'Message'}B= $me->_MESS($arg{"Message"})
ABresult
0X0
100
111
103  
104 $me->hold($arg{Hold}) || return 0
105 0 ▶ if(exists $arg{Hold});
Branch: 1 branch
BranchTrueFalseTotal
if exists $arg{"Hold"} 0 0 0
Condition0%0/5
exists $arg{'Hold'} && ($me->hold($arg{'Hold'}) || (return 0))
!ll&&!rl&&r
000
$me->hold($arg{"Hold"}) or return 0
l!l
00
MC/DC0%0/2
exists $arg{'Hold'} && ($me->hold($arg{'Hold'}) || (return 0))
exists $arg{'Hold'} $me->hold($arg{"Hold"})
Truth table0%0/3
A && B
A= exists $arg{'Hold'}B= $me->hold($arg{"Hold"})
ABresult
0X0
100
111
106  
107 $me->hold($arg{HoldLocal},1) || return 0
108 0 ▶ if(exists $arg{HoldLocal});
Branch: 1 branch
BranchTrueFalseTotal
if exists $arg{"HoldLocal"} 0 0 0
Condition0%0/5
exists $arg{'HoldLocal'} && ($me->hold($arg{'HoldLocal'}, 1) || (return 0))
!ll&&!rl&&r
000
$me->hold($arg{"HoldLocal"}, 1) or return 0
l!l
00
MC/DC0%0/2
exists $arg{'HoldLocal'} && ($me->hold($arg{'HoldLocal'}, 1) || (return 0))
exists $arg{'HoldLocal'} $me->hold($arg{"HoldLocal"}, 1)
Truth table0%0/3
A && B
A= exists $arg{'HoldLocal'}B= $me->hold($arg{"HoldLocal"}, 1)
ABresult
0X0
100
111
109  
110 $me->_COVE($arg{Coverage}) || return 0
111 0 ▶ if(exists $arg{Coverage});
Branch: 1 branch
BranchTrueFalseTotal
if exists $arg{"Coverage"} 0 0 0
Condition0%0/5
exists $arg{'Coverage'} && ($me->_COVE($arg{'Coverage'}) || (return 0))
!ll&&!rl&&r
000
$me->_COVE($arg{"Coverage"}) or return 0
l!l
00
MC/DC0%0/2
exists $arg{'Coverage'} && ($me->_COVE($arg{'Coverage'}) || (return 0))
exists $arg{'Coverage'} $me->_COVE($arg{"Coverage"})
Truth table0%0/3
A && B
A= exists $arg{'Coverage'}B= $me->_COVE($arg{"Coverage"})
ABresult
0X0
100
111
112  
113 $me->_ALER($arg{Alert} ? 1 : 0) || return 0
114 0 ▶ if(exists $arg{Alert});
Branch: 2 branches
BranchTrueFalseTotal
if exists $arg{"Alert"} 0 0 0
$arg{'Alert'} ? : 0 0 0
Condition0%0/5
exists $arg{'Alert'} && ($me->_ALER($arg{'Alert'} ? 1 : 0) || (return 0))
!ll&&!rl&&r
000
$me->_ALER($arg{"Alert"} ? 1 : 0) or return 0
l!l
00
MC/DC0%0/2
exists $arg{'Alert'} && ($me->_ALER($arg{'Alert'} ? 1 : 0) || (return 0))
exists $arg{'Alert'} $me->_ALER($arg{"Alert"} ? 1 : 0)
Truth table0%0/3
A && B
A= exists $arg{'Alert'}B= $me->_ALER($arg{"Alert"} ? 1 : 0)
ABresult
0X0
100
111
115  
116 $me->service_level($arg{ServiceLevel}) || return 0
117 0 ▶ if(exists $arg{ServiceLevel});
Branch: 1 branch
BranchTrueFalseTotal
if exists $arg{"ServiceLevel"} 0 0 0
Condition0%0/5
exists $arg{'ServiceLevel'} && ($me->service_level($arg{'ServiceLevel'}) || (return 0))
!ll&&!rl&&r
000
$me->service_level($arg{"ServiceLevel"}) or return 0
l!l
00
MC/DC0%0/2
exists $arg{'ServiceLevel'} && ($me->service_level($arg{'ServiceLevel'}) || (return 0))
exists $arg{'ServiceLevel'} $me->service_level($arg{"ServiceLevel"})
Truth table0%0/3
A && B
A= exists $arg{'ServiceLevel'}B= $me->service_level($arg{"ServiceLevel"})
ABresult
0X0
100
111
118 }
119  
120 0 $me->_SEND();
121 }
122  
123 sub data
124 0 ▶{
Subroutine data: not called CC=4 SCAR=30.0
Pod undocumented
125 0 my $me = shift;
126  
127 0 ▶ my $ok = $me->_DATA() && $me->datasend(@_);
Condition0%0/3
$me->_DATA && $me->datasend(@_)
!ll&&!rl&&r
000
MC/DC0%0/2
$me->_DATA && $me->datasend(@_)
$me->_DATA $me->datasend(@_)
Truth table0%0/3
A && B
A= $me->_DATAB= $me->datasend(@_)
ABresult
0X0
100
111
128  
129 0 ▶ return $ok
Branch: 1 branch
BranchTrueFalseTotal
unless $ok and @_ 0 0 0
Condition0%0/3
$ok and @_
!ll&&!rl&&r
000
MC/DC0%0/2
$ok and @_
$ok @_
Truth table0%0/3
A and B
A= $okB= @_
ABresult
0X0
100
111
130 unless($ok && @_);
131  
132 0 $me->dataend;
133 }
134  
135 sub login
136 0 ▶{
Subroutine login: not called CC=3 SCAR=24.8
Pod undocumented
137 0 ▶ @_ == 2 || @_ == 3 or croak 'usage: $snpp->login( USER [, PASSWORD ])';
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or @_ == 3 or croak("usage: \$snpp->login( USER [, PASSWORD ])") 0 0 0
Condition0%0/3
@_ == 2 or @_ == 3
l!l&&r!l&&!r
000
MC/DC0%0/2
@_ == 2 or @_ == 3
@_ == 2 @_ == 3
Truth table0%0/3
A or B
A= @_ == 2B= @_ == 3
ABresult
1X1
011
000
138 0 shift->_LOGI(@_);
139 }
140  
141 sub help
142 0 ▶{
Subroutine help: not called CC=3 SCAR=24.8
Pod documented
143 0 ▶ @_ == 1 or croak 'usage: $snpp->help()';
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or croak("usage: \$snpp->help()") 0 0 0
144 0 my $me = shift;
145  
146 0 ▶ return $me->_HELP() ? $me->message
Branch: 1 branch
BranchTrueFalseTotal
$me->_HELP ? : 0 0 0
147 : undef;
148 }
149  
150 sub xwho
151 0 ▶{
Subroutine xwho: not called CC=5 SCAR=34.0
Pod undocumented
152 0 ▶ @_ == 1 or croak 'usage: $snpp->xwho()';
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or croak("usage: \$snpp->xwho()") 0 0 0
153 0 my $me = shift;
154  
155 0 ▶ $me->_XWHO or return undef;
Branch: 1 branch
BranchTrueFalseTotal
$me->_XWHO or return undef 0 0 0
156  
157 0 my(%hash,$line);
158 0 my @msg = $me->message;
159 0 pop @msg; # Remove command complete line
160  
161 0 foreach $line (@msg) {
162 0 ▶ $line =~ /^\s*(\S+)\s*(.*)/ and $hash{$1} = $2;
Branch: 1 branch
BranchTrueFalseTotal
$line =~ /^\s*(\S+)\s*(.*)/ and $hash{$1} = $2 0 0 0
163 }
164  
165 0 \%hash;
166 }
167  
168 sub service_level
169 0 ▶{
Subroutine service_level: not called CC=4 SCAR=30.0
Pod undocumented
170 0 ▶ @_ == 2 or croak 'usage: $snpp->service_level( LEVEL )';
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or croak("usage: \$snpp->service_level( LEVEL )") 0 0 0
171 0 my $me = shift;
172 0 my $level = int(shift);
173  
174 0 ▶ if($level < 0 || $level > 11)
Branch: 1 branch
BranchTrueFalseTotal
if ($level < 0 or $level > 11) 0 0 0
Condition0%0/3
$level < 0 or $level > 11
l!l&&r!l&&!r
000
MC/DC0%0/2
$level < 0 or $level > 11
$level < 0 $level > 11
Truth table0%0/3
A or B
A= $level < 0B= $level > 11
ABresult
1X1
011
000
175 {
176 0 $me->set_status(550,"Invalid Service Level");
177 0 return 0;
178 }
179  
180 0 $me->_LEVE($level);
181 }
182  
183 sub alert
184 0 ▶{
Subroutine alert: not called CC=5 SCAR=34.0
Pod undocumented
185 0 ▶ @_ == 1 || @_ == 2 or croak 'usage: $snpp->alert( VALUE )';
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or @_ == 2 or croak("usage: \$snpp->alert( VALUE )") 0 0 0
Condition0%0/3
@_ == 1 or @_ == 2
l!l&&r!l&&!r
000
MC/DC0%0/2
@_ == 1 or @_ == 2
@_ == 1 @_ == 2
Truth table0%0/3
A or B
A= @_ == 1B= @_ == 2
ABresult
1X1
011
000
186 0 my $me = shift;
187 0 ▶ my $value = (@_ == 1 || shift) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 || shift() ? : 0 0 0
Condition0%0/3
@_ == 1 or shift()
l!l&&r!l&&!r
000
MC/DC0%0/2
@_ == 1 or shift()
@_ == 1 shift()
Truth table0%0/3
A or B
A= @_ == 1B= shift()
ABresult
1X1
011
000
188  
189 0 $me->_ALER($value);
190 }
191  
192 sub coverage
193 0 ▶{
Subroutine coverage: not called CC=2 SCAR=17.9
Pod undocumented
194 0 ▶ @_ == 1 or croak 'usage: $snpp->coverage( AREA )';
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or croak("usage: \$snpp->coverage( AREA )") 0 0 0
195 0 shift->_COVE(@_);
196 }
197  
198 sub hold
199 0 ▶{
Subroutine hold: not called CC=4 SCAR=30.0
Pod undocumented
200 0 ▶ @_ == 2 || @_ == 3 or croak 'usage: $snpp->hold( TIME [, LOCAL ] )';
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or @_ == 3 or croak("usage: \$snpp->hold( TIME [, LOCAL ] )") 0 0 0
Condition0%0/3
@_ == 2 or @_ == 3
l!l&&r!l&&!r
000
MC/DC0%0/2
@_ == 2 or @_ == 3
@_ == 2 @_ == 3
Truth table0%0/3
A or B
A= @_ == 2B= @_ == 3
ABresult
1X1
011
000
201 0 my $me = shift;
202 0 my $time = shift;
203 0 ▶ my $local = (shift) ? "" : " +0000";
Branch: 1 branch
BranchTrueFalseTotal
shift() ? : 0 0 0
204  
205 0 my @g = reverse((gmtime($time))[0..5]);
206 0 $g[1] += 1;
207 0 $g[0] %= 100;
208  
209 0 $me->_HOLD( sprintf("%02d%02d%02d%02d%02d%02d%s",@g,$local));
210 }
211  
212 sub caller_id
213 0 ▶{
Subroutine caller_id: not called CC=2 SCAR=17.9
Pod undocumented
214 0 ▶ @_ == 2 or croak 'usage: $snpp->caller_id( CALLER_ID )';
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or croak("usage: \$snpp->caller_id( CALLER_ID )") 0 0 0
215 0 shift->_CALL(@_);
216 }
217  
218 sub subject
219 0 ▶{
Subroutine subject: not called CC=2 SCAR=17.9
Pod undocumented
220 0 ▶ @_ == 2 or croak 'usage: $snpp->subject( SUBJECT )';
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or croak("usage: \$snpp->subject( SUBJECT )") 0 0 0
221 0 shift->_SUBJ(@_);
222 }
223  
224 sub site
225 0 ▶{
Subroutine site: not called CC=2 SCAR=17.9
Pod documented
226 0 ▶ @_ == 2 or croak 'usage: $snpp->site( CMD )';
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or croak("usage: \$snpp->site( CMD )") 0 0 0
227 0 shift->_SITE(@_);
228 }
229  
230 sub two_way
231 0 ▶{
Subroutine two_way: not called CC=2 SCAR=17.9
Pod undocumented
232 0 ▶ @_ == 1 or croak 'usage: $snpp->two_way()';
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or croak("usage: \$snpp->two_way()") 0 0 0
233 0 shift->_2WAY();
234 }
235  
236 sub ping
237 0 ▶{
Subroutine ping: not called CC=2 SCAR=17.9
Pod documented
238 0 ▶ @_ == 2 or croak 'usage: $snpp->ping( PAGER_ID )';
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or croak("usage: \$snpp->ping( PAGER_ID )") 0 0 0
239 0 shift->_PING(@_);
240 }
241  
242 sub noqueue
243 0 ▶{
Subroutine noqueue: not called CC=2 SCAR=17.9
Pod documented
244 0 ▶ @_ == 1 or croak 'usage: $snpp->noqueue()';
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or croak("usage: \$snpp->noqueue()") 0 0 0
245 0 shift->_NOQU();
246 }
247  
248 sub expire_time
249 0 ▶{
Subroutine expire_time: not called CC=2 SCAR=17.9
Pod documented
250 0 ▶ @_ == 2 or croak 'usage: $snpp->expire_time( HOURS )';
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or croak("usage: \$snpp->expire_time( HOURS )") 0 0 0
251 0 shift->_EXPT(@_);
252 }
253  
254 sub read_ack
255 0 ▶{
Subroutine read_ack: not called CC=2 SCAR=17.9
Pod documented
256 0 ▶ @_ == 2 or croak 'usage: $snpp->read_ack( TRUEFALSE )';
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or croak("usage: \$snpp->read_ack( TRUEFALSE )") 0 0 0
257 0 shift->_ACKR(@_);
258 }
259  
260 # 4.6.7 MCREsponse <2-byte_Code> Response_Text
261 sub message_response
262 0 ▶{
Subroutine message_response: not called CC=2 SCAR=17.9
Pod documented
263 0 ▶ @_ == 3 or croak 'usage: $snpp->message_response( INT, RESPONSE )';
Branch: 1 branch
BranchTrueFalseTotal
@_ == 3 or croak("usage: \$snpp->message_response( INT, RESPONSE )") 0 0 0
264 0 shift->_MCRE(@_);
265 }
266  
267 # 4.6.10 MSTAtus <Message_Tag> <Pass_Code>
268 sub message_status
269 0 ▶{
Subroutine message_status: not called CC=7 SCAR=40.3
Pod documented
270 0 ▶ @_ == 3 or croak 'usage: $snpp->message_status( Message_Tag, Pass_Code )';
Branch: 1 branch
BranchTrueFalseTotal
@_ == 3 or croak("usage: \$snpp->message_status( Message_Tag, Pass_Code )") 0 0 0
271 0 my $me = shift;
272 0 my @out = ();
273 0 my $resp = $me->command("MSTA", @_)->response();
274 0 $out[4] = $me->code();
275 0 ▶ if ($resp == CMD_2WAYQUEUED || $resp == CMD_2WAYOK || $resp == CMD_2WAYERROR)
Branch: 1 branch
BranchTrueFalseTotal
if ($resp == 9 or $resp == 8 or $resp == 7) 0 0 0
Condition0%0/6
$resp == 9 or $resp == 8 or $resp == 7
l!l&&r!l&&!r
000
$resp == 9 or $resp == 8
l!l&&r!l&&!r
000
MC/DC0%0/3
$resp == 9 or $resp == 8 or $resp == 7
$resp == 9 $resp == 8 $resp == 7
Truth table0%0/4
A or B or C
A= $resp == 9B= $resp == 8C= $resp == 7
ABCresult
1XX1
01X1
0011
0000
276 {
277 # 860 <Sequence> <Date&Time> Delivered, Awaiting Read Confirmation
278 # this regex doesn't count on every server putting the +/-GMT tag
279 # on the timestamp
280 0 my $msg = $me->message(); chomp( $msg );
281 #if ($msg =~ /^(\d+)\s+(\d+)(.*)\s+(.*)$/)
282 0 ▶ if ($msg =~ /^\s*(\d+)\s+(\d+)([+-]?\d*)\s+(.*)$/)
Branch: 1 branch
BranchTrueFalseTotal
if ($msg =~ /^\s*(\d+)\s+(\d+)([+-]?\d*)\s+(.*)$/) { } 0 0 0
283 {
284 0 splice(@out, 0, 4, ($1,$2,$3,$4));
285 }
286 else
287 {
288 0 $me->debug_print( undef, "server reply for MCRE '$msg' did not match regex" );
289 }
290 }
291 0 ▶ return wantarray ? @out : \@out;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
292 }
293  
294 # 4.6.9 SEND (Level 3)
295 sub send_two_way
296 0 ▶{
Subroutine send_two_way: not called CC=5 SCAR=34.0
Pod documented
297 0 ▶ @_ == 1 or croak 'usage: $snpp->send_two_way()';
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or croak("usage: \$snpp->send_two_way()") 0 0 0
298 0 my $me = shift;
299 0 my @out = ();
300 0 $out[3] = $me->command("SEND")->response();
301 # rfc1861 specifies that a 2way SEND can return 8xx or 9xx when successful
302 # i.e.
303 # 860 <Message_Tag> <Pass_Code> Delivered, Awaiting Read Ack
304 # 960 <Message_Tag> <Pass_Code> OK, Message QUEUED for Delivery
305 0 ▶ if ($out[3] == CMD_2WAYQUEUED || $out[3] == CMD_2WAYOK)
Branch: 1 branch
BranchTrueFalseTotal
if ($out[3] == 9 or $out[3] == 8) 0 0 0
Condition0%0/3
$out[3] == 9 or $out[3] == 8
l!l&&r!l&&!r
000
MC/DC0%0/2
$out[3] == 9 or $out[3] == 8
$out[3] == 9 $out[3] == 8
Truth table0%0/3
A or B
A= $out[3] == 9B= $out[3] == 8
ABresult
1X1
011
000
306 {
307 0 $me->message() =~ m/^(\d+)\s+(\d+)\s*(.*)$/;
308 0 splice(@out, 0, 3, ($1,$2,$3));
309 }
310 0 ▶ return wantarray ? @out : \@out;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
311 }
312  
313 sub reset
314 0 ▶{
Subroutine reset: not called CC=2 SCAR=17.9
Pod documented
315 0 ▶ @_ == 1 or croak 'usage: $snpp->reset()';
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or croak("usage: \$snpp->reset()") 0 0 0
316 0 shift->_RESE();
317 }
318  
319 sub reply_type
320 0 ▶{
Subroutine reply_type: not called CC=2 SCAR=17.9
Pod documented
321 0 ▶ @_ == 2 or croak 'usage: $snpp->reply_type( TYPE_CODE )';
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or croak("usage: \$snpp->reply_type( TYPE_CODE )") 0 0 0
322 0 shift->_RTYP(uc (@_));
323 }
324  
325 sub quit
326 0 ▶{
Subroutine quit: not called CC=2 SCAR=17.9
Pod documented
327 0 ▶ @_ == 1 or croak 'usage: $snpp->quit()';
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or croak("usage: \$snpp->quit()") 0 0 0
328 0 my $snpp = shift;
329  
330 0 $snpp->_QUIT;
331 0 $snpp->close;
332 }
333  
334  
335  
336 ##
337 ## IO/perl methods
338 ##
339  
340 sub DESTROY
341 1 ▶{
Subroutine DESTROY: called CC=2 SCAR=7.0
342 1 my $snpp = shift;
343 1 ▶ defined(fileno($snpp)) && $snpp->quit;
Branch: 1 branch
BranchTrueFalseTotal
defined fileno $snpp and $snpp->quit 0 1 1
344 1 delete ${*$snpp}{'net_snpp_host'};
345 }
346  
347 ##
348 ## Over-ride methods (Net::Cmd)
349 ##
350  
351 sub debug_text
352 0 ▶{
Subroutine debug_text: not called CC=1 SCAR=6.9
Pod documented
353 0 $_[2] =~ s/^((logi|page)\s+\S+\s+)\S+/$1 xxxx/io;
354 0 $_[2];
355 }
356  
357 sub parse_response
358 0 ▶{
Subroutine parse_response: not called CC=3 SCAR=24.8
Pod documented
359 return ()
360 0 ▶ unless $_[1] =~ s/^(\d\d\d)(.?)//o;
Branch: 1 branch
BranchTrueFalseTotal
unless $_[1] =~ s/^(\d\d\d)(.?)//o 0 0 0
361 0 my($code,$more) = ($1, $2 eq "-");
362  
363 0 ▶ $more ||= $code == 214;
Condition0%0/3
$more ||= $code == 214
l!l&&r!l&&!r
000
MC/DC0%0/2
$more ||= $code == 214
$more $code == 214
Truth table0%0/3
A ||= B
A= $moreB= $code == 214
ABresult
1X1
011
000
364  
365 0 ($code,$more);
366 }
367  
368 ##
369 ## RFC1861 commands
370 ##
371  
372 # Level 1
373  
374 0 ▶sub _PAGE { shift->command("PAGE", @_)->response() == CMD_OK }
Subroutine _PAGE: not called CC=1 SCAR=6.9
375 0 ▶sub _MESS { shift->command("MESS", @_)->response() == CMD_OK }
Subroutine _MESS: not called CC=1 SCAR=6.9
376 0 ▶sub _RESE { shift->command("RESE")->response() == CMD_OK }
Subroutine _RESE: not called CC=1 SCAR=6.9
377 # level 3 SEND returns 8xx or 9xx for successful responses
378 0 ▶sub _SEND { shift->command("SEND")->response() == CMD_OK }
Subroutine _SEND: not called CC=1 SCAR=6.9
379 0 ▶sub _QUIT { shift->command("QUIT")->response() == CMD_OK }
Subroutine _QUIT: not called CC=1 SCAR=6.9
380 0 ▶sub _HELP { shift->command("HELP")->response() == CMD_OK }
Subroutine _HELP: not called CC=1 SCAR=6.9
381 0 ▶sub _DATA { shift->command("DATA")->response() == CMD_MORE }
Subroutine _DATA: not called CC=1 SCAR=6.9
382 0 ▶sub _SITE { shift->command("SITE",@_)->response() == CMD_OK }
Subroutine _SITE: not called CC=1 SCAR=6.9
383  
384 # Level 2
385  
386 0 ▶sub _LOGI { shift->command("LOGI", @_)->response() == CMD_OK }
Subroutine _LOGI: not called CC=1 SCAR=6.9
387 0 ▶sub _LEVE { shift->command("LEVE", @_)->response() == CMD_OK }
Subroutine _LEVE: not called CC=1 SCAR=6.9
388 0 ▶sub _ALER { shift->command("ALER", @_)->response() == CMD_OK }
Subroutine _ALER: not called CC=1 SCAR=6.9
389 0 ▶sub _COVE { shift->command("COVE", @_)->response() == CMD_OK }
Subroutine _COVE: not called CC=1 SCAR=6.9
390 0 ▶sub _HOLD { shift->command("HOLD", @_)->response() == CMD_OK }
Subroutine _HOLD: not called CC=1 SCAR=6.9
391 0 ▶sub _CALL { shift->command("CALL", @_)->response() == CMD_OK }
Subroutine _CALL: not called CC=1 SCAR=6.9
392 0 ▶sub _SUBJ { shift->command("SUBJ", @_)->response() == CMD_OK }
Subroutine _SUBJ: not called CC=1 SCAR=6.9
393  
394 # Level 3
395 0 ▶ sub _2WAY { shift->command("2WAY")->response() == CMD_OK }
Subroutine _2WAY: not called CC=1 SCAR=6.9
396 0 ▶ sub _PING { shift->command("PING", @_)->response() == CMD_OK }
Subroutine _PING: not called CC=1 SCAR=6.9
397 0 ▶ sub _ACKR { shift->command("ACKR", @_)->response() == CMD_OK }
Subroutine _ACKR: not called CC=1 SCAR=6.9
398 0 ▶ sub _EXPT { shift->command("EXPT", @_)->response() == CMD_OK }
Subroutine _EXPT: not called CC=1 SCAR=6.9
399 0 ▶ sub _KTAG { shift->command("KTAG", @_)->response() == CMD_OK }
Subroutine _KTAG: not called CC=1 SCAR=6.9
400 0 ▶ sub _MCRE { shift->command("MCRE", @_)->response() == CMD_OK }
Subroutine _MCRE: not called CC=1 SCAR=6.9
401 # MSTA here is not RFC compliant (returns 8xx or 9xx on success)
402 0 ▶ sub _MSTA { shift->command("MSTA", @_)->response() == CMD_OK }
Subroutine _MSTA: not called CC=1 SCAR=6.9
403 0 ▶ sub _NOQU { shift->command("NOQU")->response() == CMD_OK }
Subroutine _NOQU: not called CC=1 SCAR=6.9
404 0 ▶ sub _RTYP { shift->command("RTYP", @_)->response() == CMD_OK }
Subroutine _RTYP: not called CC=1 SCAR=6.9
405  
406 # NonStandard
407  
408 0 ▶sub _XWHO { shift->command("XWHO")->response() == CMD_OK }
Subroutine _XWHO: not called CC=1 SCAR=6.9
409  
410 4 1;
411 __END__
« SNPP/Server.pm ↑ Summary SNPP/HylaFAX.pm »