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 16     16   119 use strict;
  16         41  
  16         614  
4 16     16   87 use warnings;
  16         25  
  16         903  
5             our $VERSION = '0.089_001';
6              
7 16     16   81 use Carp;
  16         21  
  16         1314  
8             $Carp::Internal{(__PACKAGE__)}++;
9 16     16   8018 use CryptX;
  16         40  
  16         4915  
10              
11             sub addfile {
12 3     3 0 168125 my ($self, $file) = @_;
13              
14 3         7 my ($handle, $close_handle);
15 3 100 100     19 if (ref($file) && eval { defined fileno($file) }) {
  2 100 66     17  
16 1         1 $handle = $file;
17             }
18             elsif (defined($file) && !ref($file)) {
19 1 50       76 open($handle, "<", $file) || croak "FATAL: cannot open '$file': $!";
20 1         5 binmode($handle);
21 1         3 $close_handle = 1;
22             }
23             else {
24 1         213 croak "FATAL: invalid handle";
25             }
26              
27 2         5 my $n;
28 2         4 my $buf = "";
29             {
30 2         3 local $SIG{__DIE__} = \&CryptX::_croak;
  2         25  
31 2         381 while (($n = read($handle, $buf, 32*1024))) {
32 2         61 $self->add($buf);
33             }
34 2 50       17 croak "FATAL: read failed: $!" unless defined $n;
35             }
36 2 100       14 close($handle) if $close_handle;
37              
38 2         22 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 instead.
56              
57             =head1 SEE ALSO
58              
59             =over
60              
61             =item * L
62              
63             =item * L, L, L, L
64              
65             =item * L, L, L, L, L
66              
67             =back
68              
69             =cut