X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Finterface%2Fgetter.ml;h=f6d0a6a380f5395ff0cdb7f44c3db35d360ad4d8;hb=f06e2c5a7757ef9dc8cd55fa759cbc48616cb508;hp=a72db448bf7b70df3971b27e37a48dfa9e79c95d;hpb=274cfc6d7faa3c8bbeaac47fc48365128f01c5bb;p=helm.git diff --git a/helm/interface/getter.ml b/helm/interface/getter.ml index a72db448b..f6d0a6a38 100644 --- a/helm/interface/getter.ml +++ b/helm/interface/getter.ml @@ -1,3 +1,28 @@ +(* Copyright (C) 2000, HELM Team. + * + * This file is part of HELM, an Hypertextual, Electronic + * Library of Mathematics, developed at the Computer Science + * Department, University of Bologna, Italy. + * + * HELM is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * HELM is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with HELM; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, + * MA 02111-1307, USA. + * + * For details, see the HELM World-Wide-Web page, + * http://cs.unibo.it/helm/. + *) + (******************************************************************************) (* *) (* PROJECT HELM *) @@ -9,27 +34,38 @@ 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.tmpdir ^ " " ^ url ^ "/\"" ^ + if Sys.command ("helm_wget " ^ C.tmp_dir ^ " " ^ url ^ "/\"" ^ C.indexname ^ "\"") <> 0 then raise (ErrorGetting url) ; - let tmpfilename = C.tmpdir ^ "/" ^ C.indexname in + let tmpfilename = C.tmp_dir ^ "/" ^ C.indexname in let fd = open_in tmpfilename in let uris = ref [] in try while true do - uris := (input_line fd) :: !uris + 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 @@ -37,7 +73,9 @@ let read_index url = 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 @@ -45,19 +83,21 @@ let rec mk_urls_of_uris = | he::tl -> let map = mk_urls_of_uris tl in let uris = read_index he in - let url_of_uri uri = - let url = uri ^ ".xml" 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 m -> MapOfStrings.add uri (url_of_uri uri) m) + (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 @@ -80,6 +120,12 @@ let update () = then raise PerlGetterNotResponding ; ;; +*) + +let update () = +(* deliver update request to http_getter *) + ClientHTTP.send (Configuration.getter_url ^ "update") +;; (* url_of_uri : uri -> url *) let url_of_uri uri = @@ -115,6 +161,8 @@ let get_file uri = 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 =