]> dxcluster.org Git - spider.git/commitdiff
add DXSql module and condiational processing
authorminima <minima>
Wed, 21 Dec 2005 16:21:46 +0000 (16:21 +0000)
committerminima <minima>
Wed, 21 Dec 2005 16:21:46 +0000 (16:21 +0000)
perl/DXSql.pm [new file with mode: 0644]
perl/DXVars.pm.issue
perl/cluster.pl

diff --git a/perl/DXSql.pm b/perl/DXSql.pm
new file mode 100644 (file)
index 0000000..932b9b0
--- /dev/null
@@ -0,0 +1,50 @@
+#
+# 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;
+
index 1433d080b5ca8c175cccb12f0eff66b68daed41b..c8e0cc8d645ba2beac1b57ee5fa8dce3b14f9b0d 100644 (file)
@@ -9,19 +9,6 @@
 
 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";
@@ -98,3 +85,10 @@ $motd = "$data/motd";
 
 # 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;
index d2392ceb0e2337417656a025838f56d6784055d4..2510c940cd5bfdc107ce2d5dac415628a1887fe3 100755 (executable)
@@ -116,7 +116,7 @@ use strict;
 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
@@ -287,6 +287,9 @@ sub cease
        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);
@@ -351,6 +354,16 @@ $year += 1900;
 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());