| 1 | #!/usr/local/bin/perl -w | ||||||||||||||||||||||||||||||||
| 2 | ###################################################################### | ||||||||||||||||||||||||||||||||
| 3 | # | ||||||||||||||||||||||||||||||||
| 4 | # DNS/Config/Statement/Zone.pm | ||||||||||||||||||||||||||||||||
| 5 | # | ||||||||||||||||||||||||||||||||
| 6 | # $Id: Zone.pm,v 1.4 2003/02/16 10:15:33 awolf Exp $ | ||||||||||||||||||||||||||||||||
| 7 | # $Revision: 1.4 $ | ||||||||||||||||||||||||||||||||
| 8 | # $Author: awolf $ | ||||||||||||||||||||||||||||||||
| 9 | # $Date: 2003/02/16 10:15:33 $ | ||||||||||||||||||||||||||||||||
| 10 | # | ||||||||||||||||||||||||||||||||
| 11 | # Copyright (C)2001-2003 Andy Wolf. All rights reserved. | ||||||||||||||||||||||||||||||||
| 12 | # | ||||||||||||||||||||||||||||||||
| 13 | # This library is free software; you can redistribute it and/or | ||||||||||||||||||||||||||||||||
| 14 | # modify it under the same terms as Perl itself. | ||||||||||||||||||||||||||||||||
| 15 | # | ||||||||||||||||||||||||||||||||
| 16 | ###################################################################### | ||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||
| 18 | package DNS::Config::Statement::Zone; | ||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||
| 20 | 1 | ▶ | no warnings 'portable'; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 21 | 1 | ▶ | use 5.6.0; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 22 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 23 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 24 | 1 | ▶ | use vars qw(@ISA); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||
| 26 | 1 | ▶ | use DNS::Config::Statement; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||
| 28 | 1 | @ISA = qw(DNS::Config::Statement); | |||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||
| 30 | 1 | my $VERSION = '0.66'; | |||||||||||||||||||||||||||||||
| 31 | 1 | my $REVISION = sprintf("%d.%02d", q$Revision: 1.4 $ =~ /(\d+)\.(\d+)/); | |||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||
| 33 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 34 | 0 | my($pkg) = @_; | |||||||||||||||||||||||||||||||
| 35 | 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
| |||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||
| 37 | 0 | my $self = { | |||||||||||||||||||||||||||||||
| 38 | 'TYPE' => 'master' | ||||||||||||||||||||||||||||||||
| 39 | }; | ||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||
| 41 | 0 | bless $self, $class; | |||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||
| 43 | 0 | return $self; | |||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||
| 46 | 0 | ▶ | sub parse_tree { | ||||||||||||||||||||||||||||||
|
Subroutine
parse_tree: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 47 | 0 | my($self, @array) = @_; | |||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||
| 49 | 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
| |||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||
| 51 | 0 | $self->{'NAME'} = shift @array; | |||||||||||||||||||||||||||||||
| 52 | 0 | $self->{'NAME'} =~ s/^\"//g; | |||||||||||||||||||||||||||||||
| 53 | 0 | $self->{'NAME'} =~ s/\"$//g; | |||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | if(!ref($array[0])) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 56 | 0 | $self->{'CLASS'} = shift @array; | |||||||||||||||||||||||||||||||
| 57 | 0 | $self->{'CLASS'} =~ s/^\"//g; | |||||||||||||||||||||||||||||||
| 58 | 0 | $self->{'CLASS'} =~ s/\"$//g; | |||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||
| 61 | 0 | my $data = shift @array; | |||||||||||||||||||||||||||||||
| 62 | 0 | my @data = @$data; | |||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||
| 64 | 0 | foreach my $stmt (@data) { | |||||||||||||||||||||||||||||||
| 65 | 0 | my @stmt = @$stmt; | |||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||
| 67 | 0 | my $key = uc shift @stmt; | |||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||
| 69 | 0 | ▶ | if(scalar(@stmt) == 1) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 70 | 0 | $self->{$key} = shift @stmt; | |||||||||||||||||||||||||||||||
| 71 | 0 | $self->{$key} =~ s/^\"//g; | |||||||||||||||||||||||||||||||
| 72 | 0 | $self->{$key} =~ s/\"$//g; | |||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||
| 74 | else { | ||||||||||||||||||||||||||||||||
| 75 | 0 | $self->{$key} = \@stmt; | |||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||
| 79 | 0 | return $self; | |||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||
| 82 | 0 | ▶ | sub dump { | ||||||||||||||||||||||||||||||
|
Subroutine
dump: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 83 | 0 | my($self) = @_; | |||||||||||||||||||||||||||||||
| 84 | 0 | my @array; | |||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||
| 86 | my @array2; | ||||||||||||||||||||||||||||||||
| 87 | 0 | foreach my $key (keys %$self) { | |||||||||||||||||||||||||||||||
| 88 | 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/
| |||||||||||||||||||||||||||||||||
| 89 | 0 | push @array2, ([ lc $key, q(") . $self->{$key} . q(")]); | |||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||
| 91 | ▶ | 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"
| |||||||||||||||||||||||||||||||||
| 92 | 0 | push @array2, ([ lc $key, $self->{$key}]); | |||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||
| 96 | 0 | push @array, ('zone', q(") . $self->{'NAME'} . q(")); | |||||||||||||||||||||||||||||||
| 97 | 0 | ▶ | push @array, ($self->{'CLASS'}) if(exists $self->{'CLASS'}); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 98 | 0 | push @array, (\@array2); | |||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||
| 100 | 0 | my $string = $self->substatement(@array); | |||||||||||||||||||||||||||||||
| 101 | 0 | print $string, "\n"; | |||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||
| 103 | 0 | return $self; | |||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||
| 106 | 0 | ▶ | sub name { | ||||||||||||||||||||||||||||||
|
Subroutine
name: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 107 | 0 | my($self, $name) = @_; | |||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||
| 109 | 0 | ▶ | $self->{'NAME'} = $name if($name); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||
| 111 | 0 | return $self->{'NAME'}; | |||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||
| 114 | 0 | ▶ | sub class { | ||||||||||||||||||||||||||||||
|
Subroutine
class: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 115 | 0 | my($self, $class) = @_; | |||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||
| 117 | 0 | ▶ | $self->{'CLASS'} = $class if($class); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||
| 119 | 0 | return $self->{'CLASS'}; | |||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||
| 122 | 0 | ▶ | sub type { | ||||||||||||||||||||||||||||||
|
Subroutine
type: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 123 | 0 | my($self, $type) = @_; | |||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||
| 125 | 0 | ▶ | if((lc $type eq 'master') || (lc $type eq 'slave')) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
lc $type eq "master" or lc $type eq "slave"
MC/DC0%0/2
lc $type eq "master" or lc $type eq "slave"
lc $type eq "master"
lc $type eq "slave"
Truth table0%0/3
A or B
A= lc $type eq "master"B= lc $type eq "slave"
| |||||||||||||||||||||||||||||||||
| 126 | 0 | $self->{'TYPE'} = lc $type; | |||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||
| 129 | 0 | return $self->{'TYPE'}; | |||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||
| 132 | 0 | ▶ | sub file { | ||||||||||||||||||||||||||||||
|
Subroutine
file: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 133 | 0 | my($self, $file) = @_; | |||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||
| 135 | 0 | ▶ | $self->{'FILE'} = $file if($file); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||
| 137 | 0 | return $self->{'FILE'}; | |||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||
| 140 | 0 | ▶ | sub masters { | ||||||||||||||||||||||||||||||
|
Subroutine
masters: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 141 | 0 | my($self, @hosts) = @_; | |||||||||||||||||||||||||||||||
| 142 | 0 | my @result; | |||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||
| 144 | 0 | ▶ | if(scalar(@hosts)) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 145 | 0 | $self->{'TYPE'} = 'slave'; | |||||||||||||||||||||||||||||||
| 146 | 0 | $self->{'MASTERS'} = [ \@hosts ]; | |||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||
| 149 | 0 | ▶ | if(uc $self->{'TYPE'} eq 'SLAVE') { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 150 | 0 | @result = @{ $self->{'MASTERS'} }; | |||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||
| 153 | 0 | return @result; | |||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||
| 156 | 0 | ▶ | sub master { | ||||||||||||||||||||||||||||||
|
Subroutine
master: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 157 | 0 | my($self, $host) = @_; | |||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||
| 159 | 0 | my @temp = $self->masters( $host ); | |||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||
| 161 | 0 | my $pnserver; | |||||||||||||||||||||||||||||||
| 162 | 0 | ▶ | if(scalar(@temp)) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 163 | 0 | my @tmp = @{$temp[0]}; | |||||||||||||||||||||||||||||||
| 164 | 0 | $pnserver = $tmp[0]; | |||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||
| 167 | 0 | return $pnserver; | |||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||
| 170 | 1 | 1; | |||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||
| 172 | __END__ | ||||||||||||||||||||||||||||||||