]> git.donarmstrong.com Git - debbugs.git/commitdiff
[project @ 2000-03-18 01:40:03 by gecko]
authorgecko <>
Sat, 18 Mar 2000 09:40:03 +0000 (01:40 -0800)
committergecko <>
Sat, 18 Mar 2000 09:40:03 +0000 (01:40 -0800)
Start of scripts... these are ripped from Debvote :)

Debbugs/Config.pm [new file with mode: 0644]
Debbugs/DBase.pm [new file with mode: 0644]
Debbugs/Email.pm [new file with mode: 0644]

diff --git a/Debbugs/Config.pm b/Debbugs/Config.pm
new file mode 100644 (file)
index 0000000..679b9df
--- /dev/null
@@ -0,0 +1,97 @@
+package Debvote::Config;  # assumes Some/Module.pm
+
+use strict;
+
+BEGIN 
+{      use Exporter   ();
+       use vars       qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
+       
+    # set the version for version checking
+    $VERSION     = 1.00;
+
+    @ISA         = qw(Exporter);
+    @EXPORT      = qw( );
+    %EXPORT_TAGS = ( );     # eg: TAG => [ qw!name1 name2! ],
+
+    # your exported package globals go here,
+    # as well as any optionally exported functions
+    @EXPORT_OK   = qw(%Globals &ParseConfigFile);
+}
+
+use vars      @EXPORT_OK;
+
+# initialize package globals, first exported ones
+%Globals = (   "debug" => 0,
+               "verbose" => 0,
+               "quiet" => 0,
+               ##### domains
+               "email-domain" => "bugs.domain.com",
+               "list-domain" => "lists.domain.com",
+               "web-domain" => "web.domain.com",
+               "cgi-domain" => "cgi.domain.com",
+               ##### identification
+               "project-short" => "debbugs",
+               "project-long" => "Debbugs Test Project",
+               "owner-name" => "Fred Flintstone",
+               "owner-email" => "owner@bugs.domain.com",
+               ##### directories
+               "data-dir" => "/var/lib/debbugs/spool",
+               "spool-dir" => "/var/lib/debbugs/spool/incoming",
+               "www-dir" => "/var/lib/debbugs/www",
+               "doc-dir" => "/var/lib/debbugs/www/txt",
+               "maintainer-file" => "/etc/debbugs/Maintainers",
+               "database" => "debvote.db" );
+
+#############################################################################
+#  Read Config File and parse
+#############################################################################
+sub ParseConfigFile
+{   my $configfile = $_[0];
+    my @config;
+    my $votetitle = '';
+    my $ballottype = '';
+
+    #load config file
+    print "V: Loading Config File\n" if $Globals{ "verbose" };
+    open(CONFIG,$configfile) or &::fail( "E: Unable to open `$configfile'" );
+    @config = <CONFIG>;
+    close CONFIG;
+
+    #parse config file
+    print "V: Parsing Config File\n" if $Globals{ "verbose" };
+    print "D3: Parse Config:\n@config\n" if $Globals{ 'debug' } > 2;
+    for( my $i=0; $i<=$#config; $i++)
+    {  $_ = $config[$i];
+       chop $_;
+       next unless length $_;
+       next if /^#/;
+       if ( /^Ballot Type\s*[:=]\s*([^#]*)\s*(#.*)?/i )
+       {   my $ballottype = $1;
+           chop $ballottype while $ballottype =~ /\s$/;
+           $ballottype =~ y/A-Z/a-z/;
+           $Globals{ 'ballottype' } = $ballottype;
+       }
+       elsif ( /^Database\s*[:=]\s*(\S+)/i )
+       { $Globals{ 'database' } = $1; }
+       elsif( /^Ballot Ack\s*[:=]\s*([^#]*)/i )
+       { $Globals{ "response" } = $1; }
+       elsif( /^Ballot Template\s*[:=]\s*([^#]*)/i )
+       { $Globals{ "ballot" } = $1; }
+       elsif( /^No Ballot Letter\s*[:=]\s*([^#]*)/i )
+       { $Globals{ "noballot" } = $1; }
+       elsif ( /^Title\s*[:=]\s*([^#]*)/i )
+       { $Globals{ 'title' } = $1; }
+    }
+    if( $Globals{ "debug" } )
+    {
+       print "D1: Configuration\n";
+       print "\tBallot Type = $Globals{ 'ballottype' }\n";
+       print "\tDatabase = $Globals{ 'database' }\n";
+       print "\tBallot Ack = $Globals{ 'response' }\n";
+       print "\tBallot Template = $Globals{ 'ballot' }\n";
+       print "\tTitle = $Globals{ 'title' }\n";
+    }
+    return @config;
+}
+
+END { }       # module clean-up code here (global destructor)
diff --git a/Debbugs/DBase.pm b/Debbugs/DBase.pm
new file mode 100644 (file)
index 0000000..2892f11
--- /dev/null
@@ -0,0 +1,57 @@
+package Debvote::Rank;  # assumes Some/Module.pm
+
+use strict;
+
+BEGIN {
+       use Exporter   ();
+       use vars       qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
+
+       # set the version for version checking
+       $VERSION     = 1.00;
+
+       @ISA         = qw(Exporter);
+       @EXPORT      = qw(&func1 &func2 &func4);
+       %EXPORT_TAGS = ( );     # eg: TAG => [ qw!name1 name2! ],
+
+       # your exported package globals go here,
+       # as well as any optionally exported functions
+       @EXPORT_OK   = qw($Var1 %Hashit &func3);
+}
+
+use vars      @EXPORT_OK;
+
+# non-exported package globals go here
+use vars      qw(@more $stuff);
+
+# initialize package globals, first exported ones
+$Var1   = '';
+%Hashit = ();
+
+# then the others (which are still accessible as
+# $Some::Module::stuff)
+$stuff  = '';
+@more   = ();
+
+# all file-scoped lexicals must be created before
+# the functions below that use them.
+
+# file-private lexicals go here
+my $priv_var    = '';
+my %secret_hash = ();
+
+# here's a file-private function as a closure,
+# callable as &$priv_func;  it cannot be prototyped.
+my $priv_func = sub {
+# stuff goes here.
+};
+
+# make all your functions, whether exported or not;
+# remember to put something interesting in the {} stubs
+sub func1      {}    # no prototype
+sub func2()    {}    # proto'd void
+sub func3($$)  {}    # proto'd to 2 scalars
+
+# this one isn't exported, but could be called!
+sub func4(\%)  {}    # proto'd to 1 hash ref
+
+END { }       # module clean-up code here (global destructor)
diff --git a/Debbugs/Email.pm b/Debbugs/Email.pm
new file mode 100644 (file)
index 0000000..6a97f76
--- /dev/null
@@ -0,0 +1,84 @@
+package Debbugs::Email;  
+
+use strict;
+
+BEGIN {
+       use Exporter   ();
+       use vars       qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
+
+       # set the version for version checking
+       $VERSION     = 1.00;
+
+       @ISA         = qw(Exporter);
+       @EXPORT      = qw( );
+       %EXPORT_TAGS = ( );     # eg: TAG => [ qw!name1 name2! ],
+
+       # your exported package globals go here,
+       # as well as any optionally exported functions
+       @EXPORT_OK   = qw( );
+}
+
+use vars @EXPORT_OK;
+use Debbugs::Config qw(%Globals);
+
+# initialize package globals, first exported ones
+%gtags= (      "SECRETARY_TITLE" => "Debian Project Secretary",
+               "SECRETARY_NAME" => "Darren Benham",
+               "ERRORS_TITLE" => "Nobody",
+               "ERRORS_EMAIL" => "errors\@benham.net",
+               "VOTE_TITLE" => "Set Vote Title",
+               "SECRETARY_EMAIL" => "secretary\@debian.org");
+
+#############################################################################
+#  Initialize Global Tags
+#############################################################################
+sub InitEmailTags
+{   my @config = @_;
+       
+    print "V: Initializing Email Tags\n" if $Globals{ 'verbose' };
+    for( my $i=0; $i<=$#config; $i++)
+    {  $_ = $config[$i];
+       chop $_;
+       next unless length $_;
+       next if /^#/;
+       if ( /^GTAG\s*[:=]\s*(\S)+\s*[:=]\s*([^#]*)/i )
+       {   $gtags{ $1 } = $2;
+           print "D2: (email) GTag $1=$gtags{$1}\n" if $Globals{ 'debug' } > 1;
+       }
+    }
+}
+
+#############################################################################
+#  Load File with Tags
+#############################################################################
+sub LoadEmail
+{   my $emailfile = $_[0];
+    my @email;
+
+    open( LETTER, $emailfile ) or &::fail( "Unable to open $emailfile: $!" );
+    @email = <LETTER>;
+    close LETTER;
+    &ProcessTags( \@email, \%gtags, "GTAG" );
+    return @email;
+}
+#############################################################################
+#  Process Tags
+#############################################################################
+sub ProcessTags
+{   my ($email, $tagsin, $marker) = @_;
+    my %tags=%$tagsin;
+    my $tag;
+
+    print "V: Processing Template Mail\n" if $Globals{ 'verbose' };
+    foreach my $line ( @$email )
+    {  while( $line =~ /\%$marker\_(\S*)\%/s )
+       {   if( defined( $tags{ $1 } ) ) { $tag = $tags{ $1 }; }
+           else { $tag = "(missed tag $1)"; }
+           $line =~ s/\%$marker\_(\S*)\%/$tag/;
+       }
+    }
+    1;
+}
+
+END { }       # module clean-up code here (global destructor)
+1;