+let retract (cgi : Netcgi1_compat.Netcgi_types.cgi_activation) =
+ let cgi = Netcgi1_compat.Netcgi_types.of_compat_activation cgi in
+ let env = cgi#environment in
+ (try
+ let sid = Uuidm.of_string (Netcgi.Cookie.value (env#cookie "session")) in
+ let sid = HExtlib.unopt sid in
+ cgi # set_header
+ ~cache:`No_cache
+ ~content_type:"text/xml; charset=\"utf-8\""
+ ();
+ let history = MatitaAuthentication.get_history sid in
+ let new_history,new_status =
+ match history with
+ _::(status::_ as history) ->
+ history, status
+ | [_] -> (prerr_endline "singleton";failwith "retract")
+ | _ -> (prerr_endline "nil"; assert false) in
+ NCicLibrary.time_travel new_status;
+ MatitaAuthentication.set_history sid new_history;
+ MatitaAuthentication.set_status sid new_status;
+ prerr_endline ("after retract history.length = " ^
+ string_of_int (List.length new_history));
+ let body = output_status new_status in
+ cgi#out_channel#output_string body
+ with _ -> cgi#set_header ~status:`Internal_server_error
+ ~cache:`No_cache
+ ~content_type:"text/xml; charset=\"utf-8\"" ());
+ cgi#out_channel#commit_work()
+;;
+
+
+let viewLib (cgi : Netcgi1_compat.Netcgi_types.cgi_activation) =
+ let cgi = Netcgi1_compat.Netcgi_types.of_compat_activation cgi in
+ let env = cgi#environment in
+
+ let sid = Uuidm.of_string (Netcgi.Cookie.value (env#cookie "session")) in
+ let sid = HExtlib.unopt sid in
+ cgi # set_header
+ ~cache:`No_cache
+ ~content_type:"text/html; charset=\"utf-8\""
+ ();
+ let uid = MatitaAuthentication.user_of_session sid in
+
+ let html = MatitaFilesystem.html_of_library uid in
+ cgi#out_channel#output_string
+ ((*
+ "<html><head>\n" ^
+ "<title>XML Tree Control</title>\n" ^
+ "<link href=\"treeview/xmlTree.css\" type=\"text/css\" rel=\"stylesheet\">\n" ^
+ "<script src=\"treeview/xmlTree.js\" type=\"text/javascript\"></script>\n" ^
+ "<body>\n" ^ *)
+ html (* ^ "\n</body></html>" *) );
+ cgi#out_channel#commit_work()
+
+;;
+
+open Netcgi1_compat.Netcgi_types;;
+
+(**********************************************************************)
+(* Create the webserver *)
+(**********************************************************************)
+
+
+let start() =
+ let (opt_list, cmdline_cfg) = Netplex_main.args() in
+
+ let use_mt = ref true in
+
+ let opt_list' =
+ [ "-mt", Arg.Set use_mt,
+ " Use multi-threading instead of multi-processing"
+ ] @ opt_list in
+
+ Arg.parse
+ opt_list'
+ (fun s -> raise (Arg.Bad ("Don't know what to do with: " ^ s)))
+ "usage: netplex [options]";
+ let parallelizer =
+ if !use_mt then
+ Netplex_mt.mt() (* multi-threading *)
+ else
+ Netplex_mp.mp() in (* multi-processing *)
+(*
+ let adder =
+ { Nethttpd_services.dyn_handler = (fun _ -> process1);
+ dyn_activation = Nethttpd_services.std_activation `Std_activation_buffered;
+ dyn_uri = None; (* not needed *)
+ dyn_translator = (fun _ -> ""); (* not needed *)
+ dyn_accept_all_conditionals = false;
+ } in
+*)
+ let do_advance =
+ { Nethttpd_services.dyn_handler = (fun _ -> advance);
+ dyn_activation = Nethttpd_services.std_activation `Std_activation_buffered;
+ dyn_uri = None; (* not needed *)
+ dyn_translator = (fun _ -> ""); (* not needed *)
+ dyn_accept_all_conditionals = false;
+ } in
+ let do_retract =
+ { Nethttpd_services.dyn_handler = (fun _ -> retract);
+ dyn_activation = Nethttpd_services.std_activation `Std_activation_buffered;
+ dyn_uri = None; (* not needed *)
+ dyn_translator = (fun _ -> ""); (* not needed *)
+ dyn_accept_all_conditionals = false;
+ } in
+ let goto_bottom =
+ { Nethttpd_services.dyn_handler = (fun _ -> gotoBottom);
+ dyn_activation = Nethttpd_services.std_activation `Std_activation_buffered;
+ dyn_uri = None; (* not needed *)
+ dyn_translator = (fun _ -> ""); (* not needed *)
+ dyn_accept_all_conditionals = false;
+ } in
+ let retrieve =
+ { Nethttpd_services.dyn_handler = (fun _ -> retrieve);
+ dyn_activation = Nethttpd_services.std_activation `Std_activation_buffered;
+ dyn_uri = None; (* not needed *)
+ dyn_translator = (fun _ -> ""); (* not needed *)
+ dyn_accept_all_conditionals = false;
+ } in
+ let do_register =
+ { Nethttpd_services.dyn_handler = (fun _ -> register);
+ dyn_activation = Nethttpd_services.std_activation `Std_activation_buffered;
+ dyn_uri = None; (* not needed *)
+ dyn_translator = (fun _ -> ""); (* not needed *)
+ dyn_accept_all_conditionals = false;
+ } in
+ let do_login =
+ { Nethttpd_services.dyn_handler = (fun _ -> login);
+ dyn_activation = Nethttpd_services.std_activation `Std_activation_buffered;
+ dyn_uri = None; (* not needed *)
+ dyn_translator = (fun _ -> ""); (* not needed *)
+ dyn_accept_all_conditionals = false;
+ } in
+ let do_logout =
+ { Nethttpd_services.dyn_handler = (fun _ -> logout);
+ dyn_activation = Nethttpd_services.std_activation `Std_activation_buffered;
+ dyn_uri = None; (* not needed *)
+ dyn_translator = (fun _ -> ""); (* not needed *)
+ dyn_accept_all_conditionals = false;
+ } in
+ let do_viewlib =
+ { Nethttpd_services.dyn_handler = (fun _ -> viewLib);
+ dyn_activation = Nethttpd_services.std_activation `Std_activation_buffered;
+ dyn_uri = None; (* not needed *)
+ dyn_translator = (fun _ -> ""); (* not needed *)
+ dyn_accept_all_conditionals = false;
+ } in
+
+ let nethttpd_factory =
+ Nethttpd_plex.nethttpd_factory
+ ~handlers:[ "advance", do_advance
+ ; "retract", do_retract
+ ; "bottom", goto_bottom
+ ; "open", retrieve
+ ; "register", do_register
+ ; "login", do_login
+ ; "logout", do_logout
+ ; "viewlib", do_viewlib]
+ () in