| 1 | ## Domain Registry Interface, Misc. useful functions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | ## Copyright (c) 2005-2016,2018-2019 Patrick Mevzek <netdri@dotandco.com>. All rights reserved. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | ## This file is part of Net::DRI | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | ## Net::DRI is free software; you can redistribute it and/or modify | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | ## it under the terms of the GNU General Public License as published by | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | ## the Free Software Foundation; either version 2 of the License, or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | ## (at your option) any later version. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | ## See the LICENSE file that comes with this distribution for more details. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | ######################################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | package Net::DRI::Util; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 99 | ▶ | use utf8; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 99 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 99 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 99 | ▶ | use Time::HiRes (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 99 | ▶ | use Encode (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 99 | ▶ | use Module::Load; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 99 | ▶ | use Scalar::Util (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 99 | ▶ | use Net::DRI::Exception; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | Net::DRI::Util - Various useful functions for Net::DRI operations | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | Please see the README file for details. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | =head1 SUPPORT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | For now, support questions should be sent to: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | E<lt>netdri@dotandco.comE<gt> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | Please also see the SUPPORT file in the distribution. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | E<lt>http://www.dotandco.com/services/software/Net-DRI/E<gt> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | Patrick Mevzek, E<lt>netdri@dotandco.comE<gt> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | =head1 COPYRIGHT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | Copyright (c) 2005-2016,2018-2019 Patrick Mevzek <netdri@dotandco.com>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | All rights reserved. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | This program is free software; you can redistribute it and/or modify | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | it under the terms of the GNU General Public License as published by | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | the Free Software Foundation; either version 2 of the License, or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | (at your option) any later version. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | See the LICENSE file that comes with this distribution for more details. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | #################################################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | ## See https://www.iso.org/obp/ui/#search , select 'Country codes', then 'Officially assigned', order by Alpha-2 code (last checked on 2019-08-08) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | ## qw/.A .B .C .D .E .F .G .H .I .J .K .L .M .N .O .P .Q .R .S .T .U .V .W .X .Y .Z | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 99 | our %CCA2=map { $_ => 1 } qw/ AD AE AF AG AI AL AM AO AQ AR AS AT AU AW AX AZ/, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | qw/BA BB BD BE BF BG BH BI BJ BL BM BN BO BQ BR BS BT BV BW BY BZ/, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | qw/CA CC CD CF CG CH CI CK CL CM CN CO CR CU CV CW CX CY CZ/, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | qw/ DE DJ DK DM DO DZ/, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | qw/ EC EE EG EH ER ES ET /, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | qw/ FI FJ FK FM FO FR /, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | qw/GA GB GD GE GF GG GH GI GL GM GN GP GQ GR GS GT GU GW GY /, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | qw/ HK HM HN HR HT HU /, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | qw/ ID IE IL IM IN IO IQ IR IS IT /, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | qw/ JE JM JO JP /, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | qw/ KE KG KH KI KM KN KP KR KW KY KZ/, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | qw/LA LB LC LI LK LR LS LT LU LV LY /, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | qw/MA MC MD ME MF MG MH MK ML MM MN MO MP MQ MR MS MT MU MV MW MX MY MZ/, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | qw/NA NC NE NF NG NI NL NO NP NR NU NZ/, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | qw/ OM /, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | qw/PA PE PF PG PH PK PL PM PN PR PS PT PW PY /, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | qw/QA /, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | qw/ RE RO RS RU RW /, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | qw/SA SB SC SD SE SG SH SI SJ SK SL SM SN SO SR SS ST SV SX SY SZ/, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | qw/ TC TD TF TG TH TJ TK TL TM TN TO TR TT TV TW TZ/, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | qw/UA UG UM US UY UZ/, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | qw/VA VC VE VG VI VN VU /, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | qw/ WF WS /, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | qw/ YE YT /, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | qw/ZA ZM ZW /; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | sub all_valid | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 245 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
all_valid: called CC=5 SCAR=16.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 245 | my (@args)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 245 | foreach (@args) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 569 | ▶ | return 0 unless (defined($_) && (ref($_) || length($_))); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
defined $_ and ref $_ || length $_
ref $_ or length $_
MC/DC33%1/3
defined $_ and ref $_ || length $_
defined $_
ref $_
length $_
Truth table75%3/4
A and B or C
A= defined $_B= ref $_C= length $_
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 243 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | sub hash_merge | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
hash_merge: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | my ($rmaster,$rtoadd)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | ▶ | while(my ($k,$v)=each(%$rtoadd)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | ▶ | $rmaster->{$k}={} unless exists($rmaster->{$k}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | ▶ | while(my ($kk,$vv)=each(%$v)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | ▶ | $rmaster->{$k}->{$kk}=[] unless exists($rmaster->{$k}->{$kk}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | my @t=@$vv; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | push @{$rmaster->{$k}->{$kk}},\@t; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | sub deepcopy ## no critic (Subroutines::RequireFinalReturn) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
deepcopy: not called CC=12 SCAR=50.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | my $in=shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | ▶ | return $in unless defined $in; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | my $ref=ref $in; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | ▶ | return $in unless $ref; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | my $cname; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | ▶ | ($cname,$ref)=($1,$2) if ("$in"=~m/^(\S+)=([A-Z]+)\(0x/); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | ▶ | if ($ref eq 'SCALAR') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | my $tmp=$$in; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | return \$tmp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | } elsif ($ref eq 'HASH') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | ▶ | my $r={ map { $_ => (defined $in->{$_} && ref $in->{$_}) ? deepcopy($in->{$_}) : $in->{$_} } keys(%$in) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $in->{$_} and ref $in->{$_}
MC/DC0%0/2
defined $in->{$_} and ref $in->{$_}
defined $in->{$_}
ref $in->{$_}
Truth table0%0/3
A and B
A= defined $in->{$_}B= ref $in->{$_}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | ▶ | bless($r,$cname) if defined $cname; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | return $r; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | } elsif ($ref eq 'ARRAY') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | ▶ | return [ map { (defined $_ && ref $_)? deepcopy($_) : $_ } @$in ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $_ and ref $_
MC/DC0%0/2
defined $_ and ref $_
defined $_
ref $_
Truth table0%0/3
A and B
A= defined $_B= ref $_
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | } else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | Net::DRI::Exception::usererr_invalid_parameters('Do not know how to deepcopy '.$in); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | sub link_rs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
link_rs: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | my (@rs)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | my %seen; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | foreach my $i (1..$#rs) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | ▶ | $rs[$i-1]->_set_last($rs[$i]) unless exists $seen{$rs[$i]}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | $seen{$rs[$i]}=1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | return $rs[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | #################################################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | sub isint | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 4 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
isint: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 4 | my $in=shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 4 | ▶ | return ($in=~m/^\d+$/)? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | ## eppcom:roidType | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | sub is_roid | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_roid: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | my $in=shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | ▶ | return xml_is_token($in,3,89) && $in=~m/^\w{1,80}-[0-9A-Za-z]{1,8}$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
xml_is_token($in, 3, 89) && $in =~ /^\w{1,80}-[0-9A-Za-z]{1,8}$/
MC/DC0%0/2
xml_is_token($in, 3, 89) && $in =~ /^\w{1,80}-[0-9A-Za-z]{1,8}$/
xml_is_token($in, 3, 89)
$in =~ /^\w{1,80}-[0-9A-Za-z]{1,8}$/
Truth table0%0/3
A && B
A= xml_is_token($in, 3, 89)B= $in =~ /^\w{1,80}-[0-9A-Za-z]{1,8}$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | sub check_equal | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 6 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check_equal: called CC=6 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 6 | my ($input,$ra,$default)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 6 | ▶ | return $default unless defined($input); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 5 | ▶ | foreach my $a (ref($ra)? @$ra : ($ra)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 6 | ▶ | return $a if ($a=~m/^${input}$/); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 2 | ▶ | return $default if $default; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | sub check_isa | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 3 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check_isa: called CC=4 SCAR=14.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 3 | my ($what,$isa)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 3 | ▶ | Net::DRI::Exception::usererr_invalid_parameters((${what} || 'parameter').' must be a '.$isa.' object') unless $what && is_class($what,$isa); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition60%3/5
$what and is_class($what, $isa)
$what || 'parameter'
MC/DC50%1/2
$what and is_class($what, $isa)
$what
is_class($what, $isa)
MC/DC0%0/1
$what || 'parameter'
$what
Truth table66%2/3
A and B
A= $whatB= is_class($what, $isa)
Truth table50%1/2
A
A= $what
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 2 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | sub is_class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 12 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_class: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 12 | my ($obj,$class)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 12 | ▶ | return eval { $obj->isa($class); } ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | sub isa_contactset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
isa_contactset: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | my $cs=shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | ▶ | return (defined $cs && is_class($cs,'Net::DRI::Data::ContactSet') && !$cs->is_empty())? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $cs and is_class($cs, "Net::DRI::Data::ContactSet") and not $cs->is_empty
defined $cs and is_class($cs, "Net::DRI::Data::ContactSet")
MC/DC0%0/3
defined $cs and is_class($cs, "Net::DRI::Data::ContactSet") and not $cs->is_empty
defined $cs
is_class($cs, "Net::DRI::Data::ContactSet")
not $cs->is_empty
Truth table0%0/4
A and B and not(C)
A= defined $csB= is_class($cs, "Net::DRI::Data::ContactSet")C= not $cs->is_empty
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | sub isa_contact | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 9 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
isa_contact: called CC=4 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 9 | my ($c,$class)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 9 | ▶ | $class='Net::DRI::Data::Contact' unless defined $class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 9 | ▶ | return (defined $c && is_class($c,$class))? 1 : 0; ## no way to check if it is empty or not ? Contact->validate() is too strong as it may die, Contact->roid() maybe not ok always | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $c and is_class($c, $class)
MC/DC0%0/2
defined $c and is_class($c, $class)
defined $c
is_class($c, $class)
Truth table33%1/3
A and B
A= defined $cB= is_class($c, $class)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | sub isa_hosts | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
isa_hosts: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | my ($h,$emptyok)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | ▶ | $emptyok=0 unless defined $emptyok; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | ▶ | return (defined $h && is_class($h,'Net::DRI::Data::Hosts') && ($emptyok || !$h->is_empty()) )? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
defined $h and is_class($h, "Net::DRI::Data::Hosts") and $emptyok || !$h->is_empty
defined $h and is_class($h, "Net::DRI::Data::Hosts")
$emptyok or not $h->is_empty
MC/DC0%0/4
defined $h and is_class($h, "Net::DRI::Data::Hosts") and $emptyok || !$h->is_empty
defined $h
is_class($h, "Net::DRI::Data::Hosts")
$emptyok
not $h->is_empty
Truth table0%0/5
A and B and C or not(D)
A= defined $hB= is_class($h, "Net::DRI::Data::Hosts")C= $emptyokD= not $h->is_empty
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | sub isa_nsgroup | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
isa_nsgroup: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | my $h=shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | ▶ | return (defined $h && is_class($h,'Net::DRI::Data::Hosts'))? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $h and is_class($h, "Net::DRI::Data::Hosts")
MC/DC0%0/2
defined $h and is_class($h, "Net::DRI::Data::Hosts")
defined $h
is_class($h, "Net::DRI::Data::Hosts")
Truth table0%0/3
A and B
A= defined $hB= is_class($h, "Net::DRI::Data::Hosts")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | sub isa_changes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
isa_changes: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | my $c=shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | ▶ | return (defined $c && is_class($c,'Net::DRI::Data::Changes') && !$c->is_empty())? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $c and is_class($c, "Net::DRI::Data::Changes") and not $c->is_empty
defined $c and is_class($c, "Net::DRI::Data::Changes")
MC/DC0%0/3
defined $c and is_class($c, "Net::DRI::Data::Changes") and not $c->is_empty
defined $c
is_class($c, "Net::DRI::Data::Changes")
not $c->is_empty
Truth table0%0/4
A and B and not(C)
A= defined $cB= is_class($c, "Net::DRI::Data::Changes")C= not $c->is_empty
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | sub isa_statuslist | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
isa_statuslist: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | my $s=shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | ▶ | return (defined $s && is_class($s,'Net::DRI::Data::StatusList') && !$s->is_empty())? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $s and is_class($s, "Net::DRI::Data::StatusList") and not $s->is_empty
defined $s and is_class($s, "Net::DRI::Data::StatusList")
MC/DC0%0/3
defined $s and is_class($s, "Net::DRI::Data::StatusList") and not $s->is_empty
defined $s
is_class($s, "Net::DRI::Data::StatusList")
not $s->is_empty
Truth table0%0/4
A and B and not(C)
A= defined $sB= is_class($s, "Net::DRI::Data::StatusList")C= not $s->is_empty
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | sub has_key | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 233 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_key: called CC=7 SCAR=22.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 233 | my ($rh,$key)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 233 | ▶ | return 0 unless (defined $key && $key); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $key and $key
MC/DC0%0/2
defined $key and $key
defined $key
$key
Truth table33%1/3
A and B
A= defined $keyB= $key
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 233 | ▶ | return 0 unless (defined $rh && (ref $rh eq 'HASH') && exists $rh->{$key} && defined $rh->{$key}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition55%5/9
defined $rh and ref $rh eq "HASH" and exists $rh->{$key} and defined $rh->{$key}
defined $rh and ref $rh eq "HASH" and exists $rh->{$key}
defined $rh and ref $rh eq "HASH"
MC/DC25%1/4
defined $rh and ref $rh eq "HASH" and exists $rh->{$key} and defined $rh->{$key}
defined $rh
ref $rh eq "HASH"
exists $rh->{$key}
defined $rh->{$key}
Truth table40%2/5
A and B and C and D
A= defined $rhB= ref $rh eq "HASH"C= exists $rh->{$key}D= defined $rh->{$key}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 90 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | sub has_contact | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_contact: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | my $rh=shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | ▶ | return has_key($rh,'contact') && isa_contactset($rh->{contact}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
has_key($rh, 'contact') && isa_contactset($rh->{'contact'})
MC/DC0%0/2
has_key($rh, 'contact') && isa_contactset($rh->{'contact'})
has_key($rh, 'contact')
isa_contactset($rh->{'contact'})
Truth table0%0/3
A && B
A= has_key($rh, 'contact')B= isa_contactset($rh->{'contact'})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | sub has_ns | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_ns: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | my $rh=shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | ▶ | return has_key($rh,'ns') && isa_hosts($rh->{ns}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
has_key($rh, 'ns') && isa_hosts($rh->{'ns'})
MC/DC0%0/2
has_key($rh, 'ns') && isa_hosts($rh->{'ns'})
has_key($rh, 'ns')
isa_hosts($rh->{'ns'})
Truth table0%0/3
A && B
A= has_key($rh, 'ns')B= isa_hosts($rh->{'ns'})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | sub has_duration | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_duration: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | my $rh=shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | ▶ | return has_key($rh,'duration') && check_isa($rh->{'duration'},'DateTime::Duration'); ## check_isa throws an Exception if not | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
has_key($rh, 'duration') && check_isa($rh->{'duration'}, 'DateTime::Duration')
MC/DC0%0/2
has_key($rh, 'duration') && check_isa($rh->{'duration'}, 'DateTime::Duration')
has_key($rh, 'duration')
check_isa($rh->{'duration'}, 'DateTime::Duration')
Truth table0%0/3
A && B
A= has_key($rh, 'duration')B= check_isa($rh->{'duration'}, 'DateTime::Duration')
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | sub has_auth | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_auth: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | my $rh=shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | ▶ | return (has_key($rh,'auth') && ref $rh->{'auth'} eq 'HASH')? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
has_key($rh, "auth") and ref $rh->{"auth"} eq "HASH"
MC/DC0%0/2
has_key($rh, "auth") and ref $rh->{"auth"} eq "HASH"
has_key($rh, "auth")
ref $rh->{"auth"} eq "HASH"
Truth table0%0/3
A and B
A= has_key($rh, "auth")B= ref $rh->{"auth"} eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | sub has_status | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_status: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | my $rh=shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | ▶ | return (has_key($rh,'status') && isa_statuslist($rh->{status}))? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
has_key($rh, "status") and isa_statuslist($rh->{"status"})
MC/DC0%0/2
has_key($rh, "status") and isa_statuslist($rh->{"status"})
has_key($rh, "status")
isa_statuslist($rh->{"status"})
Truth table0%0/3
A and B
A= has_key($rh, "status")B= isa_statuslist($rh->{"status"})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | #################################################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | sub microtime | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 13 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
microtime: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 13 | my ($t,$v)=Time::HiRes::gettimeofday(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 13 | return $t.sprintf('%06d',$v); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | sub fulltime | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fulltime: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | my ($t,$v)=Time::HiRes::gettimeofday(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | my @t=localtime($t); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | return sprintf('%d-%02d-%02d %02d:%02d:%02d.%06d',1900+$t[5],1+$t[4],$t[3],$t[2],$t[1],$t[0],$v); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | ## From EPP, trID=token from 3 to 64 characters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | sub create_trid_1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 1 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_trid_1: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 1 | my ($name)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 1 | my $mt=microtime(); ## length=16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 1 | return uc($name).'-'.$$.'-'.$mt; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | sub create_params | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 1 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_params: called CC=3 SCAR=11.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 1 | my ($op,$rd)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 1 | ▶ | return {} unless defined $rd; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 1 | ▶ | Net::DRI::Exception::usererr_invalid_parameters('last parameter of '.$op.', if defined, must be a ref hash holding extra parameters as needed') unless ref $rd eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 1 | return { %$rd }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | #################################################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | sub is_hostname ## RFC952/1123 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 217 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_hostname: called CC=11 SCAR=24.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 217 | my ($name,$unicode)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 217 | ▶ | return 0 unless defined $name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 216 | ▶ | $unicode=0 unless defined $unicode; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 216 | my @d=split(/\./,$name,-1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 216 | foreach my $d (@d) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 244 | ▶ | return 0 unless (defined $d && $d ne ''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $d and $d ne ""
MC/DC50%1/2
defined $d and $d ne ""
defined $d
$d ne ""
Truth table66%2/3
A and B
A= defined $dB= $d ne ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 240 | ▶ | return 0 unless (length $d <= 63); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 239 | ▶ | return 0 if (($d=~m/^-/) || ($d=~m/-$/)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$d =~ /^-/ or $d =~ /-$/
MC/DC100%2/2
$d =~ /^-/ or $d =~ /-$/
$d =~ /^-/
$d =~ /-$/
Truth table100%3/3
A or B
A= $d =~ /^-/B= $d =~ /-$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 237 | ▶ | return 0 if (!$unicode && $d=~m/[^A-Za-z0-9\-]/); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not $unicode and $d =~ /[^A-Za-z0-9\-]/
MC/DC50%1/2
not $unicode and $d =~ /[^A-Za-z0-9\-]/
not $unicode
$d =~ /[^A-Za-z0-9\-]/
Truth table66%2/3
not(A) and B
A= not $unicodeB= $d =~ /[^A-Za-z0-9\-]/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 15 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | sub is_ipv4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 35 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_ipv4: called CC=24 SCAR=32.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 35 | my ($ip,$checkpublic)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 35 | ▶ | return 0 unless defined $ip; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 34 | my (@ip)=($ip=~m/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 34 | ▶ | return 0 unless (@ip==4); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 30 | foreach my $s (@ip) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 117 | ▶ | return 0 unless (($s >= 0) && ($s <= 255)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$s >= 0 and $s <= 255
MC/DC50%1/2
$s >= 0 and $s <= 255
$s >= 0
$s <= 255
Truth table66%2/3
A and B
A= $s >= 0B= $s <= 255
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 29 | ▶ | return 1 unless (defined $checkpublic && $checkpublic); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $checkpublic and $checkpublic
MC/DC50%1/2
defined $checkpublic and $checkpublic
defined $checkpublic
$checkpublic
Truth table66%2/3
A and B
A= defined $checkpublicB= $checkpublic
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | ## Check if this IP is public (see RFC3330) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 28 | ▶ | return 0 if ($ip[0] == 0); ## 0.x.x.x [ RFC 1700 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 27 | ▶ | return 0 if ($ip[0] == 10); ## 10.x.x.x [ RFC 1918 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 26 | ▶ | return 0 if ($ip[0] == 127); ## 127.x.x.x [ RFC 1700 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 25 | ▶ | return 0 if (($ip[0] == 169) && ($ip[1]==254)); ## 169.254.0.0/16 link local | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$ip[0] == 169 and $ip[1] == 254
MC/DC50%1/2
$ip[0] == 169 and $ip[1] == 254
$ip[0] == 169
$ip[1] == 254
Truth table66%2/3
A and B
A= $ip[0] == 169B= $ip[1] == 254
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 24 | ▶ | return 0 if (($ip[0] == 172 ) && ($ip[1]>=16) && ($ip[1]<=31)); ## 172.16.x.x to 172.31.x.x [ RFC 1918 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$ip[0] == 172 and $ip[1] >= 16 and $ip[1] <= 31
$ip[0] == 172 and $ip[1] >= 16
MC/DC66%2/3
$ip[0] == 172 and $ip[1] >= 16 and $ip[1] <= 31
$ip[0] == 172
$ip[1] >= 16
$ip[1] <= 31
Truth table75%3/4
A and B and C
A= $ip[0] == 172B= $ip[1] >= 16C= $ip[1] <= 31
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 23 | ▶ | return 0 if (($ip[0] == 192 ) && ($ip[1]==0) && ($ip[2]==2)); ## 192.0.2.0/24 TEST-NET | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$ip[0] == 192 and $ip[1] == 0 and $ip[2] == 2
$ip[0] == 192 and $ip[1] == 0
MC/DC66%2/3
$ip[0] == 192 and $ip[1] == 0 and $ip[2] == 2
$ip[0] == 192
$ip[1] == 0
$ip[2] == 2
Truth table75%3/4
A and B and C
A= $ip[0] == 192B= $ip[1] == 0C= $ip[2] == 2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 22 | ▶ | return 0 if (($ip[0] == 192 ) && ($ip[1]==168)); ## 192.168.x.x [ RFC 1918 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$ip[0] == 192 and $ip[1] == 168
MC/DC50%1/2
$ip[0] == 192 and $ip[1] == 168
$ip[0] == 192
$ip[1] == 168
Truth table66%2/3
A and B
A= $ip[0] == 192B= $ip[1] == 168
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 21 | ▶ | return 0 if (($ip[0] >= 224) && ($ip[0] < 240 )); ## 224.0.0.0/4 Class D [ RFC 3171] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$ip[0] >= 224 and $ip[0] < 240
MC/DC50%1/2
$ip[0] >= 224 and $ip[0] < 240
$ip[0] >= 224
$ip[0] < 240
Truth table66%2/3
A and B
A= $ip[0] >= 224B= $ip[0] < 240
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 20 | ▶ | return 0 if ($ip[0] >= 240); ## 240.0.0.0/4 Class E [ RFC 1700 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 20 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | ## Inspired by Net::IP which unfortunately requires Perl 5.8 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | sub is_ipv6 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 10 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_ipv6: called CC=16 SCAR=33.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 10 | my ($ip,$checkpublic)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 10 | ▶ | return 0 unless defined $ip; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 10 | my (@ip)=split(/:/,$ip); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 10 | ▶ | return 0 unless ((@ip > 0) && (@ip <= 8)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@ip > 0 and @ip <= 8
MC/DC0%0/2
@ip > 0 and @ip <= 8
@ip > 0
@ip <= 8
Truth table33%1/3
A and B
A= @ip > 0B= @ip <= 8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 10 | ▶ | return 0 if (($ip=~m/^:[^:]/) || ($ip=~m/[^:]:$/)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$ip =~ /^:[^:]/ or $ip =~ /[^:]:$/
MC/DC0%0/2
$ip =~ /^:[^:]/ or $ip =~ /[^:]:$/
$ip =~ /^:[^:]/
$ip =~ /[^:]:$/
Truth table33%1/3
A or B
A= $ip =~ /^:[^:]/B= $ip =~ /[^:]:$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 10 | ▶ | return 0 if ($ip =~ s/:(?=:)//g > 1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | ## We do not allow IPv4 in IPv6 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 10 | ▶ | return 0 if grep { ! /^[a-f\d]{0,4}$/i } @ip; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 1 | ▶ | return 1 unless (defined($checkpublic) && $checkpublic); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $checkpublic and $checkpublic
MC/DC0%0/2
defined $checkpublic and $checkpublic
defined $checkpublic
$checkpublic
Truth table33%1/3
A and B
A= defined $checkpublicB= $checkpublic
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | ## Check if this IP is public | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 1 | my ($ip1,$ip2)=split(/::/,$ip); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 1 | ▶ | $ip1=join('',map { sprintf('%04s',$_) } split(/:/,$ip1 || '')); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$ip1 || ''
MC/DC0%0/1
$ip1 || ''
$ip1
Truth table50%1/2
A
A= $ip1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | ▶ | $ip2=join('',map { sprintf('%04s',$_) } split(/:/,$ip2 || '')); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$ip2 || ''
MC/DC0%0/1
$ip2 || ''
$ip2
Truth table50%1/2
A
A= $ip2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 1 | my $wip=$ip1.('0' x (32-length($ip1)-length($ip2))).$ip2; ## 32 chars | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 1 | my $bip=unpack('B128',pack('H32',$wip)); ## 128-bit array | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | ## RFC 3513 §2.4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 1 | ▶ | return 0 if ($bip=~m/^0{127}/); ## unspecified + loopback | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 1 | ▶ | return 0 if ($bip=~m/^1{7}/); ## multicast + link-local unicast + site-local unicast | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | ## everything else is global unicast, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | ## but see §4 and http://www.iana.org/assignments/ipv6-address-space | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 1 | ▶ | return 0 if ($bip=~m/^000/); ## unassigned + reserved (first 6 lines) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 1 | ▶ | return 1 if ($bip=~m/^001/); ## global unicast (2000::/3) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 0 | return 0; ## everything else is unassigned | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | #################################################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | sub compare_durations | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
compare_durations: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | my ($dtd1,$dtd2)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | ## from DateTime::Duration module, internally are stored: months, days, minutes, seconds and nanoseconds | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | ## those are the keys of the hash ref given by the deltas method | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | my %d1=$dtd1->deltas(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 0 | my %d2=$dtd2->deltas(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | ## Not perfect, but should be enough for us | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | return (($d1{months} <=> $d2{months}) || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | ($d1{days} <=> $d2{days}) || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | ($d1{minutes} <=> $d2{minutes}) || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | ($d1{seconds} <=> $d2{seconds}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | ▶ | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/9
$d1{'months'} <=> $d2{'months'} || $d1{'days'} <=> $d2{'days'} || $d1{'minutes'} <=> $d2{'minutes'} || $d1{'seconds'} <=> $d2{'seconds'}
$d1{"months"} <=> $d2{"months"} or $d1{"days"} <=> $d2{"days"} or $d1{"minutes"} <=> $d2{"minutes"}
$d1{"months"} <=> $d2{"months"} or $d1{"days"} <=> $d2{"days"}
MC/DC0%0/4
$d1{'months'} <=> $d2{'months'} || $d1{'days'} <=> $d2{'days'} || $d1{'minutes'} <=> $d2{'minutes'} || $d1{'seconds'} <=> $d2{'seconds'}
$d1{"months"} <=> $d2{"months"}
$d1{"days"} <=> $d2{"days"}
$d1{"minutes"} <=> $d2{"minutes"}
$d1{'seconds'} <=> $d2{'seconds'}
Truth table0%0/5
A or B or C || D
A= $d1{"months"} <=> $d2{"months"}B= $d1{"days"} <=> $d2{"days"}C= $d1{"minutes"} <=> $d2{"minutes"}D= $d1{'seconds'} <=> $d2{'seconds'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | #################################################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | sub xml_is_normalizedstring | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 10 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
xml_is_normalizedstring: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 10 | my ($what,$min,$max)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 10 | my $r=xml_is_string($what,$min,$max); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 10 | ▶ | return 0 if $r==0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 6 | ▶ | return 0 if $what=~m/[\r\n\t]/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 5 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | sub xml_is_string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 10 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
xml_is_string: called CC=8 SCAR=20.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 10 | my ($what,$min,$max)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 10 | ▶ | return 0 unless defined $what; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 9 | ▶ | return 0 if defined Scalar::Util::reftype($what); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 9 | ▶ | return 0 unless $what=~m/^[\x{0009}\x{000A}\x{000D}\x{0020}-\x{D7FF}\x{E000}-\x{FFFD}\x{10000}-\x{10FFFF}]*$/; ## XML Char definition (all Unicode excluding the surrogate blocks, FFFE, and FFFF) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 9 | my $l=length $what; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 9 | ▶ | return 0 if (defined $min && $l < $min); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $min and $l < $min
MC/DC100%2/2
defined $min and $l < $min
defined $min
$l < $min
Truth table100%3/3
A and B
A= defined $minB= $l < $min
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 8 | ▶ | return 0 if (defined $max && $l > $max); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $max and $l > $max
MC/DC100%2/2
defined $max and $l > $max
defined $max
$l > $max
Truth table100%3/3
A and B
A= defined $maxB= $l > $max
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 6 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | sub xml_is_token | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 19 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
xml_is_token: called CC=11 SCAR=24.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 19 | my ($what,$min,$max)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 19 | ▶ | return 0 unless defined $what; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 18 | ▶ | return 0 if defined Scalar::Util::reftype($what); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 18 | ▶ | return 0 if $what=~m/[\r\n\t]/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 17 | ▶ | return 0 if $what=~m/^\s/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 16 | ▶ | return 0 if $what=~m/\s$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 15 | ▶ | return 0 if $what=~m/\s\s/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 14 | my $l=length $what; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 14 | ▶ | return 0 if (defined $min && $l < $min); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $min and $l < $min
MC/DC100%2/2
defined $min and $l < $min
defined $min
$l < $min
Truth table100%3/3
A and B
A= defined $minB= $l < $min
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 13 | ▶ | return 0 if (defined $max && $l > $max); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $max and $l > $max
MC/DC100%2/2
defined $max and $l > $max
defined $max
$l > $max
Truth table100%3/3
A and B
A= defined $maxB= $l > $max
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 11 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | sub xml_is_ncname ## xml:id is of this type | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
xml_is_ncname: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 0 | my ($what)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 0 | ▶ | return 0 unless defined($what) && $what; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $what and $what
MC/DC0%0/2
defined $what and $what
defined $what
$what
Truth table0%0/3
A and B
A= defined $whatB= $what
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 0 | ▶ | return 0 if defined Scalar::Util::reftype($what); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 0 | return ($what=~m/^\p{ID_Start}\p{ID_Continue}*$/) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 5 | ▶ | sub verify_ushort { my $in=shift; return (defined($in) && ($in=~m/^\d+$/) && ($in < 65536))? 1 : 0; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
verify_ushort: called CC=4 SCAR=13.9
Pod
undocumented
Branch: 1 branch
Condition100%6/6
defined $in and $in =~ /^\d+$/ and $in < 65536
defined $in and $in =~ /^\d+$/
MC/DC100%3/3
defined $in and $in =~ /^\d+$/ and $in < 65536
defined $in
$in =~ /^\d+$/
$in < 65536
Truth table100%4/4
A and B and C
A= defined $inB= $in =~ /^\d+$/C= $in < 65536
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 5 | ▶ | sub verify_ubyte { my $in=shift; return (defined($in) && ($in=~m/^\d+$/) && ($in < 256))? 1 : 0; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
verify_ubyte: called CC=4 SCAR=13.9
Pod
undocumented
Branch: 1 branch
Condition100%6/6
defined $in and $in =~ /^\d+$/ and $in < 256
defined $in and $in =~ /^\d+$/
MC/DC100%3/3
defined $in and $in =~ /^\d+$/ and $in < 256
defined $in
$in =~ /^\d+$/
$in < 256
Truth table100%4/4
A and B and C
A= defined $inB= $in =~ /^\d+$/C= $in < 256
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 4 | ▶ | sub verify_hex { my $in=shift; return (defined($in) && ($in=~m/^[0-9A-F]+$/i))? 1 : 0; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
verify_hex: called CC=3 SCAR=11.0
Pod
undocumented
Branch: 1 branch
Condition100%3/3
defined $in and $in =~ /^[0-9A-F]+$/i
MC/DC100%2/2
defined $in and $in =~ /^[0-9A-F]+$/i
defined $in
$in =~ /^[0-9A-F]+$/i
Truth table100%3/3
A and B
A= defined $inB= $in =~ /^[0-9A-F]+$/i
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | sub verify_int | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 13 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
verify_int: called CC=7 SCAR=19.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 13 | my ($in,$min,$max)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 13 | ▶ | return 0 unless defined($in) && ($in=~m/^-?\d+$/); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $in and $in =~ /^-?\d+$/
MC/DC100%2/2
defined $in and $in =~ /^-?\d+$/
defined $in
$in =~ /^-?\d+$/
Truth table100%3/3
A and B
A= defined $inB= $in =~ /^-?\d+$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 11 | ▶ | return 0 if ($in < (defined $min ? $min : -2147483648)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 8 | ▶ | return 0 if ($in > (defined $max ? $max : 2147483647)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 5 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | sub verify_base64 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 31 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
verify_base64: called CC=6 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 31 | my ($in,$min,$max)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 31 | my $b04='[AQgw]'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 31 | my $b16='[AEIMQUYcgkosw048]'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 31 | my $b64='[A-Za-z0-9+/]'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 31 | ▶ | return 0 unless ($in=~m/^(?:(?:$b64 ?$b64 ?$b64 ?$b64 ?)*(?:(?:$b64 ?$b64 ?$b64 ?$b64)|(?:$b64 ?$b64 ?$b16 ?=)|(?:$b64 ?$b04 ?= ?=)))?$/); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 27 | ▶ | return 0 if (defined $min && (length $in < $min)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $min and length $in < $min
MC/DC100%2/2
defined $min and length $in < $min
defined $min
length $in < $min
Truth table100%3/3
A and B
A= defined $minB= length $in < $min
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 24 | ▶ | return 0 if (defined $max && (length $in > $max)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $max and length $in > $max
MC/DC100%2/2
defined $max and length $in > $max
defined $max
length $in > $max
Truth table100%3/3
A and B
A= defined $maxB= length $in > $max
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 23 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | ## Same in XML and in RFC3066 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | sub xml_is_language | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 3 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
xml_is_language: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 3 | my $in=shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 3 | ▶ | return 0 unless defined $in; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 3 | ▶ | return 1 if ($in=~m/^[a-zA-Z]{1,8}(?:-[a-zA-Z0-9]{1,8})*$/); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 1 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | sub xml_is_boolean | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 6 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
xml_is_boolean: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 6 | my $in=shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 6 | ▶ | return 0 unless defined $in; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 6 | ▶ | return 1 if ($in=~m/^(?:1|0|true|false)$/); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 2 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | sub xml_is_decimal | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
xml_is_decimal: not called CC=13 SCAR=52.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 0 | my ($in, $decimal, $total, $min, $max)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 0 | ▶ | return 0 unless defined $in; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 0 | ▶ | return 0 unless $in=~m/^[+-]?([0-9]+(\.[0-9]*)?|\.[0-9]+)$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 0 | ▶ | if (defined $decimal || defined $total) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $decimal or defined $total
MC/DC0%0/2
defined $decimal or defined $total
defined $decimal
defined $total
Truth table0%0/3
A or B
A= defined $decimalB= defined $total
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 0 | my ($pre, $post)=split(/\./, abs $in); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 0 | ▶ | return 0 if defined $decimal && length $post > $decimal; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $decimal and length $post > $decimal
MC/DC0%0/2
defined $decimal and length $post > $decimal
defined $decimal
length $post > $decimal
Truth table0%0/3
A and B
A= defined $decimalB= length $post > $decimal
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 0 | ▶ | return 0 if defined $total && (length($pre) + length($post)) > $total; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $total and length($pre) + length($post) > $total
MC/DC0%0/2
defined $total and length($pre) + length($post) > $total
defined $total
length($pre) + length($post) > $total
Truth table0%0/3
A and B
A= defined $totalB= length($pre) + length($post) > $total
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 0 | ▶ | return 0 if defined $min && $in < $min; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $min and $in < $min
MC/DC0%0/2
defined $min and $in < $min
defined $min
$in < $min
Truth table0%0/3
A and B
A= defined $minB= $in < $min
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 0 | ▶ | return 0 if defined $max && $in > $max; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $max and $in > $max
MC/DC0%0/2
defined $max and $in > $max
defined $max
$in > $max
Truth table0%0/3
A and B
A= defined $maxB= $in > $max
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | sub xml_parse_boolean | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
xml_parse_boolean: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 0 | my $in=shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 0 | return {'true'=>1,1=>1,0=>0,'false'=>0}->{$in}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | sub xml_escape | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 16 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
xml_escape: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 16 | my ($in)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 16 | $in=~s/&/&/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 16 | $in=~s/</</g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 16 | $in=~s/>/>/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 16 | return $in; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | sub xml_write | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 9 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
xml_write: called CC=16 SCAR=28.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 9 | my ($rd, $default_ns) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 9 | my @t; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 9 | ▶ | foreach my $d (ref $rd->[0] eq 'ARRAY' ? @$rd : ($rd)) ## $d is a node=ref array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 20 | my @c; ## list of children nodes | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | my %attr; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 20 | foreach my $e (grep { defined } @$d) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 46 | ▶ | if (ref $e eq 'HASH') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 6 | ▶ | while(my ($k,$v)=each(%$e)) { $attr{$k}=$v; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | } else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 40 | push @c,$e; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 20 | my $tag=shift(@c); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 20 | ▶ | if (defined $default_ns && index($tag, ':') == -1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $default_ns and index($tag, ":") == -1
MC/DC0%0/2
defined $default_ns and index($tag, ":") == -1
defined $default_ns
index($tag, ":") == -1
Truth table33%1/3
A and B
A= defined $default_nsB= index($tag, ":") == -1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 0 | $tag = $default_ns.':'.$tag; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 20 | my $attr = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 20 | ▶ | if (keys(%attr)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | # sort all xmlns first then others | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 0 | ▶ | $attr = ' '.join(' ',map { $_.'="'.$attr{$_}.'"' } sort { index($b,'xmlns:') <=> index($a,'xmlns:') || $a cmp $b } keys %attr); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
index($b, 'xmlns:') <=> index($a, 'xmlns:') || $a cmp $b
MC/DC0%0/2
index($b, 'xmlns:') <=> index($a, 'xmlns:') || $a cmp $b
index($b, 'xmlns:') <=> index($a, 'xmlns:')
$a cmp $b
Truth table0%0/3
A || B
A= index($b, 'xmlns:') <=> index($a, 'xmlns:')B= $a cmp $b
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 20 | ▶ | if (!@c || (@c==1 && !ref($c[0]) && ($c[0] eq ''))) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition77%7/9
not @c or @c == 1 and not ref $c[0] and $c[0] eq ""
@c == 1 and not ref $c[0] and $c[0] eq ""
@c == 1 and not ref $c[0]
MC/DC25%1/4
not @c or @c == 1 and not ref $c[0] and $c[0] eq ""
not @c
@c == 1
not ref $c[0]
$c[0] eq ""
Truth table80%4/5
not(A) or B and not(C) and D
A= not @cB= @c == 1C= not ref $c[0]D= $c[0] eq ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | 1 | push @t,'<'.$tag.$attr.'/>'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | } else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 19 | push @t,'<'.$tag.$attr.'>'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 19 | ▶ | push @t,(@c==1 && !ref($c[0]))? xml_escape($c[0]) : xml_write(\@c, $default_ns); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@c == 1 and not ref $c[0]
MC/DC100%2/2
@c == 1 and not ref $c[0]
@c == 1
not ref $c[0]
Truth table100%3/3
A and not(B)
A= @c == 1B= not ref $c[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 19 | push @t,'</'.$tag.'>'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 9 | return @t; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | sub xml_indent | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
xml_indent: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 0 | my $xml=shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 0 | chomp $xml; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 0 | my $r=''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 0 | $xml=~s!(<)!\n$1!g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 0 | $xml=~s!<(\S+)>(.+)\n</\1>!<$1>$2</$1>!g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 0 | $xml=~s!<(\S+)((?:\s+\S+=['"][^'"]+['"])+)>(.+)\n</\1>!<$1$2>$3</$1>!g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 0 | my $s=0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 0 | foreach my $m (split(/\n/,$xml)) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 0 | ▶ | next if $m=~m/^\s*$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | 0 | ▶ | $s-- if ($m=~m!^</\S+>$!); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | 0 | $r.=' ' x $s; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 0 | $r.=$m."\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 0 | ▶ | $s++ if ($m=~m!^<[^>?]+[^/](?:\s+\S+=['"][^'"]+['"])*>$!); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 0 | ▶ | $s-- if ($m=~m!^</\S+>$!); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | ## As xml_indent is used during logging, we do a final quick check (spaces should not be relevant anyway) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | ## This test should probably be dumped as some point in the future when we are confident enough. But we got hit in the past by some subtleties, so... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 0 | my $in=$xml; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | 0 | $in=~s/\s+//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | 0 | my $out=$r; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 0 | $out=~s/\s+//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | 0 | ▶ | if ($in ne $out) { Net::DRI::Exception::err_assert('xml_indent failed to do its job, please report !'); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 0 | return $r; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | sub xml_list_children | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 7 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
xml_list_children: called CC=3 SCAR=13.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 7 | my ($node, $name_filter)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | ## '*' catch all element nodes being direct children of given node | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 7 | ▶ | my @r = map { [ $_->localname() || $_->nodeName(),$_ ] } grep { $_->nodeType() == 1 } $node->getChildrenByTagName('*'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$_->localname || $_->nodeName
MC/DC0%0/2
$_->localname || $_->nodeName
$_->localname
$_->nodeName
Truth table33%1/3
A || B
A= $_->localnameB= $_->nodeName
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | 7 | ▶ | return @r unless defined $name_filter; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | 0 | return map { $_->[1] } grep { $_->[0] eq $name_filter } @r; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | sub xml_traverse | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
xml_traverse: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 0 | my ($node,$ns,@nodes)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | 0 | my $p=sprintf('*[namespace-uri()="%s" and local-name()="%s"]',$ns,shift(@nodes)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 0 | ▶ | $p.='/'.join('/',map { '*[local-name()="'.$_.'"]' } @nodes) if @nodes; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | 0 | my $r=$node->findnodes($p); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | 0 | ▶ | return unless $r->size(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 0 | ▶ | return ($r->size()==1)? $r->get_node(1) : $r->get_nodelist(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | sub xml_child_content | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 8 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
xml_child_content: called CC=3 SCAR=11.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | 8 | my ($node,$ns,$what)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | 8 | my $list=$node->getChildrenByTagNameNS($ns,$what); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 8 | ▶ | return undef unless $list->size()==1; ## no critic (Subroutines::ProhibitExplicitReturnUndef) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | 8 | my $n=$list->get_node(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | 8 | ▶ | return defined $n ? $n->textContent() : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | #################################################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | sub remcam | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
remcam: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 0 | my $in=shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | 0 | $in=~s/ID/_id/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 0 | $in=~s/([A-Z])/_$1/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | 0 | return lc($in); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | 1 | ▶ | sub encode { my ($cs,$data)=@_; return Encode::encode($cs,ref $data? $data->as_string() : $data,1); } ## Will croak on malformed data (a case that should not happen) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
encode: called CC=2 SCAR=7.2
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | 1 | ▶ | sub encode_utf8 { return encode('UTF-8',$_[0]); } ## no critic (Subroutines::RequireArgUnpacking) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
encode_utf8: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | 0 | ▶ | sub encode_ascii { return encode('ascii',$_[0]); } ## no critic (Subroutines::RequireArgUnpacking) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
encode_ascii: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | 0 | ▶ | sub decode { my ($cs,$data)=@_; return Encode::decode($cs,$data,1); } ## Will croak on malformed data (a case that should not happen) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
decode: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | 0 | ▶ | sub decode_utf8 { return decode('UTF-8',$_[0]); } ## no critic (Subroutines::RequireArgUnpacking) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
decode_utf8: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | 0 | ▶ | sub decode_ascii { return decode('ascii',$_[0]); } ## no critic (Subroutines::RequireArgUnpacking) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
decode_ascii: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | 0 | ▶ | sub decode_latin1{ return decode('iso-8859-1',$_[0]); } ## no critic (Subroutines::RequireArgUnpacking) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
decode_latin1: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | sub normalize_name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | 5 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
normalize_name: called CC=5 SCAR=18.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | 5 | my ($type,$key)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | 5 | $type=lc($type); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | ## contact IDs may be case sensitive... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | ## Will need to be redone differently with IDNs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | 5 | ▶ | $key=lc $key if ($type eq 'domain' || $type eq 'nsgroup'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$type eq "domain" or $type eq "nsgroup"
MC/DC0%0/2
$type eq "domain" or $type eq "nsgroup"
$type eq "domain"
$type eq "nsgroup"
Truth table33%1/3
A or B
A= $type eq "domain"B= $type eq "nsgroup"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | 5 | ▶ | $key=lc $key if ($type eq 'host' && $key=~m/\./); ## last test part is done only to handle the pure mess created by Nominet .UK "EPP" implementation... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$type eq "host" and $key =~ /\./
MC/DC0%0/2
$type eq "host" and $key =~ /\./
$type eq "host"
$key =~ /\./
Truth table33%1/3
A and B
A= $type eq "host"B= $key =~ /\./
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | 5 | return ($type,$key); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | ## DateTime object to Zulu time stringified | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | sub dto2zstring | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dto2zstring: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | 0 | my ($dt)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | 0 | my $date=$dt->clone()->set_time_zone('UTC'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | 0 | ▶ | return $date->ymd('-').'T'.$date->hms(':').($date->microsecond() ? '.'.sprintf('%06s',$date->microsecond()) : '').'Z'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | #################################################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | ## RFC2782 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | ## (Net::DNS rrsort for SRV records does not seem to implement the same algorithm as the one specificied in the RFC, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | ## as it just does a comparison on priority then weight) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | sub dns_srv_order | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dns_srv_order: not called CC=9 SCAR=45.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | 0 | my (@args)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | 0 | my (@r,%r); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | 0 | foreach my $ans (@args) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | 0 | push @{$r{$ans->priority()}},$ans; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | 0 | foreach my $pri (sort { $a <=> $b } keys(%r)) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | 0 | my @o=@{$r{$pri}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | 0 | ▶ | if (@o > 1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | 0 | my $ts=0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | 0 | foreach (@o) { $ts+=$_->weight(); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | 0 | my $s=0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | 0 | @o=map { $s+=$_->weight(); [ $s, $_ ] } (grep { $_->weight() == 0 } @o, grep { $_->weight() > 0 } @o); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | 0 | my $cs=0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | 0 | ▶ | while(@o > 1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | 0 | my $r=int(rand($ts-$cs+1)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | 0 | foreach my $i (0..$#o) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | 0 | ▶ | next unless $o[$i]->[0] >= $r; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | 0 | $cs+=$o[$i]->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | 0 | foreach my $j (($i+1)..$#o) { $o[$j]->[0]-=$o[$i]->[0]; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | 0 | push @r,$o[$i]->[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | 0 | splice(@o,$i,1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | 0 | push @r,$o[0]->[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | 0 | return map { [$_->target(),$_->port()] } @r; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | #################################################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | sub load_module | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | 308 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
load_module: called CC=5 SCAR=16.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | 308 | my ($class,$etype)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | 308 | my $ok = eval { Module::Load::load($class); 1; }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | 308 | ▶ | Net::DRI::Exception::err_failed_load_module($etype,$class,$@ // 'unknown error') if ! defined $ok || ! $ok || $@; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition62%5/8
not defined $ok && $ok or $@
defined $ok && $ok
$@ // "unknown error"
MC/DC33%1/3
not defined $ok && $ok or $@
defined $ok
$ok
$@
MC/DC0%0/1
$@ // "unknown error"
$@
Truth table50%2/4
not(A && B) or C
A= defined $okB= $okC= $@
Truth table50%1/2
A
A= $@
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | 231 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | #################################################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | 99 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||