X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Finterface%2Fgetter.ml;h=5b973f2efc302f2863569e6d1a03a7274393b175;hb=1c7fb836e2af4f2f3d18afd0396701f2094265ff;hp=f6d0a6a380f5395ff0cdb7f44c3db35d360ad4d8;hpb=f06e2c5a7757ef9dc8cd55fa759cbc48616cb508;p=helm.git diff --git a/helm/interface/getter.ml b/helm/interface/getter.ml index f6d0a6a38..5b973f2ef 100644 --- a/helm/interface/getter.ml +++ b/helm/interface/getter.ml @@ -32,95 +32,8 @@ (* *) (******************************************************************************) -exception ErrorGetting of string;; -(* FEATURE MOVED TO HTTP_GETTER, Zack -module OrderedStrings = - struct - type t = string - let compare (s1 : t) (s2 : t) = compare s1 s2 - end -;; -*) - - -(* FEATURE MOVED TO HTTP_GETTER, Zack -module MapOfStrings = Map.Make(OrderedStrings);; -*) - -(* FEATURE MOVED TO HTTP_GETTER, Zack -let read_index url = - let module C = Configuration in - if Sys.command ("helm_wget " ^ C.tmp_dir ^ " " ^ url ^ "/\"" ^ - C.indexname ^ "\"") <> 0 - then - raise (ErrorGetting url) ; - let tmpfilename = C.tmp_dir ^ "/" ^ 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 -;; -*) - -(* FEATURE MOVED TO HTTP_GETTER, Zack -(* 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;; - -(* FEATURE MOVED TO HTTP_GETTER, Zack -let update () = - let module C = Configuration in - let fd = open_in C.servers_file in - let servers = ref [] in - try - while true do - servers := (input_line fd) :: !servers - done - with - End_of_file -> - let urls_of_uris = mk_urls_of_uris (List.rev !servers) in - (try Sys.remove (C.uris_dbm ^ ".db") with _ -> ()) ; - let dbm = - Dbm.opendbm C.uris_dbm [Dbm.Dbm_wronly ; Dbm.Dbm_create] 0o660 - in - MapOfStrings.iter (fun uri url -> Dbm.add dbm uri url) urls_of_uris ; - Dbm.close dbm ; - (* Inform also the Perl-getter *) - if Sys.command ("wget -O /dev/null http://localhost:8081/update") <> 0 - then - raise PerlGetterNotResponding ; -;; -*) +(*CSC: il getter _DEVE_ diventare un semplice "binding" a quello in Perl *) let update () = (* deliver update request to http_getter *) @@ -146,6 +59,8 @@ let name_and_ext_of_uri uri = Str.replace_first (Str.regexp ".*/") "" str ;; +let raw_get = ClientHTTP.get_and_save + (* get_file : uri -> filename *) let get_file uri = let dir = filedir_of_uri uri in @@ -153,16 +68,14 @@ let get_file uri = if not (Sys.file_exists fn) then begin let url = url_of_uri uri in - (*CSC: use -q for quiet mode *) - if Sys.command ("helm_wget " ^ dir ^ " \"" ^ url ^"\"") <> 0 - then - raise (ErrorGetting url) ; + raw_get + (Configuration.getter_url ^ "getxml?uri=" ^ + UriManager.string_of_uri uri ^ "&format=normal&patch_dtd=no" + ) fn end ; fn ;; -let raw_get = ClientHTTP.get_and_save - (* get : uri -> filename *) (* If uri is the URI of an annotation, the annotated object is processed *) let get uri =