1 (******************************************************************************)
5 (* Claudio Sacerdoti Coen <sacerdot@cs.unibo.it> *)
8 (* This is the parser that reads the configuration file of helm *)
10 (******************************************************************************)
12 (* this should be the only hard coded constant *)
16 Sys.getenv "HELM_CONFIGURATION_PREFIX"
20 prefix ^ "/local/etc/helm/configuration.xml";;
27 print_endline ("WARNING: " ^ w) ;
28 (raise Warnings : unit)
33 let module Y = Pxp_yacc in
35 let config = {Y.default_config with Y.warner = new warner} in
36 Y.parse_document_entity config (Y.from_file filename) Y.default_spec
39 print_endline (Pxp_types.string_of_exn e) ;
43 exception Impossible;;
45 let vars = Hashtbl.create 14;;
47 (* resolve <value-of> tags and returns the string values of the variable tags *)
49 let module D = Pxp_document in
52 | he::tl when he#node_type = D.T_element "value-of" ->
53 (match he#attribute "var" with
54 Pxp_types.Value var -> Hashtbl.find vars var
55 | _ -> raise Impossible
57 | he::tl when he#node_type = D.T_data ->
59 | _ -> raise Impossible
62 (* we trust the xml file to be valid because of the validating xml parser *)
67 match n#node_type with
68 Pxp_document.T_element var ->
69 Hashtbl.add vars var (resolve (n#sub_nodes))
70 | _ -> raise Impossible
72 ((xml_document ())#root#sub_nodes)
75 let helm_dir = Hashtbl.find vars "helm_dir";;
76 let dtd_dir = Hashtbl.find vars "dtd_dir";;
77 let servers_file = Hashtbl.find vars "servers_file";;
78 let uris_dbm = Hashtbl.find vars "uris_dbm";;
79 let dest = Hashtbl.find vars "dest";;
80 let indexname = Hashtbl.find vars "indexname";;
81 let tmpdir = Hashtbl.find vars "tmpdir";;
82 let helm_dir = Hashtbl.find vars "helm_dir";;
83 let getter_url = Hashtbl.find vars "getter_url";;
85 let _ = Hashtbl.clear vars;;