| 1 | |||||||||||||||||||||
| 2 | package Net::SSLeay::OO::Functions; | ||||||||||||||||||||
| 3 | |||||||||||||||||||||
| 4 | 5 | ▶ | use Net::SSLeay; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | |||||||||||||||||||||
| 6 | 5 | my %prefixes = ( | |||||||||||||||||||
| 7 | "" => "Net::SSLeay::OO::SSL", | ||||||||||||||||||||
| 8 | BIO => "Net::SSLeay::OO::BIO", | ||||||||||||||||||||
| 9 | CIPHER => "Net::SSLeay::OO::Cipher", | ||||||||||||||||||||
| 10 | COMP => "Net::SSLeay::OO::Compression", | ||||||||||||||||||||
| 11 | CTX => "Net::SSLeay::OO::Context", | ||||||||||||||||||||
| 12 | DH => "Net::SSLeay::OO::KeyType::DH", | ||||||||||||||||||||
| 13 | ENGINE => "Net::SSLeay::OO::Engine", | ||||||||||||||||||||
| 14 | ERR => "Net::SSLeay::OO::Error", | ||||||||||||||||||||
| 15 | EVP_PKEY => "Net::SSLeay::OO::PrivateKey", | ||||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | #MD2 => undef, | ||||||||||||||||||||
| 18 | #MD4 => undef, | ||||||||||||||||||||
| 19 | #MD5 => undef, | ||||||||||||||||||||
| 20 | PEM => "Net::SSLeay::OO::PEM", | ||||||||||||||||||||
| 21 | |||||||||||||||||||||
| 22 | #P_ASN1_UTCTIME => undef, | ||||||||||||||||||||
| 23 | RAND => "Net::SSLeay::OO::PRNG", | ||||||||||||||||||||
| 24 | RSA => "Net::SSLeay::OO::KeyType::RSA", | ||||||||||||||||||||
| 25 | SESSION => "Net::SSLeay::OO::Session", | ||||||||||||||||||||
| 26 | |||||||||||||||||||||
| 27 | #X509V3_EXT => undef, | ||||||||||||||||||||
| 28 | X509_NAME => "Net::SSLeay::OO::X509::Name", | ||||||||||||||||||||
| 29 | X509_STORE => "Net::SSLeay::OO::X509::Store", | ||||||||||||||||||||
| 30 | X509_STORE_CTX => "Net::SSLeay::OO::X509::Context", | ||||||||||||||||||||
| 31 | X509 => "Net::SSLeay::OO::X509", | ||||||||||||||||||||
| 32 | ); | ||||||||||||||||||||
| 33 | |||||||||||||||||||||
| 34 | 5 | my %ready; | |||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | 5 | ▶ | while ( my ( $sym, $glob ) = each %Net::SSLeay:: ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 37 | 4880 | my $display = $sym =~ /ERRZX/; | |||||||||||||||||||
| 38 | 4880 | ▶ | print STDERR "Considering $sym: " if $display; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 39 | 4880 | my ( $sub_pkg, $method ) = | |||||||||||||||||||
| 40 | $sym =~ m{^(?:([A-Z][A-Z0-9]*(?:_[A-Z][A-Z0-9]*)*)_)? | ||||||||||||||||||||
| 41 | ([a-z]\w+)$}x; | ||||||||||||||||||||
| 42 | 4880 | ▶ | if ( !$method ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 43 | 995 | ▶ | print STDERR "didn't match pattern, next\n" if $display; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 44 | 995 | next; | |||||||||||||||||||
| 45 | } | ||||||||||||||||||||
| 46 | 5 | ▶ | use Data::Dumper; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 47 | 3885 | ▶ | if ( !*{"Net::SSLeay::$sym"}{CODE} ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 48 | 35 | ▶ | print STDERR "not a func, next\n" if $display; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 49 | 35 | next; | |||||||||||||||||||
| 50 | } | ||||||||||||||||||||
| 51 | 3850 | ▶ | if ( $method eq "new" ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 52 | 75 | ▶ | print STDERR "it's 'new', next\n" if $display; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 53 | 75 | next; | |||||||||||||||||||
| 54 | } | ||||||||||||||||||||
| 55 | 3775 | ▶ | my $pkg = $prefixes{ $sub_pkg || "" }; | ||||||||||||||||||
|
Condition100%2/2
$sub_pkg || ''
MC/DC100%1/1
$sub_pkg || ''
$sub_pkg
Truth table100%2/2
A
A= $sub_pkg
| |||||||||||||||||||||
| 56 | 3775 | ▶ | if ( !$pkg ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 57 | 860 | ▶ | print STDERR "destination package undefined; next\n" | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 58 | if $display; | ||||||||||||||||||||
| 59 | 860 | next; | |||||||||||||||||||
| 60 | } | ||||||||||||||||||||
| 61 | 2915 | ▶ | print STDERR " => belongs in $pkg as $method\n" if $display; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 62 | 2915 | ▶ | if ( *{$glob}{CODE} ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 63 | 2540 | $ready{$pkg}{$method} = \&{*$glob}; | |||||||||||||||||||
| 64 | } | ||||||||||||||||||||
| 65 | else { | ||||||||||||||||||||
| 66 | 0 | ▶ | $ready{$pkg}{$method} = sub { | ||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 67 | 0 | goto \&{"Net::SSLeay::$sym"}; | |||||||||||||||||||
| 68 | 375 | }; | |||||||||||||||||||
| 69 | } | ||||||||||||||||||||
| 70 | } | ||||||||||||||||||||
| 71 | |||||||||||||||||||||
| 72 | 14 | ▶ | sub import { | ||||||||||||||||||
|
Subroutine
import: called CC=13 SCAR=35.0
| |||||||||||||||||||||
| 73 | 14 | my $pkg = shift; | |||||||||||||||||||
| 74 | 14 | my $caller = caller; | |||||||||||||||||||
| 75 | 0 | ▶ | my $install = shift || sub {shift}; | ||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.6
Condition66%2/3
shift() || sub {
shift();
}
MC/DC0%0/2
shift() || sub {
shift();
}
shift()
sub {
shift();
}
Truth table66%2/3
A || B
A= shift()B= sub {
shift();
}
| |||||||||||||||||||||
| 76 | 14 | my %opts = @_; | |||||||||||||||||||
| 77 | 14 | my %exclude; | |||||||||||||||||||
| 78 | 14 | ▶ | if ( my $aref = $opts{-exclude} ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 79 | 0 | ▶ | die "usage: -exclude => [qw( func1 func2 )]" | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 80 | unless ref $aref eq "ARRAY"; | ||||||||||||||||||||
| 81 | 0 | %exclude = map { $_ => 1 } @$aref; | |||||||||||||||||||
| 82 | } | ||||||||||||||||||||
| 83 | 14 | my %include; | |||||||||||||||||||
| 84 | 14 | ▶ | if ( my $href = $opts{-include} ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 85 | 0 | ▶ | die "usage: -include => { foo_func => 'methname' }" | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 86 | unless ref $href eq "HASH"; | ||||||||||||||||||||
| 87 | 0 | %include = %$href; | |||||||||||||||||||
| 88 | } | ||||||||||||||||||||
| 89 | 14 | ▶ | if ( !ref $install ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 90 | 5 | my $att = $install; | |||||||||||||||||||
| 91 | 105 | ▶ | $install = sub { | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=4.4
| |||||||||||||||||||||
| 92 | 105 | my $code = shift; | |||||||||||||||||||
| 93 | 105 | my $method = shift; | |||||||||||||||||||
| 94 | 0 | ▶ | sub { | ||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||||||||||
| 95 | 0 | my $self = shift; | |||||||||||||||||||
| 96 | 0 | my @rv; | |||||||||||||||||||
| 97 | 0 | ▶ | my $pointer = $self->$att | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 98 | or die "no pointer in $self; this" | ||||||||||||||||||||
| 99 | . " object may be being used outside of its valid lifetime"; | ||||||||||||||||||||
| 100 | 0 | ▶ | if (wantarray) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 101 | 0 | @rv = $code->( $pointer, @_ ); | |||||||||||||||||||
| 102 | } | ||||||||||||||||||||
| 103 | else { | ||||||||||||||||||||
| 104 | 0 | $rv[0] = $code->( $pointer, @_ ); | |||||||||||||||||||
| 105 | } | ||||||||||||||||||||
| 106 | 0 | &Net::SSLeay::OO::Error::die_if_ssl_error( | |||||||||||||||||||
| 107 | $method); | ||||||||||||||||||||
| 108 | 0 | ▶ | wantarray ? @rv : $rv[0]; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 109 | 105 | }; | |||||||||||||||||||
| 110 | 5 | }; | |||||||||||||||||||
| 111 | } | ||||||||||||||||||||
| 112 | 14 | ▶ | if ( my $table = delete $ready{$caller} ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 113 | 10 | ▶ | while ( my ( $method, $code ) = each %$table ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 114 | 150 | ▶ | next if $exclude{$method}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 115 | 150 | my $fullname = $caller . "::" . $method; | |||||||||||||||||||
| 116 | 150 | ▶ | next if defined &{$fullname}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 117 | 145 | *{$fullname} = $install->( $code, $method ); | |||||||||||||||||||
| 118 | } | ||||||||||||||||||||
| 119 | 10 | ▶ | while ( my ( $source, $dest ) = each %include ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 120 | 0 | my $fullname = $caller . "::" . $dest; | |||||||||||||||||||
| 121 | 0 | my $code = Net::SSLeay->can($source); | |||||||||||||||||||
| 122 | 0 | ▶ | next unless $code; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 123 | 0 | *{$fullname} = $install->( $code, $dest ); | |||||||||||||||||||
| 124 | } | ||||||||||||||||||||
| 125 | } | ||||||||||||||||||||
| 126 | } | ||||||||||||||||||||
| 127 | |||||||||||||||||||||
| 128 | 5 | 1; | |||||||||||||||||||
| 129 | |||||||||||||||||||||
| 130 | __END__ | ||||||||||||||||||||