X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Finterface%2FxsltProcessor.ml;h=ec3d9fdb05c8f4c18462e2ae7a183324f414fd43;hb=fb158d51c621e55962a6139d03cd1678cfb2e8f1;hp=9165a5363637ffc83079f879edca32f54dd3fd6d;hpb=f25a6ef4d3e7263420d1e72daccf5e60c672b47b;p=helm.git diff --git a/helm/interface/xsltProcessor.ml b/helm/interface/xsltProcessor.ml index 9165a5363..ec3d9fdb0 100644 --- a/helm/interface/xsltProcessor.ml +++ b/helm/interface/xsltProcessor.ml @@ -23,63 +23,7 @@ * http://cs.unibo.it/helm/. *) -exception XsltProcessorCouldNotSend;; -exception XsltProcessorCouldNotReceive;; +let initialize = XsltProcessorHTTP.initialize -let portserver = 12345;; -let portclient = 12346;; -let time_to_wait = 10;; +let process = XsltProcessorHTTP.process -let rec process uri usecache mode = - let module U = Unix in - let uri = UriManager.string_of_uri uri in - let pid = string_of_int (U.getpid ()) - and filename' = - let uri' = Str.replace_first (Str.regexp ".*:") "" uri in - Str.global_replace (Str.regexp "/") "_" - (Str.global_replace (Str.regexp "_") "__" uri') - in let tmpfile = "/tmp/helm_" ^ filename' ^ "_" ^ pid in - (* test if the cache can be used *) - let tmp_file_exists = Sys.file_exists tmpfile in - if usecache && tmp_file_exists then - tmpfile - else - let url = Configuration.getter_url ^ uri in - (* 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 = "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 socketserver = U.socket U.PF_INET U.SOCK_DGRAM 0 in - let rec contact_server () = - let n = - Printf.printf "sending %s to server...\n" string_to_send; - flush stdout; - 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 ; - 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 socketserver "" 0 0 [] = -1 then - raise XsltProcessorCouldNotReceive ; - ignore (U.alarm 0) ; (* stop the bomb *) - Sys.set_signal Sys.sigalrm Sys.Signal_default ; - U.close socketserver ; - tmpfile - with - U.Unix_error(_,"recv",_) -> - print_endline "Xaland server not responding. Retrying..." ; - flush stdout; - contact_server () - in - contact_server () -;;