blib/lib/BIND/Conf_Parser.pm

filter: Statementstmt 5.1% 30 / 578 Branchbran 0.0% 0 / 264 Conditioncond 0.0% 0 / 36 MC/DCmcdc 0.0% 0 / 23 Subroutinesub 15.0% 9 / 60 Podpod 30.4% 14 / 46 totaltotal 5.2% 53 / 1007 CC 152 SCAR 46.5
CC
152
Cov
3%
parse_zone
342.0
parse_logging_channel
272.0
parse_conf
240.0
CRAP 104.7
↑ Summary
1 #
2 # BIND::Conf_Parser - Parser class for BIND configuration files
3 #
4 package BIND::Conf_Parser;
5  
6 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use integer;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 1 $VERSION = "0.95";
13  
14 # token classes
15 1 ▶use constant WORD => 'W';
Subroutine BEGIN: called CC=1 SCAR=0.0
16 1 ▶use constant STRING => '"';
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 ▶use constant NUMBER => '#';
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1 ▶use constant IPADDR => '.';
Subroutine BEGIN: called CC=1 SCAR=0.0
19 1 ▶use constant ENDoFILE => '';
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 0 ▶sub choke {
Subroutine choke: not called CC=1 SCAR=6.9
Pod undocumented
22 0 shift;
23 0 confess "parse error: ", @_
24 }
25  
26 0 ▶sub set_toke($$;$) {
Subroutine set_toke: not called CC=1 SCAR=6.9
Pod undocumented
27 0 my($self, $token, $data) = @_;
28 0 $self->{_token} = $token;
29 0 $self->{_data} = $data;
30 }
31  
32  
33 0 ▶sub where($;$) {
Subroutine where: not called CC=2 SCAR=17.9
Pod undocumented
34 0 my $self = shift;
35 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 0 0 0
36 0 $self->{_file} . ":" . $_[0]
37 } else {
38 $self->{_file} . ":" . $self->{_line}
39 0 }
40 }
41  
42 0 ▶sub read_line($) {
Subroutine read_line: not called CC=1 SCAR=6.9
Pod undocumented
43 0 my $self = shift;
44 0 $self->{_line}++;
45 0 chomp($self->{_curline} = $self->{_fh}->getline);
46 }
47  
48 0 ▶sub check_comment($) {
Subroutine check_comment: not called CC=8 SCAR=42.8
Pod undocumented
49 0 my $self = shift;
50 0 for my $i ($self->{_curline}) {
51 0 ▶ $i=~m:\G#.*:gc and last;
Branch: 1 branch
BranchTrueFalseTotal
$i =~ /\G#.*/cg and last 0 0 0
52 0 ▶ $i=~m:\G//.*:gc and last;
Branch: 1 branch
BranchTrueFalseTotal
$i =~ m[\G//.*]cg and last 0 0 0
53 0 ▶ if ($i=~m:\G/\*:gc) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i =~ m[\G/\*]cg) 0 0 0
54 0 my($line) = $self->{_line};
55 0 ▶ until ($i=~m:\G.*?\*/:gc) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($i =~ m[\G.*?\*/]cg) 0 0 0
56 0 ▶ $self->read_line || $i ne "" ||
Branch: 1 branch
BranchTrueFalseTotal
$self->read_line or $i ne "" or $self->choke("EOF in comment starting at ", $self->where($line)) 0 0 0
Condition0%0/3
$self->read_line or $i ne ""
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->read_line or $i ne ""
$self->read_line $i ne ""
Truth table0%0/3
A or B
A= $self->read_lineB= $i ne ""
ABresult
1X1
011
000
57 $self->choke("EOF in comment starting at ",
58 $self->where($line));
59 }
60 }
61 0 return 0
62 }
63 0 return 1
64 }
65  
66 0 ▶sub lex_string($) {
Subroutine lex_string: not called CC=6 SCAR=37.4
Pod undocumented
67 0 my $self = shift;
68 0 my($s, $line);
69 0 $line = $self->{_line};
70 0 $s = "";
71 0 LOOP: for my $i ($self->{_curline}) {
72 # the lexer in bind doesn't implement backslash escapes of any kind
73 # $i=~/\G([^"\\]+)/gc and do { $s .= $1; redo LOOP };
74 # $i=~/\G\\(["\\])/gc and do { $s .= $1; redo LOOP };
75 0 ▶ $i=~/\G([^"]+)/gc and do { $s .= $1; redo LOOP };
Branch: 1 branch
BranchTrueFalseTotal
$i =~ /\G([^"]+)/cg and do { $s .= $1; redo LOOP } 0 0 0
76 0 ▶ $i=~/\G"/gc and $self->set_toke(STRING, $s), return;
Branch: 1 branch
BranchTrueFalseTotal
$i =~ /\G"/cg and $self->set_toke("\"", $s), return 0 0 0
77 # Must be at the end of the line
78 0 ▶ if ($self->read_line) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->read_line) { } 0 0 0
elsif ($i eq '') { } 0 0 0
79 0 $s .= "\n";
80 } elsif ($i eq "") {
81 0 $self->choke("EOF in quoted string starting at ",
82 $self->where($line));
83 }
84 0 redo LOOP;
85 }
86 }
87  
88 0 ▶sub lex_ident($$) {
Subroutine lex_ident: not called CC=3 SCAR=24.8
Pod undocumented
89 0 my $self = shift;
90 0 my($i) = @_;
91 0 ▶ while (! $self->check_comment &&
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->check_comment and $self->{"_curline"} =~ m[\G([^/"*!{};\s]+)]cg) 0 0 0
Condition0%0/3
not $self->check_comment and $self->{"_curline"} =~ m[\G([^/"*!{};\s]+)]cg
!ll&&!rl&&r
000
MC/DC0%0/2
not $self->check_comment and $self->{"_curline"} =~ m[\G([^/"*!{};\s]+)]cg
not $self->check_comment $self->{"_curline"} =~ m[\G([^/"*!{};\s]+)]cg
Truth table0%0/3
not(A) and B
A= not $self->check_commentB= $self->{"_curline"} =~ m[\G([^/"*!{};\s]+)]cg
ABresult
0X0
100
111
92 $self->{_curline} =~ m:\G([^/"*!{};\s]+):gc) {
93 0 $i .= $1;
94 }
95 0 $self->set_toke(WORD, $i);
96 }
97  
98 0 ▶sub lex_ipv4($$) {
Subroutine lex_ipv4: not called CC=11 SCAR=48.8
Pod undocumented
99 0 my $self = shift;
100 0 my($i) = @_;
101 0 LOOP: for my $j ($self->{_curline}) {
102 0 ▶ $self->check_comment and last LOOP;
Branch: 1 branch
BranchTrueFalseTotal
$self->check_comment and last LOOP 0 0 0
103 0 ▶ $j=~/\G(\d+)/gc and do { $i .= $1; redo LOOP };
Branch: 1 branch
BranchTrueFalseTotal
$j =~ /\G(\d+)/cg and do { $i .= $1; redo LOOP } 0 0 0
104 0 ▶ $j=~/\G(\.\.)/gc ||
Branch: 1 branch
BranchTrueFalseTotal
$j =~ /\G(\.\.)/cg || $j =~ m[\G([^./"*!{};\s]+)]cg and $self->lex_ident("$i$1"), return 0 0 0
Condition0%0/3
$j =~ /\G(\.\.)/cg or $j =~ m[\G([^./"*!{};\s]+)]cg
l!l&&r!l&&!r
000
MC/DC0%0/2
$j =~ /\G(\.\.)/cg or $j =~ m[\G([^./"*!{};\s]+)]cg
$j =~ /\G(\.\.)/cg $j =~ m[\G([^./"*!{};\s]+)]cg
Truth table0%0/3
A or B
A= $j =~ /\G(\.\.)/cgB= $j =~ m[\G([^./"*!{};\s]+)]cg
ABresult
1X1
011
000
105 $j=~m:\G([^./"*!{};\s]+):gc and $self->lex_ident("$i$1"), return;
106 0 ▶ $j=~/\G\./gc and do { $i .= "."; redo LOOP };
Branch: 1 branch
BranchTrueFalseTotal
$j =~ /\G\./cg and do { $i .= '.'; redo LOOP } 0 0 0
107 }
108 0 my($dots);
109 0 $dots = $i =~ tr/././;
110 0 ▶ if ($dots > 3 || substr($i, -1) eq '.') {
Branch: 1 branch
BranchTrueFalseTotal
if ($dots > 3 or substr($i, -1) eq ".") 0 0 0
Condition0%0/3
$dots > 3 or substr($i, -1) eq "."
l!l&&r!l&&!r
000
MC/DC0%0/2
$dots > 3 or substr($i, -1) eq "."
$dots > 3 substr($i, -1) eq "."
Truth table0%0/3
A or B
A= $dots > 3B= substr($i, -1) eq "."
ABresult
1X1
011
000
111 0 $self->set_toke(WORD, $i);
112 return
113 0 }
114 0 ▶ if ($dots == 1) {
Branch: 2 branches
BranchTrueFalseTotal
if ($dots == 1) { } 0 0 0
elsif ($dots == 2) { } 0 0 0
115 0 $i .= ".0.0";
116 } elsif ($dots == 2) {
117 0 $i .= ".0";
118 }
119 0 $self->set_toke(IPADDR, $i);
120 }
121  
122 0 ▶sub lex_number($$) {
Subroutine lex_number: not called CC=6 SCAR=37.4
Pod undocumented
123 0 my $self = shift;
124 0 my($n) = @_;
125 0 LOOP: for my $i ($self->{_curline}) {
126 0 ▶ $self->check_comment and last LOOP;
Branch: 1 branch
BranchTrueFalseTotal
$self->check_comment and last LOOP 0 0 0
127 0 ▶ $i=~/\G(\d+)/gc and do { $n .= $1; redo LOOP };
Branch: 1 branch
BranchTrueFalseTotal
$i =~ /\G(\d+)/cg and do { $n .= $1; redo LOOP } 0 0 0
128 0 ▶ $i=~/\G\./gc and $self->lex_ipv4("$n."), return;
Branch: 1 branch
BranchTrueFalseTotal
$i =~ /\G\./cg and $self->lex_ipv4("$n."), return 0 0 0
129 0 ▶ $i=~m:\G([^/"*!{};\s]+):gc and $self->lex_ident("$n$1"), return;
Branch: 1 branch
BranchTrueFalseTotal
$i =~ m[\G([^/"*!{};\s]+)]cg and $self->lex_ident("$n$1"), return 0 0 0
130 }
131 0 $self->set_toke(NUMBER, $n);
132 }
133  
134 0 ▶sub lex($) {
Subroutine lex: not called CC=11 SCAR=48.8
Pod undocumented
135 0 my $self = shift;
136 0 OUTER: while(1) { for my $i ($self->{_curline}) {
137 INNER: {
138 0 ▶ $self->check_comment and last INNER;
Branch: 1 branch
BranchTrueFalseTotal
$self->check_comment and last INNER 0 0 0
139 0 ▶ $i=~/\G\s+/gc and redo;
Branch: 1 branch
BranchTrueFalseTotal
$i =~ /\G\s+/cg and redo 0 0 0
140 0 ▶ $i=~m:\G([*/!{};]):gc and $self->set_toke($1), last OUTER;
Branch: 1 branch
BranchTrueFalseTotal
$i =~ m[\G([*/!{};])]cg and $self->set_toke($1), last OUTER 0 0 0
141 0 ▶ $i=~/\G"/gc and $self->lex_string(), last OUTER;
Branch: 1 branch
BranchTrueFalseTotal
$i =~ /\G"/cg and $self->lex_string, last OUTER 0 0 0
142 0 ▶ $i=~/\G(\d+)/gc and $self->lex_number($1), last OUTER;
Branch: 1 branch
BranchTrueFalseTotal
$i =~ /\G(\d+)/cg and $self->lex_number($1), last OUTER 0 0 0
143 0 ▶ $i=~/\G(.)/gc and $self->lex_ident($1), last OUTER;
Branch: 1 branch
BranchTrueFalseTotal
$i =~ /\G(.)/cg and $self->lex_ident($1), last OUTER 0 0 0
144 }
145 0 ▶ $i=~/\G\Z/gc or $self->choke("Unknown character at ", $self->where);
Branch: 1 branch
BranchTrueFalseTotal
$i =~ /\G\Z/cg or $self->choke("Unknown character at ", $self->where) 0 0 0
146 0 ▶ $self->read_line || $i ne "" or $self->set_toke(ENDoFILE), last OUTER;
Branch: 1 branch
BranchTrueFalseTotal
$self->read_line or $i ne "" or $self->set_toke("\4"), last OUTER 0 0 0
Condition0%0/3
$self->read_line or $i ne ""
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->read_line or $i ne ""
$self->read_line $i ne ""
Truth table0%0/3
A or B
A= $self->read_lineB= $i ne ""
ABresult
1X1
011
000
147 } }
148 0 return $self;
149 }
150  
151 0 ▶sub t2d($) {
Subroutine t2d: not called CC=6 SCAR=37.4
Pod undocumented
152 0 my $self = shift;
153 0 ▶ $self->{_token} eq WORD and return qq('$self->{_data}');
Branch: 1 branch
BranchTrueFalseTotal
$self->{"_token"} eq "W" and return qq['$self->{"_data"}'] 0 0 0
154 0 ▶ $self->{_token} eq STRING and return qq("$self->{_data}");
Branch: 1 branch
BranchTrueFalseTotal
$self->{"_token"} eq "\"" and return qq["$self->{"_data"}"] 0 0 0
155 $self->{_token} eq NUMBER ||
156 0 ▶ $self->{_token} eq IPADDR and return $self->{_data};
Branch: 1 branch
BranchTrueFalseTotal
$self->{"_token"} eq "#" || $self->{"_token"} eq "." and return $self->{"_data"} 0 0 0
Condition0%0/3
$self->{"_token"} eq "#" or $self->{"_token"} eq "."
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"_token"} eq "#" or $self->{"_token"} eq "."
$self->{"_token"} eq "#" $self->{"_token"} eq "."
Truth table0%0/3
A or B
A= $self->{"_token"} eq "#"B= $self->{"_token"} eq "."
ABresult
1X1
011
000
157 0 ▶ $self->{_token} eq ENDoFILE and return "<end of file>";
Branch: 1 branch
BranchTrueFalseTotal
$self->{"_token"} eq "\4" and return "<end of file>" 0 0 0
158 0 return qq('$self->{_token}');
159 }
160  
161 0 ▶sub t2n($;$) {
Subroutine t2n: not called CC=3 SCAR=24.8
Pod undocumented
162 0 my($token, $need_article);
163 my($map) = {
164 WORD , [ an => "identifier"],
165 STRING , [ a => "string"],
166 NUMBER , [ a => "number"],
167 IPADDR , [ an => "IP address"],
168 ENDoFILE , [ "End of File"],
169 '*' , [ an => "asterisk"],
170 '!' , [ an => "exclamation point"],
171 '{' , [ an => "open brace"],
172 '}' , [ a => "close brace"],
173 ';' , [ a => "semicolon"],
174 0 }->{$token};
175 0 ▶ return "Fwuh? `$token'" unless $map;
Branch: 1 branch
BranchTrueFalseTotal
unless $map 0 0 0
176 0 ▶ if ($need_article) {
Branch: 1 branch
BranchTrueFalseTotal
if ($need_article) { } 0 0 0
177 0 join(" ", @{ $map })
178 } else {
179 0 $map->[-1]
180 }
181 }
182  
183 0 ▶sub expect($$$;$) {
Subroutine expect: not called CC=11 SCAR=48.8
Pod undocumented
184 0 my $self = shift;
185 0 my($token, $mess, $nolex) = @_;
186 0 ▶ $self->lex unless $nolex;
Branch: 1 branch
BranchTrueFalseTotal
unless $nolex 0 0 0
187 0 ▶ $token = [ $token ] unless ref $token;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $token 0 0 0
188 0 foreach (@{ $token }) {
189 0 ▶ if (ref $_) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_) { } 0 0 0
190 0 ▶ next unless $self->{_token} eq WORD;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"_token"} eq "W" 0 0 0
191 0 foreach (@$_) {
192 0 ▶ return if $_ eq $self->{_data};
Branch: 1 branch
BranchTrueFalseTotal
if $_ eq $self->{"_data"} 0 0 0
193 }
194 0 $self->choke("Invalid identifier `", $self->{_data}, "' at ",
195 $self->where);
196 } else {
197 0 ▶ return if $_ eq $self->{_token};
Branch: 1 branch
BranchTrueFalseTotal
if $_ eq $self->{"_token"} 0 0 0
198 }
199 }
200 0 ▶ if (@{ $token } == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$token;} == 1) { } 0 0 0
201 0 $token = ${ $token }[0];
202 0 ▶ $token = WORD if ref $token;
Branch: 1 branch
BranchTrueFalseTotal
if ref $token 0 0 0
203 0 $self->choke("Expected ", t2n($token, 1), ", saw ",
204 $self->t2d, " $mess at ", $self->where);
205 } else {
206 0 $self->choke("Unexpected ", t2n($self->{_token}), " (",
207 $self->t2d, ") $mess at ", $self->where);
208 }
209 }
210  
211 0 ▶sub open_file($$) {
Subroutine open_file: not called CC=2 SCAR=17.9
Pod undocumented
212 0 require IO::File;
213 0 my $self = shift;
214 0 my($file) = @_;
215 0 ▶ $self->{_fh} = IO::File->new($file, "r")
Branch: 1 branch
BranchTrueFalseTotal
$self->{"_fh"} = "IO::File"->new($file, "r") or croak("Unable to open $file for reading: $!") 0 0 0
216 or croak "Unable to open $file for reading: $!";
217 0 $self->{_file} = $file;
218 }
219  
220 0 ▶sub parse_bool($$) {
Subroutine parse_bool: not called CC=2 SCAR=17.9
Pod undocumented
221 0 my($self, $mess) = @_;
222 0 $self->expect([ WORD, STRING, NUMBER ], $mess);
223 my($value) = {
224 "yes" => 1,
225 "no" => 0,
226 "true" => 1,
227 "false" => 0,
228 "1" => 1,
229 "0" => 0,
230 0 }->{$self->{_data}};
231 0 ▶ return $value if defined $value;
Branch: 1 branch
BranchTrueFalseTotal
if defined $value 0 0 0
232 0 $self->choke("Expected a boolean, saw `", $self->{_data}, "' at ",
233 $self->where);
234 }
235 0 ▶sub parse_addrmatchlist($$;$) {
Subroutine parse_addrmatchlist: not called CC=8 SCAR=42.8
Pod undocumented
236 0 my($self, $mess, $nolex) = @_;
237 0 $self->expect('{', $mess, $nolex);
238 0 my(@items, $negated, $data);
239 0 while(1) {
240 0 $negated = 0;
241 0 $self->expect([ IPADDR, NUMBER, WORD, STRING, '!', '{', '}' ], $mess);
242 0 ▶ last if $self->{_token} eq '}';
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_token"} eq "}" 0 0 0
243 0 ▶ if ($self->{_token} eq '!') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_token"} eq "!") 0 0 0
244 0 $negated = 1;
245 0 $self->expect([ IPADDR, NUMBER, WORD, STRING, '{' ],
246 "following `!'");
247 }
248 0 ▶ if ($self->{_token} eq '{') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_token"} eq "{") 0 0 0
249 0 push @items, [ $negated, $self->parse_addrmatchlist($mess, 1) ];
250 next
251 0 }
252 0 ▶ if ($self->{_token} eq WORD || $self->{_token} eq STRING) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_token"} eq "W" or $self->{"_token"} eq "\"") 0 0 0
Condition0%0/3
$self->{"_token"} eq "W" or $self->{"_token"} eq "\""
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"_token"} eq "W" or $self->{"_token"} eq "\""
$self->{"_token"} eq "W" $self->{"_token"} eq "\""
Truth table0%0/3
A or B
A= $self->{"_token"} eq "W"B= $self->{"_token"} eq "\""
ABresult
1X1
011
000
253 0 push @items, [ $negated, "acl", $self->{_data} ];
254 next
255 0 }
256 0 $data = $self->{_data};
257 0 ▶ $self->expect( $self->{_token} eq NUMBER ? '/' : [ '/', ';' ], $mess);
Branch: 1 branch
BranchTrueFalseTotal
$self->{'_token'} eq '#' ? : 0 0 0
258 0 ▶ if ($self->{_token} eq ';') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_token"} eq ";") 0 0 0
259 0 push @items, [ $negated, $data ];
260 redo # we already slurped the ';'
261 0 }
262 0 $self->expect(NUMBER, "following `/'");
263 0 push @items, [ $negated, $data, $self->{_data} ];
264 } continue {
265 0 $self->expect(';', $mess);
266 }
267 return \@items
268 0 }
269 0 ▶sub parse_addrlist($$) {
Subroutine parse_addrlist: not called CC=2 SCAR=17.9
Pod undocumented
270 0 my($self, $mess) = @_;
271 0 $self->expect('{', $mess);
272 0 my(@addrs);
273 0 while (1) {
274 0 $self->expect([ IPADDR, '}' ], $mess);
275 0 ▶ last if $self->{_token} eq '}';
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_token"} eq "}" 0 0 0
276 0 push @addrs, $self->{_data};
277 0 $self->expect(';', "reading address list");
278 }
279 0 return \@addrs;
280 # return \@addrs if @addrs;
281 # $self->choke("Expected at least one IP address, saw none at ",
282 # $self->where);
283 }
284 0 ▶sub parse_size($$) {
Subroutine parse_size: not called CC=2 SCAR=17.9
Pod undocumented
285 0 my($self, $mess) = @_;
286 0 $self->expect([ WORD, STRING ], $mess);
287 0 my($data) = $self->{_data};
288 0 ▶ if ($data =~ /^(\d+)([kmg])$/i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($data =~ /^(\d+)([kmg])$/i) 0 0 0
289 return $1 * {
290 'k' => 1024,
291 'm' => 1024*1024,
292 'g' => 1024*1024*1024,
293 0 }->{lc($2)};
294 }
295 0 $self->choke("Expected size string, saw `$data' at ", $self->where);
296 }
297 0 ▶sub parse_forward($$) {
Subroutine parse_forward: not called CC=1 SCAR=6.9
Pod undocumented
298 0 my($self, $mess) = @_;
299 0 $self->expect([[qw(only first)]], $mess);
300 0 return $self->{_data};
301 }
302 0 ▶sub parse_transfer_format($$) {
Subroutine parse_transfer_format: not called CC=1 SCAR=6.9
Pod undocumented
303 0 my($self, $mess) = @_;
304 0 $self->expect([[qw(one-answer many-answers)]], $mess);
305 0 return $self->{_data};
306 }
307 0 ▶sub parse_check_names($$) {
Subroutine parse_check_names: not called CC=1 SCAR=6.9
Pod undocumented
308 0 my($self, $mess) = @_;
309 0 $self->expect([[qw(warn fail ignore)]], $mess);
310 0 return $self->{_data};
311 }
312 0 ▶sub parse_pubkey($$) {
Subroutine parse_pubkey: not called CC=3 SCAR=24.8
Pod undocumented
313 0 my($self, $mess) = @_;
314 0 my($flags, $proto, $algo);
315 0 $self->expect([ NUMBER, WORD, STRING ], $mess);
316 0 $flags = $self->{_data};
317 0 ▶ if ($self->{_token} ne NUMBER) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_token"} ne "#") 0 0 0
318 0 ▶ $flags = oct($flags) if $flags =~ /^0/;
Branch: 1 branch
BranchTrueFalseTotal
if $flags =~ /^0/ 0 0 0
319 }
320 0 $self->expect(NUMBER, $mess);
321 0 $proto = $self->{_data};
322 0 $self->expect(NUMBER, $mess);
323 0 $algo = $self->{_data};
324 0 $self->expect(STRING, $mess);
325 0 return [ $flags, $proto, $algo, $self->{_data} ];
326 }
327  
328 0 ▶sub parse_logging_category($) {
Subroutine parse_logging_category: not called CC=2 SCAR=17.9
Pod undocumented
329 0 my $self = shift;
330 0 $self->expect([ WORD, STRING ], "following `category'");
331 0 my($name) = $self->{_data};
332 0 $self->expect('{', "following `category $name'");
333 0 my(@names);
334 0 while (1) {
335 0 $self->expect([ WORD, STRING, '}' ], "reading category `$name'");
336 0 ▶ last if $self->{_token} eq '}';
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_token"} eq "}" 0 0 0
337 0 push @names, $self->{_data};
338 0 $self->expect(';', "reading category `$name'");
339 }
340 0 $self->expect(';', "to finish category `$name'");
341 0 $self->handle_logging_category($name, \@names);
342 }
343  
344 0 ▶sub parse_logging_channel($) {
Subroutine parse_logging_channel: not called CC=16 SCAR=56.1
Pod undocumented
345 0 my $self = shift;
346 0 $self->expect([ WORD, STRING ], "following `channel'");
347 0 my($name) = $self->{_data};
348 0 $self->expect('{', "following `channel $name'");
349 0 my(%options, $temp);
350 0 while (1) {
351 0 $self->expect([ [ qw(file syslog null severity print-category
352 print-severity print-time) ], '}' ],
353 "reading channel `$name'");
354 0 ▶ last if $self->{_token} eq '}';
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_token"} eq "}" 0 0 0
355 0 $temp = $self->{_data};
356 0 ▶ if ($temp =~ /^print-/) {
Branch: 5 branches
BranchTrueFalseTotal
if ($temp =~ /^print-/) { } 0 0 0
elsif ($temp eq 'null') { } 0 0 0
elsif ($temp eq 'file') { } 0 0 0
elsif ($temp eq 'syslog') { } 0 0 0
elsif ($temp eq 'severity') { } 0 0 0
357 0 $options{$temp} = $self->parse_bool("following `$temp'");
358 } elsif ($temp eq "null") {
359 $self->choke("Destination already specified for channel `$name'")
360 0 ▶ if exists $options{dest};
Branch: 1 branch
BranchTrueFalseTotal
if exists $options{"dest"} 0 0 0
361 0 $options{dest} = "null";
362 } elsif ($temp eq "file") {
363 $self->choke("Destination already specified for channel `$name'")
364 0 ▶ if exists $options{dest};
Branch: 1 branch
BranchTrueFalseTotal
if exists $options{"dest"} 0 0 0
365 0 $self->expect(STRING, "following `file'");
366 0 $options{dest} = $self->{_data};
367 0 while(1) {
368 0 $self->expect([ [ qw(version size) ], ';' ],
369 "reading channel `$name' file specifier");
370 0 ▶ last if $self->{_token} eq ';';
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_token"} eq ";" 0 0 0
371 0 ▶ if ($self->{_data} eq "size") {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'_data'} eq 'size') { } 0 0 0
372 0 $options{size} = $self->parse_size("following `size'");
373 } else { # versions
374 0 $self->expect([ WORD, NUMBER ], "following `versions'");
375 0 ▶ if ($self->{_token} eq NUMBER) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'_token'} eq '#') { } 0 0 0
elsif ($self->{'_data'} eq 'unlimited') { } 0 0 0
376 0 $options{versions} = $self->{_data};
377 } elsif ($self->{_data} eq "unlimited") {
378 0 $options{versions} = -1;
379 0 } else { $self->choke("Unexpected identifier following ",
380 "`versions' at ", $self->where);
381 }
382 }
383 }
384 redo # already slurped ';'
385 0 } elsif ($temp eq "syslog") {
386 $self->choke("Destination already specified for channel `$name'")
387 0 ▶ if exists $options{dest};
Branch: 1 branch
BranchTrueFalseTotal
if exists $options{"dest"} 0 0 0
388 0 $self->expect([[qw(kern user mail daemon auth syslog lpr news
389 uucp cron authpriv ftp local0 local1 local2
390 local3 local4 local5 local6 local7)]],
391 "following `syslog'");
392  
393 0 $options{dest} = "syslog " . $self->{_data};
394 } elsif ($temp eq "severity") {
395 0 $self->expect([[qw(critical error warning notice info debug
396 dynamic)]], "following `severity'");
397 0 $options{severity} = $self->{_data};
398 0 ▶ if ($options{severity} eq "debug") {
Branch: 1 branch
BranchTrueFalseTotal
if ($options{"severity"} eq "debug") 0 0 0
399 0 $self->expect([ NUMBER, ';' ], "reading channel `$name'");
400 0 ▶ if ($self->{_token} eq NUMBER) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'_token'} eq '#') { } 0 0 0
401 0 $options{severity} .= " " . $self->{_data};
402 } else {
403 redo # already slurped the ';'
404 0 }
405 }
406 }
407 } continue {
408 0 $self->expect(';', "reading channel `$name'");
409 }
410 0 $self->expect(';', "to finish channel `$name'");
411 0 $self->handle_logging_channel($name, \%options);
412 }
413  
414 0 ▶sub parse_logging($) {
Subroutine parse_logging: not called CC=3 SCAR=24.8
Pod undocumented
415 0 my $self = shift;
416 0 $self->expect('{', "following `logging'");
417 0 while (1) {
418 0 $self->expect([ [ qw(category channel) ], '}' ],
419 "reading logging options");
420 0 ▶ last if $self->{_token} eq '}';
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_token"} eq "}" 0 0 0
421 0 ▶ if ($self->{_data} eq "category") {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'_data'} eq 'category') { } 0 0 0
422 0 $self->parse_logging_category;
423 } else { # channel
424 0 $self->parse_logging_channel;
425 }
426 }
427 0 $self->expect(';', "to finish logging declaration");
428 }
429  
430 my(%opt_table) = (
431 "version" => STRING,
432 "directory" => STRING,
433 "named-xfer" => STRING,
434 "dump-file" => STRING,
435 "memstatistics-file" => STRING,
436 "pid-file" => STRING,
437 "statistics-file" => STRING,
438 "auth-nxdomain" => \&parse_bool,
439 "deallocate-on-exit" => \&parse_bool,
440 "dialup" => \&parse_bool,
441 "fake-iquery" => \&parse_bool,
442 "fetch-glue" => \&parse_bool,
443 0 ▶ "has-old-clients" => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
444 0 my($self, $mess) = @_;
445 0 my($arg) = $self->parse_bool("following `has-old-clients'");
446 0 $self->handle_option("auth-nxdomain", $arg);
447 0 $self->handle_option("maintain-ixfr-base", $arg);
448 0 $self->handle_option("rfc2308-type1", ! $arg);
449 0 return (0, 0, 1);
450 },
451 "host-statistics" => \&parse_bool,
452 "multiple-cnames" => \&parse_bool,
453 "notify" => \&parse_bool,
454 "recursion" => \&parse_bool,
455 "rfc2308-type1" => \&parse_bool,
456 "use-id-pool" => \&parse_bool,
457 "treat-cr-as-space" => \&parse_bool,
458 "also-notify" => \&parse_addrlist,
459 "forward" => \&parse_forward,
460 "forwarders" => \&parse_addrlist,
461 0 ▶ "check-names" => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
462 0 my($self, $mess) = @_;
463 0 $self->expect([[qw(master slave response)]], $mess);
464 0 my($type);
465 0 $type = $self->{_data};
466 0 return [$type, $self->parse_check_names($mess)
467 ];
468 },
469 "allow-query" => \&parse_addrmatchlist,
470 "allow-transfer" => \&parse_addrmatchlist,
471 "allow-recursion" => \&parse_addrmatchlist,
472 "blackhole" => \&parse_addrmatchlist,
473 0 ▶ "listen-on" => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
474 0 my($self, $mess) = @_;
475 0 $self->expect([ [ 'port' ], '{' ], $mess);
476 0 my($port);
477 0 ▶ if ($self->{_token} eq WORD) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'_token'} eq 'W') { } 0 0 0
478 0 $self->expect(NUMBER, "following `port'");
479 0 $port = 0 + $self->{_data};
480 0 $self->expect('{', $mess);
481 } else {
482 0 $port = 53;
483 }
484 0 return [$port, $self->parse_addrmatchlist($mess, 1)];
485 },
486 0 ▶ "query-source" => sub {
Subroutine __ANON__: not called CC=8 SCAR=42.8
487 0 my($self, $mess) = @_;
488 0 my($port, $address) = (0, 0);
489 0 $self->expect([[qw(port address)]], $mess);
490 0 ▶ if ($self->{_data} eq "address") {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'_data'} eq 'address') { } 0 0 0
491 0 $self->expect([ IPADDR, '*' ], "following `address'");
492 0 ▶ $address = $self->{_token} eq '*' ? 0 : $self->{_data};
Branch: 1 branch
BranchTrueFalseTotal
$self->{'_token'} eq '*' ? : 0 0 0
493 0 $self->expect([ [ 'port' ], ';' ], $mess);
494 0 ▶ if ($self->{_token} eq WORD) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_token"} eq "W") 0 0 0
495 0 $self->expect([ NUMBER, '*' ], "following `port'");
496 0 ▶ $port = $self->{_token} eq '*' ? 0 : $self->{_data};
Branch: 1 branch
BranchTrueFalseTotal
$self->{'_token'} eq '*' ? : 0 0 0
497 }
498 } else { #port
499 0 $self->expect([ NUMBER, '*' ], "following `port'");
500 0 ▶ $port = $self->{_token} eq '*' ? 0 : $self->{_data};
Branch: 1 branch
BranchTrueFalseTotal
$self->{'_token'} eq '*' ? : 0 0 0
501 0 $self->expect([ [ 'address' ], ';' ], $mess);
502 0 ▶ if ($self->{_token} eq WORD) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_token"} eq "W") 0 0 0
503 0 $self->expect([ IPADDR, '*' ], "following `address'");
504 0 ▶ $address = $self->{_token} eq '*' ? 0 : $self->{_data};
Branch: 1 branch
BranchTrueFalseTotal
$self->{'_token'} eq '*' ? : 0 0 0
505 }
506 }
507 # Blech. We need to signal that we ate the ';'.
508 0 return ([$port, $address], $self->{_token} eq ';');
509 },
510 "lame-ttl" => NUMBER,
511 "max-transfer-time-in" => NUMBER,
512 "max-ncache-ttl" => NUMBER,
513 "min-roots" => NUMBER,
514 "serial-queries" => NUMBER,
515 "transfer-format" => \&parse_transfer_format,
516 "transfers-in" => NUMBER,
517 "transfers-out" => NUMBER,
518 "transfers-per-ns" => NUMBER,
519 "transfer-source" => IPADDR,
520 "maintain-ixfr-base" => \&parse_bool,
521 "max-ixfr-log-size" => NUMBER,
522 "coresize" => \&parse_size,
523 "datasize" => \&parse_size,
524 "files" => \&parse_size,
525 "stacksize" => \&parse_size,
526 "cleaning-interval" => NUMBER,
527 "heartbeat-interval" => NUMBER,
528 "interface-interval" => NUMBER,
529 "statistics-interval" => NUMBER,
530 "topology" => \&parse_addrmatchlist,
531 "sortlist" => \&parse_addrmatchlist,
532 0 ▶ "rrset-order" => sub {
Subroutine __ANON__: not called CC=5 SCAR=34.0
533 0 my($self, $mess) = @_;
534 0 $self->expect('{', $mess);
535 0 my(@items, $class, $type, $name);
536 0 $mess = "while reading `rrset-order' list";
537 0 while(1) {
538 0 $class = $type = "any";
539 0 $name = "*";
540 0 $self->expect([[qw(class type name order)], '}'], $mess);
541 0 ▶ last if $self->{_token} eq '}';
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_token"} eq "}" 0 0 0
542 0 ▶ if ($self->{_data} eq "class") {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_data"} eq "class") 0 0 0
543 0 $self->expect([ WORD, STRING ], "following `class'");
544 0 $class = lc($self->{_data});
545 0 $self->expect([[qw(type name order)]], $mess);
546 }
547 0 ▶ if ($self->{_data} eq "type") {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_data"} eq "type") 0 0 0
548 0 $self->expect([ WORD, STRING ], "following `type'");
549 0 $type = lc($self->{_data});
550 0 $self->expect([[qw(name order)]], $mess);
551 }
552 0 ▶ if ($self->{_data} eq "name") {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_data"} eq "name") 0 0 0
553 0 $self->expect(STRING, "following `name'");
554 0 $name = lc($self->{_data});
555 0 $self->expect([[qw(order)]], $mess);
556 }
557 # Must be 'order'
558 0 $self->expect(WORD, "following `order'");
559 0 push(@items, [$class, $type, $name, $self->{_data}]);
560 0 $self->expect(';', $mess);
561 }
562 0 return \@items;
563 },
564 1 );
565  
566 0 ▶sub parse_key($) {
Subroutine parse_key: not called CC=2 SCAR=17.9
Pod undocumented
567 0 my $self = shift;
568 0 $self->expect([ WORD, STRING ], "following `key'");
569 0 my($key, $algo, $secret);
570 0 $key = $self->{_data};
571 0 $self->expect('{', "following key name `$key'");
572 0 $self->expect([[qw(algorithm secret)]], "reading key $key");
573 0 ▶ if ($self->{_data} eq "secret") {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'_data'} eq 'secret') { } 0 0 0
574 0 $self->expect([ WORD, STRING ], "reading secret for key `$key'");
575 0 $secret = $self->{_data};
576 0 $self->expect(';', "reading key `$key'");
577 0 $self->expect([["algorithm"]], "reading key `$key'");
578 0 $self->expect([ WORD, STRING ], "reading algorithm for key `$key'");
579 0 $algo = $self->{_data};
580 } else {
581 0 $self->expect([ WORD, STRING ], "reading algorithm for key `$key'");
582 0 $algo = $self->{_data};
583 0 $self->expect(';', "reading key `$key'");
584 0 $self->expect([["secret"]], "reading key `$key'");
585 0 $self->expect([ WORD, STRING ], "reading secret for key `$key'");
586 0 $secret = $self->{_data};
587 }
588 0 $self->expect(';', "reading key `$key'");
589 0 $self->expect('}', "reading key `$key'");
590 0 $self->expect(';', "to finish key `$key'");
591 0 $self->handle_key($key, $algo, $secret);
592 }
593  
594 0 ▶sub parse_controls($) {
Subroutine parse_controls: not called CC=4 SCAR=30.0
Pod undocumented
595 0 my $self = shift;
596 0 $self->expect('{', "following `controls'");
597 0 while(1) {
598 0 $self->expect([ [ qw(inet unix) ], ';' ], "reading `controls'");
599 0 ▶ last if $self->{_token} eq ';';
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_token"} eq ";" 0 0 0
600 0 ▶ if ($self->{_data} eq "inet") {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'_data'} eq 'inet') { } 0 0 0
601 0 my($addr, $port);
602 0 $self->expect([ IPADDR, '*' ], "following `inet'");
603 0 ▶ $addr = $self->{_token} eq '*' ? 0 : $self->{_data};
Branch: 1 branch
BranchTrueFalseTotal
$self->{'_token'} eq '*' ? : 0 0 0
604 0 $self->expect([["port"]], "following inet address");
605 0 $self->expect(NUMBER, "following `port'");
606 0 $port = 0 + $self->{_data};
607 0 $self->expect([["allow"]], "following port number");
608 0 $self->handle_control("inet", [ $addr, $port,
609 $self->parse_addrmatchlist("following `allow'") ]);
610 } else { # unix
611 0 my($path, $perm, $owner);
612 0 $self->expect(STRING, "following `unix'");
613 0 $path = $self->{_data};
614 0 $self->expect([["perm"]], "following socket path");
615 0 $self->expect(NUMBER, "following `perm'");
616 0 $perm = $self->{_data};
617 0 $self->expect([["owner"]], "following permissions");
618 0 $self->expect(NUMBER, "following `owner'");
619 0 $owner = $self->{_data};
620 0 $self->expect([["group"]], "following owner name");
621 0 $self->expect(NUMBER, "following `group'");
622 $self->handle_control("unix",
623 0 [ $path, $perm, $owner, $self->{_data} ]);
624 }
625 }
626 0 $self->expect('}', "finishing `controls'");
627 }
628  
629 0 ▶sub parse_server($) {
Subroutine parse_server: not called CC=7 SCAR=40.3
Pod undocumented
630 0 my $self = shift;
631 0 $self->expect(IPADDR, "following `server'");
632 0 my($addr, %options);
633 0 $addr = $self->{_data};
634 0 $self->expect('{', "following `server $addr'");
635 0 while (1) {
636 0 $self->expect([ [ qw(bogus support-ixfr transfers
637 transfer-format keys) ] , '}' ],
638 "reading server `$addr'");
639 0 ▶ last if $self->{_token} eq '}';
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_token"} eq "}" 0 0 0
640 0 ▶ if ($self->{_data} eq "bogus") {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_data"} eq "bogus") 0 0 0
641 0 $options{bogus} = $self->parse_bool("following `bogus'");
642 next
643 0 }
644 0 ▶ if ($self->{_data} eq "support-ixfr") {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_data"} eq "support-ixfr") 0 0 0
645 0 $options{"support-ixfr"} =
646 $self->parse_bool("following `support-ixfr'");
647 next
648 0 }
649 0 ▶ if ($self->{_data} eq "transfers") {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_data"} eq "transfers") 0 0 0
650 0 $self->expect(NUMBER, "following `transfers'");
651 0 $options{transfers} = $self->{_data};
652 next
653 0 }
654 0 ▶ if ($self->{_data} eq "transfer-format") {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_data"} eq "transfer-format") 0 0 0
655 0 $options{"transfer-format"} =
656 $self->parse_transfer_format("following `transfer-format'");
657 next
658 0 }
659 # keys
660 0 $self->expect('{', "following `keys'");
661 0 my(@keys);
662 0 while (1) {
663 0 $self->expect([ WORD, STRING, '}' ], "reading key ids");
664 0 ▶ last if $self->{_token} eq '}';
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_token"} eq "}" 0 0 0
665 0 push @keys, $self->{_data};
666 }
667 0 $options{"keys"} = \@keys;
668 } continue {
669 0 $self->expect(';', "reading server `$addr'");
670 }
671 0 $self->expect(';', "to finish server `$addr'");
672 0 $self->handle_server($addr, \%options);
673 }
674  
675 0 ▶sub parse_trusted_keys($) {
Subroutine parse_trusted_keys: not called CC=2 SCAR=17.9
Pod undocumented
676 0 my $self = shift;
677 0 $self->expect('{', "following `trusted-keys'");
678 0 my($domain, $flags, $proto, $algo);
679 0 while(1) {
680 0 $self->expect([ WORD, '}' ], "while reading key for `trusted-keys'");
681 0 ▶ last if $self->{_token} eq '}';
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_token"} eq "}" 0 0 0
682 0 $domain = $self->{_data};
683 0 $self->handle_trusted_key($domain,
684 $self->parse_pubkey("while reading key for `trusted-keys'"));
685 }
686 0 $self->expect(';', "to finish trusted-keys");
687 }
688  
689 0 ▶sub parse_zone($) {
Subroutine parse_zone: not called CC=18 SCAR=58.3
Pod undocumented
690 0 my $self = shift;
691 0 my($name, $class);
692 0 $self->expect([ WORD, STRING ], "following `zone'");
693 0 $name = $self->{_data};
694 0 $self->expect([ WORD, STRING, '{', ';' ], "following `zone $name'");
695 0 ▶ if ($self->{_token} eq ';') {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'_token'} eq ';') { } 0 0 0
elsif ($self->{'_token'} eq '{') { } 0 0 0
696 0 $self->handle_empty_zone($name, 'in');
697 return
698 0 } elsif ($self->{_token} eq '{') {
699 0 $class = 'in';
700 } else {
701 0 $class = lc($self->{_data});
702 0 $self->expect([ '{', ';' ], "following `zone $name $class'");
703 0 ▶ if ($self->{_token} eq ';') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_token"} eq ";") 0 0 0
704 0 $self->handle_empty_zone($name, $class);
705 return
706 0 }
707 }
708 0 my(%options, $temp);
709 0 while (1) {
710 0 $self->expect([ [ qw(type file masters transfer-source check-names
711 allow-update allow-query allow-transfer
712 max-transfer-time-in dialup notify also-notify
713 ixfr-base pubkey forward fowarders) ],
714 STRING, '}' ], "reading zone `$name'");
715 0 ▶ last if $self->{_token} eq '}';
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_token"} eq "}" 0 0 0
716 0 $temp = $self->{_data};
717 0 ▶ if ($temp eq "type") {
Branch: 1 branch
BranchTrueFalseTotal
if ($temp eq "type") 0 0 0
718 0 $self->expect([[qw(master slave stub forward hint)]],
719 "following `$temp'");
720 0 $options{$temp} = $self->{_data};
721 next
722 0 }
723 0 ▶ if ($temp eq "file" || $temp eq "ixfr-base") {
Branch: 1 branch
BranchTrueFalseTotal
if ($temp eq "file" or $temp eq "ixfr-base") 0 0 0
Condition0%0/3
$temp eq "file" or $temp eq "ixfr-base"
l!l&&r!l&&!r
000
MC/DC0%0/2
$temp eq "file" or $temp eq "ixfr-base"
$temp eq "file" $temp eq "ixfr-base"
Truth table0%0/3
A or B
A= $temp eq "file"B= $temp eq "ixfr-base"
ABresult
1X1
011
000
724 0 $self->expect([ WORD, STRING ], "following `$temp'");
725 0 $options{$temp} = $self->{_data};
726 next
727 0 }
728 0 ▶ if ($temp eq "masters" || $temp eq "also-notify" ||
Branch: 1 branch
BranchTrueFalseTotal
if ($temp eq "masters" or $temp eq "also-notify" or $temp eq "forwarders") 0 0 0
Condition0%0/6
$temp eq "masters" or $temp eq "also-notify" or $temp eq "forwarders"
l!l&&r!l&&!r
000
$temp eq "masters" or $temp eq "also-notify"
l!l&&r!l&&!r
000
MC/DC0%0/3
$temp eq "masters" or $temp eq "also-notify" or $temp eq "forwarders"
$temp eq "masters" $temp eq "also-notify" $temp eq "forwarders"
Truth table0%0/4
A or B or C
A= $temp eq "masters"B= $temp eq "also-notify"C= $temp eq "forwarders"
ABCresult
1XX1
01X1
0011
0000
729 $temp eq "forwarders") {
730 0 $options{$temp} = $self->parse_addrlist("following `$temp'");
731 next
732 0 }
733 0 ▶ if ($temp eq "dialup" || $temp eq "notify") {
Branch: 1 branch
BranchTrueFalseTotal
if ($temp eq "dialup" or $temp eq "notify") 0 0 0
Condition0%0/3
$temp eq "dialup" or $temp eq "notify"
l!l&&r!l&&!r
000
MC/DC0%0/2
$temp eq "dialup" or $temp eq "notify"
$temp eq "dialup" $temp eq "notify"
Truth table0%0/3
A or B
A= $temp eq "dialup"B= $temp eq "notify"
ABresult
1X1
011
000
734 0 $options{$temp} = $self->parse_bool("following `$temp'");
735 next
736 0 }
737 0 ▶ if ($temp eq "max-transfer-time-in") {
Branch: 1 branch
BranchTrueFalseTotal
if ($temp eq "max-transfer-time-in") 0 0 0
738 0 $self->expect(NUMBER, "following `$temp'");
739 0 $options{$temp} = $self->{_data};
740 next
741 0 }
742 0 ▶ if ($temp eq "check-names") {
Branch: 1 branch
BranchTrueFalseTotal
if ($temp eq "check-names") 0 0 0
743 0 $options{$temp} = $self->parse_check_names("following `$temp'");
744 next
745 0 }
746 0 ▶ if ($temp eq "forward") {
Branch: 1 branch
BranchTrueFalseTotal
if ($temp eq "forward") 0 0 0
747 0 $options{$temp} = $self->parse_forward("following `$temp'");
748 next
749 0 }
750 0 ▶ if ($temp eq "pubkey") {
Branch: 1 branch
BranchTrueFalseTotal
if ($temp eq "pubkey") 0 0 0
751 0 $options{$temp} = $self->parse_pubkey("following `$temp'");
752 next
753 0 }
754 0 $options{$temp} = $self->parse_addrmatchlist("following `$temp'");
755 } continue {
756 0 $self->expect(';', "reading zone `$name'");
757 }
758 0 $self->expect(';', "to finish zone `$name'");
759 0 ▶ if (! exists $options{type}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not exists $options{'type'}) { } 0 0 0
760 0 $self->handle_empty_zone($name, $class, \%options);
761 } else {
762 0 $self->handle_zone($name, $class, $options{type}, \%options);
763 }
764 }
765  
766 0 ▶sub parse_options($) {
Subroutine parse_options: not called CC=5 SCAR=34.0
Pod undocumented
767 0 my $self = shift;
768 0 $self->expect('{', "following `options'");
769 0 my($type, $option, $arg, $ate_semi, $did_handle_option);
770 0 while (1) {
771 0 $self->expect([ WORD, '}' ], "reading options");
772 0 ▶ last if $self->{_token} eq '}';
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_token"} eq "}" 0 0 0
773 0 $option = $self->{_data};
774 0 $type = $opt_table{$option};
775 0 $ate_semi = $did_handle_option = 0;
776 0 ▶ if (ref $type) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $type) { } 0 0 0
777 0 ($arg, $ate_semi, $did_handle_option) =
778 &$type($self, "following `$option'");
779 } else {
780 0 $self->expect($type, "following `$option'");
781 0 $arg = $self->{_data};
782 }
783 0 ▶ $self->expect(';', "following argument for option `$option'")
Branch: 1 branch
BranchTrueFalseTotal
unless $ate_semi 0 0 0
784 unless $ate_semi;
785 0 ▶ $self->handle_option($option, $arg)
Branch: 1 branch
BranchTrueFalseTotal
unless $did_handle_option 0 0 0
786 unless $did_handle_option;
787 }
788 0 $self->expect(';', "to finish options");
789 }
790  
791 0 ▶sub parse_conf() {
Subroutine parse_conf: not called CC=15 SCAR=54.8
Pod undocumented
792 0 my $self = shift;
793 0 $self->{_curline} = '';
794 0 $self->{_flags} = { };
795 0 while (1) {
796 0 $self->expect([ ENDoFILE, WORD ], "at beginning of statement");
797 0 ▶ if ($self->{_token} eq ENDoFILE) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_token"} eq "\4") 0 0 0
798 0 ▶ if ($self->{_fhs} && @{$self->{_fhs}}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_fhs"} and @{$self->{"_fhs"};}) 0 0 0
Condition0%0/3
$self->{"_fhs"} and @{$self->{"_fhs"};}
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"_fhs"} and @{$self->{"_fhs"};}
$self->{"_fhs"} @{$self->{"_fhs"};}
Truth table0%0/3
A and B
A= $self->{"_fhs"}B= @{$self->{"_fhs"};}
ABresult
0X0
100
111
799 0 my($pos);
800 (@$self{qw(_fh _file _curline)}, $pos) =
801 0 @{ pop @{$self->{_fhs}} };
802 0 pos($self->{_curline}) = $pos;
803 0 redo;
804 }
805 0 last;
806 }
807 0 ▶ if ($self->{_data} eq "acl") {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_data"} eq "acl") 0 0 0
808 0 $self->expect([ WORD, STRING ], "following `acl'");
809 0 my($name, $amlist);
810 0 $name = $self->{_data};
811 0 $amlist = $self->parse_addrmatchlist("reading acl `$name'");
812 0 $self->expect(';', "to finish acl `$name'");
813 0 $self->handle_acl($name, $amlist);
814 next
815 0 }
816 0 ▶ if ($self->{_data} eq "include") {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_data"} eq "include") 0 0 0
817 0 $self->expect(STRING, "following `include'");
818 0 my($include) = $self->{_data};
819 0 $self->expect(';', "reading include statement");
820 0 push @{$self->{_fhs}},
821 0 [ @$self{qw(_fh _file _curline)}, pos($self->{_curline}) ];
822 0 $self->open_file($include);
823 next
824 0 }
825 0 ▶ if ($self->{_data} eq "key") {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_data"} eq "key") 0 0 0
826 0 $self->parse_key;
827 next
828 0 }
829 0 ▶ if ($self->{_data} eq "logging") {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_data"} eq "logging") 0 0 0
830 0 ▶ if ($self->{_flags}{seen_logging}++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_flags"}{"seen_logging"}++) 0 0 0
831 0 $self->choke("Cannot redefine logging (", $self->where, ")");
832 }
833 0 $self->parse_logging;
834 next
835 0 }
836 0 ▶ if ($self->{_data} eq "options") {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_data"} eq "options") 0 0 0
837 0 ▶ if ($self->{_flags}{seen_options}++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_flags"}{"seen_options"}++) 0 0 0
838 0 $self->choke("Cannot redefine options (", $self->where, ")");
839 }
840 0 $self->parse_options;
841 next
842 0 }
843 0 ▶ if ($self->{_data} eq "controls") {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_data"} eq "controls") 0 0 0
844 0 $self->parse_controls;
845 next
846 0 }
847 0 ▶ if ($self->{_data} eq "server") {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_data"} eq "server") 0 0 0
848 0 $self->parse_server;
849 next
850 0 }
851 0 ▶ if ($self->{_data} eq "trusted-keys") {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_data"} eq "trusted-keys") 0 0 0
852 0 $self->parse_trusted_keys;
853 next
854 0 }
855 0 ▶ if ($self->{_data} eq "zone") {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_data"} eq "zone") 0 0 0
856 0 $self->parse_zone;
857 next
858 0 }
859 0 $self->choke("Unknown configuration entry `", $self->{_data}, "' at ",
860 $self->where);
861 }
862 $self
863 0 }
864  
865 # The external entry points
866 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
Pod documented
867 0 my $class = shift;
868 0 my $self = { };
869 0 bless $self, $class;
870 0 $self
871 }
872  
873 0 ▶sub parse_file {
Subroutine parse_file: not called CC=2 SCAR=17.9
Pod documented
874 0 my $self = shift;
875 0 ▶ $self = $self->new unless ref $self;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self 0 0 0
876 0 $self->open_file(@_);
877 0 $self->{_line} = 0;
878 0 $self->parse_conf;
879 }
880  
881 0 ▶sub parse_fh {
Subroutine parse_fh: not called CC=3 SCAR=24.8
Pod documented
882 0 my $self = shift;
883 0 ▶ $self = $self->new unless ref $self;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self 0 0 0
884 0 $self->{_fh} = shift;
885 0 ▶ $self->{_file} = @_ ? shift : "a file handle";
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 0 0 0
886 0 $self->{_line} = 0;
887 0 $self->parse_conf;
888 }
889  
890 0 ▶sub parse {
Subroutine parse: not called CC=3 SCAR=24.8
Pod documented
891 0 require IO::Scalar;
892 0 my $self = shift;
893 0 my $scalar = shift;
894 0 ▶ $self = $self->new unless ref $self;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self 0 0 0
895 0 $self->{_fh} = IO::Scalar->new(\$scalar);
896 0 ▶ $self->{_file} = @_ ? shift : "a scalar";
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 0 0 0
897 0 $self->{_line} = 0;
898 0 $self->parse_conf;
899 }
900  
901 # The callbacks
902 0 ▶sub handle_logging_category {}; # $name, \@names
Subroutine handle_logging_category: not called CC=1 SCAR=0.0
Pod documented
903 0 ▶sub handle_logging_channel {}; # $name, \%options
Subroutine handle_logging_channel: not called CC=1 SCAR=0.0
Pod documented
904 0 ▶sub handle_key {}; # $name, $algo, $secret
Subroutine handle_key: not called CC=1 SCAR=0.0
Pod documented
905 0 ▶sub handle_acl {}; # $name, $addrmatchlist
Subroutine handle_acl: not called CC=1 SCAR=0.0
Pod documented
906 0 ▶sub handle_option {}; # $option, $argument
Subroutine handle_option: not called CC=1 SCAR=0.0
Pod documented
907 0 ▶sub handle_server {}; # $name, \%options
Subroutine handle_server: not called CC=1 SCAR=0.0
Pod documented
908 0 ▶sub handle_trusted_key {}; # $domain, [ $flags, $proto, $algo, $keydata ]
Subroutine handle_trusted_key: not called CC=1 SCAR=0.0
Pod documented
909 0 ▶sub handle_empty_zone {}; # $name, $class, \%options
Subroutine handle_empty_zone: not called CC=1 SCAR=0.0
Pod documented
910 0 ▶sub handle_zone {}; # $name, $class, $type, \%options
Subroutine handle_zone: not called CC=1 SCAR=0.0
Pod documented
911 0 ▶sub handle_control {}; # $socket_type, \@type_specific_data
Subroutine handle_control: not called CC=1 SCAR=0.0
Pod documented
912  
913 1 1;
914  
915 __END__
↑ Summary