From: Claudio Sacerdoti Coen Date: Thu, 28 Dec 2000 17:09:16 +0000 (+0000) Subject: configuration.ml moved to configuration.ml.in to use autoconf X-Git-Tag: nogzip~18 X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=commitdiff_plain;h=93b0c2d038540dd1f3088609ecb0aea6d09a392c;p=helm.git configuration.ml moved to configuration.ml.in to use autoconf --- diff --git a/helm/interface/configuration.ml b/helm/interface/configuration.ml deleted file mode 100644 index 9a36cb37d..000000000 --- a/helm/interface/configuration.ml +++ /dev/null @@ -1,85 +0,0 @@ -(******************************************************************************) -(* *) -(* PROJECT HELM *) -(* *) -(* Claudio Sacerdoti Coen *) -(* 06/05/2000 *) -(* *) -(* This is the parser that reads the configuration file of helm *) -(* *) -(******************************************************************************) - -(* this should be the only hard coded constant *) -let filename = - let prefix = - try - Sys.getenv "HELM_CONFIGURATION_PREFIX" - with - Not_found -> "" - in - prefix ^ "/local/etc/helm/configuration.xml";; - -exception Warnings;; - -class warner = - object - method warn w = - print_endline ("WARNING: " ^ w) ; - (raise Warnings : unit) - end -;; - -let xml_document () = - let module Y = Pxp_yacc in - try - let config = {Y.default_config with Y.warner = new warner} in - Y.parse_document_entity config (Y.from_file filename) Y.default_spec - with - e -> - print_endline (Pxp_types.string_of_exn e) ; - raise e -;; - -exception Impossible;; - -let vars = Hashtbl.create 14;; - -(* resolve tags and returns the string values of the variable tags *) -let rec resolve = - let module D = Pxp_document in - function - [] -> "" - | he::tl when he#node_type = D.T_element "value-of" -> - (match he#attribute "var" with - Pxp_types.Value var -> Hashtbl.find vars var - | _ -> raise Impossible - ) ^ resolve tl - | he::tl when he#node_type = D.T_data -> - he#data ^ resolve tl - | _ -> raise Impossible -;; - -(* we trust the xml file to be valid because of the validating xml parser *) -let _ = - List.iter - (function - n -> - match n#node_type with - Pxp_document.T_element var -> - Hashtbl.add vars var (resolve (n#sub_nodes)) - | _ -> raise Impossible - ) - ((xml_document ())#root#sub_nodes) -;; - -let helm_dir = Hashtbl.find vars "helm_dir";; -let dtd_dir = Hashtbl.find vars "dtd_dir";; -let servers_file = Hashtbl.find vars "servers_file";; -let uris_dbm = Hashtbl.find vars "uris_dbm";; -let dest = Hashtbl.find vars "dest";; -let indexname = Hashtbl.find vars "indexname";; -let tmpdir = Hashtbl.find vars "tmpdir";; -let helm_dir = Hashtbl.find vars "helm_dir";; -let getter_url = Hashtbl.find vars "getter_url";; - -let _ = Hashtbl.clear vars;; diff --git a/helm/interface/configuration.ml.in b/helm/interface/configuration.ml.in new file mode 100644 index 000000000..add4c3a88 --- /dev/null +++ b/helm/interface/configuration.ml.in @@ -0,0 +1,85 @@ +(******************************************************************************) +(* *) +(* PROJECT HELM *) +(* *) +(* Claudio Sacerdoti Coen *) +(* 28/12/2000 *) +(* *) +(* This is the parser that reads the configuration file of helm *) +(* *) +(******************************************************************************) + +(* this should be the only hard coded constant *) +let filename = + let prefix = + try + Sys.getenv "HELM_CONFIGURATION_PREFIX" + with + Not_found -> "" + in + prefix ^ "/local/etc/helm/configuration.xml";; + +exception Warnings;; + +class warner = + object + method warn w = + print_endline ("WARNING: " ^ w) ; + (raise Warnings : unit) + end +;; + +let xml_document () = + let module Y = Pxp_yacc in + try + let config = {Y.default_config with Y.warner = new warner} in + Y.parse_document_entity config (Y.from_file filename) Y.default_spec + with + e -> + print_endline (Pxp_types.string_of_exn e) ; + raise e +;; + +exception Impossible;; + +let vars = Hashtbl.create 14;; + +(* resolve tags and returns the string values of the variable tags *) +let rec resolve = + let module D = Pxp_document in + function + [] -> "" + | he::tl when he#node_type = D.T_element "value-of" -> + (match he#attribute "var" with + Pxp_types.Value var -> Hashtbl.find vars var + | _ -> raise Impossible + ) ^ resolve tl + | he::tl when he#node_type = D.T_data -> + he#data ^ resolve tl + | _ -> raise Impossible +;; + +(* we trust the xml file to be valid because of the validating xml parser *) +let _ = + List.iter + (function + n -> + match n#node_type with + Pxp_document.T_element var -> + Hashtbl.add vars var (resolve (n#sub_nodes)) + | _ -> raise Impossible + ) + ((xml_document ())#root#sub_nodes) +;; + +let helm_dir = Hashtbl.find vars "helm_dir";; +let dtd_dir = Hashtbl.find vars "dtd_dir";; +let servers_file = Hashtbl.find vars "servers_file";; +let uris_dbm = Hashtbl.find vars "uris_dbm";; +let dest = Hashtbl.find vars "dest";; +let indexname = Hashtbl.find vars "indexname";; +let tmpdir = Hashtbl.find vars "tmpdir";; +let helm_dir = Hashtbl.find vars "helm_dir";; +let getter_url = Hashtbl.find vars "getter_url";; + +let _ = Hashtbl.clear vars;;