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 "Owner Webpage" => "owner-webpage",
61 "Spool Dir" => "spool-dir",
62 "Work Dir" => "work-dir",
63 "Web Dir" => "www-dir",
64 "Doc Dir" => "doc-dir",
65 "Maintainer File" => "maintainer-file",
66 "Pseudo Description File" => "pseudo-description",
67 "Submit List" => "submit-list",
68 "Maint List" => "maint-list",
69 "Quiet List" => "quiet-list",
70 "Forwarded List" => "forwarded-list",
71 "Done List" => "done-list",
72 "Request List" => "request-list",
73 "Submitter List" => "submitter-list",
74 "Control List" => "control-list",
75 "Summary List" => "summary-list",
76 "Mirror List" => "mirror-list",
78 "Singular Term" => "singluar",
79 "Plural Term" => "plural",
80 "Expire Age" => "expire-age",
81 "Save Expired Bugs" => "save-expired",
82 "Mirrors" => "mirrors",
83 "Default Severity" => "default-severity",
84 "Normal Severity" => "normal-severity",
88 chop $string while $string =~ /\s$/;
92 #############################################################################
93 # Read Config File and parse
94 #############################################################################
96 { my $configfile = $_[0];
102 print "V: Loading Config File\n" if $Globals{ "verbose" };
103 open(CONFIG,$configfile) or &fail( "E: Unable to open `$configfile'" );
108 print "V: Parsing Config File\n" if $Globals{ "verbose" };
109 print "D3: Parse Config:\n@config\n" if $Globals{ 'debug' } > 2;
110 print "D1: Configuration\n" if $Globals{ 'debug' };
112 for( my $i=0; $i<=$#config; $i++)
115 next unless length $_;
118 if ( /^([^:=]*)\s*[:=]\s*([^#]*)/i ) {
119 my $key = strip( $1 );
120 my $value = strip( $2 );
121 $value = "" if(!defined($value));
122 if ( $key =~ /Severity\s+#*(\d+)\s*(.*)/ ) {
125 if( $options =~ /\btext\b/ ) {
126 $Severity{ 'Text' }{ $severity } = $value;
127 print "D2: (config) Severity $severity text = $value\n" if $Globals{ 'debug' } > 1;
129 $Severity{ $1 } = $value;
130 print "D2: (config) Severity $severity = $value" if $Globals{ 'debug' } > 1;
131 if( $options =~ /\bdefault\b/ ) {
132 $Globals{ "default-severity" } = $severity;
133 print ", default" if $Globals{ 'debug' } > 1;
135 if( $options =~ /\bstrong\b/ ) {
136 $Strong{ $severity } = 1;
137 print ", strong" if $Globals{ 'debug' } > 1;
139 print "\n" if $Globals{ 'debug' } > 1;
143 my $map = $ConfigMap{$key};
145 $Globals{ $map } = $value;
146 print "$key = '$value'\n" if $Globals{ 'debug' } > 1;
153 print "Unknown line in config!($_)\n";
159 END { } # module clean-up code here (global destructor)