87664f81 |
1 | # -*-perl-*- |
2 | # |
3 | # $Id: SWConfig.pm.in,v 1.1 1999/07/30 18:48:05 mdw Exp $ |
4 | # |
5 | # Exports configuration variables |
6 | # |
7 | # (c) 1999 EBI |
8 | # |
9 | |
10 | #----- Licensing notice ----------------------------------------------------- |
11 | # |
12 | # This file is part of sw-tools. |
13 | # |
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. |
18 | # |
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. |
23 | # |
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. |
27 | |
28 | #----- Revision history ----------------------------------------------------- |
29 | # |
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. |
33 | # |
34 | |
35 | #----- Package preamble ----------------------------------------------------- |
36 | |
37 | package SWConfig; |
38 | use IO; |
39 | use Exporter; |
40 | @ISA = qw(Exporter); |
41 | @EXPORT = qw(%C); |
42 | |
43 | #----- Configuration variables ---------------------------------------------- |
44 | |
45 | %C = (); |
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'; |
52 | |
53 | foreach my $k (qw(datadir index doc)) { |
54 | $C{$k} =~ s/\$\{(\w+)\}/$C{$1}/eg; |
55 | } |
56 | |
57 | #----- Read a configuration file -------------------------------------------- |
58 | |
59 | if (my $fh = IO::File->new("$C{datadir}/sw.conf")) { |
60 | LINE: while (my $line = $fh->getline()) { |
61 | chomp($line); |
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; |
65 | $C{$k} = $v; |
66 | } |
67 | } |
68 | |
69 | #----- That's all, folks ---------------------------------------------------- |
70 | |
71 | 1; |