let utf8_length = Netconversion.ustring_length `Enc_utf8
+let utf8_parsed_text s floc =
+ let start, stop = HExtlib.loc_of_floc floc in
+ let len = stop - start in
+ let res = Netconversion.ustring_sub `Enc_utf8 start len s in
+ res, String.length res
+
(*** from matitaScript.ml ***)
(* let only_dust_RE = Pcre.regexp "^(\\s|\n|%%[^\n]*\n)*$" *)
| GrafiteAst.Comment (loc, _) -> loc in
let _,lend = HExtlib.loc_of_floc floc in
- let parsed_text, parsed_text_len =
- MatitaGtkMisc.utf8_parsed_text unparsed_text (HExtlib.floc_of_loc (0,lend)) in
+ let parsed_text, _parsed_text_len =
+ utf8_parsed_text unparsed_text (HExtlib.floc_of_loc (0,lend)) in
let byte_parsed_text_len = String.length parsed_text in
let unparsed_txt' =
String.sub unparsed_text byte_parsed_text_len
(status, parsed_text, unparsed_txt'),"",(*parsed_text_len*)
utf8_length parsed_text
-
-let status = ref (new MatitaEngine.status "cic:/matita");;
+(* FIXME: currently hard coded to single user mode *)
+let status = ref (new MatitaEngine.status (Some "ricciott") "cic:/matita");;
let history = ref [!status];;
+let sequent_size = ref 40;;
-let include_paths = ["/home/barolo/matitaB/matita/lib"];;
+let include_paths = ref [];;
(* <metasenv>
* <meta number="...">
| Stack.Open i ->
let meta = List.assoc i metasenv in
snd (ApplyTransformation.ntxt_of_cic_sequent
- ~metasenv ~subst ~map_unicode_to_tex:false 80 s (i,meta))
+ ~metasenv ~subst ~map_unicode_to_tex:false !sequent_size s (i,meta))
| Stack.Closed _ -> "This goal has already been closed."
in
let render_sequent is_loc acc depth tag (pos,sw) =
Http_daemon.respond ~headers:["Content-Type", contenttype] ~code:(`Code 200) ~body:s outchan
;;
-let call_service outchan =
- try
- (ignore(MatitaEngine.assert_ng
- ~include_paths:["/home/barolo/matitaB/matita/lib"] (* ~outch:outchan *)
- "/home/barolo/matitaB/matita/lib/basics/pts.ma");
- prerr_endline "fatto";
- let s = read_file "/home/barolo/matitaB/matita/lib/basics/pts.ma.mad"
- in
- Http_daemon.respond ~headers:["Content-Type", "text/html"] ~code:(`Code 200) ~body:s outchan
- )
- with
- e -> Http_daemon.respond ~code:(`Code 500) outchan
-;;
-
let retrieve (cgi : Netcgi1_compat.Netcgi_types.cgi_activation) =
let cgi = Netcgi1_compat.Netcgi_types.of_compat_activation cgi in
cgi # set_header
(read_file filename) in
prerr_endline ("sending:\nBEGIN\n" ^ body ^ "\nEND");
let body = "<file>" ^ body ^ "</file>" in
- let _,baseuri,_,_ =
- Librarian.baseuri_of_script ~include_paths:[] filename
- in
+ let baseuri, incpaths =
+ try
+ let root, baseuri, _fname, _tgt =
+ Librarian.baseuri_of_script ~include_paths:[] filename in
+ let includes =
+ try
+ Str.split (Str.regexp " ")
+ (List.assoc "include_paths" (Librarian.load_root_file (root^"/root")))
+ with Not_found -> []
+ in
+ let rc = root :: includes in
+ List.iter (HLog.debug) rc; baseuri, rc
+ with
+ Librarian.NoRootFor _ | Librarian.FileNotFound _ -> "",[] in
+ include_paths := incpaths;
status := (!status)#set_baseuri baseuri;
cgi#out_channel#output_string body;
cgi#out_channel#commit_work()
let advance0 text =
let (st,new_statements,new_unparsed),(* newtext TODO *) _,parsed_len =
(* try *)
- eval_statement include_paths (*buffer*) !status (`Raw text)
+ eval_statement !include_paths (*buffer*) !status (`Raw text)
(* with End_of_file -> raise Margin *)
in
status := st;
history := st :: !history;
+ prerr_endline ("after advance0 history.length = " ^ string_of_int (List.length !history));
parsed_len, new_unparsed
history, status
| [_] -> (prerr_endline "singleton";failwith "retract")
| _ -> (prerr_endline "nil"; assert false) in
- NCicLibrary.time_travel !status;
+ NCicLibrary.time_travel new_status;
history := new_history;
status := new_status;
+ prerr_endline ("after retract history.length = " ^ string_of_int (List.length !history));
let body = output_status !status in
cgi#out_channel#output_string body;
cgi#out_channel#commit_work()
; "open", retrieve ]
() in
MatitaInit.initialize_all ();
+ (* test begin *)
+ MatitaAuthentication.add_user "ricciott" "pippo123";
+ MatitaAuthentication.add_user "asperti" "pluto456";
+ (* test end *)
Netplex_main.startup
parallelizer
Netplex_log.logger_factories (* allow all built-in logging styles *)