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