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