added set/usdb and del/usdb commands
authorminima <minima>
Tue, 15 Oct 2002 12:42:35 +0000 (12:42 +0000)
committerminima <minima>
Tue, 15 Oct 2002 12:42:35 +0000 (12:42 +0000)
Changes
cmd/Aliases
cmd/Commands_en.hlp
cmd/delete/usdb.pl [new file with mode: 0644]
cmd/set/usdb.pl [new file with mode: 0644]
perl/Messages
perl/USDB.pm

diff --git a/Changes b/Changes
index 43d787ce5659f4857a647f70c38865001350ee40..0f60b7dd56aa4bc987ecc88085ee77a75a9d41a1 100644 (file)
--- a/Changes
+++ b/Changes
@@ -13,12 +13,15 @@ is this:-
    http://www.dxcluster.org/download/usdbraw.gz to somewhere like /tmp.
 2. update from CVS.
 3. Restart (on linux, just stop the node and *don't* restart on Windows).
-4. remove /spider/data/user.v1
+4. remove /spider/data/usdb.v1
 5. cd /spider/perl
 6. (perl) create_usdb.pl /tmp/usdbraw.gz (or wherever you put it)
 6a. If you don't have Compress::Zlib loaded then you will need to gunzip
     it manually and do: create_usdb.pl /tmp/usdbraw (not Windows :-)
 7. on linux, in a console window do: load/usdb, on windows: restart the node. 
+
+Added set/usdb command to add adding or changing of a callsign in the USDB
+
 14Oct02=======================================================================
 1. added show/usdb command as a simple, direct interface to the information
 available in the USDB stuff.
index 2592ef7c3a7be779e3adafeebb8353f4a8bc533e..390864ff06f59086ba0964e7f6dfcc297b1bd664 100644 (file)
@@ -40,7 +40,6 @@ package CmdAlias;
        '^cre?a?t?e?$', 'apropos create', 'apropos',
        ],
        'd' => [
-         '^dele?t?e?/u', 'delete/user', 'delete/user',
          '^dele?t?e?/fu', 'kill full', 'kill',
          '^dele?t?e?$', 'kill', 'kill',
          '^dir?e?c?t?o?r?y?/a\w*', 'directory all', 'directory',
@@ -112,7 +111,7 @@ package CmdAlias;
          '^set/nota', 'unset/talk', 'unset/talk',
          '^set/noww', 'unset/wwv', 'unset/wwv',
          '^set/nowx', 'unset/wx', 'unset/wx',
-      '^set/us', 'unset/node', 'unset/node',
+      '^set/user', 'unset/node', 'unset/node',
        '^set$', 'apropos set', 'apropos',
          '^sho?w?/u$', 'show/user', 'show/user',
          '^sho?w?/bu', 'show/files bulletins', 'show/files',
index 51d1622ecf7ec80ce7df31e53539eab820bb8cd1..11032115d4315c62ba26a87a4cbd8472eef888db 100644 (file)
@@ -353,6 +353,17 @@ DX cluster <callsign>. This process creates a new 'client' process which will
 use the script in /spider/connect/<callsign> to effect the 'chat' exchange
 necessary to traverse the network(s) to logon to the cluster <callsign>.
 
+=== 9^DELETE/USDB <callsign> ...^Delete this user from the US State Database
+This command will completely remove a one or more callsigns
+from the US States database.
+
+There is NO SECOND CHANCE.
+
+It goes without saying that you should use this command CAREFULLY!
+
+Note that these callsign may be re-instated by any weekly updates from 
+the FCC.
+
 === 9^DELETE/USER <callsign> ...^Delete this user from the User Database
 This command will completely remove a one or more users from the database.
 
@@ -1648,6 +1659,15 @@ SEND messages to the sysop.
 === 0^SET/TALK^Allow TALK messages to come out on your terminal
 === 0^UNSET/TALK^Stop TALK messages coming out on your terminal
 
+=== 9^SET/USDB <call> <state> <city>^add/update a US DB callsign
+This command allows you to add or alter a callsign in the US state
+database. Use with extreme caution. Anything you do here will be
+overwritten by any weekly updates that affect this callsign
+
+  set/usdb g1tlh nh downtown rindge
+
+see also DELETE/USDB
+
 === 0^SET/WCY^Allow WCY messages to come out on your terminal
 === 0^UNSET/WCY^Stop WCY messages coming out on your terminal
 
diff --git a/cmd/delete/usdb.pl b/cmd/delete/usdb.pl
new file mode 100644 (file)
index 0000000..e6f1a57
--- /dev/null
@@ -0,0 +1,25 @@
+#
+# delete a usdb entry
+#
+# Please note that this may screw up everything to do with
+# spotting onwards
+#
+# Copyright (c) 2002 - Dirk Koopman G1TLH
+#
+# $Id$
+#
+
+my ($self, $line) = @_;
+my @args = split /\s+/, $line;
+my $call;
+my @out;
+my $user;
+
+return (1, $self->msg('e5')) if $self->priv < 9;
+
+foreach $call (@args) {
+       USDB::del($call);
+       push @out, $self->msg('susdb4', $call);
+       Log('DXCommand', $self->msg('susdb4', $call));
+}
+return (1, @out);
diff --git a/cmd/set/usdb.pl b/cmd/set/usdb.pl
new file mode 100644 (file)
index 0000000..9e9ef05
--- /dev/null
@@ -0,0 +1,24 @@
+#
+# Add/modify a USDB entry
+#
+# There are no checks and NO balances.
+#
+# Copyright (c) 2002 Dirk Koopman
+#
+# $Id$
+#
+
+my ($self, $line) = @_;
+return (1, $self->msg('e5')) if $self->priv < 9;
+
+my ($call, $state, $city) = split /\s+/, uc $line, 3;
+return (1, $self->msg('susdb1')) if length $state != 2 || !is_callsign($call);
+
+my ($ocity, $ostate) = USDB::get($call);
+my @out;
+push @out, $self->msg('susdb2', $call, $ocity, $ostate ) if $ocity;
+USDB::add($call, $city, $state);
+push @out, $self->msg('susdb3', $call, $city, $state );
+Log('DXCommand', $self->msg('susdb3', $call, $city, $state));
+return (1, @out);
+
index 3829d2ebd73938d2c629eb804d43cee1bb0b391e..cd9e572be8302264817d2961eb448831bb77b605 100644 (file)
@@ -262,6 +262,10 @@ package DXM;
                                statdx => 'Total DX Spots last 31 days',
                                sun => 'Location                              dd/mm/yyyy Rise   Set',
                                sun_with_azel => 'Location                              dd/mm/yyyy Rise   Set      Azim   Elev',
+                               susdb1 => 'usage: callsign state city',
+                               susdb2 => 'USDB $_[0] was $_[1], $_[2]',
+                               susdb3 => 'USDB $_[0] now $_[1], $_[2]',
+                               susdb4 => 'USDB $_[0] deleted',
                                suser1 => 'usage: callsign user_field_name value',
                                suser2 => 'User $_[0] not found',
                                suser3 => 'User field \'$_[0]\' was \'$_[1]\' now set to \'$_[2]\'',
index 719ac66afe30db127d95008c32305d09ef8532dd..cba7ddb96c96f6b783e9e4f6db3e168f4e0f2184 100644 (file)
@@ -28,7 +28,7 @@ $dbfn = "$main::data/usdb.v1";
 sub init
 {
        end();
-       if (tie %db, 'DB_File', $dbfn, O_RDONLY, 0664, $DB_BTREE) {
+       if (tie %db, 'DB_File', $dbfn, O_RDWR, 0664, $DB_BTREE) {
                $present = 1;
                return "US Database loaded";
        }
@@ -50,6 +50,29 @@ sub get
        return @s;
 }
 
+sub _add
+{
+       my ($db, $call, $city, $state) = @_;
+       
+       # lookup the city 
+       my $s = uc "$city|$state";
+       my $ctyn = $db->{$s};
+       unless ($ctyn) {
+               my $no = $db->{'##'} || 1;
+               $ctyn = "#$no";
+               $db->{$s} = $ctyn;
+               $db->{$ctyn} = $s; 
+               $no++;
+               $db->{'##'} = "$no";
+       }
+       $db->{uc $call} = $ctyn; 
+}
+
+sub add
+{
+       _add(\%db, @_);
+}
+
 sub getstate
 {
        return () unless $present;
@@ -64,6 +87,12 @@ sub getcity
        return @s ? $s[0] : undef;
 }
 
+sub del
+{
+       my $call = uc shift;
+       delete $db{$call};
+}
+
 #
 # load in / update an existing DB with a standard format (GZIPPED)
 # "raw" file.
@@ -128,19 +157,9 @@ sub load
                        my $l = $_;
                        $l =~ s/[\r\n]+$//;
                        my ($call, $city, $state) = split /\|/, $l;
+
+                       _add(\%dbn, $call, $city, $state);
                        
-                       # lookup the city 
-                       my $s = "$city|$state";
-                       my $ctyn = $dbn{$s};
-                       unless ($ctyn) {
-                               my $no = $dbn{'##'} || 1;
-                               $ctyn = "#$no";
-                               $dbn{$s} = $ctyn;
-                               $dbn{$ctyn} = $s; 
-                               $no++;
-                               $dbn{'##'} = "$no";
-                       }
-                       $dbn{$call} = $ctyn; 
                        $count++;
                }
                $of->close;