]> dxcluster.net Git - spider.git/blob - cmd/dbshow.pl
include CTY-1803 changes
[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 (Route::Node::get($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                 my $pre = $db->print('pre');
44                 push @out, $pre if defined $pre;
45 #               push @out, "@f";
46                 for (@f) {
47                         push @out, $db->name . " $_";
48                         my $value = $db->getkey($_) || "";
49 #                       push @out, $db->name . ": $_ :";
50                         if ($value) {
51                                 push @out, split /\n/, $value;
52                                 $count++;
53                         } else {
54                                 push @out, $self->msg('db2', uc $_, uc $db->{name});
55                         }
56                 }
57                 if ($count) {
58                         my $post = $db->print('post');
59                         push @out, $post if $post;
60 #                       last;
61                 }
62         }
63 }
64
65 return (1, @out);