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