]> matita.cs.unibo.it Git - helm.git/blob - helm/configuration/lib/configuration.pl.in
Autoconf used
[helm.git] / helm / configuration / lib / configuration.pl.in
1 use XML::Parser;
2
3 use Env;
4 my $HELM_CONFIGURATION_PREFIX = $ENV{"HELM_CONFIGURATION_PREFIX"};
5 # this should be the only fixed constant
6 if (defined ($HELM_CONFIGURATION_PREFIX) {
7    $configuration_file =
8     $HELM_CONFIGURATION_PREFIX."/etc/helm/configuration.xml";
9 }
10
11 $parser = new XML::Parser(Handlers => {Start => \&handle_start,
12                                        End   => \&handle_end,
13                                        Char  => \&handle_char});
14
15
16 $parser->parsefile($configuration_file, ErrorContext => 3);
17
18
19 sub handle_start
20 {
21    if ($_[1] eq "value-of") {
22       $$varname .= ${$_[3]};
23    } elsif ($_[1] ne "configuration") {
24       $varname = $_[1];
25    }
26 }
27
28 sub handle_end
29 {
30    if ($_[1] ne "value-of" && $_[1] ne "configuration") {
31       # Next line for debugging only:
32       # print "OK: #$_[1]# := #$$varname#\n";
33       $varname = undef;
34    }
35 }
36
37 sub handle_char
38 {
39    $$varname .= $_[1];
40 }