Codebase list libcrypt-ssleay-perl / f9eb659
Clean up Crypt::SSLeay::MainContext I don't even know why there was a home-made import method in that package. Also got rid of a couple of package globals. A. Sinan Unur 9 years ago
1 changed file(s) with 6 addition(s) and 23 deletion(s). Raw diff Collapse all Expand all
33
44 use strict;
55 use Carp ();
6 use Exporter qw ( import );
7
8 use vars qw( @EXPORT @EXPORT_OK );
9 @EXPORT = ();
10 @EXPORT_OK = qw( main_ctx );
611
712 require Crypt::SSLeay::CTX;
813
3338 )
3439 );
3540
36 my $ctx = &main_ctx();
37
3841 sub main_ctx {
3942 my $ctx = Crypt::SSLeay::CTX->new(
40 defined $ENV{CRYPT_SSLEAY_ALLOW_SSLv3}
43 $ENV{CRYPT_SSLEAY_ALLOW_SSLv3} ? 1 : 0
4144 );
4245
4346 if ($ENV{CRYPT_SSLEAY_CIPHER}) {
5154 $ctx;
5255 }
5356
54 my %sub_cache = ('main_ctx' => \&main_ctx );
55
56 sub import {
57 my $pkg = shift;
58 my $callpkg = caller();
59 my @func = @_;
60 for (@func) {
61 s/^&//;
62 Carp::croak("Can't export $_ from $pkg") if /\W/;;
63 my $sub = $sub_cache{$_};
64 unless ($sub) {
65 my $method = $_;
66 $method =~ s/^main_ctx_//; # optional prefix
67 $sub = $sub_cache{$_} = sub { $ctx->$method(@_) };
68 }
69 no strict 'refs';
70 *{"${callpkg}::$_"} = $sub;
71 }
72 }
73
7457 1;