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