| 1 | package Mail::Pyzor::SHA; | ||||||||||||||||||||||
| 2 | |||||||||||||||||||||||
| 3 | # Copyright 2018 cPanel, LLC. | ||||||||||||||||||||||
| 4 | # All rights reserved. | ||||||||||||||||||||||
| 5 | # http://cpanel.net | ||||||||||||||||||||||
| 6 | # | ||||||||||||||||||||||
| 7 | # <@LICENSE> | ||||||||||||||||||||||
| 8 | # Licensed to the Apache Software Foundation (ASF) under one or more | ||||||||||||||||||||||
| 9 | # contributor license agreements. See the NOTICE file distributed with | ||||||||||||||||||||||
| 10 | # this work for additional information regarding copyright ownership. | ||||||||||||||||||||||
| 11 | # The ASF licenses this file to you under the Apache License, Version 2.0 | ||||||||||||||||||||||
| 12 | # (the "License"); you may not use this file except in compliance with | ||||||||||||||||||||||
| 13 | # the License. You may obtain a copy of the License at: | ||||||||||||||||||||||
| 14 | # | ||||||||||||||||||||||
| 15 | # http://www.apache.org/licenses/LICENSE-2.0 | ||||||||||||||||||||||
| 16 | # | ||||||||||||||||||||||
| 17 | # Unless required by applicable law or agreed to in writing, software | ||||||||||||||||||||||
| 18 | # distributed under the License is distributed on an "AS IS" BASIS, | ||||||||||||||||||||||
| 19 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||||||||||||||||||||
| 20 | # See the License for the specific language governing permissions and | ||||||||||||||||||||||
| 21 | # limitations under the License. | ||||||||||||||||||||||
| 22 | # </@LICENSE> | ||||||||||||||||||||||
| 23 | # | ||||||||||||||||||||||
| 24 | |||||||||||||||||||||||
| 25 | 4 | ▶ | use strict; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 26 | 4 | ▶ | use warnings; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 27 | |||||||||||||||||||||||
| 28 | 4 | ▶ | use constant _ORDER => ( 'Digest::SHA1', 'Digest::SHA' ); | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 29 | |||||||||||||||||||||||
| 30 | 4 | our $VERSION = '0.06'; | |||||||||||||||||||||
| 31 | |||||||||||||||||||||||
| 32 | 4 | my $_sha_module; | |||||||||||||||||||||
| 33 | |||||||||||||||||||||||
| 34 | 6 | ▶ | sub _sha_module { | ||||||||||||||||||||
|
Subroutine
_sha_module: called CC=6 SCAR=27.2
| |||||||||||||||||||||||
| 35 | 0 | ▶ | if ( !$_sha_module ) { | ||||||||||||||||||||
|
Subroutine
_sha_module: not called CC=6 SCAR=27.2
Branch: 2 branches
| |||||||||||||||||||||||
| 36 | |||||||||||||||||||||||
| 37 | # First check if one of the modules is loaded. | ||||||||||||||||||||||
| 38 | 0 | ▶ | if ( my @loaded = grep { $_->can('sha1') } _ORDER ) { | ||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||
| 39 | 0 | $_sha_module = $loaded[0]; | |||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||
| 41 | else { | ||||||||||||||||||||||
| 42 | 0 | local $@; | |||||||||||||||||||||
| 43 | |||||||||||||||||||||||
| 44 | 0 | my @modules = _ORDER(); | |||||||||||||||||||||
| 45 | |||||||||||||||||||||||
| 46 | 0 | ▶ | while ( my $module = shift @modules ) { | ||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||
| 47 | 0 | my $path = "$module.pm"; | |||||||||||||||||||||
| 48 | 0 | $path =~ s<::></>g; | |||||||||||||||||||||
| 49 | |||||||||||||||||||||||
| 50 | 0 | ▶ | if ( eval { require $path; 1 } ) { | ||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||
| 51 | 0 | $_sha_module = $module; | |||||||||||||||||||||
| 52 | 0 | last; | |||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||
| 54 | elsif ( !@modules ) { | ||||||||||||||||||||||
| 55 | 0 | die; | |||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||
| 60 | |||||||||||||||||||||||
| 61 | 0 | return $_sha_module; | |||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||
| 63 | |||||||||||||||||||||||
| 64 | 2 | ▶ | sub sha1 { | ||||||||||||||||||||
|
Subroutine
sha1: called CC=1 SCAR=1.2
Pod
undocumented
| |||||||||||||||||||||||
| 65 | 0 | ▶ | return _sha_module()->can('sha1')->(@_); | ||||||||||||||||||||
|
Subroutine
sha1: not called CC=1 SCAR=1.2
Pod
undocumented
| |||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||
| 67 | |||||||||||||||||||||||
| 68 | 4 | ▶ | sub sha1_hex { | ||||||||||||||||||||
|
Subroutine
sha1_hex: called CC=1 SCAR=1.2
Pod
undocumented
| |||||||||||||||||||||||
| 69 | 0 | ▶ | return _sha_module()->can('sha1_hex')->(@_); | ||||||||||||||||||||
|
Subroutine
sha1_hex: not called CC=1 SCAR=1.2
Pod
undocumented
| |||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||
| 71 | |||||||||||||||||||||||
| 72 | 4 | 1; | |||||||||||||||||||||