]> git.donarmstrong.com Git - debbugs.git/commitdiff
[project @ 2000-03-20 06:51:14 by gecko]
authorgecko <>
Mon, 20 Mar 2000 14:51:15 +0000 (06:51 -0800)
committergecko <>
Mon, 20 Mar 2000 14:51:15 +0000 (06:51 -0800)
Well, there is the start of the framework.  If anyone else wishes to pick it
up and run with it, I have a few idea.  In the meantime, I need to see what
I have to do implement template emails.  I'm not sure what "tags"
(variables) I want to use in the template files.  Also, I want to change
"service" to use this new framework :)

Debbugs/Config.pm
Debbugs/DBase.pm
devel/debbugs.cfg

index 1cca98c53cfe05a59ffd74163e85c1c15d0299ac..a374da096f17be79c41f880a4ca4887df2d4d06e 100644 (file)
@@ -1,4 +1,4 @@
-package Debvote::Config;  # assumes Some/Module.pm
+package Debbugs::Config;  # assumes Some/Module.pm
 
 use strict;
 
@@ -15,13 +15,14 @@ BEGIN
 
     # your exported package globals go here,
     # as well as any optionally exported functions
-    @EXPORT_OK   = qw(%Globals %Severities &ParseConfigFile);
+    @EXPORT_OK   = qw(%Globals %Severity &ParseConfigFile);
 }
 
 use vars      @EXPORT_OK;
+use Debbugs::Common;
 
 # initialize package globals, first exported ones
-%Severities = ();
+%Severity = ();
 %Globals = (   "debug" => 0,
                "verbose" => 0,
                "quiet" => 0,
@@ -34,7 +35,7 @@ use vars      @EXPORT_OK;
                "project-short" => "debbugs",
                "project-long" => "Debbugs Test Project",
                "owner-name" => "Fred Flintstone",
-               "owner-email" => "owner@bugs.domain.com",
+               "owner-email" => "owner\@bugs.domain.com",
                ##### directories
                "work-dir" => "/var/lib/debbugs/spool",
                "spool-dir" => "/var/lib/debbugs/spool/incoming",
@@ -59,7 +60,7 @@ sub ParseConfigFile
 
     #load config file
     print "V: Loading Config File\n" if $Globals{ "verbose" };
-    open(CONFIG,$configfile) or &::fail( "E: Unable to open `$configfile'" );
+    open(CONFIG,$configfile) or &fail( "E: Unable to open `$configfile'" );
     @config = <CONFIG>;
     close CONFIG;
 
@@ -136,7 +137,7 @@ sub ParseConfigFile
        { $Globals{ 'normal-severity' } = strip( $1 ); }
         elsif ( /^Severity\s+#*(\d+)\s*[:=]\s*([^#]*)/i )
         {   $Severity{ $1 } = $2;
-            print "D2: (config) Severity $1=$choice{$1}\n" if $Globals{ 'debug' } > 1;
+            print "D2: (config) Severity $1=$Severity{$1}\n" if $Globals{ 'debug' } > 1;
         }
     }
     if( $Globals{ "debug" } )
index 2892f117e12f34ff07ae325d6228bd85058f0f83..9ed81600a002e53e301d9c984a6b3528a03f162f 100644 (file)
@@ -1,4 +1,4 @@
-package Debvote::Rank;  # assumes Some/Module.pm
+package Debbugs::DBase;  # assumes Some/Module.pm
 
 use strict;
 
@@ -10,48 +10,99 @@ BEGIN {
        $VERSION     = 1.00;
 
        @ISA         = qw(Exporter);
-       @EXPORT      = qw(&func1 &func2 &func4);
+       @EXPORT      = qw( %Record );
        %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);
+       @EXPORT_OK   = qw( %Record );
 }
 
 use vars      @EXPORT_OK;
+use Fcntl ':flock';
+use Debbugs::Config qw(%Globals);
+use Debbugs::Common;
+use FileHandle;
 
-# non-exported package globals go here
-use vars      qw(@more $stuff);
+%Record = ();
 
-# initialize package globals, first exported ones
-$Var1   = '';
-%Hashit = ();
+my $LoadedRecord = 0;
+my $FileLocked = 0;
+my $FileHandle = new FileHandle;
 
-# then the others (which are still accessible as
-# $Some::Module::stuff)
-$stuff  = '';
-@more   = ();
+sub ParseVersion1Record
+{
+    my @data = @_;
+    my @fields = ( "originator", "date", "subject", "msgid", "package",
+               "keywords", "done", "forwarded", "mergedwith", "severity" );
+    my $i = 0;
+    foreach my $line ( @data )
+    {
+       chop( $line );
+       $Record{ $fields[$i] } = $line;
+       $i++;
+    }
+}
 
-# all file-scoped lexicals must be created before
-# the functions below that use them.
+sub ParseVersion2Record
+{
+    # I envision the next round of records being totally different in
+    # meaning.  In order to maintain compatability, version tagging will be
+    # implemented in thenext go around and different versions will be sent
+    # off to different functions to be parsed and interpreted into a format
+    # that the rest of the system will understand.  All data will be saved
+    # in whatever 'new" format ixists.  The difference will be a "Version: x"
+    # at the top of the file.
 
-# file-private lexicals go here
-my $priv_var    = '';
-my %secret_hash = ();
+    print "No version 2 records are understood at this time\n";
+    exit 1;
+}
 
-# here's a file-private function as a closure,
-# callable as &$priv_func;  it cannot be prototyped.
-my $priv_func = sub {
-# stuff goes here.
-};
+sub ReadRecord
+{
+    my $record = $_[0];
+    if ( $record ne $LoadedRecord )
+    {
+       my $path = '';
+       my @data;
+       
+       #find proper directory to store in
+        #later, this will be for tree'd data directory the way
+        #expire is now,..
+       $path = "/db/".$record.".status";
+    
+       open( $FileHandle, $Globals{ "work-dir" } . $path ) 
+           || &fail( "Unable to open record: ".$Globals{ "work-dir" }."$path\n");
+       flock( $FileHandle, LOCK_EX ) || &fail( "Unable to lock record $record\n" );
+       @data = <$FileHandle>;
+       if ( scalar( @data ) =~ /Version: (\d*)/ )
+       {
+           if ( $1 == 2 )
+           { &ParseVersion2Record( @data ); }
+           else
+           { &fail( "Unknown record version: $1\n"); }
+       }
+       else { &ParseVersion1Record( @data ); }
+       $LoadedRecord = $record;
+    }
 
-# 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
+}
+
+sub WriteRecord
+{
+    my @fields = ( "originator", "date", "subject", "msgid", "package",
+               "keywords", "done", "forwarded", "mergedwith", "severity" );
+    seek( $FileHandle, 0, 0 );
+    for( my $i = 0; $i < $#fields; $i++ )
+    {
+       if ( defined( $fields[$i] ) )
+       { print $FileHandle $Record{ $fields[$i] } . "\n"; }
+       else { print $FileHandle "\n"; }
+    }
+    close $FileHandle;
+    $LoadedRecord = 0;
+}
 
-# this one isn't exported, but could be called!
-sub func4(\%)  {}    # proto'd to 1 hash ref
+1;
 
 END { }       # module clean-up code here (global destructor)
index 0c3e5af26bc2e7d8d6b327b358e37c63ccd9d4e5..504410cb22f891361270cd4f2f6a296dfdd0e463 100644 (file)
@@ -1,31 +1,19 @@
 ##########################################################################
-# Domain Names                                                           #
+# These are the hash keys that are used in %Debbugs::Config::Globals     #
 ##########################################################################
 Email Domain = "email-domain"
 List Domain = "list-domain"
 Web Domain = "web-domain"
 CGI Domain = "cgi-domain"
-
-##########################################################################
-# Identification                                                         #
-##########################################################################
 Short Name = "project-short"
 Long Name = "project-long"
 Owner Name = "owner-name"
 Owner Email = "owner-email"
-
-##########################################################################
-# Paths/files                                                            #
-##########################################################################
 Spool Dir = "spool-dir"
 Work Dir = "work-dir"
 Web Dir = "www-dir"
 Doc Dir = "doc-dir"
 Maintainer File = "maintainer-file"
-
-##########################################################################
-# Lists                                                                  #
-##########################################################################
 Submit List = "submit-list"
 Maint List = "maint-list"
 Quiet List = "quiet-list"
@@ -36,23 +24,18 @@ Submitter List = "submitter-list"
 Control List = "control-list"
 Summary List = "summary-list"
 Mirror List = "mirror-list"
-
-##########################################################################
-# Other Configuration Issues                                             #
-##########################################################################
 Mailer = "mailer"
 Singular Term = "singular'
 Plural Term = "plural"
 Expire Age = "expire-age"
 Save Expired Bugs = "save-expired"
 Mirrors = "mirrors"
-
-##########################################################################
-# Severity Information                                                   #
-##########################################################################
 Default Severity = "default-severity"
 Normal Severity = "normal-severity"
 
+##########################################################################
+# These are stored in %Debbugs::Config::Severities keyed on their #      #
+##########################################################################
 Severity #1 = fixed
 Severity #2 = wishlist
 Severity #3 = normal