1 (* Copyright (C) 2002, HELM Team.
3 * This file is part of HELM, an Hypertextual, Electronic
4 * Library of Mathematics, developed at the Computer Science
5 * Department, University of Bologna, Italy.
7 * HELM is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * HELM is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with HELM; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
22 * For details, see the HELM World-Wide-Web page,
23 * http://cs.unibo.it/helm/.
28 let _ = Helm_registry.load_from "/projects/helm/etc/proofChecker.conf.xml";;
30 let port = Helm_registry.get_int "proofchecker.port";;
32 let (html_preamble, html_postamble) =
37 <title>Proof-Checking %s</title>
39 <body bgcolor=\"white\">
40 <h1>Proof-Checking %s:</h1>
50 let bad_request outchan =
51 printf "INVALID REQUEST !!!!!\n\n";
53 Http_daemon.respond_error ~status:(`Client_error `Bad_request) outchan;
61 <title>ProofChecker's help message</title>
67 Usage: <kbd>http://hostname:proofcheckerport/</kbd><em>command</em>
73 <b><kbd>help</kbd></b><br />
74 display this help message
77 <b><kbd>proofCheck?uri=uri</kbd></b><br />
78 proof-checks the object whose URI is specified by <em>uri</em>
85 let outchan = ref stderr;;
88 HelmLogger.register_log_callback
89 (fun ?append_NL msg ->
90 output_string !outchan (HelmLogger.html_of_html_msg msg) ;
94 let callback (req : Http_types.request) outchan' =
100 let uri = req#param "uri" in
101 Http_daemon.send_basic_headers ~code:200 outchan' ;
102 Http_daemon.send_header "Content-type" "text/html" outchan' ;
103 Http_daemon.send_CRLF outchan' ;
104 printf "Request to proof-check \"%s\"..." uri;
106 fprintf outchan' "%s" (html_preamble uri);
109 CicTypeChecker.typecheck (UriManager.uri_of_string uri);
111 fprintf outchan' "%s\n" (Printexc.to_string e);
113 fprintf outchan' "%s" html_postamble;
117 with Http_types.Param_not_found _ -> (* 'uri' argument not found *)
121 Http_daemon.respond ~body:usage_string
122 ~headers:["Content-Type", "text/html"] outchan'
123 | req -> bad_request outchan'
127 printf "Proof Checker started and listening on port %d\n" port;
129 Http_daemon.start' ~port ~mode:`Fork callback ;
130 printf "Proof Checker is terminating, bye!\n"