| 1 | package Crypt::SSLeay::MainContext; | ||||||||||||
| 2 | |||||||||||||
| 3 | # maintains a single instance of the Crypt::SSLeay::CTX class | ||||||||||||
| 4 | |||||||||||||
| 5 | 1 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | 1 | ▶ | use Carp (); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 7 | |||||||||||||
| 8 | require Crypt::SSLeay::CTX; | ||||||||||||
| 9 | |||||||||||||
| 10 | my $ctx = &main_ctx(); | ||||||||||||
| 11 | |||||||||||||
| 12 | 0 | ▶ | sub main_ctx { | ||||||||||
|
Subroutine
main_ctx: not called CC=3 SCAR=24.8
| |||||||||||||
| 13 | 0 | ▶ | my $ssl_version = shift || 23; | ||||||||||
|
Condition0%0/2
shift() || 23
MC/DC0%0/1
shift() || 23
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||
| 14 | |||||||||||||
| 15 | 0 | my $ctx = Crypt::SSLeay::CTX->new($ssl_version); | |||||||||||
| 16 | $ctx->set_cipher_list($ENV{CRYPT_SSLEAY_CIPHER}) | ||||||||||||
| 17 | 0 | ▶ | if $ENV{CRYPT_SSLEAY_CIPHER}; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 18 | |||||||||||||
| 19 | 0 | $ctx; | |||||||||||
| 20 | } | ||||||||||||
| 21 | |||||||||||||
| 22 | my %sub_cache = ('main_ctx' => \&main_ctx ); | ||||||||||||
| 23 | |||||||||||||
| 24 | 0 | ▶ | sub import { | ||||||||||
|
Subroutine
import: not called CC=4 SCAR=26.4
| |||||||||||||
| 25 | 0 | my $pkg = shift; | |||||||||||
| 26 | 0 | my $callpkg = caller(); | |||||||||||
| 27 | 0 | my @func = @_; | |||||||||||
| 28 | 0 | for (@func) { | |||||||||||
| 29 | 0 | s/^&//; | |||||||||||
| 30 | 0 | ▶ | Carp::croak("Can't export $_ from $pkg") if /\W/;; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 31 | 0 | my $sub = $sub_cache{$_}; | |||||||||||
| 32 | 0 | ▶ | unless ($sub) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 33 | 0 | my $method = $_; | |||||||||||
| 34 | 0 | $method =~ s/^main_ctx_//; # optional prefix | |||||||||||
| 35 | 0 | ▶ | $sub = $sub_cache{$_} = sub { $ctx->$method(@_) }; | ||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||
| 36 | } | ||||||||||||
| 37 | 1 | ▶ | no strict 'refs'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 38 | 0 | *{"${callpkg}::$_"} = $sub; | |||||||||||
| 39 | } | ||||||||||||
| 40 | } | ||||||||||||
| 41 | |||||||||||||
| 42 | 1; | ||||||||||||