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 "Owner Email" => "OWNER_EMAIL",
90 "Owner Name" => "OWNER_NAME",
91 "Long Name" => "LONG_NAME",
92 "Short Name" => "SHORT_NAME",
93 "Email Domain" => "EMAIL_DOMAIN",
94 "List Domain" => "LIST_DOMAIN",
95 "Web Domain" => "WEB_DOMAIN",
96 "CGI Domain" => "CGI_DOMAIN",
97 "Submit List" => "SUBMIT_LIST",
98 "Maint List" => "MAINT_LIST",
99 "Quiet List" => "QUIET_LIST",
100 "Forwarded List" => "FORWARDED_LIST",
101 "Done List" => "DONE_LIST",
102 "Request List" => "REQUEST_LIST",
103 "Submitter List" => "SUBMITTER_LIST",
104 "Control List" => "CONTROL_LIST",
105 "Summary List" => "SUMMARY_LIST",
106 "Mirror List" => "MIRROR_LIST",
107 "Mirrors" => "MIRRORS",
111 { my $string = $_[0];
112 chop $string while $string =~ /\s$/;
116 #############################################################################
117 # Read Config File and parse
118 #############################################################################
120 { my $configfile = $_[0];
126 print "V: Loading Config File\n" if $Globals{ "verbose" };
127 open(CONFIG,$configfile) or &fail( "E: Unable to open `$configfile'" );
132 print "V: Parsing Config File\n" if $Globals{ "verbose" };
133 print "D3: Parse Config:\n@config\n" if $Globals{ 'debug' } > 2;
134 print "D1: Configuration\n" if $Globals{ 'debug' };
136 for( my $i=0; $i<=$#config; $i++)
139 next unless length $_;
142 if ( /^([^:=]*)\s*[:=]\s*([^#]*)/i ) {
143 my $key = strip( $1 );
144 my $value = strip( $2 );
145 $value = "" if(!defined($value));
146 if ( $key =~ /Severity\s+#*(\d+)\s*(.*)/ ) {
149 if( $options =~ /\btext\b/ ) {
150 $Severity{ 'Text' }{ $severity } = $value;
151 print "D2: (config) Severity $severity text = $value\n" if $Globals{ 'debug' } > 1;
153 $Severity{ $1 } = $value;
154 print "D2: (config) Severity $severity = $value" if $Globals{ 'debug' } > 1;
155 if( $options =~ /\bdefault\b/ ) {
156 $Globals{ "default-severity" } = $severity;
157 print ", default" if $Globals{ 'debug' } > 1;
159 if( $options =~ /\bstrong\b/ ) {
160 $Strong{ $severity } = 1;
161 print ", strong" if $Globals{ 'debug' } > 1;
163 print "\n" if $Globals{ 'debug' } > 1;
167 my $map = $ConfigMap{$key};
169 $Globals{ $map } = $value;
170 print "$key = '$value'\n" if $Globals{ 'debug' } > 1;
171 my $tagmap = $GTagMap{$key};
172 if(defined($tagmap)) {
173 $GTags{ $tagmap } = $value;
174 print "GTAG_$tagmap = $value from $key\n" if $Globals{ 'debug' } > 1;
183 print "Unknown line in config!($_)\n";
189 END { } # module clean-up code here (global destructor)