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