-package Debvote::Config; # assumes Some/Module.pm
+package Debbugs::Config; # assumes Some/Module.pm
use strict;
# 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,
"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",
#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;
{ $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" } )
-package Debvote::Rank; # assumes Some/Module.pm
+package Debbugs::DBase; # assumes Some/Module.pm
use strict;
$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)
##########################################################################
-# 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"
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