1 (******************************************************************************)
5 (* Claudio Sacerdoti Coen <sacerdot@cs.unibo.it> *)
8 (* This is the parser that reads the configuration file of helm *)
10 (******************************************************************************)
12 exception MalformedDir of string
14 (* this should be the only hard coded constant *)
18 Sys.getenv "HELM_CONFIGURATION_DIR"
20 Not_found -> "/projects/helm/V7/phd/local/etc/helm"
22 if prefix.[(String.length prefix) - 1] = '/' then
23 raise (MalformedDir prefix) ;
24 prefix ^ "/configuration.xml";;
31 print_endline ("WARNING: " ^ w) ;
32 (raise Warnings : unit)
37 let module Y = Pxp_yacc in
39 let config = {Y.default_config with Y.warner = new warner} in
40 Y.parse_document_entity config (Y.from_file filename) Y.default_spec
43 print_endline (Pxp_types.string_of_exn e) ;
47 exception Impossible;;
49 let vars = Hashtbl.create 14;;
51 (* resolve <value-of> tags and returns the string values of the variable tags *)
53 let module D = Pxp_document in
56 | he::tl when he#node_type = D.T_element "value-of" ->
57 (match he#attribute "var" with
58 Pxp_types.Value var -> Hashtbl.find vars var
59 | _ -> raise Impossible
61 | he::tl when he#node_type = D.T_data ->
63 | _ -> raise Impossible
66 (* we trust the xml file to be valid because of the validating xml parser *)
71 match n#node_type with
72 Pxp_document.T_element var ->
73 Hashtbl.add vars var (resolve (n#sub_nodes))
74 | _ -> raise Impossible
76 ((xml_document ())#root#sub_nodes)
79 (* try to read a configuration variable, given its name into the
80 * configuration.xml file and its name into the shell environment.
81 * The shell variable, if present, has precedence over configuration.xml
83 let read_configuration_var_env xml_name env_name =
88 Not_found -> Hashtbl.find vars xml_name
91 Printf.printf "Sorry, cannot find variable `%s', please check your configuration\n" xml_name ;
95 let read_configuration_var xml_name =
97 Hashtbl.find vars xml_name
100 Printf.printf "Sorry, cannot find variable `%s', please check your configuration\n" xml_name ;
104 let helm_dir = read_configuration_var "helm_dir";;
105 let dtd_dir = read_configuration_var "dtd_dir";;
106 let style_dir = read_configuration_var_env "style_dir" "HELM_STYLE_DIR";;
107 let servers_file = read_configuration_var "servers_file";;
108 let uris_dbm = read_configuration_var "uris_dbm";;
109 let dest = read_configuration_var "dest";;
110 let indexname = read_configuration_var "indexname";;
111 let tmp_dir = read_configuration_var "tmp_dir"
112 let helm_dir = read_configuration_var "helm_dir";;
113 let getter_url = read_configuration_var_env "getter_url" "HELM_GETTER_URL";;
114 let processor_url = read_configuration_var_env "processor_url" "HELM_PROCESSOR_URL";;
115 let annotations_dir = read_configuration_var_env "annotations_dir" "HELM_ANNOTATIONS_DIR"
116 let annotations_url = read_configuration_var_env "annotations_url" "HELM_ANNOTATIONS_URL"
118 let _ = Hashtbl.clear vars;;