fixed double logout messages
[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
429         return if $self->{disconnecting}++;
430
431         delete $self->{senddbg};
432
433         my $uref = Route::User::get($call);
434         my @rout;
435         if ($uref) {
436                 @rout = $main::routeroot->del_user($uref);
437                 dbg("B/C PC17 on $main::mycall for: $call") if isdbg('route');
438         } else {
439                 confess "trying to disconnect a non existant user $call";
440         }
441
442         # issue a pc17 to everybody interested
443         DXProt::route_pc17($DXProt::me, $main::routeroot, @rout) if @rout;
444
445         # I was the last node visited
446     $self->user->node($main::mycall);
447                 
448         # send info to all logged in thingies
449         $self->tell_login('logoutu');
450
451         Log('DXCommand', "$call disconnected");
452
453         $self->SUPER::disconnect;
454 }
455
456 #
457 # short cut to output a prompt
458 #
459
460 sub prompt
461 {
462         my $self = shift;
463         $self->send($self->msg($self->here ? 'pr' : 'pr2', $self->call, cldate($main::systime), ztime($main::systime)));
464 }
465
466 # broadcast a message to all users [except those mentioned after buffer]
467 sub broadcast
468 {
469         my $pkg = shift;                        # ignored
470         my $s = shift;                          # the line to be rebroadcast
471         
472     foreach my $dxchan (DXChannel->get_all()) {
473                 next unless $dxchan->{sort} eq 'U'; # only interested in user channels  
474                 next if grep $dxchan == $_, @_;
475                 $dxchan->send($s);                      # send it
476         }
477 }
478
479 # gimme all the users
480 sub get_all
481 {
482         return grep {$_->{sort} eq 'U'} DXChannel->get_all();
483 }
484
485 # run a script for this user
486 sub run_script
487 {
488         my $self = shift;
489         my $silent = shift || 0;
490         
491 }
492
493 #
494 # search for the command in the cache of short->long form commands
495 #
496
497 sub search
498 {
499         my ($path, $short_cmd, $suffix) = @_;
500         my ($apath, $acmd);
501         
502         # commands are lower case
503         $short_cmd = lc $short_cmd;
504         dbg("command: $path $short_cmd\n") if isdbg('command');
505
506         # do some checking for funny characters
507         return () if $short_cmd =~ /\/$/;
508
509         # return immediately if we have it
510         ($apath, $acmd) = split ',', $cmd_cache{$short_cmd} if $cmd_cache{$short_cmd};
511         if ($apath && $acmd) {
512                 dbg("cached $short_cmd = ($apath, $acmd)\n") if isdbg('command');
513                 return ($apath, $acmd);
514         }
515         
516         # if not guess
517         my @parts = split '/', $short_cmd;
518         my $dirfn;
519         my $curdir = $path;
520         my $p;
521         my $i;
522         my @lparts;
523         
524         for ($i = 0; $i < @parts; $i++) {
525                 my  $p = $parts[$i];
526                 opendir(D, $curdir) or confess "can't open $curdir $!";
527                 my @ls = readdir D;
528                 closedir D;
529                 my $l;
530                 foreach $l (sort @ls) {
531                         next if $l =~ /^\./;
532                         if ($i < $#parts) {             # we are dealing with directories
533                                 if ((-d "$curdir/$l") && $p eq substr($l, 0, length $p)) {
534                                         dbg("got dir: $curdir/$l\n") if isdbg('command');
535                                         $dirfn .= "$l/";
536                                         $curdir .= "/$l";
537                                         last;
538                                 }
539                         } else {                        # we are dealing with commands
540                                 @lparts = split /\./, $l;                  
541                                 next if $lparts[$#lparts] ne $suffix;        # only look for .$suffix files
542                                 if ($p eq substr($l, 0, length $p)) {
543                                         pop @lparts; #  remove the suffix
544                                         $l = join '.', @lparts;
545                                         #                 chop $dirfn;               # remove trailing /
546                                         $dirfn = "" unless $dirfn;
547                                         $cmd_cache{"$short_cmd"} = join(',', ($path, "$dirfn$l")); # cache it
548                                         dbg("got path: $path cmd: $dirfn$l\n") if isdbg('command');
549                                         return ($path, "$dirfn$l"); 
550                                 }
551                         }
552                 }
553         }
554         return ();  
555 }  
556
557 # clear the command name cache
558 sub clear_cmd_cache
559 {
560         %cmd_cache = ();
561 }
562
563 #
564 # the persistant execution of things from the command directories
565 #
566 #
567 # This allows perl programs to call functions dynamically
568
569 # This has been nicked directly from the perlembed pages
570 #
571
572 #require Devel::Symdump;  
573
574 sub valid_package_name {
575         my($string) = @_;
576         $string =~ s/([^A-Za-z0-9\/])/sprintf("_%2x",unpack("C",$1))/eg;
577         
578         #second pass only for words starting with a digit
579         $string =~ s|/(\d)|sprintf("/_%2x",unpack("C",$1))|eg;
580         
581         #Dress it up as a real package name
582         $string =~ s/\//_/og;
583         return $string;
584 }
585
586 # find a cmd reference
587 # this is really for use in user written stubs
588 #
589 # use the result as a symbolic reference:-
590 #
591 # no strict 'refs';
592 # @out = &$r($self, $line);
593 #
594 sub find_cmd_ref
595 {
596         my $cmd = shift;
597         my $r;
598         
599         if ($cmd) {
600                 
601                 # first expand out the entry to a command
602                 my ($path, $fcmd) = search($main::localcmd, $cmd, "pl");
603                 ($path, $fcmd) = search($main::cmd, $cmd, "pl") if !$path || !$fcmd;
604                 
605                 # make sure it is loaded
606                 $r = find_cmd_name($path, $fcmd);
607         }
608         return $r;
609 }
610
611
612 # this bit of magic finds a command in the offered directory
613 sub find_cmd_name {
614         my $path = shift;
615         my $cmdname = shift;
616         my $package = valid_package_name($cmdname);
617         my $filename = "$path/$cmdname.pl";
618         my $mtime = -M $filename;
619         
620         # return if we can't find it
621         $errstr = undef;
622         unless (defined $mtime) {
623                 $errstr = DXM::msg('e1');
624                 return undef;
625         }
626         
627         if(defined $Cache{$package}->{mtime} &&$Cache{$package}->{mtime} <= $mtime) {
628                 #we have compiled this subroutine already,
629                 #it has not been updated on disk, nothing left to do
630                 #print STDERR "already compiled $package->handler\n";
631                 ;
632         } else {
633
634                 my $sub = readfilestr($filename);
635                 unless ($sub) {
636                         $errstr = "Syserr: can't open '$filename' $!";
637                         return undef;
638                 };
639                 
640                 #wrap the code into a subroutine inside our unique package
641                 my $eval = qq( sub { $sub } );
642                 
643                 if (isdbg('eval')) {
644                         my @list = split /\n/, $eval;
645                         my $line;
646                         for (@list) {
647                                 dbg($_ . "\n") if isdbg('eval');
648                         }
649                 }
650                 
651                 $Cache{$package} = {mtime => $mtime, 'eval' => $eval };
652         }
653
654         return $package;
655 }
656
657 sub local_send
658 {
659         my ($self, $let, $buf) = @_;
660         if ($self->{state} eq 'prompt' || $self->{state} eq 'talk') {
661                 if ($self->{enhanced}) {
662                         $self->send_later($let, $buf);
663                 } else {
664                         $self->send($buf);
665                 }
666         } else {
667                 $self->delay($buf);
668         }
669 }
670
671 # send a talk message here
672 sub talk
673 {
674         my ($self, $from, $to, $via, $line) = @_;
675         $line =~ s/\\5E/\^/g;
676         $self->local_send('T', "$to de $from: $line") if $self->{talk};
677         Log('talk', $to, $from, $main::mycall, $line);
678         # send a 'not here' message if required
679         unless ($self->{here} && $from ne $to) {
680                 my $key = "$to$from";
681                 unless (exists $nothereslug{$key}) {
682                         my ($ref, $dxchan);
683                         if (($ref = Route::get($from)) && ($dxchan = $ref->dxchan)) {
684                                 my $name = $self->user->name || $to;
685                                 my $s = $self->user->nothere || $dxchan->msg('nothere', $name);
686                                 $nothereslug{$key} = $main::systime;
687                                 $dxchan->talk($to, $from, undef, $s);
688                         }
689                 }
690         }
691 }
692
693 # send an announce
694 sub announce
695 {
696         my $self = shift;
697         my $line = shift;
698         my $isolate = shift;
699         my $to = shift;
700         my $target = shift;
701         my $text = shift;
702         my ($filter, $hops);
703
704         if ($self->{annfilter}) {
705                 ($filter, $hops) = $self->{annfilter}->it(@_ );
706                 return unless $filter;
707         }
708
709         unless ($self->{ann}) {
710                 return if $_[0] ne $main::myalias && $_[0] ne $main::mycall;
711         }
712         return if $target eq 'SYSOP' && $self->{priv} < 5;
713         my $buf = "$to$target de $_[0]: $text";
714         $buf =~ s/\%5E/^/g;
715         $buf .= "\a\a" if $self->{beep};
716         $self->local_send($target eq 'WX' ? 'W' : 'N', $buf);
717 }
718
719 # send a dx spot
720 sub dx_spot
721 {
722         my $self = shift;
723         my $line = shift;
724         my $isolate = shift;
725         my ($filter, $hops);
726
727         return unless $self->{dx};
728         
729         if ($self->{spotsfilter}) {
730                 ($filter, $hops) = $self->{spotsfilter}->it(@_ );
731                 return unless $filter;
732         }
733
734         my $buf = Spot::formatb($self->{user}->wantgrid, $_[0], $_[1], $_[2], $_[3], $_[4]);
735         $buf .= "\a\a" if $self->{beep};
736         $buf =~ s/\%5E/^/g;
737         $self->local_send('X', $buf);
738 }
739
740 sub wwv
741 {
742         my $self = shift;
743         my $line = shift;
744         my $isolate = shift;
745         my ($filter, $hops);
746
747         return unless $self->{wwv};
748         
749         if ($self->{wwvfilter}) {
750                 ($filter, $hops) = $self->{wwvfilter}->it(@_ );
751                 return unless $filter;
752         }
753
754         my $buf = "WWV de $_[6] <$_[1]>:   SFI=$_[2], A=$_[3], K=$_[4], $_[5]";
755         $buf .= "\a\a" if $self->{beep};
756         $self->local_send('V', $buf);
757 }
758
759 sub wcy
760 {
761         my $self = shift;
762         my $line = shift;
763         my $isolate = shift;
764         my ($filter, $hops);
765
766         return unless $self->{wcy};
767         
768         if ($self->{wcyfilter}) {
769                 ($filter, $hops) = $self->{wcyfilter}->it(@_ );
770                 return unless $filter;
771         }
772
773         my $buf = "WCY de $_[10] <$_[1]> : K=$_[4] expK=$_[5] A=$_[3] R=$_[6] SFI=$_[2] SA=$_[7] GMF=$_[8] Au=$_[9]";
774         $buf .= "\a\a" if $self->{beep};
775         $self->local_send('Y', $buf);
776 }
777
778 # broadcast debug stuff to all interested parties
779 sub broadcast_debug
780 {
781         my $s = shift;                          # the line to be rebroadcast
782         
783         foreach my $dxchan (DXChannel->get_all) {
784                 next unless $dxchan->{enhanced} && $dxchan->{senddbg};
785                 $dxchan->send_later('L', $s);
786         }
787 }
788
789
790 1;
791 __END__