X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Finterface%2FxsltProcessor.ml;h=3d3690f395154b8c76bd680e7700c736db3a3039;hb=4ef40e8fb4de63f9699268b389f052007bc87f54;hp=c82a8f5f8c960e0c94d8b99c1eccf4baa8be9a05;hpb=c01d2aaea05f7385bee46addd900cd0397756389;p=helm.git diff --git a/helm/interface/xsltProcessor.ml b/helm/interface/xsltProcessor.ml index c82a8f5f8..3d3690f39 100644 --- a/helm/interface/xsltProcessor.ml +++ b/helm/interface/xsltProcessor.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/. + *) + exception XsltProcessorCouldNotSend;; exception XsltProcessorCouldNotReceive;; @@ -23,36 +48,30 @@ let rec process uri usecache mode = (* purge the cache if asked to *) if not usecache && tmp_file_exists then Sys.remove tmpfile ; - let string_to_send = mode ^ " " ^ url ^ " " ^ tmpfile in + (* let string_to_send = mode ^ " " ^ url ^ " " ^ tmpfile in *) + let string_to_send = "apply " ^ url ^ " " ^ tmpfile ^ + match mode with + "cic" -> " C1 C2" + | "theory" -> " T1 T2" + in (* next function is for looping in case the server is not responding *) - let rec contact_server () = - let socketclient = U.socket U.PF_INET U.SOCK_DGRAM 0 - and socketserver = U.socket U.PF_INET U.SOCK_DGRAM 0 in - let bounded = ref false in - while not !bounded do - try - U.bind socketclient (U.ADDR_INET(U.inet_addr_any,portclient)) ; - bounded := true - with _ -> - print_endline "Port unavailable. Retrying..." ; flush stdout ; - U.sleep 5 (* wait hoping the inetaddr is released *) - done ; + let socketserver = U.socket U.PF_INET U.SOCK_DGRAM 0 in + let rec contact_server () = let n = U.sendto socketserver string_to_send 0 (String.length string_to_send) [] (U.ADDR_INET(U.inet_addr_any,portserver)) in if n = -1 then raise XsltProcessorCouldNotSend ; - U.close socketserver ; - let process_signal _ = U.close socketclient in + let process_signal _ = () in Sys.set_signal Sys.sigalrm (Sys.Signal_handle process_signal) ; (* if the server does not respond, repeat the query *) ignore (U.alarm time_to_wait) ; try - if U.recv socketclient "" 0 0 [] = -1 then + if U.recv socketserver "" 0 0 [] = -1 then raise XsltProcessorCouldNotReceive ; ignore (U.alarm 0) ; (* stop the bomb *) Sys.set_signal Sys.sigalrm Sys.Signal_default ; - U.close socketclient ; + U.close socketserver ; tmpfile with U.Unix_error(_,"recv",_) -> @@ -60,5 +79,5 @@ let rec process uri usecache mode = flush stdout; contact_server () in - contact_server () + contact_server () ;;