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 <h3>Proof-Checking %s:</h3>
50 let bad_request outchan =
51 printf "INVALID REQUEST !!!!!\n\n";
53 Http_daemon.respond_error ~code:(`Status (`Client_error `Bad_request))
62 <title>ProofChecker's help message</title>
68 Usage: <kbd>http://hostname:proofcheckerport/</kbd><em>command</em>
74 <b><kbd>help</kbd></b><br />
75 display this help message
78 <b><kbd>proofCheck?uri=uri</kbd></b><br />
79 proof-checks the object whose URI is specified by <em>uri</em>
86 let outchan = ref stderr;;
89 HelmLogger.register_log_callback
90 (fun ?append_NL msg ->
91 output_string !outchan (HelmLogger.html_of_html_msg msg) ;
95 let callback (req : Http_types.request) outchan' =
101 let uri = req#param "uri" in
102 Http_daemon.send_basic_headers ~code:(`Code 200) outchan' ;
103 Http_daemon.send_header "Content-type" "text/html" outchan' ;
104 Http_daemon.send_CRLF outchan' ;
105 printf "Request to proof-check \"%s\"..." uri;
107 fprintf outchan' "%s" (html_preamble uri);
110 ignore (CicTypeChecker.typecheck (UriManager.uri_of_string uri));
112 fprintf outchan' "%s\n" (Printexc.to_string e);
114 fprintf outchan' "%s" html_postamble;
118 with Http_types.Param_not_found _ -> (* 'uri' argument not found *)
122 Http_daemon.respond ~body:usage_string
123 ~headers:["Content-Type", "text/html"] outchan'
124 | req -> bad_request outchan'
128 printf "Proof Checker started and listening on port %d\n" port;
130 Http_daemon.start' ~port ~mode:`Fork callback ;
131 printf "Proof Checker is terminating, bye!\n"