]> gb7djk.dxcluster.net Git - spider.git/blob - cmd/dbshow.pl
Make sure that a privilege is always defined even if it is 0
[spider.git] / cmd / dbshow.pl
1 #!/usr/bin/perl
2 #
3 # Database update routine
4 #
5 # Copyright (c) 1999 Dirk Koopman G1TLH
6 #
7 my ($self, $line) = @_;
8 my @f = split /\s+/, $line;
9 my @out;
10
11 my $name = shift @f if @f;
12 my $db = DXDb::getdesc($name);
13 return (1, $self->msg('db3', $name)) unless $db;
14
15 my @db; 
16 push @db, $name;
17 push @db, @{$db->chain} if $db->chain;
18
19 my $n;
20 foreach  $n (@db) {
21         $db = DXDb::getdesc($n);
22         return (1, $self->msg('db3', $n)) unless $db;
23         
24         if ($db->remote) {
25
26                 # remote databases
27                 unless (DXCluster->get_exact($db->remote) || DXChannel->get($db->remote)) {
28                         push @out, $self->msg('db4', uc $name, $db->remote);
29                         last;
30                 }
31                 
32                 push @out, $self->msg('db11', $db->remote);
33                 push @f, " " unless @f;
34                 for (@f) {
35                         my $n = DXDb::newstream($self->call);
36                         DXProt::route(undef, $db->remote, DXProt::pc44($main::mycall, $db->remote, $n, uc $db->name,uc $_, $self->call));
37                 }
38                 last;
39         } else {
40
41                 # local databases can chain to remote ones
42                 my $count;
43                 push @out, $db->print('pre');
44                 push @out, "@f";
45                 for (@f) {
46                         push @out, $db->name . " $_";
47                         my $value = $db->getkey($_) || "";
48                         push @out, $db->name . ": $_ : $value";
49                         if ($value) {
50                                 push @out, split /\n/, $value;
51                                 $count++;
52                         } else {
53                                 push @out, $self->msg('db2', uc $_, uc $db->{name});
54                         }
55                 }
56                 if ($count) {
57                         push @out, $db->print('post');
58                         last;
59                 }
60         }
61 }
62
63 return (1, @out);