1 package Debvote::Config; # assumes Some/Module.pm
7 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
9 # set the version for version checking
14 %EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ],
16 # your exported package globals go here,
17 # as well as any optionally exported functions
18 @EXPORT_OK = qw(%Globals &ParseConfigFile);
23 # initialize package globals, first exported ones
24 %Globals = ( "debug" => 0,
28 "email-domain" => "bugs.domain.com",
29 "list-domain" => "lists.domain.com",
30 "web-domain" => "web.domain.com",
31 "cgi-domain" => "cgi.domain.com",
33 "project-short" => "debbugs",
34 "project-long" => "Debbugs Test Project",
35 "owner-name" => "Fred Flintstone",
36 "owner-email" => "owner@bugs.domain.com",
38 "data-dir" => "/var/lib/debbugs/spool",
39 "spool-dir" => "/var/lib/debbugs/spool/incoming",
40 "www-dir" => "/var/lib/debbugs/www",
41 "doc-dir" => "/var/lib/debbugs/www/txt",
42 "maintainer-file" => "/etc/debbugs/Maintainers",
43 "database" => "debvote.db" );
45 #############################################################################
46 # Read Config File and parse
47 #############################################################################
49 { my $configfile = $_[0];
55 print "V: Loading Config File\n" if $Globals{ "verbose" };
56 open(CONFIG,$configfile) or &::fail( "E: Unable to open `$configfile'" );
61 print "V: Parsing Config File\n" if $Globals{ "verbose" };
62 print "D3: Parse Config:\n@config\n" if $Globals{ 'debug' } > 2;
63 for( my $i=0; $i<=$#config; $i++)
66 next unless length $_;
68 if ( /^Ballot Type\s*[:=]\s*([^#]*)\s*(#.*)?/i )
69 { my $ballottype = $1;
70 chop $ballottype while $ballottype =~ /\s$/;
71 $ballottype =~ y/A-Z/a-z/;
72 $Globals{ 'ballottype' } = $ballottype;
74 elsif ( /^Database\s*[:=]\s*(\S+)/i )
75 { $Globals{ 'database' } = $1; }
76 elsif( /^Ballot Ack\s*[:=]\s*([^#]*)/i )
77 { $Globals{ "response" } = $1; }
78 elsif( /^Ballot Template\s*[:=]\s*([^#]*)/i )
79 { $Globals{ "ballot" } = $1; }
80 elsif( /^No Ballot Letter\s*[:=]\s*([^#]*)/i )
81 { $Globals{ "noballot" } = $1; }
82 elsif ( /^Title\s*[:=]\s*([^#]*)/i )
83 { $Globals{ 'title' } = $1; }
85 if( $Globals{ "debug" } )
87 print "D1: Configuration\n";
88 print "\tBallot Type = $Globals{ 'ballottype' }\n";
89 print "\tDatabase = $Globals{ 'database' }\n";
90 print "\tBallot Ack = $Globals{ 'response' }\n";
91 print "\tBallot Template = $Globals{ 'ballot' }\n";
92 print "\tTitle = $Globals{ 'title' }\n";
97 END { } # module clean-up code here (global destructor)