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