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 "proofChecker.conf.xml";;
32 Helm_registry.get_int "proofchecker.port"
34 Helm_registry.Key_not_found _ -> 48084
37 let (html_preamble, html_postamble) =
42 <title>Proof-Checking %s</title>
44 <body bgcolor=\"white\">
45 <h1>Proof-Checking %s:</h1>
55 let bad_request outchan =
56 printf "INVALID REQUEST !!!!!\n\n";
58 Http_daemon.respond_error ~status:(`Client_error `Bad_request) outchan;
66 <title>ProofChecker's help message</title>
72 Usage: <kbd>http://hostname:proofcheckerport/</kbd><em>command</em>
78 <b><kbd>help</kbd></b><br />
79 display this help message
82 <b><kbd>proofCheck?uri=uri</kbd></b><br />
83 proof-checks the object whose URI is specified by <em>uri</em>
90 let outchan = ref stderr;;
93 HelmLogger.register_log_callback
94 (fun ?append_NL msg ->
95 output_string !outchan (HelmLogger.html_of_html_msg msg) ;
99 let callback (req : Http_types.request) outchan' =
103 outchan := outchan' ;
105 let uri = req#param "uri" in
106 Http_daemon.send_basic_headers ~code:200 outchan' ;
107 Http_daemon.send_header "Content-type" "text/html" outchan' ;
108 Http_daemon.send_CRLF outchan' ;
109 printf "Request to proof-check \"%s\"..." uri;
111 fprintf outchan' "%s" (html_preamble uri);
114 CicTypeChecker.typecheck (UriManager.uri_of_string uri);
116 fprintf outchan' "%s\n" (Printexc.to_string e);
118 fprintf outchan' "%s" html_postamble;
122 with Http_types.Param_not_found _ -> (* 'uri' argument not found *)
126 Http_daemon.respond ~body:usage_string
127 ~headers:["Content-Type", "text/html"] outchan'
128 | req -> bad_request outchan'
132 printf "Proof Checker started and listening on port %d\n" port;
134 Http_daemon.start' ~port ~mode:`Fork callback ;
135 printf "Proof Checker is terminating, bye!\n"