--- /dev/null
+#
+# The master SQL module
+#
+# $Id$
+#
+# Copyright (c) 2006 Dirk Koopman G1TLH
+#
+
+package DXSql;
+
+use strict;
+
+our $active = 0;
+
+sub init
+{
+ return $active if $active;
+
+ eval {
+ require DBI;
+ };
+ unless ($@) {
+ import DBI;
+ $active++;
+ }
+ return $active;
+}
+
+sub new
+{
+ my $class = shift;
+ my $dsn = shift;
+ my $user = shift;
+ my $passwd = shift;
+ my $self;
+
+ return undef unless $active;
+ my $dbh;
+ eval {$dbh = DBI->connect($dsn, $user, $passwd); };
+ $self = bless {dbh => $dbh}, $class if $dbh;
+ return $self;
+}
+
+sub finish
+{
+ my $self = shift;
+ $self->{dbh}->disconnect;
+}
+1;
+
package main;
-require Exporter;
-@ISA = qw(Exporter);
-
-@EXPORT_OK = qw($mycall $myname $myalias $mylatitude $mylongtitude $mylocator
- $myqth $myemail $myprot_version
- $clusterport $clusteraddr $debugfn
- $def_hopcount $data $system $cmd
- $userfn $motd $local_cmd $mybbsaddr
- $lang @my_cc
- $pc50_interval $user_interval
- );
-
-
# this really does need to change for your system!!!!
# use CAPITAL LETTERS
$mycall = "GB7DJK";
# are we debugging ?
@debug = qw(chan state msg cron connect);
+
+# the SQL database DBI dsn
+#$dsn = "dbi:sqlite:$root/data/dxspider.db";
+#$dbuser = "";
+#$dbpass = "";
+
+1;
use vars qw(@inqueue $systime $version $starttime $lockfn @outstanding_connects
$zombies $root @listeners $lang $myalias @debug $userfn $clusteraddr
$clusterport $mycall $decease $is_win $routeroot $me $reqreg $bumpexisting
- $allowdxby
+ $allowdxby $dbh $dsn $dbuser $dbpass
);
@inqueue = (); # the main input queue, an array of hashes
Log('cluster', "DXSpider V$version, build $build ended");
dbgclose();
Logclose();
+
+ $dbh->finish if $dbh;
+
unlink $lockfn;
# $SIG{__WARN__} = $SIG{__DIE__} = sub {my $a = shift; cluck($a); };
exit(0);
dbg("Copyright (c) 1998-$year Dirk Koopman G1TLH");
dbg("DXSpider Version $version, build $build started");
+# try to load the database
+if ($dsn && -e "$root/perl/DXSql.pm") {
+ require DXSql;
+ import DXSql;
+
+ if (DXSql::init()) {
+ $dbh = DXSql->new($dsn, $dbuser, $dbpass);
+ }
+}
+
# load Prefixes
dbg("loading prefixes ...");
dbg(USDB::init());