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 *)
13 let filename = "/home/cadet/sacerdot/local/etc/helm/configuration.xml";;
20 print_endline ("WARNING: " ^ w) ;
21 (raise Warnings : unit)
26 let module Y = Pxp_yacc in
28 let config = {Y.default_config with Y.warner = new warner} in
29 Y.parse_document_entity config (Y.from_file filename) Y.default_spec
32 print_endline (Pxp_types.string_of_exn e) ;
36 exception Impossible;;
38 let vars = Hashtbl.create 14;;
40 (* resolve <value-of> tags and returns the string values of the variable tags *)
42 let module D = Pxp_document in
45 | he::tl when he#node_type = D.T_element "value-of" ->
46 (match he#attribute "var" with
47 Pxp_types.Value var -> Hashtbl.find vars var
48 | _ -> raise Impossible
50 | he::tl when he#node_type = D.T_data ->
52 | _ -> raise Impossible
55 (* we trust the xml file to be valid because of the validating xml parser *)
60 match n#node_type with
61 Pxp_document.T_element var ->
62 Hashtbl.add vars var (resolve (n#sub_nodes))
63 | _ -> raise Impossible
65 ((xml_document ())#root#sub_nodes)
68 let helm_dir = Hashtbl.find vars "helm_dir";;
69 let dtd_dir = Hashtbl.find vars "dtd_dir";;
70 let servers_file = Hashtbl.find vars "servers_file";;
71 let uris_dbm = Hashtbl.find vars "uris_dbm";;
72 let dest = Hashtbl.find vars "dest";;
73 let indexname = Hashtbl.find vars "indexname";;
74 let tmpdir = Hashtbl.find vars "tmpdir";;
75 let helm_dir = Hashtbl.find vars "helm_dir";;
76 let getter_url = Hashtbl.find vars "getter_url";;
78 let _ = Hashtbl.clear vars;;