| 1 | package Crypt::Sodium::XS::MemVault; | ||||||||||
| 2 | 26 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 26 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | 26 | ▶ | use Crypt::Sodium::XS; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 26 | ▶ | use Exporter 'import'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 26 | ▶ | use Fcntl qw( | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | F_GETFD F_SETFD | ||||||||||
| 10 | O_CREAT O_NOCTTY O_RDONLY O_RDWR O_TRUNC O_WRONLY | ||||||||||
| 11 | 26 | ); | |||||||||
| 12 | |||||||||||
| 13 | 26 | our %EXPORT_TAGS = ( | |||||||||
| 14 | constructors => [qw[ | ||||||||||
| 15 | mv_new | ||||||||||
| 16 | mv_from_base64 | ||||||||||
| 17 | mv_from_hex | ||||||||||
| 18 | mv_from_fd | ||||||||||
| 19 | mv_from_file | ||||||||||
| 20 | mv_from_tty | ||||||||||
| 21 | mv_from_tty_file | ||||||||||
| 22 | mv_from_ttyno | ||||||||||
| 23 | ]], | ||||||||||
| 24 | ); | ||||||||||
| 25 | 26 | $EXPORT_TAGS{all} = [ @{$EXPORT_TAGS{constructors}} ]; | |||||||||
| 26 | 26 | our @EXPORT_OK = @{$EXPORT_TAGS{all}}; | |||||||||
| 27 | |||||||||||
| 28 | 26 | ▶ | use overload ( | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.8
| |||||||||||
| 29 | fallback => 0, | ||||||||||
| 30 | nomethod => \&_overload_nomethod, | ||||||||||
| 31 | bool => \&_overload_bool, | ||||||||||
| 32 | "!" => \&_overload_bool, | ||||||||||
| 33 | eq => \&_overload_eq, | ||||||||||
| 34 | '==' => \&_overload_eq, | ||||||||||
| 35 | 'ne' => \&_overload_ne, | ||||||||||
| 36 | '!=' => \&_overload_ne, | ||||||||||
| 37 | '""' => \&to_bytes, | ||||||||||
| 38 | x => \&_overload_mult, | ||||||||||
| 39 | '.' => \&concat, | ||||||||||
| 40 | '.=' => \&concat_inplace, | ||||||||||
| 41 | cmp => \&compare, | ||||||||||
| 42 | '<=>' => \&compare, | ||||||||||
| 43 | 10 | ▶ | '>' => sub { ($_[2] ? compare($_[1], $_[0]) : compare($_[0], $_[1])) == 1 }, | ||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||
| 44 | 0 | ▶ | 'gt' => sub { ($_[2] ? compare($_[1], $_[0]) : compare($_[0], $_[1])) == 1 }, | ||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||
| 45 | 6 | ▶ | '>=' => sub { ($_[2] ? compare($_[1], $_[0]) : compare($_[0], $_[1])) != -1 }, | ||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||
| 46 | 0 | ▶ | 'ge' => sub { ($_[2] ? compare($_[1], $_[0]) : compare($_[0], $_[1])) != -1 }, | ||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||
| 47 | 6 | ▶ | '<' => sub { ($_[2] ? compare($_[1], $_[0]) : compare($_[0], $_[1])) == -1 }, | ||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||
| 48 | 0 | ▶ | 'lt' => sub { ($_[2] ? compare($_[1], $_[0]) : compare($_[0], $_[1])) == -1 }, | ||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||
| 49 | 6 | ▶ | '<=' => sub { ($_[2] ? compare($_[1], $_[0]) : compare($_[0], $_[1])) != 1 }, | ||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||
| 50 | 0 | ▶ | 'le' => sub { ($_[2] ? compare($_[1], $_[0]) : compare($_[0], $_[1])) != 1 }, | ||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||
| 51 | 26 | '&' => \&bitwise_and, | |||||||||
| 52 | '&=' => \&bitwise_and_equals, | ||||||||||
| 53 | '|' => \&bitwise_or, | ||||||||||
| 54 | '|=' => \&bitwise_or_equals, | ||||||||||
| 55 | '^' => \&bitwise_xor, | ||||||||||
| 56 | '^=' => \&bitwise_xor_equals, | ||||||||||
| 57 | 26 | ); | |||||||||
| 58 | |||||||||||
| 59 | 2 | ▶ | sub mv_new { __PACKAGE__->new(@_); } | ||||||||
|
Subroutine
mv_new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 60 | 2 | ▶ | sub mv_from_base64 { __PACKAGE__->new_from_base64(@_); } | ||||||||
|
Subroutine
mv_from_base64: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 61 | 2 | ▶ | sub mv_from_hex { __PACKAGE__->new_from_hex(@_); } | ||||||||
|
Subroutine
mv_from_hex: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 62 | 1 | ▶ | sub mv_from_fd { __PACKAGE__->new_from_fd(@_); } | ||||||||
|
Subroutine
mv_from_fd: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 63 | 1 | ▶ | sub mv_from_file { __PACKAGE__->new_from_file(@_); } | ||||||||
|
Subroutine
mv_from_file: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 64 | 0 | ▶ | sub mv_from_tty { __PACKAGE__->new_from_tty(@_); } | ||||||||
|
Subroutine
mv_from_tty: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 65 | 0 | ▶ | sub mv_from_ttyno { __PACKAGE__->new_from_ttyno(@_); } | ||||||||
|
Subroutine
mv_from_ttyno: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 66 | |||||||||||
| 67 | 7 | ▶ | sub new_from_file { | ||||||||
|
Subroutine
new_from_file: called CC=3 SCAR=11.3
Pod
documented
| |||||||||||
| 68 | 7 | my $invocant = shift; | |||||||||
| 69 | 7 | my $path = shift; | |||||||||
| 70 | 7 | ▶ | $path = '' unless defined $path; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 71 | 7 | ▶ | sysopen(my $fh, $path, O_NOCTTY|O_RDONLY) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 72 | or die "$path: new_from_file:open: $!"; | ||||||||||
| 73 | 7 | return $invocant->new_from_fd(fileno($fh), @_); | |||||||||
| 74 | } | ||||||||||
| 75 | |||||||||||
| 76 | 26 | my $tty_init = eval 'Fcntl::O_TTY_INIT()'; | |||||||||
| 77 | 26 | ▶ | $tty_init = 0 if !defined($tty_init); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 78 | 0 | ▶ | sub new_from_tty { | ||||||||
|
Subroutine
new_from_tty: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||
| 79 | 0 | my $invocant = shift; | |||||||||
| 80 | # undef intended to indicate 'controlling tty' | ||||||||||
| 81 | 0 | my $path = shift; | |||||||||
| 82 | 0 | ▶ | $path = '/dev/tty' unless defined $path; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 83 | 0 | ▶ | sysopen(my $fh, $path, O_NOCTTY|O_RDWR|$tty_init) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 84 | or die "$path: new_from_tty:open: $!"; | ||||||||||
| 85 | 0 | return $invocant->new_from_ttyno(fileno($fh), @_); | |||||||||
| 86 | } | ||||||||||
| 87 | |||||||||||
| 88 | 0 | ▶ | sub to_file { | ||||||||
|
Subroutine
to_file: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||
| 89 | 0 | my $invocant = shift; | |||||||||
| 90 | 0 | my $path = shift; | |||||||||
| 91 | 0 | ▶ | $path = '' unless defined $path; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 92 | 0 | my $mode = shift; | |||||||||
| 93 | 0 | ▶ | $mode = 0600 unless defined $mode; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 94 | 0 | ▶ | sysopen(my $fh, $path, O_CREAT|O_NOCTTY|O_TRUNC|O_WRONLY, $mode) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 95 | or die "$path: to_file:open: $!"; | ||||||||||
| 96 | 0 | return $invocant->to_fd(fileno($fh), @_); | |||||||||
| 97 | } | ||||||||||
| 98 | |||||||||||
| 99 | 26 | 1; | |||||||||
| 100 | |||||||||||
| 101 | __END__ | ||||||||||