X-Git-Url: http://gb7djk.dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FRoute.pm;h=695eed8dffa05aea3e627b4a31c793060d6000f0;hb=8c23f70c2487e906a80ef323763cb7cb123baf28;hp=7858e16ce7500dcce1864b07e2ba4f857cd1cd77;hpb=ebbf88f53284e6b7e77c3319047607b1c5cd2518;p=spider.git diff --git a/perl/Route.pm b/perl/Route.pm index 7858e16c..695eed8d 100644 --- a/perl/Route.pm +++ b/perl/Route.pm @@ -16,14 +16,16 @@ package Route; use DXDebug; use DXChannel; +use DXUtil; + use Prefix; use strict; use vars qw($VERSION $BRANCH); -$VERSION = sprintf( "%d.%03d", q$Revision$ =~ /(\d+)\.(\d+)/ ); -$BRANCH = sprintf( "%d.%03d", q$Revision$ =~ /\d+\.\d+\.(\d+)\.(\d+)/ || (0,0)); +$VERSION = sprintf( "%d.%03d", q$Revision$ =~ /:\s+(\d+)\.(\d+)/ ); +$BRANCH = sprintf( "%d.%03d", q$Revision$ =~ /:\s+\d+\.\d+\.(\d+)\.(\d+)/ || (0,0)); $main::build += $VERSION; $main::branch += $BRANCH; @@ -66,7 +68,7 @@ sub new $pkg = ref $pkg if ref $pkg; my $self = bless {call => $call}, $pkg; - dbg("create $pkg with $call") if isdbg('routelow'); + dbg("Create $pkg with $call") if isdbg('routelow'); # add in all the dxcc, itu, zone info ($self->{dxcc}, $self->{itu}, $self->{cq}, $self->{state}, $self->{city}) = @@ -168,6 +170,47 @@ sub conf return $r ? 1 : 0; } +# +# pc59 entity encoding and decoding +# +sub enc_pc59 +{ + my $self = shift; + my $sort = shift || 'N'; + my $out = "$sort$self->{flag}$self->{call}"; + if ($self->{build}) { + $out .= "b$self->{build}"; + } elsif ($self->{version}) { + $out .= "v$self->{version}"; + } +} + +sub dec_pc59 +{ + my $node = shift; + my $s = ref($node) ? shift : $node; + $node = undef; + + my ($sort, $here, $call) = unpack "A A A*", $s; + return unless is_callsign($call); + return unless $here =~ /^[0123]$/; + return unless $sort =~ /^[NUE]$/; + if ($sort eq 'E' || $sort eq 'N') { + $node = Route::Node::get($call) || Route::Node->new($call); + if ($s =~ /b([\d\.])/) { + $node->{build} = $1; + } + if ($s =~ /v([\d\.])/) { + $node->{version} = $1; + } + } elsif ($sort eq 'U') { + $node = Route::User::get($call) || Route::User->new($call); + } + $node->{flags} = $here; + $node->{lastseen} = $main::systime; + return $node; +} + # # display routines #