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   95 use strict;
  16         36  
  16         503  
4 16     16   70 use warnings;
  16         22  
  16         732  
5             our $VERSION = '0.090';
6              
7 16     16   67 use Carp;
  16         21  
  16         981  
8             $Carp::Internal{(__PACKAGE__)}++;
9 16     16   5669 use CryptX;
  16         27  
  16         4015  
10              
11             sub addfile {
12 3     3 0 138199 my ($self, $file) = @_;
13              
14 3         7 my ($handle, $close_handle);
15 3 100 100     17 if (ref($file) && eval { defined fileno($file) }) {
  2 100 66     14  
16 1         3 $handle = $file;
17             }
18             elsif (defined($file) && !ref($file)) {
19 1 50       73 open($handle, "<", $file) || croak "FATAL: cannot open '$file': $!";
20 1         4 binmode($handle);
21 1         2 $close_handle = 1;
22             }
23             else {
24 1         179 croak "FATAL: invalid handle";
25             }
26              
27 2         3 my $n;
28 2         5 my $buf = "";
29             {
30 2         3 local $SIG{__DIE__} = \&CryptX::_croak;
  2         18  
31 2         48 while (($n = read($handle, $buf, 32*1024))) {
32 2         58 $self->add($buf);
33             }
34 2 50       8 croak "FATAL: read failed: $!" unless defined $n;
35             }
36 2 100       15 close($handle) if $close_handle;
37              
38 2         25 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