line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/local/bin/perl -w |
2
|
|
|
|
|
|
|
###################################################################### |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# DNS/Config/File.pm |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# $Id: File.pm,v 1.5 2003/02/16 10:15:31 awolf Exp $ |
7
|
|
|
|
|
|
|
# $Revision: 1.5 $ |
8
|
|
|
|
|
|
|
# $Author: awolf $ |
9
|
|
|
|
|
|
|
# $Date: 2003/02/16 10:15:31 $ |
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::File; |
19
|
|
|
|
|
|
|
|
20
|
2
|
|
|
2
|
|
1280
|
no warnings 'portable'; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
77
|
|
21
|
2
|
|
|
2
|
|
24
|
use 5.6.0; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
77
|
|
22
|
2
|
|
|
2
|
|
10
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
56
|
|
23
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
712
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
my $VERSION = '0.66'; |
26
|
|
|
|
|
|
|
my $REVISION = sprintf("%d.%02d", q$Revision: 1.5 $ =~ /(\d+)\.(\d+)/); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub new { |
29
|
1
|
|
|
1
|
0
|
23
|
my($pkg, %hash) = @_; |
30
|
1
|
|
|
|
|
2
|
my $ref; |
31
|
|
|
|
|
|
|
|
32
|
1
|
|
|
|
|
6
|
my $type = 'DNS::Config::File::' . ucfirst $hash{'type'}; |
33
|
1
|
|
|
|
|
2
|
my $file = $hash{'file'}; |
34
|
1
|
|
|
|
|
3
|
my $conf = $hash{'config'}; |
35
|
|
|
|
|
|
|
|
36
|
1
|
|
|
|
|
89
|
eval "require $type"; |
37
|
|
|
|
|
|
|
|
38
|
1
|
50
|
|
|
|
9
|
if(!$@) { |
39
|
1
|
|
|
|
|
7
|
$ref = $type->new($file, $conf); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
else { |
42
|
0
|
|
|
|
|
0
|
warn $@; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
1
|
|
|
|
|
6
|
return $ref; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub read { |
49
|
1
|
|
|
1
|
0
|
3
|
my($self, $file) = @_; |
50
|
1
|
|
|
|
|
2
|
my @lines; |
51
|
|
|
|
|
|
|
|
52
|
1
|
|
33
|
|
|
10
|
$file = $file || $self->{'FILE'}; |
53
|
|
|
|
|
|
|
|
54
|
1
|
50
|
|
|
|
41
|
if(open(FILE, $file)) { |
55
|
1
|
|
|
|
|
18
|
@lines = ; |
56
|
1
|
|
|
|
|
4
|
chomp @lines; |
57
|
1
|
|
|
|
|
9
|
close FILE; |
58
|
|
|
|
|
|
|
} |
59
|
0
|
|
|
|
|
0
|
else { warn "File $file not found !\n"; } |
60
|
|
|
|
|
|
|
|
61
|
1
|
|
|
|
|
7
|
return @lines; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub parse { |
65
|
0
|
|
|
0
|
0
|
|
my($self, $file) = @_; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
# Overwrite in sub classes ! |
68
|
|
|
|
|
|
|
|
69
|
0
|
|
|
|
|
|
return $self; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub dump { |
73
|
0
|
|
|
0
|
0
|
|
my($self, $file) = @_; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
# Overwrite in sub classes ! |
76
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
|
return $self; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub debug { |
81
|
0
|
|
|
0
|
0
|
|
my($self) = @_; |
82
|
|
|
|
|
|
|
|
83
|
0
|
0
|
|
|
|
|
return undef unless($self->{'CONFIG'}); |
84
|
|
|
|
|
|
|
|
85
|
0
|
|
|
|
|
|
eval { |
86
|
2
|
|
|
2
|
|
1114
|
use Data::Dumper; |
|
2
|
|
|
|
|
17578
|
|
|
2
|
|
|
|
|
239
|
|
87
|
|
|
|
|
|
|
|
88
|
0
|
|
|
|
|
|
print Dumper($self->{'CONFIG'}); |
89
|
|
|
|
|
|
|
}; |
90
|
|
|
|
|
|
|
|
91
|
0
|
|
|
|
|
|
return 1; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
1; |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
__END__ |