File Coverage

blib/lib/Crypt/Mac.pm
Criterion Covered Total %
statement 30 31 96.7
branch 8 10 80.0
condition 5 6 83.3
subroutine 5 6 83.3
pod 0 1 0.0
total 48 54 88.8


line stmt bran cond sub pod time code
1             package Crypt::Mac;
2              
3 15     15   91 use strict;
  15         23  
  15         439  
4 15     15   50 use warnings;
  15         22  
  15         792  
5             our $VERSION = '0.088_004';
6              
7 15     15   59 use Carp;
  15         17  
  15         844  
8             $Carp::Internal{(__PACKAGE__)}++;
9 15     15   5238 use CryptX;
  15         29  
  15         3800  
10              
11             sub addfile {
12 3     3 0 138101 my ($self, $file) = @_;
13              
14 3         4 my ($handle, $close_handle);
15 3 100 100     14 if (ref($file) && eval { defined fileno($file) }) {
  2 100 66     13  
16 1         2 $handle = $file;
17             }
18             elsif (defined($file) && !ref($file)) {
19 1 50       57 open($handle, "<", $file) || croak "FATAL: cannot open '$file': $!";
20 1         3 binmode($handle);
21 1         3 $close_handle = 1;
22             }
23             else {
24 1         172 croak "FATAL: invalid handle";
25             }
26              
27 2         2 my $n;
28 2         4 my $buf = "";
29             {
30 2         2 local $SIG{__DIE__} = \&CryptX::_croak;
  2         8  
31 2         56 while (($n = read($handle, $buf, 32*1024))) {
32 2         58 $self->add($buf);
33             }
34 2 50       7 croak "FATAL: read failed: $!" unless defined $n;
35             }
36 2 100       11 close($handle) if $close_handle;
37              
38 2         18 return $self;
39             }
40              
41 0     0     sub CLONE_SKIP { 1 } # prevent cloning
42              
43             1;
44              
45             =pod
46              
47             =head1 NAME
48              
49             Crypt::Mac - [internal only]
50              
51             =head1 SYNOPSIS
52              
53             Do not use this module directly.
54              
55             Use a concrete MAC module such as L or
56             L.
57              
58             =head1 DESCRIPTION
59              
60             Internal base class for MAC implementations.
61              
62             Do not use this module directly. Use a concrete implementation such as
63             L, L, L, or
64             another C module.
65              
66             =cut