line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/perl |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
########################################################################## |
4
|
|
|
|
|
|
|
# Copyright (c) 2010 Alexander Bluhm |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# Permission to use, copy, modify, and distribute this software for any |
7
|
|
|
|
|
|
|
# purpose with or without fee is hereby granted, provided that the above |
8
|
|
|
|
|
|
|
# copyright notice and this permission notice appear in all copies. |
9
|
|
|
|
|
|
|
# |
10
|
|
|
|
|
|
|
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
11
|
|
|
|
|
|
|
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
12
|
|
|
|
|
|
|
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
13
|
|
|
|
|
|
|
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
14
|
|
|
|
|
|
|
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
15
|
|
|
|
|
|
|
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
16
|
|
|
|
|
|
|
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
17
|
|
|
|
|
|
|
########################################################################## |
18
|
|
|
|
|
|
|
|
19
|
2
|
|
|
2
|
|
2926674
|
use strict; |
|
2
|
|
|
|
|
12
|
|
|
2
|
|
|
|
|
94
|
|
20
|
2
|
|
|
2
|
|
17
|
use warnings; |
|
2
|
|
|
|
|
10
|
|
|
2
|
|
|
|
|
135
|
|
21
|
2
|
|
|
2
|
|
1235
|
use Getopt::Long qw(:config posix_default bundling); |
|
2
|
|
|
|
|
18818
|
|
|
2
|
|
|
|
|
24
|
|
22
|
2
|
|
|
2
|
|
1838
|
use OSPF::LSDB::YAML; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
388
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub usage(@) { |
25
|
1
|
50
|
|
1
|
|
3
|
print STDERR "Error: @_\n" if @_; |
26
|
1
|
|
|
|
|
82
|
print STDERR <
|
27
|
|
|
|
|
|
|
Convert OSPF LSDB in YAML format from old verion to current. |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
Usage: $0 [-h] [oldospf.yaml] [ospf.yaml] |
30
|
|
|
|
|
|
|
-h help, print usage |
31
|
|
|
|
|
|
|
oldospf.yaml input file, default stdin |
32
|
|
|
|
|
|
|
ospf.yaml output file, default stdout |
33
|
|
|
|
|
|
|
EOF |
34
|
1
|
|
|
|
|
170
|
exit(2); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub main() { |
38
|
|
|
|
|
|
|
GetOptions( |
39
|
1
|
|
|
1
|
|
299
|
'h' => sub { usage() }, |
40
|
2
|
50
|
|
2
|
|
15
|
) or usage("Bad option"); |
41
|
1
|
50
|
|
|
|
186
|
usage("Only two arguments allowed") if @ARGV > 2; |
42
|
|
|
|
|
|
|
|
43
|
1
|
|
|
|
|
9
|
my $yaml = OSPF::LSDB::YAML->new(); |
44
|
1
|
50
|
|
|
|
4
|
if (@ARGV > 0) { |
45
|
1
|
|
|
|
|
4
|
$yaml->LoadFile($ARGV[0]); |
46
|
|
|
|
|
|
|
} else { |
47
|
0
|
|
|
|
|
0
|
local $/; |
48
|
0
|
|
|
|
|
0
|
$yaml->Load(); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
1
|
50
|
|
|
|
873
|
if (@ARGV > 1) { |
52
|
1
|
|
|
|
|
6
|
$yaml->DumpFile($ARGV[1]); |
53
|
|
|
|
|
|
|
} else { |
54
|
0
|
|
|
|
|
|
print $yaml->Dump(); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
main(); |