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   99 use strict;
  16         29  
  16         476  
4 16     16   81 use warnings;
  16         18  
  16         733  
5             our $VERSION = '0.089_002';
6              
7 16     16   62 use Carp;
  16         16  
  16         1058  
8             $Carp::Internal{(__PACKAGE__)}++;
9 16     16   5954 use CryptX;
  16         30  
  16         4129  
10              
11             sub addfile {
12 3     3 0 150403 my ($self, $file) = @_;
13              
14 3         3 my ($handle, $close_handle);
15 3 100 100     37 if (ref($file) && eval { defined fileno($file) }) {
  2 100 66     12  
16 1         2 $handle = $file;
17             }
18             elsif (defined($file) && !ref($file)) {
19 1 50       59 open($handle, "<", $file) || croak "FATAL: cannot open '$file': $!";
20 1         2 binmode($handle);
21 1         2 $close_handle = 1;
22             }
23             else {
24 1         177 croak "FATAL: invalid handle";
25             }
26              
27 2         3 my $n;
28 2         2 my $buf = "";
29             {
30 2         4 local $SIG{__DIE__} = \&CryptX::_croak;
  2         9  
31 2         48 while (($n = read($handle, $buf, 32*1024))) {
32 2         56 $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         17 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