Initial revision
[webpac] / all2xml.pl
1 #!/usr/bin/perl -w
2
3 use strict;
4 use OpenIsis;
5 use Getopt::Std;
6 use Data::Dumper;
7 use XML::Simple;
8
9 my $config=XMLin();
10
11 print Dumper($config);
12
13 my %opts;
14
15 getopts('d:m:q', \%opts);
16
17 my $db_dir = $opts{d};
18
19 die "usage: $0 -d [database_dir] -m [database1,database2] " if (! %opts);
20
21 #--------------------------------------------------------------------
22
23 my $last_tell=0;
24
25 my @isis_dirs = ( '.' );        # use dirname as database name
26
27 if ($opts{m}) {
28         @isis_dirs = split(/,/,$opts{m});
29 }
30
31 my @isis_dbs;
32
33 foreach (@isis_dirs) {
34         if (-e "$common::isis_data/$db_dir/$_/LIBRI") {
35                 push @isis_dbs,"$common::isis_data/$db_dir/$_/LIBRI/LIBRI";
36         }
37         if (-e "$common::isis_data/$db_dir/$_/PERI") {
38                 push @isis_dbs,"$common::isis_data/$db_dir/$_/PERI/PERI";
39         }
40         if (-e "$common::isis_data/$db_dir/$_/AMS") {
41                 push @isis_dbs,"$common::isis_data/$db_dir/$_/AMS/AMS";
42         }
43         if (-e "$common::isis_data/$db_dir/$_/ARTI") {
44 #               push @isis_dbs,"$common::isis_data/$db_dir/$_/ARTI/ARTI";
45         }
46 }
47
48 foreach my $isis_db (@isis_dbs) {
49
50         my $db = OpenIsis::open( "$isis_db" ) || warn "can't open '$isis_db'";
51
52         my $max_rowid = OpenIsis::maxRowid( $db );
53
54         my $last_pcnt = 0;
55
56         for (my $row_id = 1; $row_id <= $max_rowid; $row_id++ ) {
57                 my $row = OpenIsis::read( $db, $row_id );
58
59                 # output current process indicator
60                 my $pcnt = int($row->{mfn} * 100 / $max_rowid);
61                 if ($pcnt != $last_pcnt) {
62                         printf STDERR ("%5d / %5d -- %-2d %%\n",$row->{mfn},$max_rowid,$pcnt) if (! $opts{q});
63                         $last_pcnt = $pcnt;
64                 }
65         }
66 }