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   133 use strict;
  15         33  
  15         580  
4 15     15   72 use warnings;
  15         25  
  15         992  
5             our $VERSION = '0.089';
6              
7 15     15   78 use Carp;
  15         24  
  15         1333  
8             $Carp::Internal{(__PACKAGE__)}++;
9 15     15   7363 use CryptX;
  15         41  
  15         5333  
10              
11             sub addfile {
12 3     3 0 146639 my ($self, $file) = @_;
13              
14 3         3 my ($handle, $close_handle);
15 3 100 100     18 if (ref($file) && eval { defined fileno($file) }) {
  2 100 66     14  
16 1         2 $handle = $file;
17             }
18             elsif (defined($file) && !ref($file)) {
19 1 50       104 open($handle, "<", $file) || croak "FATAL: cannot open '$file': $!";
20 1         3 binmode($handle);
21 1         3 $close_handle = 1;
22             }
23             else {
24 1         208 croak "FATAL: invalid handle";
25             }
26              
27 2         3 my $n;
28 2         6 my $buf = "";
29             {
30 2         3 local $SIG{__DIE__} = \&CryptX::_croak;
  2         9  
31 2         75 while (($n = read($handle, $buf, 32*1024))) {
32 2         59 $self->add($buf);
33             }
34 2 50       7 croak "FATAL: read failed: $!" unless defined $n;
35             }
36 2 100       17 close($handle) if $close_handle;
37              
38 2         20 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