Branch Coverage

blib/lib/Net/DirectConnect/pslib/psmisc.pm
Criterion Covered Total %
branch 5 602 0.8


line true false branch
132 0 1 if $static{'lib_init_psmisc'}{$ENV{'SCRIPT_FILENAME'}}++
224 0 0 unless $config{'lng'}{$_}{'months'}
230 0 0 unless ($ENV{'SERVER_PORT'})
254 0 0 $_[0] < 3 ? :
0 0 $_[0] < 1 ? :
0 0 $_[0] < 8 && $_[0] - int($_[0]) ? :
273 0 0 $ENV{'SERVER_PORT'} ? :
276 0 0 if $size >= $kilo * 1099511627776
277 0 0 if $size >= $kilo * 1073741824
278 0 0 if $size >= $kilo * 1048576
279 0 0 if $size >= $kilo * 1024
280 0 0 if $size > 0
285 0 0 if $_ =~ s/kb?$//gi
286 0 0 if $_ =~ s/mb?$//gi
287 0 0 if $_ =~ s/gb?$//gi
288 0 0 if $_ =~ s/tb?$//gi
292 0 0 $_[0] < 10 ? :
296 0 0 if $tim < 0
298 0 0 if $tim == 0 or $tim > 1000000000
300 0 0 if $tim < 60
302 0 0 if $tim < 60
304 0 0 if $tim < 24
306 0 0 if $tim <= 31
308 0 0 if $tim < 12
323 0 0 if length $_[0] <= $maxlen
336 0 0 ref $_[0] eq 'HASH' ? :
339 0 0 /^([^=]+=?)=(.+)$/ ? :
340 0 0 if $k =~ s/^(.+?)(\d*)([=!><~\@]+)$/$1$2/
341 0 0 $1 < 100 ? :
344 0 0 wantarray ? :
350 0 0 if not $string and $ENV{'CONTENT_LENGTH'}
354 0 0 $string ? :
358 0 0 wantarray ? :
365 0 0 wantarray ? :
370 0 0 unless $INC{$path}
373 0 0 if UNIVERSAL::isa($_[0], 'ARRAY')
375 0 0 if UNIVERSAL::isa($_[0], 'HASH')
377 0 0 if UNIVERSAL::isa($f, 'CODE')
380 0 0 is_array $_ ? :
0 0 @_ == 1 && !defined($_[0]) ? :
382 0 0 wantarray ? :
386 0 0 is_code $_ ? :
0 0 is_hash $_ ? :
0 0 is_array $_ ? :
387 0 0 wantarray ? :
414 0 0 if defined $mask and not $mask
424 0 0 if defined $mask and not $mask
425 0 0 if $str =~ /^(magnet|file):/i
433 0 0 utf8::is_utf8($str) ? :
446 0 0 unless $noutf
455 0 0 defined $_ ? :
0 0 if $fh{$_} and not @_
456 0 0 unless @_
457 0 0 unless open $fh{$_}, '>>', $_
0 0 unless $fh{$_}
0 0 unless ($fh{$_})
459 0 0 if (time > $savetime + 5)
470 0 0 unless open my $fh, '>', $_
484 0 0 if defined $config{'log_' . $_[0]} and not $config{'log_' . $_[0]} and not $config{'log_all'}
486 0 0 defined $config{'log_' . $_[0]} ? :
0 0 defined $config{'log_all'} ? :
494 0 0 if $file =~ s/^[\-_]// or not $file
495 0 0 if $file =~ s/^[+\#]//
496 0 0 if $file eq '1'
499 0 0 if my $html = !$file
500 0 0 if $file eq '1'
503 0 0 if $_
513 0 0 $xml ? :
0 0 $html ? :
0 0 $config{'log_datetime'} eq '0' ? :
0 0 $config{'log_micro'} ? :
0 0 $config{'log_pid'} ? :
0 0 ($html || $xml) && !$file ? :
0 0 $config{'log_caller'} ? :
0 0 $html ? :
0 0 $xml ? :
522 0 0 unless $config{'log_cache'}
529 0 0 if @_ and $config{'log_screen'} and not $noscreen and !utf8::is_utf8($string) || utf8::valid($string)
532 0 0 if $config{'log_flush'}
537 0 0 unless open my $f, '<', $_[0]
545 0 0 unless open my $f, '<', $_[0]
556 0 0 $_[1] ? :
0 0 if $_[1] ? open($handle, $_[0], $_[1]) : open($handle, $_[0])
564 0 0 unless $proc
568 0 0 if $nologbody and not $handler
569 0 0 unless my $h = openproc('-|' . $layer, "$proc $config{'stderr_redirect'}")
572 0 0 unless length $_
573 0 0 unless $nologbody
574 0 0 if ref $handler eq 'CODE' and $ret = &$handler($_)
583 0 0 if ($cmd)
585 0 0 if ($^O =~ /^(?:(ms)?(dos|win(32|nt)?))/i and not $^O =~ /^cygwin/i) { }
601 0 0 if ($start)
632 0 0 if $fname eq '(eval)'
633 0 0 $indent ? :
0 0 ref $_ ? :
635 0 0 @_ ? :
636 0 0 wantarray ? :
644 0 0 $_[0] =~ /^\d+$/ ? :
645 0 0 $_ > 1 ? :
666 0 0 unless ref $_[0]
683 0 0 if ref $config{'human'}{$via} eq 'CODE'
690 0 0 if (not $static{'func_cache'}{$save}) { }
692 0 0 wantarray ? :
697 0 0 unless ($name =~ /^\d+\.\d+\.\d+\.\d+$/)
699 0 0 unless length $_ == 4
707 0 0 unless $_ = (gethostbyname $_[0])[4]
719 0 0 if $ip =~ /^(?:0|127)\./ and !$host =~ /^(?:0|127)\./
720 0 0 ref $config{'norm_skip_host'} eq 'Regexp' ? :
0 0 if $config{'norm_skip_host'} and ref $config{'norm_skip_host'} eq 'Regexp' ? $host =~ /$config{'norm_skip_host'}/ : $host =~ /$config{'norm_skip_host'}/i
726 0 0 if $err
728 0 0 unless $tmp = inet_aton($ip)
729 0 0 unless $host = (gethostbyaddr $tmp, 2)[0]
730 0 0 unless $config{'ip_normalize_pre'}
731 0 0 if $host =~ /^$repl\./
735 0 0 $host =~ /\..+\./ ? :
736 0 0 unless @_ = grep($_, (gethostbyname $thost)[4..14])
740 0 0 unless @_ = (gethostbyname $host)[4]
748 0 0 if $_[1]
749 0 0 $_[0] - $start >= 0 ? :
757 0 0 if defined $_[0]
764 0 0 $_[0]{'prot'} ? :
0 0 $_[0]{'pass'} ? :
0 0 $_[0]{'user'} ? :
0 0 $_[0]{'port'} && (!$static{'port2prot'}{$_[0]{'port'}} || $static{'port2prot'}{$_[0]{'port'}} ne $_[0]{'prot'}) ? :
0 0 $_[0]{'dcuser'} ? :
0 0 !$_[0]{'path'} || $_[0]{'path'} =~ m[^/] ? :
0 0 !($_[0]{'path'} || $_[0]{'host'} && ($_[0]{'name'} || $_[0]{'ext'})) || $_[0]{'path'} =~ m[/$] ? :
0 0 $_[0]{'ext'} ? :
0 0 $_[0]{'param'} ? :
0 0 $_[0]{'pos'} ? :
797 0 0 if $_{'path'} ne '/'
798 0 0 if $_{'name'} or $_{'ext'}
800 0 0 if $_{'name'} =~ s/#(.+)$//
801 0 0 if $_{'name'} =~ s/\?(.+)$//
802 0 0 $_{'name'} =~ s/\.([^\.]+)$// ? :
803 0 0 unless $_{'port'} and !$static{'port2prot'}{$_{'port'}} || $static{'port2prot'}{$_{'port'}} ne $_{'prot'}
805 0 0 if ($_{'prot'} eq 'dchub')
808 0 0 $1 ? :
0 0 unless $_{'path'} =~ s[^/([^/]+)][] and $dcuser = $1
816 0 0 unless $config{'sql'}{'table'}{$table}{'dcuser'}
0 0 if (%{{} unless $config{'sql'}{'table'}{$table}{'dcuser'};}) { }
825 0 0 wantarray ? :
830 0 0 unless $config{'sql'}{'table'}{$table}{'user'}
831 0 0 unless $config{'sql'}{'table'}{$table}{'pass'}
837 0 0 unless $config{'sql'}{'table'}{$table}{'dcuser'}
840 0 0 %{{} unless $config{'sql'}{'table'}{$table}{'user'};} ? :
0 0 %{{} unless $config{'sql'}{'table'}{$table}{'pass'};} ? :
0 0 $_[0]{'port'} && (!$static{'port2prot'}{$_[0]{'port'}} || $static{'port2prot'}{$_[0]{'port'}} ne $_[0]{'prot'}) && (!%{{} unless $config{'sql'}{'table'}{$table}{'port'};} || $_[0]{'prot'} eq 'dchub') ? :
0 0 %{{} unless $config{'sql'}{'table'}{$table}{'dcuser'};} ? :
850 0 0 if not $cto or $cto eq 'utf-8'
870 0 0 if $cto eq $cfrom or not length $string or not $cfrom or not $cto
871 0 0 if $config{'debug'}
887 0 0 if $cto eq $cfrom or not length $string or not $cfrom or not $cto
894 0 0 if $cfrom eq 'utf-8' and $config{'trans'}{$cto}
895 0 0 if $cto eq 'utf-8' and $config{'trans'}{$cfrom}
897 0 0 if ($config{'trans'}{$cfrom} and $config{'trans'}{$cto})
902 0 0 wantarray ? :
909 0 0 if $cto eq 'utf-8'
930 0 0 wantarray ? :
937 0 0 if $cfrom eq 'utf-8'
965 0 0 wantarray ? :
971 0 0 if $from eq $to
973 0 0 wantarray ? :
978 0 0 $$hash{$_} >= $max ? :
992 0 0 length $$string > $config{'cp_detect_length'} ? :
998 0 0 wantarray ? :
1021 0 0 if $cp_to eq 'utf-8' and utf8::decode($$string)
1024 0 0 if (not hconfig('no_cp_detect', $host) and ++$$data{'tries'} < 20 || !$$data{'cp'})
1030 0 0 if ($$data{'cp'})
1036 0 0 if $$data{'cp'} eq $cp_to
1042 0 0 if ($cp_default and $cp_default ne $cp_to)
1054 0 0 if $config{'trans_up'}{$cp} and $config{'trans_lo'}{$cp}
1061 0 0 if $config{'trans_up'}{$cp} and $config{'trans_lo'}{$cp}
1068 0 0 unless length $_
1070 0 0 if ref $_ eq 'CODE'
1071 0 0 if ref $_[0]
1072 0 0 if ref $_ eq 'SCALAR'
1079 0 0 defined $config{'lng'}{''}{$key} ? :
0 0 defined $config{'lng'}{$lang ||= $work{'lang'} || $config{'lang'}}{$key} ? :
1097 0 0 unless utf8::is_utf8($_)
1105 0 0 if (use_try 'JSON::XS')
1106 0 0 if (use_try 'JSON')
1117 0 0 unless $a <=> $b
1121 0 0 unless $b <=> $a
1129 0 0 if $timeout
1130 0 0 if $timeout
1131 0 0 if ref $proc eq 'CODE'
1132 0 0 if $timeout
1134 0 0 if ($timeout and $@) { }
1135 0 0 unless $@ eq "alarm\n"
1148 0 0 unless m[/$]
1150 0 0 @_ ? :
0 0 if length $`
1157 0 0 unless defined $def
1158 0 0 unless defined $int and length $int
1163 0 0 unless $int =~ /^-?\d+$/
1165 0 0 if defined $min and $int < $min
1167 0 0 if defined $max and $int > $max
1201 0 0 unless @_
1214 0 0 unless $static{'no_sig_log'} or $ENV{'SERVER_PORT'}
1215 0 0 unless ($static{'port2prot'})
1221 0 0 if ($_[0] > 1 and $config{'system'} eq 'win') { }
1231 0 0 $work{'sleeper'}{$where} ? :
0 0 if not $max or $ENV{'SERVER_PORT'}
1237 0 0 $work{'sleeper'}{$where} > $max ? :
1245 0 0 unless ref $deck eq 'ARRAY'
1251 0 0 wantarray ? :
1256 0 0 if $config{'no_flush'}
1284 0 0 if ref $_[0] eq 'ARRAY'
1296 0 0 $1 ? :
1303 0 0 unless (@files)
1313 0 0 if $static{'config_read'}{$ENV{'SCRIPT_FILENAME'} . $file}++ and not $_[0]
1317 0 0 if (not $ENV{'SERVER_PORT'} || -e $file and -e $file . '.dist' and use_try 'File::Copy')
1321 0 0 if $_ += do $file
1322 0 0 unless $_
1326 0 0 unless ($_ or $_[1])
1327 0 0 if defined $ENV{'SERVER_PORT'}
1349 0 0 unless $config{'post_init_every'}
1356 0 0 unless $config{'post_init_once'}
1367 0 0 if ref $_[0] eq 'ARRAY'
1368 0 0 if $_[0]
1371 0 0 if ref $_[2] eq 'CODE'
1374 0 0 if (not %config)
1375 0 0 if defined $ENV{'SERVER_PORT'}
1376 0 0 if $@
1390 0 0 unless open my $fh, '<', $INC{$file} || $file
1395 0 0 if $@
1407 0 1 unless ($sub)
1426 0 0 if (length $c > 200)
1435 0 0 if $config{'cachedir'}
1436 0 0 if $asfile and $asfile != 1
1438 0 0 if ($config{'cache_http'} and -e $c and -M $c < $config{'cache_http'})
1439 0 0 if $asfile
1440 0 0 if (open CF, '<', $c)
1447 0 0 if $config{'no_http_get'}
1451 0 0 unless return eval { do { printlog 'err', 'http use libs', @!, $! unless eval 'use LWP::UserAgent; use URI::URL;1;'; my $ua = 'LWP::UserAgent'->new('agent', $config{'useragent'} || $config{'crawler_name'}, 'timeout', hconfig('timeout', $url{'host'}, $url{'prot'}) || 10, %{{} unless $config{'lwp'};}, %{{} unless $lwpopt;}); if (ref $config{'proxy'} eq 'ARRAY') { local(@_) = @{shuffle($config{'proxy'})->[0];}; $ua->proxy(@_); } elsif ($config{'proxy'}) { $ua->proxy('http', $config{'proxy'}); } ; $ua->mirror($what, $c), (return $c) if $asfile; $method ||= 'GET'; my $resp = $ua->request('HTTP::Request'->new($method, 'URI::URL'->new($what), 'HTTP::Headers'->new(%{{} unless $headers_in;}), $content)); my $ret = $headers_out ? 'as_string' : 'content'; if ($resp->is_success) { if ($config{'cachedir'}) { return unless open CF, '>', $c; binmode CF; print CF $resp->$ret; close CF; } ; return $asfile ? $c : $resp->$ret; } else { printlog 'dev', 'http getfail', $what, $resp->code, $resp->message; return undef; } ; 1 } }
1453 0 0 unless eval 'use LWP::UserAgent; use URI::URL;1;'
1454 0 0 unless $config{'lwp'}
1457 0 0 unless $lwpopt
1460 0 0 if (ref $config{'proxy'} eq 'ARRAY') { }
0 0 elsif ($config{'proxy'}) { }
1468 0 0 if $asfile
1472 0 0 unless $headers_in
1486 0 0 $headers_out ? :
1490 0 0 if ($resp->is_success) { }
1491 0 0 if ($config{'cachedir'})
1492 0 0 unless open CF, '>', $c
1502 0 0 $asfile ? :
1517 0 0 unless my $ret = eval { do { printlog 'err', 'http use libs', @!, $! unless eval 'use LWP::UserAgent; use URI::URL;1;'; my $resp = 'LWP::UserAgent'->new('timeout', hconfig('timeout'), %{{} unless $config{'lwp'};}, %{{} unless $lwpopt;})->request('HTTP::Request'->new($method || 'GET', 'URI::URL'->new($what), 'HTTP::Headers'->new('User-Agent', $config{'useragent'} || $config{'crawler_name'}))); return $resp->code } }
1518 0 0 unless eval 'use LWP::UserAgent; use URI::URL;1;'
1521 0 0 unless $config{'lwp'}
1522 0 0 unless $lwpopt
1548 0 0 unless $sca
1549 0 0 unless open SSF, '<', $sca
1551 0 0 if /^\s*[#;]/
1553 0 0 unless my $host = shift()
1560 0 0 wantarray ? :
1594 0 0 if ref $every eq 'ARRAY'
1595 0 0 if ref $every eq 'HASH'
1596 0 0 unless ref $every
1600 0 0 if not $schedule{$$p{'id'}}{'func'} or $$p{'update'}
1601 0 0 if $$p{'wait'} and not $schedule{$$p{'id'}}{'last'}
1603 0 0 if $schedule{$$p{'id'}}{'last'} + $$p{'every'} < time and !$$p{'runs'} || $schedule{$$p{'id'}}{'runs'} < $$p{'runs'} and !(ref $$p{'cond'} eq 'CODE') || $$p{'cond'}($p, $schedule{$$p{'id'}}, @_) and ref $schedule{$$p{'id'}}{'func'} eq 'CODE'
1612 0 0 length $_[0] ? :
1617 0 0 ref $_[0] eq 'HASH' ? :
1619 0 0 unless length $p{'timeout'}
1627 0 0 if time - $^T + 86400 * (-M lockfile($name)) > $p{'old'}
1629 0 0 if time - $waitstart > $p{'timeout'}
1630 0 0 unless $waits++
1633 0 0 if $waits
1634 0 0 if $p{'readonly'}
1638 0 0 if (open my $f, '<', lockfile $name) { }
1643 0 0 if $_ ne $c
1655 0 0 if length $name and lockfile $name ne $_
1659 0 0 $name ? :
1668 0 1 if @locks
1683 11 5 unless $name
1692 0 0 unless length $_
1694 0 0 if ref $_ eq 'CODE'
1696 0 0 if ref $_[0]
1697 0 0 if ref $_ eq 'SCALAR'
1746 0 0 unless exists $program{$current}
1747 0 0 if ($program{$current}{'func'} and not $program{$current}{'disabled'})
1751 0 0 if $@
1752 0 0 wantarray ? :
1764 0 0 if $current eq 'default' and not $n
1767 0 0 if (!($program{$current}{'notmask'} && $par =~ /$program{$current}{'notmask'}/i) && $par =~ /$program{$current}{'mask'}/i || $program{$current}{'force'} and not $program{$current}{'runned'})
1778 0 0 defined $$param{$par} && $$param{$par} ne '' ? :
0 0 $program{$current}{'param_name'} ? :
1786 0 0 if $r[0] and not ref $r[0]
1787 0 0 if $program{$current}{'once'} or $program{$current}{'force'}
1823 0 0 if $$self{'auto_connect'}
1848 0 0 if $$self{'in_connect'} or $$self{'in_disconnect'}
1849 0 0 if $$self{'connected'}
1854 0 0 if (!$$self{'connect_tries'} || $$self{'connect_tried'}++ <= $$self{'connect_tries'} and !$$self{'connect_chain_tries'} || $$self{'connect_chain_tried'}++ <= $$self{'connect_chain_tries'}) { }
1859 0 0 unless ($self->_connect)
1888 0 0 if $aftersleep
1901 0 0 unless $$self{'connected'}
1909 0 0 unless $$self{'connected'}
1918 0 0 if $$self{'connected'} and not $$self{'connect_check'}
1923 0 0 unless $self->_check