1 package Debbugs::Config; # assumes Some/Module.pm
7 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
9 # set the version for version checking
13 @EXPORT = qw(%Globals %Strong %Severity );
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 %Severity %Strong &ParseConfigFile &ParseXMLConfigFile);
25 # initialize package globals, first exported ones
28 $Severity{ 'Text' } = ();
29 %Globals = ( "debug" => 0,
33 "email-domain" => "bugs.domain.com",
34 "list-domain" => "lists.domain.com",
35 "web-domain" => "web.domain.com",
36 "cgi-domain" => "cgi.domain.com",
38 "project-short" => "debbugs",
39 "project-long" => "Debbugs Test Project",
40 "owner-name" => "Fred Flintstone",
41 "owner-email" => "owner\@bugs.domain.com",
43 "work-dir" => "/var/lib/debbugs/spool",
44 "spool-dir" => "/var/lib/debbugs/spool/incoming",
45 "www-dir" => "/var/lib/debbugs/www",
46 "doc-dir" => "/var/lib/debbugs/www/txt",
48 "maintainer-file" => "/etc/debbugs/Maintainers",
49 "pseudo-description" => "/etc/debbugs/pseudo-packages.description");
52 "Email Domain" => "email-domain",
53 "List Domain" => "list-domain",
54 "Web Domain" => "web-domain",
55 "CGI Domain" => "cgi-domain",
56 "Short Name" => "project-short",
57 "Long Name" => "project-long",
58 "Owner Name" => "owner-name",
59 "Owner Email" => "owner-email",
60 "Errors Email" => "errors-email",
61 "Owner Webpage" => "owner-webpage",
62 "Spool Dir" => "spool-dir",
63 "Work Dir" => "work-dir",
64 "Web Dir" => "www-dir",
65 "Doc Dir" => "doc-dir",
66 "Maintainer File" => "maintainer-file",
67 "Pseudo Description File" => "pseudo-description",
68 "Submit List" => "submit-list",
69 "Maint List" => "maint-list",
70 "Quiet List" => "quiet-list",
71 "Forwarded List" => "forwarded-list",
72 "Done List" => "done-list",
73 "Request List" => "request-list",
74 "Submitter List" => "submitter-list",
75 "Control List" => "control-list",
76 "Summary List" => "summary-list",
77 "Mirror List" => "mirror-list",
79 "Singular Term" => "singluar",
80 "Plural Term" => "plural",
81 "Expire Age" => "expire-age",
82 "Save Expired Bugs" => "save-expired",
83 "Mirrors" => "mirrors",
84 "Default Severity" => "default-severity",
85 "Normal Severity" => "normal-severity",
89 chop $string while $string =~ /\s$/;
93 #############################################################################
94 # Read Config File and parse
95 #############################################################################
97 { my $configfile = $_[0];
103 print "V: Loading Config File\n" if $Globals{ "verbose" };
104 open(CONFIG,$configfile) or &fail( "E: Unable to open `$configfile'" );
109 print "V: Parsing Config File\n" if $Globals{ "verbose" };
110 print "D3: Parse Config:\n@config\n" if $Globals{ 'debug' } > 2;
111 print "D1: Configuration\n" if $Globals{ 'debug' };
113 for( my $i=0; $i<=$#config; $i++)
116 next unless length $_;
119 if ( /^([^:=]*)\s*[:=]\s*([^#]*)/i ) {
120 my $key = strip( $1 );
121 my $value = strip( $2 );
122 $value = "" if(!defined($value));
123 if ( $key =~ /Severity\s+#*(\d+)\s*(.*)/ ) {
126 if( $options =~ /\btext\b/ ) {
127 $Severity{ 'Text' }{ $severity } = $value;
128 print "D2: (config) Severity $severity text = $value\n" if $Globals{ 'debug' } > 1;
130 $Severity{ $1 } = $value;
131 print "D2: (config) Severity $severity = $value" if $Globals{ 'debug' } > 1;
132 if( $options =~ /\bdefault\b/ ) {
133 $Globals{ "default-severity" } = $severity;
134 print ", default" if $Globals{ 'debug' } > 1;
136 if( $options =~ /\bstrong\b/ ) {
137 $Strong{ $severity } = 1;
138 print ", strong" if $Globals{ 'debug' } > 1;
140 print "\n" if $Globals{ 'debug' } > 1;
144 my $map = $ConfigMap{$key};
146 $Globals{ $map } = $value;
147 print "$key = '$value'\n" if $Globals{ 'debug' } > 1;
154 print "Unknown line in config!($_)\n";
160 END { } # module clean-up code here (global destructor)