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