summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorDaniel Friesel <derf@derf.homelinux.org>2010-06-06 18:09:27 +0200
committerDaniel Friesel <derf@derf.homelinux.org>2010-06-06 18:09:27 +0200
commitaa5098642d7e55d5a9fa83998457d788b71798c0 (patch)
tree0f6d273ca573bb09df47389d58542b1454243870 /bin
parent05b9609ce1269d7b0457187e20f47ce42af0265c (diff)
Detect non-itinerary efa.vrr.de output (i.e. upon invalid input data)
Diffstat (limited to 'bin')
-rwxr-xr-xbin/efa24
1 files changed, 16 insertions, 8 deletions
diff --git a/bin/efa b/bin/efa
index 3056c81..aa82864 100755
--- a/bin/efa
+++ b/bin/efa
@@ -223,7 +223,7 @@ sub opt_timeout {
sub parse_tree {
my ($full_tree) = @_;
my $con_part = 0;
- my $con_no = 0;
+ my $con_no;
my $cons;
my $xp_td = XML::LibXML::XPathExpression->new('//table//table/tr/td');
@@ -255,11 +255,22 @@ sub parse_tree {
}
}
- if (not $td->exists($xp_img) and $td->textContent() !~ /^\s*$/) {
+ if (
+ defined $con_no and not $td->exists($xp_img)
+ and $td->textContent() !~ /^\s*$/
+ )
+ {
push(@{$cons->[$con_no]->[$con_part]}, $td->textContent());
}
}
- return $cons;
+
+ if (defined $con_no) {
+ return $cons;
+ }
+ else {
+ say "efa.vrr.de returned no connections, check your input data.";
+ exit 3;
+ }
}
GetOptions(
@@ -362,10 +373,6 @@ check_no_connections($tree);
$connections = parse_tree($tree);
-if (@{$connections} == 0) {
- die("Got no connections, parse error?\n");
-}
-
for my $i (0 .. $#{$connections}) {
display_connection($connections->[$i]);
if ($i != $#{$connections}) {
@@ -523,7 +530,8 @@ Print version information
0 Everything went well
1 Ambiguous input, re-run efa with different arguments
- 2 efa.vrr.de error
+ 2 efa.vrr.de error (i.e. unable to find matching connections)
+ 3 efa.vrr.de error (usually invalid input data)
255 Any other kind of error
=head1 CONFIGURATION