| 1 | #!/usr/local/bin/perl -w | ||||||||||||||||||||
| 2 | ###################################################################### | ||||||||||||||||||||
| 3 | # | ||||||||||||||||||||
| 4 | # DNS/Zone/File.pm | ||||||||||||||||||||
| 5 | # | ||||||||||||||||||||
| 6 | # $Id: File.pm,v 1.8 2003/02/04 15:37:34 awolf Exp $ | ||||||||||||||||||||
| 7 | # $Revision: 1.8 $ | ||||||||||||||||||||
| 8 | # $Author: awolf $ | ||||||||||||||||||||
| 9 | # $Date: 2003/02/04 15:37:34 $ | ||||||||||||||||||||
| 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::Zone::File; | ||||||||||||||||||||
| 19 | |||||||||||||||||||||
| 20 | 2 | ▶ | no warnings 'portable'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 21 | 2 | ▶ | use 5.6.0; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 22 | 2 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 23 | 2 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 24 | |||||||||||||||||||||
| 25 | 2 | ▶ | use DNS::Zone; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 26 | 2 | ▶ | use DNS::Zone::Label; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 27 | 2 | ▶ | use DNS::Zone::Record; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 28 | |||||||||||||||||||||
| 29 | 2 | my $VERSION = '0.85'; | |||||||||||||||||||
| 30 | 2 | my $REVISION = sprintf("%d.%02d", q$Revision: 1.8 $ =~ /(\d+)\.(\d+)/); | |||||||||||||||||||
| 31 | |||||||||||||||||||||
| 32 | 2 | my $map = { | |||||||||||||||||||
| 33 | 'default' => 'DNS::Zone::File::Default' | ||||||||||||||||||||
| 34 | }; | ||||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | 1 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=11.3
Pod
undocumented
| |||||||||||||||||||||
| 37 | 1 | my($pkg, %hash) = @_; | |||||||||||||||||||
| 38 | 1 | my $ref; | |||||||||||||||||||
| 39 | |||||||||||||||||||||
| 40 | 1 | ▶ | my $type = $hash{'type'} || 'default'; | ||||||||||||||||||
|
Condition50%1/2
$hash{'type'} || 'default'
MC/DC0%0/1
$hash{'type'} || 'default'
$hash{'type'}
Truth table50%1/2
A
A= $hash{'type'}
| |||||||||||||||||||||
| 41 | 1 | my $zone = $hash{'zone'}; | |||||||||||||||||||
| 42 | 1 | my $file = $hash{'file'}; | |||||||||||||||||||
| 43 | |||||||||||||||||||||
| 44 | 1 | eval "require $map->{$type}"; | |||||||||||||||||||
| 45 | |||||||||||||||||||||
| 46 | 1 | ▶ | if(!$@) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 47 | 1 | $ref = $map->{$type}->new($zone, $file); | |||||||||||||||||||
| 48 | } | ||||||||||||||||||||
| 49 | else { | ||||||||||||||||||||
| 50 | 0 | warn $@; | |||||||||||||||||||
| 51 | } | ||||||||||||||||||||
| 52 | |||||||||||||||||||||
| 53 | 1 | return $ref; | |||||||||||||||||||
| 54 | } | ||||||||||||||||||||
| 55 | |||||||||||||||||||||
| 56 | 1 | ▶ | sub read { | ||||||||||||||||||
|
Subroutine
read: called CC=3 SCAR=11.7
Pod
undocumented
| |||||||||||||||||||||
| 57 | 1 | my($self, $file) = @_; | |||||||||||||||||||
| 58 | 1 | my @lines; | |||||||||||||||||||
| 59 | |||||||||||||||||||||
| 60 | 1 | ▶ | $file = $file || $self->{'FILE'}; | ||||||||||||||||||
|
Condition33%1/3
$file || $self->{'FILE'}
MC/DC0%0/2
$file || $self->{'FILE'}
$file
$self->{'FILE'}
Truth table33%1/3
A || B
A= $fileB= $self->{'FILE'}
| |||||||||||||||||||||
| 61 | |||||||||||||||||||||
| 62 | 1 | ▶ | if(open(FILE, $file)) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 63 | 1 | @lines = <FILE>; | |||||||||||||||||||
| 64 | 1 | chomp @lines; | |||||||||||||||||||
| 65 | 1 | close FILE; | |||||||||||||||||||
| 66 | } | ||||||||||||||||||||
| 67 | 0 | else { warn "Cannot read file $file !"; } | |||||||||||||||||||
| 68 | |||||||||||||||||||||
| 69 | 1 | return @lines; | |||||||||||||||||||
| 70 | } | ||||||||||||||||||||
| 71 | |||||||||||||||||||||
| 72 | 0 | ▶ | sub parse { | ||||||||||||||||||
|
Subroutine
parse: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 73 | 0 | my($self, $file) = @_; | |||||||||||||||||||
| 74 | |||||||||||||||||||||
| 75 | # Overwrite in sub classes ! | ||||||||||||||||||||
| 76 | |||||||||||||||||||||
| 77 | 0 | return $self; | |||||||||||||||||||
| 78 | } | ||||||||||||||||||||
| 79 | |||||||||||||||||||||
| 80 | 0 | ▶ | sub dump { | ||||||||||||||||||
|
Subroutine
dump: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 81 | 0 | my($self, $file) = @_; | |||||||||||||||||||
| 82 | |||||||||||||||||||||
| 83 | # Overwrite in sub classes ! | ||||||||||||||||||||
| 84 | |||||||||||||||||||||
| 85 | 0 | return $self; | |||||||||||||||||||
| 86 | } | ||||||||||||||||||||
| 87 | |||||||||||||||||||||
| 88 | 0 | ▶ | sub debug { | ||||||||||||||||||
|
Subroutine
debug: not called CC=1 SCAR=1.7
Pod
undocumented
| |||||||||||||||||||||
| 89 | 0 | my($self) = @_; | |||||||||||||||||||
| 90 | |||||||||||||||||||||
| 91 | 0 | eval { | |||||||||||||||||||
| 92 | 2 | ▶ | use Data::Dumper; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 93 | |||||||||||||||||||||
| 94 | 0 | print Dumper($self); | |||||||||||||||||||
| 95 | }; | ||||||||||||||||||||
| 96 | |||||||||||||||||||||
| 97 | 0 | return $self; | |||||||||||||||||||
| 98 | } | ||||||||||||||||||||
| 99 | |||||||||||||||||||||
| 100 | 2 | 1; | |||||||||||||||||||
| 101 | |||||||||||||||||||||
| 102 | __END__ | ||||||||||||||||||||