6986a41aa60b1d8188dbc06d7ce4715a32eb35c1
[spider.git] / perl / DXCommandmode.pm
1 #!/usr/bin/perl
2 #
3 # This module impliments the user facing command mode for a dx cluster
4 #
5 # Copyright (c) 1998 Dirk Koopman G1TLH
6 #
7 # $Id$
8
9
10 package DXCommandmode;
11
12 use POSIX;
13
14 @ISA = qw(DXChannel);
15
16 use DXUtil;
17 use DXChannel;
18 use DXUser;
19 use DXVars;
20 use DXDebug;
21 use DXM;
22 use DXLog;
23 use DXLogPrint;
24 use DXBearing;
25 use CmdAlias;
26 use Filter;
27 use Minimuf;
28 use DXDb;
29 use AnnTalk;
30 use WCY;
31 use Sun;
32 use Internet;
33
34 use strict;
35 use vars qw(%Cache %cmd_cache $errstr %aliases $scriptbase $maxerrors %nothereslug $suppress_ann_to_talk);
36
37 %Cache = ();                                    # cache of dynamically loaded routine's mod times
38 %cmd_cache = ();                                # cache of short names
39 $errstr = ();                                   # error string from eval
40 %aliases = ();                                  # aliases for (parts of) commands
41 $scriptbase = "$main::root/scripts"; # the place where all users start scripts go
42 $maxerrors = 20;                                # the maximum number of concurrent errors allowed before disconnection
43 $suppress_ann_to_talk = 1;              # don't announce 'to <call> ' or '<call> ' type announcements
44
45
46 use vars qw($VERSION $BRANCH);
47 $VERSION = sprintf( "%d.%03d", q$Revision$ =~ /(\d+)\.(\d+)/ );
48 $BRANCH = sprintf( "%d.%03d", q$Revision$ =~ /\d+\.\d+\.(\d+)\.(\d+)/ ) || 0;
49 $main::build += $VERSION;
50 $main::branch += $BRANCH;
51
52 #
53 # obtain a new connection this is derived from dxchannel
54 #
55
56 sub new 
57 {
58         my $self = DXChannel::alloc(@_);
59
60         # routing, this must go out here to prevent race condx
61         my $pkg = shift;
62         my $call = shift;
63         my @rout = $main::routeroot->add_user($call, Route::here(1));
64         DXProt::route_pc16($DXProt::me, $main::routeroot, @rout) if @rout;
65
66         return $self;
67 }
68
69 # this is how a a connection starts, you get a hello message and the motd with
70 # possibly some other messages asking you to set various things up if you are
71 # new (or nearly new and slacking) user.
72
73 sub start
74
75         my ($self, $line, $sort) = @_;
76         my $user = $self->{user};
77         my $call = $self->{call};
78         my $name = $user->{name};
79         
80         # log it
81         my $host = $self->{conn}->{peerhost} || "unknown";
82         Log('DXCommand', "$call connected from $host");
83
84         $self->{name} = $name ? $name : $call;
85         $self->send($self->msg('l2',$self->{name}));
86         $self->send_file($main::motd) if (-e $main::motd);
87         $self->state('prompt');         # a bit of room for further expansion, passwords etc
88         $self->{priv} = $user->priv || 0;
89         $self->{lang} = $user->lang || $main::lang || 'en';
90         $self->{pagelth} = $user->pagelth || 20;
91         $self->{priv} = 0 if $line =~ /^(ax|te)/; # set the connection priv to 0 - can be upgraded later
92         ($self->{width}) = $line =~ /width=(\d+)/;
93         $self->{width} = 80 unless $self->{width} && $self->{width} > 80;
94         $self->{consort} = $line;       # save the connection type
95         
96         # set some necessary flags on the user if they are connecting
97         $self->{beep} = $user->wantbeep;
98         $self->{ann} = $user->wantann;
99         $self->{wwv} = $user->wantwwv;
100         $self->{wcy} = $user->wantwcy;
101         $self->{talk} = $user->wanttalk;
102         $self->{wx} = $user->wantwx;
103         $self->{dx} = $user->wantdx;
104         $self->{logininfo} = $user->wantlogininfo;
105         $self->{here} = 1;
106
107         # get the filters
108         $self->{spotsfilter} = Filter::read_in('spots', $call, 0) || Filter::read_in('spots', 'user_default', 0);
109         $self->{wwvfilter} = Filter::read_in('wwv', $call, 0) || Filter::read_in('wwv', 'user_default', 0);
110         $self->{wcyfilter} = Filter::read_in('wcy', $call, 0) || Filter::read_in('wcy', 'user_default', 0);
111         $self->{annfilter} = Filter::read_in('ann', $call, 0) || Filter::read_in('ann', 'user_default', 0) ;
112
113         # clean up qra locators
114         my $qra = $user->qra;
115         $qra = undef if ($qra && !DXBearing::is_qra($qra));
116         unless ($qra) {
117                 my $lat = $user->lat;
118                 my $long = $user->long;
119                 $user->qra(DXBearing::lltoqra($lat, $long)) if (defined $lat && defined $long);  
120         }
121
122         # send prompts and things
123         my $info = Route::cluster();
124         $self->send("Cluster:$info");
125         $self->send($self->msg('namee1')) if !$user->name;
126         $self->send($self->msg('qthe1')) if !$user->qth;
127         $self->send($self->msg('qll')) if !$user->qra || (!$user->lat && !$user->long);
128         $self->send($self->msg('hnodee1')) if !$user->qth;
129         $self->send($self->msg('m9')) if DXMsg::for_me($call);
130         $self->prompt;
131
132         # decide on echo
133         if (!$user->wantecho) {
134                 $self->send_now('E', "0");
135                 $self->send($self->msg('echow'));
136         }
137         
138         $self->tell_login('loginu');
139         
140         # do we need to send a forward/opernam?
141         my $lastoper = $user->lastoper || 0;
142         my $homenode = $user->homenode || ""; 
143         if ($homenode eq $main::mycall && $lastoper + $DXUser::lastoperinterval < $main::systime) {
144                 run_cmd($DXProt::me, "forward/opernam $call");
145                 $user->lastoper($main::systime);
146         }
147 }
148
149 #
150 # This is the normal command prompt driver
151 #
152
153 sub normal
154 {
155         my $self = shift;
156         my $cmdline = shift;
157         my @ans;
158         
159         # remove leading and trailing spaces
160         $cmdline =~ s/^\s*(.*)\s*$/$1/;
161         
162         if ($self->{state} eq 'page') {
163                 my $i = $self->{pagelth};
164                 my $ref = $self->{pagedata};
165                 my $tot = @$ref;
166                 
167                 # abort if we get a line starting in with a
168                 if ($cmdline =~ /^a/io) {
169                         undef $ref;
170                         $i = 0;
171                 }
172         
173                 # send a tranche of data
174                 while ($i-- > 0 && @$ref) {
175                         my $line = shift @$ref;
176                         $line =~ s/\s+$//o;     # why am having to do this? 
177                         $self->send($line);
178                 }
179                 
180                 # reset state if none or else chuck out an intermediate prompt
181                 if ($ref && @$ref) {
182                         $tot -= $self->{pagelth};
183                         $self->send($self->msg('page', $tot));
184                 } else {
185                         $self->state('prompt');
186                 }
187         } elsif ($self->{state} eq 'sysop') {
188                 my $passwd = $self->{user}->passwd;
189                 my @pw = split / */, $passwd;
190                 if ($passwd) {
191                         my @l = @{$self->{passwd}};
192                         my $str = "$pw[$l[0]].*$pw[$l[1]].*$pw[$l[2]].*$pw[$l[3]].*$pw[$l[4]]";
193                         if ($cmdline =~ /$str/) {
194                                 $self->{priv} = $self->{user}->priv;
195                         } else {
196                                 $self->send($self->msg('sorry'));
197                         }
198                 } else {
199                         $self->send($self->msg('sorry'));
200                 }
201                 delete $self->{passwd};
202                 $self->state('prompt');
203         } elsif ($self->{state} eq 'talk') {
204                 if ($cmdline =~ m{^(?:/EX|/ABORT)}i) {
205                         for (@{$self->{talklist}}) {
206                                 $self->send_talks($_,  $self->msg('talkend'));
207                         }
208                         $self->state('prompt');
209                         delete $self->{talklist};
210                 } elsif ($cmdline =~ m(^/\w+)) {
211                         $cmdline =~ s(^/)();
212                         $self->send_ans(run_cmd($self, $cmdline));
213                         $self->send($self->talk_prompt);
214                 } elsif ($self->{talklist} && @{$self->{talklist}}) {
215                         # send what has been said to whoever is in this person's talk list
216                         for (@{$self->{talklist}}) {
217                                 $self->send_talks($_, $cmdline);
218                         }
219                         $self->send($self->talk_prompt) if $self->{state} eq 'talk';
220                 } else {
221                         # for safety
222                         $self->state('prompt');
223                 }
224         } else {
225                 $self->send_ans(run_cmd($self, $cmdline));
226         } 
227         
228         # send a prompt only if we are in a prompt state
229         $self->prompt() if $self->{state} =~ /^prompt/o;
230 }
231
232 # send out the talk messages taking into account vias and connectivity
233 sub send_talks
234 {
235         my ($self, $ent, $line) = @_;
236         
237         my ($to, $via) = $ent =~ /(\S+)>(\S+)/;
238         $to = $ent unless $to;
239         my $call = $via ? $via : $to;
240         my $clref = Route::get($call);
241         my $dxchan = $clref->dxchan if $clref;
242         if ($dxchan) {
243                 $dxchan->talk($self->{call}, $to, $via, $line);
244         } else {
245                 $self->send($self->msg('disc2', $via ? $via : $to));
246                 my @l = grep { $_ ne $ent } @{$self->{talklist}};
247                 if (@l) {
248                         $self->{talklist} = \@l;
249                 } else {
250                         delete $self->{talklist};
251                         $self->state('prompt');
252                 }
253         }
254 }
255
256 sub talk_prompt
257 {
258         my $self = shift;
259         my @call;
260         for (@{$self->{talklist}}) {
261                 my ($to, $via) = /(\S+)>(\S+)/;
262                 $to = $_ unless $to;
263                 push @call, $to;
264         }
265         return $self->msg('talkprompt', join(',', @call));
266 }
267
268 #
269 # send a load of stuff to a command user with page prompting
270 # and stuff
271 #
272
273 sub send_ans
274 {
275         my $self = shift;
276         
277         if ($self->{pagelth} && @_ > $self->{pagelth}) {
278                 my $i;
279                 for ($i = $self->{pagelth}; $i-- > 0; ) {
280                         my $line = shift @_;
281                         $line =~ s/\s+$//o;     # why am having to do this? 
282                         $self->send($line);
283                 }
284                 $self->{pagedata} =  [ @_ ];
285                 $self->state('page');
286                 $self->send($self->msg('page', scalar @_));
287         } else {
288                 for (@_) {
289                         if (defined $_) {
290                                 $self->send($_);
291                         } else {
292                                 $self->send('');
293                         }
294                 }
295         } 
296 }
297
298 # this is the thing that runs the command, it is done like this for the 
299 # benefit of remote command execution
300 #
301
302 sub run_cmd
303 {
304         my $self = shift;
305         my $user = $self->{user};
306         my $call = $self->{call};
307         my $cmdline = shift;
308         my @ans;
309         
310         if ($self->{func}) {
311                 my $c = qq{ \@ans = $self->{func}(\$self, \$cmdline) };
312                 dbg("stored func cmd = $c\n") if isdbg('eval');
313                 eval  $c;
314                 if ($@) {
315                         return ("Syserr: Eval err $errstr on stored func $self->{func}", $@);
316                 }
317         } else {
318
319                 return () if length $cmdline == 0;
320                 
321                 # strip out //
322                 $cmdline =~ s|//|/|og;
323                 
324                 # split the command line up into parts, the first part is the command
325                 my ($cmd, $args) = split /\s+/, $cmdline, 2;
326                 $args = "" unless defined $args;
327                 
328                 if ($cmd) {
329                         
330                         my ($path, $fcmd);
331                         
332                         dbg("cmd: $cmd") if isdbg('command');
333                         
334                         # alias it if possible
335                         my $acmd = CmdAlias::get_cmd($cmd);
336                         if ($acmd) {
337                                 ($cmd, $args) = split /\s+/, "$acmd $args", 2;
338                                 $args = "" unless defined $args;
339                                 dbg("aliased cmd: $cmd $args") if isdbg('command');
340                         }
341                         
342                         # first expand out the entry to a command
343                         ($path, $fcmd) = search($main::localcmd, $cmd, "pl");
344                         ($path, $fcmd) = search($main::cmd, $cmd, "pl") if !$path || !$fcmd;
345
346                         if ($path && $cmd) {
347                                 dbg("path: $cmd cmd: $fcmd") if isdbg('command');
348                         
349                                 my $package = find_cmd_name($path, $fcmd);
350                                 @ans = (0) if !$package ;
351                                 
352                                 if ($package) {
353                                         dbg("package: $package") if isdbg('command');
354                                         my $c;
355                                         unless (exists $Cache{$package}->{'sub'}) {
356                                                 $c = eval $Cache{$package}->{'eval'};
357                                                 if ($@) {
358                                                         return DXDebug::shortmess($@);
359                                                 }
360                                                 $Cache{$package}->{'sub'} = $c;
361                                         }
362                                         $c = $Cache{$package}->{'sub'};
363                                         eval {
364                                                 @ans = &{$c}($self, $args);
365                                     };
366                                         
367                                         if ($@) {
368                                                 #cluck($@);
369                                                 return (DXDebug::shortmess($@));
370                                         };
371                                 }
372                         } else {
373                                 dbg("cmd: $cmd not found") if isdbg('command');
374                                 if (++$self->{errors} > $maxerrors) {
375                                         $self->send($self->msg('e26'));
376                                         $self->disconnect;
377                                         return ();
378                                 } else {
379                                         return ($self->msg('e1'));
380                                 }
381                         }
382                 }
383         }
384         
385         my $ok = shift @ans;
386         if ($ok) {
387                 delete $self->{errors};
388         } else {
389                 if (++$self->{errors} > $maxerrors) {
390                         $self->send($self->msg('e26'));
391                         $self->disconnect;
392                         return ();
393                 }
394         }
395         return (@ans);
396 }
397
398 #
399 # This is called from inside the main cluster processing loop and is used
400 # for despatching commands that are doing some long processing job
401 #
402 sub process
403 {
404         my $t = time;
405         my @dxchan = DXChannel->get_all();
406         my $dxchan;
407         
408         foreach $dxchan (@dxchan) {
409                 next if $dxchan->sort ne 'U';  
410                 
411                 # send a prompt if no activity out on this channel
412                 if ($t >= $dxchan->t + $main::user_interval) {
413                         $dxchan->prompt() if $dxchan->{state} =~ /^prompt/o;
414                         $dxchan->t($t);
415                 }
416         }
417
418         while (my ($k, $v) = each %nothereslug) {
419                 if ($main::systime >= $v + 300) {
420                         delete $nothereslug{$k};
421                 }
422         }
423 }
424
425 #
426 # finish up a user context
427 #
428 sub disconnect
429 {
430         my $self = shift;
431         my $call = $self->call;
432
433         return if $self->{disconnecting}++;
434
435         delete $self->{senddbg};
436
437         my $uref = Route::User::get($call);
438         my @rout;
439         if ($uref) {
440                 @rout = $main::routeroot->del_user($uref);
441                 dbg("B/C PC17 on $main::mycall for: $call") if isdbg('route');
442         } else {
443                 confess "trying to disconnect a non existant user $call";
444         }
445
446         # issue a pc17 to everybody interested
447         DXProt::route_pc17($DXProt::me, $main::routeroot, @rout) if @rout;
448
449         # I was the last node visited
450     $self->user->node($main::mycall);
451                 
452         # send info to all logged in thingies
453         $self->tell_login('logoutu');
454
455         Log('DXCommand', "$call disconnected");
456
457         $self->SUPER::disconnect;
458 }
459
460 #
461 # short cut to output a prompt
462 #
463
464 sub prompt
465 {
466         my $self = shift;
467         $self->send($self->msg($self->here ? 'pr' : 'pr2', $self->call, cldate($main::systime), ztime($main::systime)));
468 }
469
470 # broadcast a message to all users [except those mentioned after buffer]
471 sub broadcast
472 {
473         my $pkg = shift;                        # ignored
474         my $s = shift;                          # the line to be rebroadcast
475         
476     foreach my $dxchan (DXChannel->get_all()) {
477                 next unless $dxchan->{sort} eq 'U'; # only interested in user channels  
478                 next if grep $dxchan == $_, @_;
479                 $dxchan->send($s);                      # send it
480         }
481 }
482
483 # gimme all the users
484 sub get_all
485 {
486         return grep {$_->{sort} eq 'U'} DXChannel->get_all();
487 }
488
489 # run a script for this user
490 sub run_script
491 {
492         my $self = shift;
493         my $silent = shift || 0;
494         
495 }
496
497 #
498 # search for the command in the cache of short->long form commands
499 #
500
501 sub search
502 {
503         my ($path, $short_cmd, $suffix) = @_;
504         my ($apath, $acmd);
505         
506         # commands are lower case
507         $short_cmd = lc $short_cmd;
508         dbg("command: $path $short_cmd\n") if isdbg('command');
509
510         # do some checking for funny characters
511         return () if $short_cmd =~ /\/$/;
512
513         # return immediately if we have it
514         ($apath, $acmd) = split ',', $cmd_cache{$short_cmd} if $cmd_cache{$short_cmd};
515         if ($apath && $acmd) {
516                 dbg("cached $short_cmd = ($apath, $acmd)\n") if isdbg('command');
517                 return ($apath, $acmd);
518         }
519         
520         # if not guess
521         my @parts = split '/', $short_cmd;
522         my $dirfn;
523         my $curdir = $path;
524         my $p;
525         my $i;
526         my @lparts;
527         
528         for ($i = 0; $i < @parts; $i++) {
529                 my  $p = $parts[$i];
530                 opendir(D, $curdir) or confess "can't open $curdir $!";
531                 my @ls = readdir D;
532                 closedir D;
533                 my $l;
534                 foreach $l (sort @ls) {
535                         next if $l =~ /^\./;
536                         if ($i < $#parts) {             # we are dealing with directories
537                                 if ((-d "$curdir/$l") && $p eq substr($l, 0, length $p)) {
538                                         dbg("got dir: $curdir/$l\n") if isdbg('command');
539                                         $dirfn .= "$l/";
540                                         $curdir .= "/$l";
541                                         last;
542                                 }
543                         } else {                        # we are dealing with commands
544                                 @lparts = split /\./, $l;                  
545                                 next if $lparts[$#lparts] ne $suffix;        # only look for .$suffix files
546                                 if ($p eq substr($l, 0, length $p)) {
547                                         pop @lparts; #  remove the suffix
548                                         $l = join '.', @lparts;
549                                         #                 chop $dirfn;               # remove trailing /
550                                         $dirfn = "" unless $dirfn;
551                                         $cmd_cache{"$short_cmd"} = join(',', ($path, "$dirfn$l")); # cache it
552                                         dbg("got path: $path cmd: $dirfn$l\n") if isdbg('command');
553                                         return ($path, "$dirfn$l"); 
554                                 }
555                         }
556                 }
557         }
558         return ();  
559 }  
560
561 # clear the command name cache
562 sub clear_cmd_cache
563 {
564         %cmd_cache = ();
565 }
566
567 #
568 # the persistant execution of things from the command directories
569 #
570 #
571 # This allows perl programs to call functions dynamically
572
573 # This has been nicked directly from the perlembed pages
574 #
575
576 #require Devel::Symdump;  
577
578 sub valid_package_name {
579         my($string) = @_;
580         $string =~ s/([^A-Za-z0-9\/])/sprintf("_%2x",unpack("C",$1))/eg;
581         
582         #second pass only for words starting with a digit
583         $string =~ s|/(\d)|sprintf("/_%2x",unpack("C",$1))|eg;
584         
585         #Dress it up as a real package name
586         $string =~ s/\//_/og;
587         return $string;
588 }
589
590 # find a cmd reference
591 # this is really for use in user written stubs
592 #
593 # use the result as a symbolic reference:-
594 #
595 # no strict 'refs';
596 # @out = &$r($self, $line);
597 #
598 sub find_cmd_ref
599 {
600         my $cmd = shift;
601         my $r;
602         
603         if ($cmd) {
604                 
605                 # first expand out the entry to a command
606                 my ($path, $fcmd) = search($main::localcmd, $cmd, "pl");
607                 ($path, $fcmd) = search($main::cmd, $cmd, "pl") if !$path || !$fcmd;
608                 
609                 # make sure it is loaded
610                 $r = find_cmd_name($path, $fcmd);
611         }
612         return $r;
613 }
614
615
616 # this bit of magic finds a command in the offered directory
617 sub find_cmd_name {
618         my $path = shift;
619         my $cmdname = shift;
620         my $package = valid_package_name($cmdname);
621         my $filename = "$path/$cmdname.pl";
622         my $mtime = -M $filename;
623         
624         # return if we can't find it
625         $errstr = undef;
626         unless (defined $mtime) {
627                 $errstr = DXM::msg('e1');
628                 return undef;
629         }
630         
631         if(defined $Cache{$package}->{mtime} &&$Cache{$package}->{mtime} <= $mtime) {
632                 #we have compiled this subroutine already,
633                 #it has not been updated on disk, nothing left to do
634                 #print STDERR "already compiled $package->handler\n";
635                 ;
636         } else {
637
638                 my $sub = readfilestr($filename);
639                 unless ($sub) {
640                         $errstr = "Syserr: can't open '$filename' $!";
641                         return undef;
642                 };
643                 
644                 #wrap the code into a subroutine inside our unique package
645                 my $eval = qq( sub { $sub } );
646                 
647                 if (isdbg('eval')) {
648                         my @list = split /\n/, $eval;
649                         my $line;
650                         for (@list) {
651                                 dbg($_ . "\n") if isdbg('eval');
652                         }
653                 }
654                 
655                 $Cache{$package} = {mtime => $mtime, 'eval' => $eval };
656         }
657
658         return $package;
659 }
660
661 sub local_send
662 {
663         my ($self, $let, $buf) = @_;
664         if ($self->{state} eq 'prompt' || $self->{state} eq 'talk') {
665                 if ($self->{enhanced}) {
666                         $self->send_later($let, $buf);
667                 } else {
668                         $self->send($buf);
669                 }
670         } else {
671                 $self->delay($buf);
672         }
673 }
674
675 # send a talk message here
676 sub talk
677 {
678         my ($self, $from, $to, $via, $line) = @_;
679         $line =~ s/\\5E/\^/g;
680         $self->local_send('T', "$to de $from: $line") if $self->{talk};
681         Log('talk', $to, $from, $main::mycall, $line);
682         # send a 'not here' message if required
683         unless ($self->{here} && $from ne $to) {
684                 my $key = "$to$from";
685                 unless (exists $nothereslug{$key}) {
686                         my ($ref, $dxchan);
687                         if (($ref = Route::get($from)) && ($dxchan = $ref->dxchan)) {
688                                 my $name = $self->user->name || $to;
689                                 my $s = $self->user->nothere || $dxchan->msg('nothere', $name);
690                                 $nothereslug{$key} = $main::systime;
691                                 $dxchan->talk($to, $from, undef, $s);
692                         }
693                 }
694         }
695 }
696
697 # send an announce
698 sub announce
699 {
700         my $self = shift;
701         my $line = shift;
702         my $isolate = shift;
703         my $to = shift;
704         my $target = shift;
705         my $text = shift;
706         my ($filter, $hops);
707
708         if ($suppress_ann_to_talk) {
709                 my ($to, $call) = $text =~ /^\s*([\w-]+)[\s:]+([\w-]+)/;
710                 return if ($to && $call && ((uc $to =~ /^TO?$/ && is_callsign(uc $call)) || is_callsign($call = uc $to)));
711         }       
712
713         if ($self->{annfilter}) {
714                 ($filter, $hops) = $self->{annfilter}->it(@_ );
715                 return unless $filter;
716         }
717
718         unless ($self->{ann}) {
719                 return if $_[0] ne $main::myalias && $_[0] ne $main::mycall;
720         }
721         return if $target eq 'SYSOP' && $self->{priv} < 5;
722         my $buf = "$to$target de $_[0]: $text";
723         $buf =~ s/\%5E/^/g;
724         $buf .= "\a\a" if $self->{beep};
725         $self->local_send($target eq 'WX' ? 'W' : 'N', $buf);
726 }
727
728 # send a dx spot
729 sub dx_spot
730 {
731         my $self = shift;
732         my $line = shift;
733         my $isolate = shift;
734         my ($filter, $hops);
735
736         return unless $self->{dx};
737         
738         if ($self->{spotsfilter}) {
739                 ($filter, $hops) = $self->{spotsfilter}->it(@_ );
740                 return unless $filter;
741         }
742
743         my $buf = Spot::formatb($self->{user}->wantgrid, $_[0], $_[1], $_[2], $_[3], $_[4]);
744         $buf .= "\a\a" if $self->{beep};
745         $buf =~ s/\%5E/^/g;
746         $self->local_send('X', $buf);
747 }
748
749 sub wwv
750 {
751         my $self = shift;
752         my $line = shift;
753         my $isolate = shift;
754         my ($filter, $hops);
755
756         return unless $self->{wwv};
757         
758         if ($self->{wwvfilter}) {
759                 ($filter, $hops) = $self->{wwvfilter}->it(@_ );
760                 return unless $filter;
761         }
762
763         my $buf = "WWV de $_[6] <$_[1]>:   SFI=$_[2], A=$_[3], K=$_[4], $_[5]";
764         $buf .= "\a\a" if $self->{beep};
765         $self->local_send('V', $buf);
766 }
767
768 sub wcy
769 {
770         my $self = shift;
771         my $line = shift;
772         my $isolate = shift;
773         my ($filter, $hops);
774
775         return unless $self->{wcy};
776         
777         if ($self->{wcyfilter}) {
778                 ($filter, $hops) = $self->{wcyfilter}->it(@_ );
779                 return unless $filter;
780         }
781
782         my $buf = "WCY de $_[10] <$_[1]> : K=$_[4] expK=$_[5] A=$_[3] R=$_[6] SFI=$_[2] SA=$_[7] GMF=$_[8] Au=$_[9]";
783         $buf .= "\a\a" if $self->{beep};
784         $self->local_send('Y', $buf);
785 }
786
787 # broadcast debug stuff to all interested parties
788 sub broadcast_debug
789 {
790         my $s = shift;                          # the line to be rebroadcast
791         
792         foreach my $dxchan (DXChannel->get_all) {
793                 next unless $dxchan->{enhanced} && $dxchan->{senddbg};
794                 $dxchan->send_later('L', $s);
795         }
796 }
797
798
799 1;
800 __END__