let version = Http_getter_const.version
-let servers_file = lazy (Helm_registry.get "getter.servers_file")
-let cic_dbm = lazy (Helm_registry.get "getter.cic_dbm")
-let nuprl_dbm = lazy (Helm_registry.get "getter.nuprl_dbm")
-let rdf_dbm = lazy (Helm_registry.get "getter.rdf_dbm")
-let xsl_dbm = lazy (Helm_registry.get "getter.xsl_dbm")
-let xml_index = lazy (Helm_registry.get "getter.xml_indexname")
-let rdf_index = lazy (Helm_registry.get "getter.rdf_indexname")
-let xsl_index = lazy (Helm_registry.get "getter.xsl_indexname")
-let cic_dir = lazy (Helm_registry.get "getter.cic_dir")
-let nuprl_dir = lazy (Helm_registry.get "getter.nuprl_dir")
-let rdf_dir = lazy (Helm_registry.get "getter.rdf_dir")
+let servers_file = lazy (
+ Helm_registry.get_opt Helm_registry.get "getter.servers_file")
+let cic_dbm = lazy (Helm_registry.get "getter.maps_dir" ^ "/cic_db")
+let nuprl_dbm = lazy (Helm_registry.get "getter.maps_dir" ^ "/nuprl_db")
+let rdf_dbm = lazy (Helm_registry.get "getter.maps_dir" ^ "/rdf_db")
+let xsl_dbm = lazy (Helm_registry.get "getter.maps_dir" ^ "/xsl_db")
+let xml_index = lazy (
+ Helm_registry.get_opt_default Helm_registry.get "index.txt"
+ "getter.xml_indexname")
+let rdf_index = lazy (
+ Helm_registry.get_opt_default Helm_registry.get "rdf_index.txt"
+ "getter.rdf_indexname")
+let xsl_index = lazy (
+ Helm_registry.get_opt_default Helm_registry.get "xslt_index.txt"
+ "getter.xsl_indexname")
+let cic_dir = lazy (Helm_registry.get "getter.cache_dir" ^ "/cic")
+let nuprl_dir = lazy (Helm_registry.get "getter.cache_dir" ^ "/nuprl")
+let rdf_dir = lazy (Helm_registry.get "getter.cache_dir" ^ "/rdf")
let dtd_dir = lazy (Helm_registry.get "getter.dtd_dir")
let dtd_base_urls = lazy (
let rex = Pcre.regexp "/*$" in
- let raw_urls = Helm_registry.get_string_list "getter.dtd_base_urls" in
+ let raw_urls =
+ Helm_registry.get_opt_default Helm_registry.get_string_list
+ ["http://helm.cs.unibo.it/dtd"; "http://mowgli.cs.unibo.it/dtd"]
+ "getter.dtd_base_urls"
+ in
List.map (Pcre.replace ~rex) raw_urls)
-let port = lazy (Helm_registry.get_int "getter.port")
+let port = lazy (
+ Helm_registry.get_opt_default Helm_registry.get_int 58081 "getter.port")
let _servers = ref None
| Some servers -> servers)
let load_servers () =
- let pos = ref (-1) in
- List.rev (Http_getter_misc.fold_file
- (fun line servers ->
- if Http_getter_misc.is_blank_line line then
- servers
- else
- (incr pos; (!pos, line) :: servers))
- []
- (Lazy.force servers_file))
+ let pos = ref ~-1 in
+ match Lazy.force servers_file with
+ | None ->
+ List.map (fun s -> incr pos; (!pos, s))
+ (Helm_registry.get_string_list "getter.servers")
+ | Some servers_file ->
+ List.rev (Http_getter_misc.fold_file
+ (fun line servers ->
+ if Http_getter_misc.is_blank_line line then
+ servers
+ else
+ (incr pos; (!pos, line) :: servers))
+ []
+ servers_file)
let reload_servers () = _servers := Some (load_servers ())
let save_servers () =
- let oc = open_out (Lazy.force servers_file) in
- List.iter (fun (_,server) -> output_string oc (server ^ "\n"))
- (servers ());
+ match Lazy.force servers_file with
+ | None -> ()
+ | Some servers_file ->
+ let oc = open_out servers_file in
+ List.iter (fun (_,server) -> output_string oc (server ^ "\n"))
+ (servers ());
close_out oc
let host =
let cache_mode =
lazy
- (match String.lowercase (Helm_registry.get "getter.cache_mode") with
+ (let mode_string =
+ Helm_registry.get_opt_default Helm_registry.get "gz" "getter.cache_mode"
+ in
+ match String.lowercase mode_string with
| "normal" -> `Normal
| "gz" -> `Gzipped
| mode -> failwith ("Invalid cache mode: " ^ mode))
(Lazy.force xsl_dbm) (Lazy.force xml_index)
(Lazy.force rdf_index) (Lazy.force xsl_index) (Lazy.force cic_dir)
(Lazy.force nuprl_dir) (Lazy.force rdf_dir)
- (Lazy.force dtd_dir) (Lazy.force servers_file) (Lazy.force host)
+ (Lazy.force dtd_dir)
+ (match Lazy.force servers_file with
+ | None -> "no servers file"
+ | Some servers_file -> servers_file)
+ (Lazy.force host)
(Lazy.force port) (Lazy.force my_own_url)
(String.concat " " (Lazy.force dtd_base_urls))
(match Lazy.force cache_mode with