]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/ocaml/mathql_interpreter/mQIConn.ml
- mathql interpreter flags reorganized
[helm.git] / helm / ocaml / mathql_interpreter / mQIConn.ml
index 9c9cfa995b870f515af8ffcf6069e18b3b37d54e..d0dedf143ca20beed109c4db9399d15412a6e940 100644 (file)
@@ -26,7 +26,7 @@
 (*  AUTOR: Ferruccio Guidi <fguidi@cs.unibo.it>
  *)
 
-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