added the ability for HDB to use sh/qrz remotely
authorminima <minima>
Wed, 12 Mar 2003 18:38:21 +0000 (18:38 +0000)
committerminima <minima>
Wed, 12 Mar 2003 18:38:21 +0000 (18:38 +0000)
Changes
cmd/Commands_en.hlp
cmd/dbavail.pl
cmd/dbcreate.pl
perl/DXDb.pm

diff --git a/Changes b/Changes
index 28a42c5b02483e53c966c85f70eaebb44a6cd46a..1111a68fd76ef8de1dc6eae4b5e675db2c74b583 100644 (file)
--- a/Changes
+++ b/Changes
@@ -2,6 +2,11 @@
 1. added HC and QRZ.com to possible QSL locations, if you want to pick up
 historical info (ie start again), run create_qsl.pl after update and restart
 the node (which you will need to do anyway).
+2. changed the dbcreate command so that you can say: 
+   dbcreate dxqsl cmd show/dxqsl
+which will allow local and remote users to execute commands as though they
+are Databases. You can also include these databases in chains. What you do
+with this, is ofcourse a moot question.   
 11Mar03=======================================================================
 1. Changed the name of show/qsl to show/dxqsl.
 2. Alter Commands_en.hlp to match new name and issue manual updates (g0vgs)
index 5a2c33451f2ff6de9adcda78e05604a58b24b23f..b5c10c19255ce7c6e87176c4072e3c1e194d2472 100644 (file)
@@ -378,6 +378,7 @@ in the system. It is also aliased to SHOW/COMMAND.
 === 9^DBCREATE <name>^Create a database entry
 === 9^DBCREATE <name> chain <name> [<name>..]^Create a chained database entry
 === 9^DBCREATE <name> remote <node>^Create a remote database entry
+=== 9^DBCREATE <name> cmd <dxspider command>^make a local command available as a DB
 DBCREATE allows you to define a database in the system. It doesn't actually
 create anything, just defines it.
 
@@ -430,6 +431,16 @@ to allow
 
 to work as they may be used to.
 
+You can also make local commands available as 'pseudo' databases. You
+can therefore make spider special commands available as a database. I
+imagine that this will be primarily useful for remote access from 
+legacy nodes. For example:-
+
+  DBCREATE dxqsl cmd show/dxqsl
+
+You also use one of these databases in a chain. This may be useful 
+locally. 
+
 See DBIMPORT for the importing of existing AK1A format data to databases.
 See DBSHOW for generic database enquiry
  
index 0974ee7feafa4f0d4eeb3b9da70b8cbc40bc3471..5bfcb32e17d2bc937afc933bf7faf40b12e4dc19 100644 (file)
@@ -10,7 +10,7 @@ my @out;
 my $f;
 
 foreach $f (values %DXDb::avail) {
-       push @out, "DB Name          Location   Chain" unless @out;
-       push @out, sprintf "%-15s  %-10s %s", $f->name, $f->remote ? $f->remote : "Local", $f->chain ? parray($f->chain) : ""; 
+       push @out, "DB Name          Location   Cmd            Chain" unless @out;
+       push @out, sprintf "%-15s  %-10s %-15s %s", $f->name, $f->remote ? $f->remote : "Local", ($f->localcmd || ""), $f->chain ? parray($f->chain) : ""; 
 }
 return (1, @out);
index 8f47b63f6cc71fa063a6779e89990d8b4e100fdc..837141e2142ddaf601229e373335afe6f8cf6d86 100644 (file)
@@ -14,12 +14,17 @@ return (1, $self->msg('db6', $name)) if DXDb::getdesc($name);
 
 my $remote;
 my $chain;
+my $cmd;
 while (@f) {
        my $f = lc shift @f;
        if ($f eq 'remote') {
                $remote = uc shift @f if @f;
                next;
        }
+       if ($f eq 'cmd') {
+               $cmd = lc shift @f if @f;
+               next;
+       }
        if ($f eq 'chain') {
                if (@f) {
                        $chain = [ @f ];
@@ -27,6 +32,6 @@ while (@f) {
                }
        }
 }
-DXDb::new($name, $remote, $chain);
+DXDb::new($name, $remote, $chain, $cmd);
 push @out, $self->msg($remote ? 'db7' : 'db8', $name, $remote);
 return (1, @out);
index f54d6f14ff02b882fbefdd26cf21bbcab0fa1f4b..e399545d0616798c6cd832276d16b6c6c80a659f 100644 (file)
@@ -42,6 +42,7 @@ $dbbase = "$main::root/db";           # where all the databases are kept;
                  tae => '9,End App txt',
                  atemplate => '9,App Templates,parray',
                  help => '0,Help txt,parray',
+                 localcmd => '0,Local Command',
                 );
 
 $lastprocesstime = time;
@@ -157,7 +158,16 @@ sub getkey
 
        # make sure we are open
        $self->open;
-       if ($self->{db}) {
+       if ($self->{localcmd}) {
+               my $dxchan = $main::me;
+               $dxchan->{remotecmd} = 1; # for the benefit of any command that needs to know
+               my $oldpriv = $dxchan->{priv};
+               $dxchan->{priv} = 0;
+               my @in = (DXCommandmode::run_cmd($dxchan, "$self->{localcmd} $key"));
+               $dxchan->{priv} = $oldpriv;
+               delete $dxchan->{remotecmd};
+               return @in ? join("\n", @in) : undef;
+       } elsif ($self->{db}) {
                my $s = $self->{db}->get($key, $value);
                return $s ? undef : $value;
        }
@@ -187,10 +197,14 @@ sub new
        my $name = shift;
        my $remote = shift;
        my $chain = shift;
+       my $cmd = shift;
+       
        $self->{name} = lc $name;
        $self->{remote} = uc $remote if $remote;
        $self->{chain} = $chain if $chain && ref $chain;
        $self->{accesst} = $self->{createt} = $self->{lastt} = $main::systime;
+       $self->{localcmd} = lc $cmd if $cmd;
+       
        $avail{$self->{name}} = $self;
        mkdir $dbbase, 02775 unless -e $dbbase;
        save();