]> matita.cs.unibo.it Git - helm.git/blob - helm/configuration/local/lib/helm/configuration.pl
Many bug fixed
[helm.git] / helm / configuration / local / lib / helm / configuration.pl
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 $configuration_file =
7  $HELM_CONFIGURATION_PREFIX."/local/etc/helm/configuration.xml";
8
9 $parser = new XML::Parser(Handlers => {Start => \&handle_start,
10                                        End   => \&handle_end,
11                                        Char  => \&handle_char});
12
13
14 $parser->parsefile($configuration_file, ErrorContext => 3);
15
16
17 sub handle_start
18 {
19    if ($_[1] eq "value-of") {
20       $$varname .= ${$_[3]};
21    } elsif ($_[1] ne "configuration") {
22       $varname = $_[1];
23    }
24 }
25
26 sub handle_end
27 {
28    if ($_[1] ne "value-of" && $_[1] ne "configuration") {
29       # Next line for debugging only:
30       # print "OK: #$_[1]# := #$$varname#\n";
31       $varname = undef;
32    }
33 }
34
35 sub handle_char
36 {
37    $$varname .= $_[1];
38 }