From: Ferruccio Guidi Date: Fri, 20 Feb 2004 16:31:07 +0000 (+0000) Subject: - mathql interpreter flags reorganized X-Git-Tag: v0_0_4~128 X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=commitdiff_plain;h=bcec0bb27e0dce3e72c97011f9c9dd210f604705;p=helm.git - mathql interpreter flags reorganized - logging function in NQIConn.init is now optional: default is ignore --- diff --git a/helm/Makefile b/helm/Makefile index 721a89621..b87be5027 100644 --- a/helm/Makefile +++ b/helm/Makefile @@ -1,4 +1,4 @@ -DIRS = ocaml hbugs gTopLevel searchEngine mathql_test +DIRS = ocaml hbugs gTopLevel searchEngine mathql_test hxp DIRS_BYTE = $(patsubst %,%.byte,$(DIRS)) DIRS_OPT = $(patsubst %,%.opt,$(DIRS)) diff --git a/helm/gTopLevel/gTopLevel.conf.xml.sample b/helm/gTopLevel/gTopLevel.conf.xml.sample index 89001df56..94fd2874a 100644 --- a/helm/gTopLevel/gTopLevel.conf.xml.sample +++ b/helm/gTopLevel/gTopLevel.conf.xml.sample @@ -14,12 +14,14 @@
mathql_db_map.txt dbname=mowgli host=mowgli.cs.unibo.it user=helm password=awH21Un - - - - - - + + + + + + + +
diff --git a/helm/gTopLevel/gTopLevel.ml b/helm/gTopLevel/gTopLevel.ml index 69ad5d502..9ff7e8fc6 100644 --- a/helm/gTopLevel/gTopLevel.ml +++ b/helm/gTopLevel/gTopLevel.ml @@ -62,7 +62,7 @@ let _ = (* GLOBAL CONSTANTS *) let mqi_debug_fun s = debug_print ~level:2 s -let mqi_handle = MQIC.init mqi_debug_fun +let mqi_handle = MQIC.init ~log:mqi_debug_fun () let xlinkns = Gdome.domString "http://www.w3.org/1999/xlink";; diff --git a/helm/hbugs/tutors/search_pattern_apply_tutor.ml b/helm/hbugs/tutors/search_pattern_apply_tutor.ml index 0943dd146..26183e2b9 100644 --- a/helm/hbugs/tutors/search_pattern_apply_tutor.ml +++ b/helm/hbugs/tutors/search_pattern_apply_tutor.ml @@ -134,7 +134,7 @@ let main () = broker_id := Some (Hbugs_tutors_common.register_to_broker my_own_id my_own_url "FOO" "Search_pattern_apply tutor"); - let mqi_handle = MQIC.init prerr_string in + let mqi_handle = MQIC.init ~log:prerr_string () in if Sys.file_exists environment_file then restore_environment (); Http_daemon.start' diff --git a/helm/mathql_test/mqgtop.ml b/helm/mathql_test/mqgtop.ml index 7f8e2b85b..bb7764747 100644 --- a/helm/mathql_test/mqgtop.ml +++ b/helm/mathql_test/mqgtop.ml @@ -53,7 +53,7 @@ module GU = MQGUtil let get_handle () = C.init ~flags:(C.flags_of_string ! int_options) - (fun s -> print_string s; flush stdout) + ~log:(fun s -> print_string s; flush stdout) () let issue handle q = let mode = [Open_wronly; Open_append; Open_creat; Open_text] in diff --git a/helm/mathql_test/mqitop.ml b/helm/mathql_test/mqitop.ml index efac469a8..055841052 100644 --- a/helm/mathql_test/mqitop.ml +++ b/helm/mathql_test/mqitop.ml @@ -36,7 +36,7 @@ let _ = let ich = Lexing.from_channel stdin in let flags = if Array.length Sys.argv >= 2 then Sys.argv.(1) else "" in let log s = print_string s; flush stdout in - let handle = C.init ~flags:(C.flags_of_string flags) log in + let handle = C.init ~flags:(C.flags_of_string flags) ~log:log () in if not (C.connected handle) then begin print_endline "mqitop: no connection"; flush stdout end; diff --git a/helm/ocaml/mathql_interpreter/mQIConn.ml b/helm/ocaml/mathql_interpreter/mQIConn.ml index 9c9cfa995..d0dedf143 100644 --- a/helm/ocaml/mathql_interpreter/mQIConn.ml +++ b/helm/ocaml/mathql_interpreter/mQIConn.ml @@ -26,7 +26,7 @@ (* AUTOR: Ferruccio Guidi *) -type flag = Postgres | Galax | Stat | Quiet | Warn | Log | Source +type flag = Galax | Postgres | Queries | Result | Source | Times | Warn type handle = { log : string -> unit; (* logging function *) @@ -51,22 +51,22 @@ let pgc handle = handle.pgc let flags handle = handle.set let string_of_flag = function - | Postgres -> "P" | Galax -> "G" - | Stat -> "S" - | Quiet -> "Q" + | Postgres -> "P" + | Queries -> "Q" + | Result -> "R" + | Source -> "S" + | Times -> "T" | Warn -> "W" - | Log -> "L" - | Source -> "V" let flag_of_char = function - | 'P' -> [Postgres] | 'G' -> [Galax] - | 'S' -> [Stat] - | 'Q' -> [Quiet] + | 'P' -> [Postgres] + | 'Q' -> [Queries] + | 'R' -> [Result] + | 'S' -> [Source] + | 'T' -> [Times] | 'W' -> [Warn] - | 'L' -> [Log] - | 'V' -> [Source] | _ -> [] let string_fold_left f a s = @@ -80,7 +80,7 @@ let string_of_flags flags = let flags_of_string s = string_fold_left (fun l c -> l @ flag_of_char c) [] s -let init ?(flags = []) mylog = +let init ?(flags = []) ?(log = ignore) () = let flags = if flags = [] then flags_of_string (Helm_registry.get "mathql_interpreter.flags") @@ -93,7 +93,7 @@ let init ?(flags = []) mylog = then MQIMap.empty_map else MQIMap.read_map in g () in - {log = mylog; set = flags; + {log = log; set = flags; pgc = if List.mem Galax flags then None @@ -109,7 +109,6 @@ let close handle = let connected handle = if set handle Galax then false else (pgc handle) <> None -let init_if_connected ?(flags = []) mylog = - let handle = init ~flags:flags mylog in +let init_if_connected ?(flags = []) ?(log = ignore) () = + let handle = init ~flags:flags ~log:log () in ignore (pgc handle); handle - diff --git a/helm/ocaml/mathql_interpreter/mQIConn.mli b/helm/ocaml/mathql_interpreter/mQIConn.mli index cb1ae4ddc..b83453ae9 100644 --- a/helm/ocaml/mathql_interpreter/mQIConn.mli +++ b/helm/ocaml/mathql_interpreter/mQIConn.mli @@ -26,18 +26,18 @@ (* AUTOR: Ferruccio Guidi *) -type flag = Postgres | Galax | Stat | Quiet | Warn | Log | Source +type flag = Galax | Postgres | Queries | Result | Source | Times | Warn val string_of_flags : flag list -> string val flags_of_string : string -> flag list type handle -val init : ?flags:(flag list) -> (string -> unit) -> handle +val init : ?flags:(flag list) -> ?log:(string -> unit) -> unit -> handle val close : handle -> unit val connected : handle -> bool -val init_if_connected : ?flags:(flag list) -> (string -> unit) -> handle +val init_if_connected : ?flags:(flag list) -> ?log:(string -> unit) -> unit -> handle (* The following functions allow to read the handle internal fields. * For exclusive use of the interpreter. diff --git a/helm/ocaml/mathql_interpreter/mQIProperty.ml b/helm/ocaml/mathql_interpreter/mQIProperty.ml index be559adc7..639fc6bb0 100644 --- a/helm/ocaml/mathql_interpreter/mQIProperty.ml +++ b/helm/ocaml/mathql_interpreter/mQIProperty.ml @@ -57,7 +57,7 @@ let cl_print l = let pg_query h table cols ct cfl = let exec q = - if C.set h C.Log then C.log h (q ^ "\n"); + if C.set h C.Queries then C.log h (q ^ "\n"); P.exec (C.pgc h) q in let rec iter f sep = function diff --git a/helm/ocaml/mathql_interpreter/mQueryInterpreter.ml b/helm/ocaml/mathql_interpreter/mQueryInterpreter.ml index 8a3a3b3cf..453b1643c 100644 --- a/helm/ocaml/mathql_interpreter/mQueryInterpreter.ml +++ b/helm/ocaml/mathql_interpreter/mQueryInterpreter.ml @@ -133,7 +133,7 @@ let execute h x = let t = P.start_time () in P.text_of_query (C.log h) "\n" x; let s = P.stop_time t in - if C.set h C.Stat then + if C.set h C.Times then C.log h (Printf.sprintf "Log source: %s\n" s); eval_query c x end else begin @@ -141,7 +141,7 @@ let execute h x = let t = P.start_time () in P.text_of_result (C.log h) "\n" s; let r = P.stop_time t in - if C.set h C.Stat then + if C.set h C.Times then C.log h (Printf.sprintf "Log: %s\n" r); s end @@ -196,7 +196,7 @@ let execute h x = let t = P.start_time () in let r = MQIProperty.exec h q1 subj cons_true cons_false exp in let s = P.stop_time t in - if C.set h C.Stat then + if C.set h C.Times then C.log h (Printf.sprintf "Property: %s,%i\n" s (List.length r)); r | M.StatQuery x -> @@ -237,8 +237,9 @@ let execute h x = let t = P.start_time () in if C.set h C.Source then P.text_of_query (C.log h) "\n" x; let r = eval_query c x in + if C.set h C.Result then P.text_of_result (C.log h) "\n" r; let s = P.stop_time t in - if C.set h C.Stat then + if C.set h C.Times then C.log h (Printf.sprintf "MQIExecute: %s,%s\n" s (C.string_of_flags (C.flags h))); r diff --git a/helm/searchEngine/searchEngine.ml b/helm/searchEngine/searchEngine.ml index 507dadb63..f3690204f 100644 --- a/helm/searchEngine/searchEngine.ml +++ b/helm/searchEngine/searchEngine.ml @@ -610,7 +610,7 @@ printf "Current directory is %s\n" (Sys.getcwd ()); printf "HTML directory is %s\n" pages_dir; flush stdout; Unix.putenv "http_proxy" ""; -let mqi_handle = C.init debug_print in +let mqi_handle = C.init ~log:debug_print () in Http_daemon.start' ~port (callback mqi_handle); C.close mqi_handle; printf "%s is terminating, bye!\n" daemon_name