]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/configuration/local/lib/helm/configuration.pl
Initial revision
[helm.git] / helm / configuration / local / lib / helm / configuration.pl
diff --git a/helm/configuration/local/lib/helm/configuration.pl b/helm/configuration/local/lib/helm/configuration.pl
new file mode 100644 (file)
index 0000000..deea890
--- /dev/null
@@ -0,0 +1,35 @@
+use XML::Parser;
+
+# this should be the only fixed constant
+$configuration_file = "/home/cadet/sacerdot/local/etc/helm/configuration.xml";
+
+$parser = new XML::Parser(Handlers => {Start => \&handle_start,
+                                       End   => \&handle_end,
+                                       Char  => \&handle_char});
+
+
+$parser->parsefile($configuration_file, ErrorContext => 3);
+
+
+sub handle_start
+{
+   if ($_[1] eq "value-of") {
+      $$varname .= ${$_[3]};
+   } elsif ($_[1] ne "configuration") {
+      $varname = $_[1];
+   }
+}
+
+sub handle_end
+{
+   if ($_[1] ne "value-of" && $_[1] ne "configuration") {
+      # Next line for debugging only:
+      # print "OK: #$_[1]# := #$$varname#\n";
+      $varname = undef;
+   }
+}
+
+sub handle_char
+{
+   $$varname .= $_[1];
+}