X-Git-Url: http://gb7djk.dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2Fshowdx;h=869519f39089953b55fee8e24121ab61f88e4d11;hb=378cbf24f1b918e78d8b93c9e7ce3cf46fe28ec7;hp=b84d34ba4871bb05e1691a8f2ae39fac074d98e0;hpb=d3568fec5fb3e19f72dc4813dd2e18a7031dd6bb;p=spider.git diff --git a/perl/showdx b/perl/showdx index b84d34ba..869519f3 100755 --- a/perl/showdx +++ b/perl/showdx @@ -2,9 +2,10 @@ # # Implement an external "show/dx" command # -# Copyright (c) 1998-2000 Dirk Koopman G1TLH +# Copyright (c) 1998-2023 Dirk Koopman G1TLH # +package main; # search local then perl directories BEGIN { @@ -14,40 +15,128 @@ BEGIN { unshift @INC, "$root/perl"; # this IS the right way round! unshift @INC, "$root/local"; + + our $local_data = "$root/local_data"; + our $data = "$root/data"; } +#no warnings; + use IO::Handle; use DXUtil; use Bands; use Spot; use VE7CC; +use DXCommandmode; +use DXUser; +use DXM; + +$Spot::spotcachedays = 0; +$Spot::readback = 0; + + +STDOUT->autoflush(1); +Spot::init(); +Bands::load(); +Prefix::init(); +DXUser::init(0); +DXM::load(); + +my $call = 'N0CALL'; +my $self = bless {_nospawn => 1, width => 80, call=>$call, lang=>'en' }, 'DXCommandmode' ; +$self->{user} = DXUser::get($call); +my $wantreal = 0; + +while ($ARGV[0] =~ /^-+/) { + if ($ARGV[0] =~ /^-+[?h]/i) { + help(); + exit(2); + } + $wantreal = 1 if $ARGV[0] =~ /^-+r/i; + $ve7cc = 1 if $ARGV[0] =~ /^-+v/i; + if ($ARGV[0] =~ /^-+w$/i && $ARGV[1] && $ARGV[1] =~ /^\d+$/) { + $self->{width} = $ARGV[1]; + shift @ARGV; + } + if ($ARGV[0] =~ /^-+c/i && $ARGV[1] && is_callsign(uc $ARGV[1])) { + $call = uc $ARGV[1]; + my $ref = DXUser::get($call); + if ($ref) { + $self->{call} = $call; + $self->{user} = $ref; + } + shift @ARGV; + } + $self->{user}->wantgrid(1), ++$wantreal if $self->{user} && $ARGV[0] =~ /^-+(wa|wg)/i; + $self->{user}->wantusstate(1), ++$wantreal if $self->{user} && $ARGV[0] =~ /^-+(wa|wu)/i; + $self->{user}->wantdxitu(1), ++$wantreal if $self->{user} && $ARGV[0] =~ /^-+(wa|wi)/i; + $self->{user}->wantdxcq(1), ++$wantreal if $self->{user} && $ARGV[0] =~ /^-+(wa|wc)/i; + + shift @ARGV; +} + +$self->{ve7cc} = $ve7cc; $dxdir = "/spider/cmd/show"; $dxcmd = "dx.pl"; $s = readfilestr($dxdir, $dxcmd); -$dxproc = eval "sub { $s }"; + +eval $s; die $@ if $@; -STDOUT->autoflush(1); -Spot::init(); -Bands::load(); $expr = join ' ', @ARGV if @ARGV; for (;;) { if ($expr) { $myexpr = $expr; + $myexpr = 'real ' . $myexpr if $wantreal && $myexpr !~ /\breal\b/; } else { print "show/dx: "; $myexpr = ; last unless defined $myexpr; chomp $myexpr; last if $myexpr =~ /^q$/i; + $myexpr = 'real ' . $myexpr if $wantreal && $myexpr !~ /\breal\b/; } - my @out = map {"$_\n"} &$dxproc(undef, $myexpr); + + my @out = map {"$_\n"} handle($self, $myexpr); shift @out; # remove return code print @out; last if $expr; } -exit(0); +exit @out > 0 ? 0 : 1; + +sub help +{ + print qq{A static TEST Program that allows standalone sh/dx queries +from the command line. + +$0: Usage (examples) + showdx on 40m + showdx 50 on 40m + showdx by g1tlh + showdx -v -c g1tlh by g1tlh + showdx -w 132 -wc -wg -wu 50 on 40m + +$0: Arguments: + -?: + -h: print this text. + -c : pretend to be this callsign + -r: set 'real' mode (a.k.a show/fdx) (saves typing 'real ' in the query) + -v: output in VE7CC computer friendly mode. + -w : use this width + -wc: set want cq zones + -wg: set want grid squares + -wi: set want itu zones + -wu: set want US states + -wa: set all of the above + + NOTE: setting any of -wc, -wg, -wi, -wu flags implies adding 'real ' to + the query, if not already present. +}; +} + +sub dbg {}; +sub isdbg {};