From 973a2853ac360d77e8bc6382450c0a9e11da1f52 Mon Sep 17 00:00:00 2001 From: minima Date: Tue, 15 Oct 2002 12:42:35 +0000 Subject: [PATCH] added set/usdb and del/usdb commands --- Changes | 5 ++++- cmd/Aliases | 3 +-- cmd/Commands_en.hlp | 20 ++++++++++++++++++++ cmd/delete/usdb.pl | 25 +++++++++++++++++++++++++ cmd/set/usdb.pl | 24 ++++++++++++++++++++++++ perl/Messages | 4 ++++ perl/USDB.pm | 45 ++++++++++++++++++++++++++++++++------------- 7 files changed, 110 insertions(+), 16 deletions(-) create mode 100644 cmd/delete/usdb.pl create mode 100644 cmd/set/usdb.pl diff --git a/Changes b/Changes index 43d787ce..0f60b7dd 100644 --- 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. diff --git a/cmd/Aliases b/cmd/Aliases index 2592ef7c..390864ff 100644 --- a/cmd/Aliases +++ b/cmd/Aliases @@ -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', diff --git a/cmd/Commands_en.hlp b/cmd/Commands_en.hlp index 51d1622e..11032115 100644 --- a/cmd/Commands_en.hlp +++ b/cmd/Commands_en.hlp @@ -353,6 +353,17 @@ DX cluster . This process creates a new 'client' process which will use the script in /spider/connect/ to effect the 'chat' exchange necessary to traverse the network(s) to logon to the cluster . +=== 9^DELETE/USDB ...^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 ...^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 ^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 index 00000000..e6f1a57f --- /dev/null +++ b/cmd/delete/usdb.pl @@ -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 index 00000000..9e9ef05e --- /dev/null +++ b/cmd/set/usdb.pl @@ -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); + diff --git a/perl/Messages b/perl/Messages index 3829d2eb..cd9e572b 100644 --- a/perl/Messages +++ b/perl/Messages @@ -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]\'', diff --git a/perl/USDB.pm b/perl/USDB.pm index 719ac66a..cba7ddb9 100644 --- a/perl/USDB.pm +++ b/perl/USDB.pm @@ -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; -- 2.34.1