| 1 | # Call.pm | ||||||||||||||||||||||||||||||||||||||||||
| 2 | # | ||||||||||||||||||||||||||||||||||||||||||
| 3 | # Copyright (c) 1995-2011 Paul Marquess. All rights reserved. | ||||||||||||||||||||||||||||||||||||||||||
| 4 | # Copyright (c) 2011-2014, 2018-2022 Reini Urban. All rights reserved. | ||||||||||||||||||||||||||||||||||||||||||
| 5 | # Copyright (c) 2014-2017 cPanel Inc. All rights reserved. | ||||||||||||||||||||||||||||||||||||||||||
| 6 | # | ||||||||||||||||||||||||||||||||||||||||||
| 7 | # This program is free software; you can redistribute it and/or | ||||||||||||||||||||||||||||||||||||||||||
| 8 | # modify it under the same terms as Perl itself. | ||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | package Filter::Util::Call ; | ||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | 20 | require 5.006 ; # our | |||||||||||||||||||||||||||||||||||||||||
| 13 | 20 | require Exporter; | |||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | 20 | ▶ | use XSLoader (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 20 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | 20 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | 20 | our @ISA = qw(Exporter); | |||||||||||||||||||||||||||||||||||||||||
| 20 | 20 | our @EXPORT = qw( filter_add filter_del filter_read filter_read_exact) ; | |||||||||||||||||||||||||||||||||||||||||
| 21 | 20 | our $VERSION = "1.64" ; | |||||||||||||||||||||||||||||||||||||||||
| 22 | 20 | our $XS_VERSION = $VERSION; | |||||||||||||||||||||||||||||||||||||||||
| 23 | 20 | $VERSION = eval $VERSION; | |||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | sub filter_read_exact($) | ||||||||||||||||||||||||||||||||||||||||||
| 26 | { | ||||||||||||||||||||||||||||||||||||||||||
| 27 | 9 | ▶ | my ($size) = @_ ; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
filter_read_exact: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | 9 | my ($left) = $size ; | |||||||||||||||||||||||||||||||||||||||||
| 29 | 9 | my ($status) ; | |||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | 9 | ▶ | unless ( $size > 0 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | 1 | require Carp; | |||||||||||||||||||||||||||||||||||||||||
| 33 | 1 | Carp::croak("filter_read_exact: size parameter must be > 0"); | |||||||||||||||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||
| 36 | # try to read a block which is exactly $size bytes long | ||||||||||||||||||||||||||||||||||||||||||
| 37 | 8 | ▶ | while ($left and ($status = filter_read($left)) > 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$left and ($status = &filter_read($left)) > 0
MC/DC100%2/2
$left and ($status = &filter_read($left)) > 0
$left
($status = &filter_read($left)) > 0
Truth table100%3/3
A and B
A= $leftB= ($status = &filter_read($left)) > 0
| |||||||||||||||||||||||||||||||||||||||||||
| 38 | 7 | $left = $size - length $_ ; | |||||||||||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | # EOF with pending data is a special case | ||||||||||||||||||||||||||||||||||||||||||
| 42 | 8 | ▶ | return 1 if $status == 0 and length $_ ; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$status == 0 and length $_
MC/DC100%2/2
$status == 0 and length $_
$status == 0
length $_
Truth table100%3/3
A and B
A= $status == 0B= length $_
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||
| 44 | 7 | return $status ; | |||||||||||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||
| 47 | sub filter_add($) | ||||||||||||||||||||||||||||||||||||||||||
| 48 | { | ||||||||||||||||||||||||||||||||||||||||||
| 49 | 22 | ▶ | my($obj) = @_ ; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
filter_add: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | # Did we get a code reference? | ||||||||||||||||||||||||||||||||||||||||||
| 52 | 22 | my $coderef = (ref $obj eq 'CODE'); | |||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||
| 54 | # If the parameter isn't already a reference, make it one. | ||||||||||||||||||||||||||||||||||||||||||
| 55 | 22 | ▶ | if (!$coderef and (!ref($obj) or ref($obj) =~ /^ARRAY|HASH$/)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
not $coderef and !ref($obj) || ref($obj) =~ /^ARRAY|HASH$/
not ref $obj or ref($obj) =~ /^ARRAY|HASH$/
MC/DC66%2/3
not $coderef and !ref($obj) || ref($obj) =~ /^ARRAY|HASH$/
not $coderef
not ref $obj
ref($obj) =~ /^ARRAY|HASH$/
Truth table75%3/4
not(A) and not(B) or C
A= not $coderefB= not ref $objC= ref($obj) =~ /^ARRAY|HASH$/
| |||||||||||||||||||||||||||||||||||||||||||
| 56 | 2 | $obj = bless (\$obj, (caller)[0]); | |||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | # finish off the installation of the filter in C. | ||||||||||||||||||||||||||||||||||||||||||
| 60 | 22 | Filter::Util::Call::real_import($obj, (caller)[0], $coderef) ; | |||||||||||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||
| 63 | 20 | XSLoader::load('Filter::Util::Call'); | |||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||
| 65 | 20 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 66 | __END__ | ||||||||||||||||||||||||||||||||||||||||||