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