04Nov99=======================================================================
1. Removed ~ from the end of the PC18.
+2. Removed a hangover from duff character checking in cluster.pl
03Nov99=======================================================================
1. Simplified command caching so it uses anonymous subroutines, you should
also get error messages back on the console now when developing.
package DXCommandmode;
use POSIX;
-use IO::File;
@ISA = qw(DXChannel);
use Filter;
use Carp;
use Minimuf;
+use DXDb;
use strict;
-use vars qw(%Cache %cmd_cache $errstr %aliases);
+use vars qw(%Cache %cmd_cache $errstr %aliases $scriptbase);
%Cache = (); # cache of dynamically loaded routine's mod times
%cmd_cache = (); # cache of short names
$errstr = (); # error string from eval
%aliases = (); # aliases for (parts of) commands
+$scriptbase = "$main::root/scripts"; # the place where all users start scripts go
#
# obtain a new connection this is derived from dxchannel
return @out;
}
+# run a script for this user
+sub run_script
+{
+ my $self = shift;
+ my $silent = shift || 0;
+
+}
+
#
# search for the command in the cache of short->long form commands
#
#print STDERR "already compiled $package->handler\n";
;
} else {
-
- my $fh = new IO::File;
- if (!open $fh, $filename) {
+
+ my $sub = readfilestr($filename);
+ unless ($sub) {
$errstr = "Syserr: can't open '$filename' $!";
return undef;
};
- local $/ = undef;
- my $sub = <$fh>;
- close $fh;
#wrap the code into a subroutine inside our unique package
my $eval = qq( sub { $sub } );
+#!/usr/bin/perl -w
+#
+# Database Handler module for DXSpider
+#
+# Copyright (c) 1999 Dirk Koopman G1TLH
+#
+
+
+1;
sub load_forward
{
my @out;
- do "$forwardfn" if -e "$forwardfn";
- push @out, $@ if $@;
+ my $s = readfilestr($forwardfn);
+ if ($s) {
+ eval $s;
+ push @out, $@ if $@;
+ }
return @out;
}
sub load_badmsg
{
my @out;
- do "$badmsgfn" if -e "$badmsgfn";
- push @out, $@ if $@;
+ my $s = readfilestr($badmsgfn);
+ if ($s) {
+ eval $s;
+ push @out, $@ if $@;
+ }
return @out;
}
package DXUtil;
use Date::Parse;
+use IO::File;
+
use Carp;
require Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(atime ztime cldate cldatetime slat slong yesno promptf
- parray parraypairs shellregex
+ parray parraypairs shellregex readfilestr
print_all_fields cltounix iscallsign
);
return 1 if $call =~ /^\d+\w+/;
return undef;
}
+
+# read in a file into a string and return it.
+# the filename can be split into a dir and file and the
+# file can be in upper or lower case.
+# there can also be a suffix
+sub readfilestr
+{
+ my ($dir, $file, $suffix) = @_;
+ my $fn;
+
+ if ($suffix) {
+ $fn = "$dir/$file.$suffix";
+ unless (-e $fn) {
+ my $f = uc $file;
+ $fn = "$dir/$file.$suffix";
+ }
+ } elsif ($file) {
+ $fn = "$dir/$file";
+ unless (-e $fn) {
+ my $f = uc $file;
+ $fn = "$dir/$file";
+ }
+ } else {
+ $fn = $dir;
+ }
+ my $fh = new IO::File $fn;
+ my $s = undef;
+ if ($fh) {
+ local $/ = undef;
+ $s = <$fh>;
+ $fh->close;
+ }
+ return $s;
+}
use CmdAlias;
use Filter;
use Local;
+use DXDb;
use Fcntl ':flock';
use Carp qw(cluck);
# translate any crappy characters into hex characters
if ($line =~ /[\x00-\x06\x08\x0a-\x1f\x7f-\xff]/o) {
$line =~ s/([\x00-\x1f\x7f-\xff])/uc sprintf("%%%02x",ord($1))/eg;
- ++$error;
-# dbg('chan', "<- $sort $call **CRAP**: $line");
-# return;
}
# do the really sexy console interface bit! (Who is going to do the TK interface then?)
$dxchan->start($line, $sort);
} elsif ($sort eq 'I') {
die "\$user not defined for $call" if !defined $user;
-
- if ($error) {
- dbg('chan', "DROPPED with $error duff characters");
- } else {
- # normal input
- $dxchan->normal($line);
- }
+ # normal input
+ $dxchan->normal($line);
disconnect($dxchan) if ($dxchan->{state} eq 'bye');
} elsif ($sort eq 'Z') {
disconnect($dxchan);