-module OrderedStrings =
- struct
- type t = string
- let compare (s1 : t) (s2 : t) = compare s1 s2
- end
-;;
-
-module MapOfStrings = Map.Make(OrderedStrings);;
-
-let read_index url =
- let module C = Configuration in
- if Sys.command ("helm_wget " ^ C.tmpdir ^ " " ^ url ^ "/\"" ^
- C.indexname ^ "\"") <> 0
- then
- raise (ErrorGetting url) ;
- let tmpfilename = C.tmpdir ^ "/" ^ C.indexname in
- let fd = open_in tmpfilename in
- let uris = ref [] in
- try
- while true do
- let (uri,comp) =
- match (Str.split (Str.regexp "[ \t]+") (input_line fd)) with
- [uri] -> (uri,"")
- | [uri;comp] -> (uri,".gz")
- in
- uris := (uri,comp) :: !uris
- done ;
- [] (* only to make the compiler happy *)
- with
- End_of_file ->
- Sys.remove tmpfilename ;
- !uris
-;;
-
-(* mk_urls_of_uris list_of_servers_base_urls *)
-let rec mk_urls_of_uris =
- function
- [] -> MapOfStrings.empty
- | he::tl ->
- let map = mk_urls_of_uris tl in
- let uris = read_index he in
- let url_of_uri (uri,comp) =
- let url = uri ^ ".xml" ^ comp in
- let url' = Str.replace_first (Str.regexp "cic:") he url in
- let url'' = Str.replace_first (Str.regexp "theory:") he url' in
- url''
- in
- List.fold_right
- (fun (uri,comp) m -> MapOfStrings.add uri (url_of_uri (uri,comp)) m)
- uris map
-;;
-
-exception PerlGetterNotResponding;;