| 1 | #!/usr/local/bin/perl -w | ||||||||||||||||||||||||||||||||
| 2 | ###################################################################### | ||||||||||||||||||||||||||||||||
| 3 | # | ||||||||||||||||||||||||||||||||
| 4 | # DNS/Config/Statement/Key.pm | ||||||||||||||||||||||||||||||||
| 5 | # | ||||||||||||||||||||||||||||||||
| 6 | # $Id: Key.pm,v 1.3 2003/02/16 10:15:33 awolf Exp $ | ||||||||||||||||||||||||||||||||
| 7 | # $Revision: 1.3 $ | ||||||||||||||||||||||||||||||||
| 8 | # $Author: awolf $ | ||||||||||||||||||||||||||||||||
| 9 | # $Date: 2003/02/16 10:15:33 $ | ||||||||||||||||||||||||||||||||
| 10 | # | ||||||||||||||||||||||||||||||||
| 11 | # Copyright (C)2003 Bruce Campbell. All rights reserved. | ||||||||||||||||||||||||||||||||
| 12 | # Base Class (Options) (C)2001-2003 Andy Wolf. All rights reserved. | ||||||||||||||||||||||||||||||||
| 13 | # | ||||||||||||||||||||||||||||||||
| 14 | # This library is free software; you can redistribute it and/or | ||||||||||||||||||||||||||||||||
| 15 | # modify it under the same terms as Perl itself. | ||||||||||||||||||||||||||||||||
| 16 | # | ||||||||||||||||||||||||||||||||
| 17 | ###################################################################### | ||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||
| 19 | package DNS::Config::Statement::Key; | ||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||
| 21 | 1 | ▶ | no warnings 'portable'; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 22 | 1 | ▶ | use 5.6.0; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 23 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 24 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 25 | 1 | ▶ | use vars qw(@ISA); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||
| 27 | 1 | ▶ | use DNS::Config::Statement; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||
| 29 | 1 | @ISA = qw(DNS::Config::Statement); | |||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||
| 31 | 1 | my $VERSION = '0.66'; | |||||||||||||||||||||||||||||||
| 32 | 1 | my $REVISION = sprintf("%d.%02d", q$Revision: 1.3 $ =~ /(\d+)\.(\d+)/); | |||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||
| 34 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 35 | 0 | my($pkg) = @_; | |||||||||||||||||||||||||||||||
| 36 | 0 | ▶ | my $class = ref($pkg) || $pkg; | ||||||||||||||||||||||||||||||
|
Condition0%0/3
ref $pkg || $pkg
MC/DC0%0/2
ref $pkg || $pkg
ref $pkg
$pkg
Truth table0%0/3
A || B
A= ref $pkgB= $pkg
| |||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||
| 38 | 0 | my $self = { | |||||||||||||||||||||||||||||||
| 39 | 'ALGORITHM' => 'hmac-md5' | ||||||||||||||||||||||||||||||||
| 40 | }; | ||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||
| 43 | 0 | bless $self, $class; | |||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||
| 45 | 0 | return $self; | |||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||
| 48 | 0 | ▶ | sub parse_tree { | ||||||||||||||||||||||||||||||
|
Subroutine
parse_tree: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 49 | 0 | my($self, @array) = @_; | |||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | return undef if((scalar(@array) < 2) || (scalar(@array) > 3)); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
scalar @array < 2 or scalar @array > 3
MC/DC0%0/2
scalar @array < 2 or scalar @array > 3
scalar @array < 2
scalar @array > 3
Truth table0%0/3
A or B
A= scalar @array < 2B= scalar @array > 3
| |||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||
| 53 | 0 | $self->{'NAME'} = shift @array; | |||||||||||||||||||||||||||||||
| 54 | 0 | $self->{'NAME'} =~ s/^\"//g; | |||||||||||||||||||||||||||||||
| 55 | 0 | $self->{'NAME'} =~ s/\"$//g; | |||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||
| 57 | 0 | my $data = shift @array; | |||||||||||||||||||||||||||||||
| 58 | 0 | my @data = @$data; | |||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||
| 60 | 0 | foreach my $stmt (@data) { | |||||||||||||||||||||||||||||||
| 61 | 0 | my @stmt = @$stmt; | |||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||
| 63 | 0 | my $key = uc shift @stmt; | |||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | if(scalar(@stmt) == 1) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 66 | 0 | $self->{$key} = shift @stmt; | |||||||||||||||||||||||||||||||
| 67 | 0 | $self->{$key} =~ s/^\"//g; | |||||||||||||||||||||||||||||||
| 68 | 0 | $self->{$key} =~ s/\"$//g; | |||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||
| 70 | else { | ||||||||||||||||||||||||||||||||
| 71 | 0 | $self->{$key} = \@stmt; | |||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||
| 75 | 0 | return $self; | |||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||
| 78 | 0 | ▶ | sub dump { | ||||||||||||||||||||||||||||||
|
Subroutine
dump: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 79 | 0 | my($self) = @_; | |||||||||||||||||||||||||||||||
| 80 | 0 | my @array; | |||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||
| 82 | my @array2; | ||||||||||||||||||||||||||||||||
| 83 | 0 | foreach my $key (keys %$self) { | |||||||||||||||||||||||||||||||
| 84 | 0 | ▶ | if(($key =~ /FILE/) || ($key =~ /DIRECTORY/)) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$key =~ /FILE/ or $key =~ /DIRECTORY/
MC/DC0%0/2
$key =~ /FILE/ or $key =~ /DIRECTORY/
$key =~ /FILE/
$key =~ /DIRECTORY/
Truth table0%0/3
A or B
A= $key =~ /FILE/B= $key =~ /DIRECTORY/
| |||||||||||||||||||||||||||||||||
| 85 | 0 | push @array2, ([ lc $key, q(") . $self->{$key} . q(")]); | |||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||
| 87 | ▶ | elsif(($key ne 'NAME') && ($key ne 'CLASS')) { | |||||||||||||||||||||||||||||||
|
Condition0%0/3
$key ne "NAME" and $key ne "CLASS"
MC/DC0%0/2
$key ne "NAME" and $key ne "CLASS"
$key ne "NAME"
$key ne "CLASS"
Truth table0%0/3
A and B
A= $key ne "NAME"B= $key ne "CLASS"
| |||||||||||||||||||||||||||||||||
| 88 | 0 | push @array2, ([ lc $key, $self->{$key}]); | |||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||
| 92 | 0 | push @array, ('key', q(") . $self->{'NAME'} . q(")); | |||||||||||||||||||||||||||||||
| 93 | 0 | ▶ | push @array, ($self->{'CLASS'}) if(exists $self->{'CLASS'}); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 94 | 0 | push @array, (\@array2); | |||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||
| 96 | 0 | my $string = $self->substatement(@array); | |||||||||||||||||||||||||||||||
| 97 | 0 | print $string, "\n"; | |||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||
| 99 | 0 | return $self; | |||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||
| 102 | 0 | ▶ | sub name { | ||||||||||||||||||||||||||||||
|
Subroutine
name: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 103 | 0 | my($self, $name) = @_; | |||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||
| 105 | 0 | ▶ | $self->{'NAME'} = $name if($name); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||
| 107 | 0 | return $self->{'NAME'}; | |||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | sub algorithm { | ||||||||||||||||||||||||||||||
|
Subroutine
algorithm: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 111 | 0 | my($self, $alg) = @_; | |||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||
| 113 | 0 | ▶ | $self->{'ALGORITHM'} = $alg if($alg); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||
| 115 | 0 | return $self->{'ALGORITHM'}; | |||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||
| 118 | 0 | ▶ | sub secret { | ||||||||||||||||||||||||||||||
|
Subroutine
secret: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 119 | 0 | my($self, $secret) = @_; | |||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | $self->{'SECRET'} = $secret if($secret); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||
| 123 | 0 | return $self->{'SECRET'}; | |||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||
| 126 | 1 | 1; | |||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||
| 128 | __END__ | ||||||||||||||||||||||||||||||||