3 # $Id: SWConfig.pm.in,v 1.1 1999/07/30 18:48:05 mdw Exp $
5 # Exports configuration variables
10 #----- Licensing notice -----------------------------------------------------
12 # This file is part of sw-tools.
14 # sw-tools is free software; you can redistribute it and/or modify
15 # it under the terms of the GNU General Public License as published by
16 # the Free Software Foundation; either version 2 of the License, or
17 # (at your option) any later version.
19 # sw-tools is distributed in the hope that it will be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU General Public License for more details.
24 # You should have received a copy of the GNU General Public License
25 # along with sw-tools; if not, write to the Free Software Foundation,
26 # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
28 #----- Revision history -----------------------------------------------------
30 # $Log: SWConfig.pm.in,v $
31 # Revision 1.1 1999/07/30 18:48:05 mdw
32 # Useful bits for the Perl support code.
35 #----- Package preamble -----------------------------------------------------
43 #----- Configuration variables ----------------------------------------------
46 $C{pkg
} = '@PACKAGE@';
47 $C{version
} = '@VERSION@';
48 $C{prefix
} = '@prefix@';
49 $C{datadir
} = '@datadir@';
50 $C{index} = '${prefix}/sw-index';
51 $C{doc
} = '${prefix}/doc';
53 foreach my $k (qw(datadir
index doc
)) {
54 $C{$k} =~ s/\$\{(\w+)\}/$C{$1}/eg;
57 #----- Read a configuration file --------------------------------------------
59 if (my $fh = IO
::File
->new("$C{datadir}/sw.conf")) {
60 LINE
: while (my $line = $fh->getline()) {
62 next LINE
if $line =~ /^\s*\#/ || $line =~ /^\s*$/;
63 my ($k, $v) = split(/\s*=\s*|\s+/, $line, 2);
64 $v =~ s/\$\{(\w+)\}/$C{$1}/eg;
69 #----- That's all, folks ----------------------------------------------------