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 %GTags %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 %GTags %Severity %Strong &ParseConfigFile &ParseXMLConfigFile);
25 # initialize package globals, first exported ones
28 $Severity{ 'Text' } = ();
30 %Globals = ( "debug" => 0,
34 "email-domain" => "bugs.domain.com",
35 "list-domain" => "lists.domain.com",
36 "web-domain" => "web.domain.com",
37 "cgi-domain" => "cgi.domain.com",
39 "project-short" => "debbugs",
40 "project-long" => "Debbugs Test Project",
41 "owner-name" => "Fred Flintstone",
42 "owner-email" => "owner\@bugs.domain.com",
44 "work-dir" => "/var/lib/debbugs/spool",
45 "spool-dir" => "/var/lib/debbugs/spool/incoming",
46 "www-dir" => "/var/lib/debbugs/www",
47 "doc-dir" => "/var/lib/debbugs/www/txt",
49 "maintainer-file" => "/etc/debbugs/Maintainers",
50 "pseudo-description" => "/etc/debbugs/pseudo-packages.description");
53 "Email Domain" => "email-domain",
54 "List Domain" => "list-domain",
55 "Web Domain" => "web-domain",
56 "CGI Domain" => "cgi-domain",
57 "Short Name" => "project-short",
58 "Long Name" => "project-long",
59 "Owner Name" => "owner-name",
60 "Owner Email" => "owner-email",
61 "Errors Email" => "errors-email",
62 "Owner Webpage" => "owner-webpage",
63 "Spool Dir" => "spool-dir",
64 "Work Dir" => "work-dir",
65 "Web Dir" => "www-dir",
66 "Doc Dir" => "doc-dir",
67 "Template Dir" => "template-dir",
68 "Not-Don-Con" => "not-don-con",
69 "Maintainer File" => "maintainer-file",
70 "Pseudo Description File" => "pseudo-description",
71 "Submit List" => "submit-list",
72 "Maint List" => "maint-list",
73 "Quiet List" => "quiet-list",
74 "Forwarded List" => "forwarded-list",
75 "Done List" => "done-list",
76 "Request List" => "request-list",
77 "Submitter List" => "submitter-list",
78 "Control List" => "control-list",
79 "Summary List" => "summary-list",
80 "Mirror List" => "mirror-list",
82 "Singular Term" => "singluar",
83 "Plural Term" => "plural",
84 "Expire Age" => "expire-age",
85 "Save Expired Bugs" => "save-expired",
86 "Mirrors" => "mirrors",
87 "Default Severity" => "default-severity",
88 "Normal Severity" => "normal-severity",
92 "email-domain" => "EMAIL_DOMAIN",
93 "list-domain" => "LIST_DOMAIN",
94 "web-domain" => "WEB_DOMAIN",
95 "cgi-domain" => "CGI_DOMAIN",
96 "project-short" => "SHORT_NAME",
97 "project-long" => "LONG_NAME",
98 "owner-name" => "OWNER_NAME",
99 "owner-email" => "OWNER_EMAIL",
100 "submit-list" => "SUBMIT_LIST",
101 "quiet-list" => "QUIET_LIST",
102 "forwarded-list" => "FORWARDED_LIST",
103 "done-list" => "DONE_LIST",
104 "request-list" => "REQUEST_LIST",
105 "submitter-list" => "SUBMITTER_LIST",
106 "control-list" => "CONTROL_LIST",
107 "summary-list" => "SUMMARY_LIST",
108 "mirror-list" => "MIRROR_LIST",
109 "mirrors" => "MIRRORS"
113 { my $string = $_[0];
114 chop $string while $string =~ /\s$/;
118 #############################################################################
119 # Read Config File and parse
120 #############################################################################
122 { my $configfile = $_[0];
128 print "V: Loading Config File\n" if $Globals{ "verbose" };
129 open(CONFIG,$configfile) or &fail( "E: Unable to open `$configfile'" );
134 print "V: Parsing Config File\n" if $Globals{ "verbose" };
135 print "D3: Parse Config:\n@config\n" if $Globals{ 'debug' } > 2;
136 print "D1: Configuration\n" if $Globals{ 'debug' };
138 for( my $i=0; $i<=$#config; $i++)
141 next unless length $_;
144 if ( /^([^:=]*)\s*[:=]\s*([^#]*)/i ) {
145 my $key = strip( $1 );
146 my $value = strip( $2 );
147 $value = "" if(!defined($value));
148 if ( $key =~ /Severity\s+#*(\d+)\s*(.*)/ ) {
151 if( $options =~ /\btext\b/ ) {
152 $Severity{ 'Text' }{ $severity } = $value;
153 print "D2: (config) Severity $severity text = $value\n" if $Globals{ 'debug' } > 1;
155 $Severity{ $1 } = $value;
156 print "D2: (config) Severity $severity = $value" if $Globals{ 'debug' } > 1;
157 if( $options =~ /\bdefault\b/ ) {
158 $Globals{ "default-severity" } = $severity;
159 print ", default" if $Globals{ 'debug' } > 1;
161 if( $options =~ /\bstrong\b/ ) {
162 $Strong{ $severity } = 1;
163 print ", strong" if $Globals{ 'debug' } > 1;
165 print "\n" if $Globals{ 'debug' } > 1;
169 my $map = $ConfigMap{$key};
171 $Globals{ $map } = $value;
172 print "$key = '$value'" if $Globals{ 'debug' } > 1;
173 my $gtag = $GTagsMap{ $map };
175 $GTags{ $gtag } = $value;
176 print "GTag = '$gtag'" if $Globals{ 'debug' } > 1;
178 print "\n" if $Globals{ 'debug' } > 1;
186 print "Unknown line in config!($_)\n";
192 END { } # module clean-up code here (global destructor)