2 # Copyright (C) 2008 Michal Vaner (vorner@ucw.cz)
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # he Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 package PciIds::Config;
25 our @EXPORT = qw(&checkConf &defConf %config &confList);
30 open CONFIG, $directory."cf/config" or die "Config file not found. Make sure config is in the cf directory and the correct path is in Startup.pm\n";
32 next if( /^\s*(|#.*)$/ );
35 die "Invalid syntax on line $_\n" unless( ( $name, $val ) = /^\s*(.*\S)\s*=\s*(.*\S)\s*$/ );
36 $val =~ s/^"(.*)"$/$1/;
37 ( $val ) = ( $val =~ /(.*)/ ); #Untaint the value - config is considered part of the program
38 $config{$name} = $val;
45 foreach( @{$names} ) {
46 die "Variable not set: $_\n" unless( defined $config{$_} );
52 foreach( keys %{$underlay} ) {
53 $config{$_} = $underlay->{$_} unless( defined $config{$_} );
60 push @result, $config{$_} foreach( @{$names} );