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