|
@@ -144,30 +144,45 @@ let get_current () =
|
|
|
failwith "Deprecated"
|
|
|
;;
|
|
|
|
|
|
+(* Types used to return accurate logs *)
|
|
|
+type accurate_log =
|
|
|
+ (Rc.entry * int) list
|
|
|
+;;
|
|
|
+type accurate_log_simple =
|
|
|
+ (string * int) list
|
|
|
+;;
|
|
|
+
|
|
|
(* Get number of launch for each command in rc file, as follow:
|
|
|
- * (command:string, number of the command:int) list *)
|
|
|
-let get_accurate_log ?rc_name ~tmp () =
|
|
|
+ * (Rc.entry, number of launch for the command:int) list *)
|
|
|
+let get_accurate_log_complete ?rc_name ~tmp () =
|
|
|
let open List in
|
|
|
-
|
|
|
- (* Read rc *)
|
|
|
- (* XXX Forcing evaluation of lazy value Const.rc_file before it is
|
|
|
- * necessary *)
|
|
|
- let name : string = Option.value ~default:(Lazy.force !Const.rc_file) rc_name
|
|
|
- in
|
|
|
- let rc = File_com.init_rc ~rc:(Lazy.return name) () in
|
|
|
-
|
|
|
- let rc_in_tmp = get_log ~rc_tmp:(Assoc.find tmp.Tmp_biniou_t.rc name
|
|
|
+ let rc = Rc.init ?rc:rc_name () in
|
|
|
+ let rc_in_tmp = get_log ~rc_tmp:(Assoc.find tmp.Tmp_biniou_t.rc rc#get_name
|
|
|
|> Option.value ~default:[])
|
|
|
in
|
|
|
- map rc.Settings_t.progs ~f:(fun key ->
|
|
|
+ map rc#entries ~f:(fun entry ->
|
|
|
+ let key = entry#command in
|
|
|
Assoc.find rc_in_tmp key
|
|
|
|> Option.value ~default:0
|
|
|
- |> (function number -> (key,number)))
|
|
|
+ |> (function number -> (entry, number)))
|
|
|
+;;
|
|
|
+
|
|
|
+(* Get (may transform an existing log) number of launch for each command in rc file, as follow:
|
|
|
+ * (command:string, number of launch for the command:int) list *)
|
|
|
+let get_accurate_log ?entry_log ~tmp () =
|
|
|
+ let entry_log =
|
|
|
+ match entry_log with
|
|
|
+ | None -> get_accurate_log_complete ~tmp ()
|
|
|
+ | Some log -> log
|
|
|
+ in
|
|
|
+ entry_log |>
|
|
|
+ List.map ~f:(fun (entry, nb_of_launch) -> (entry#command, nb_of_launch))
|
|
|
;;
|
|
|
|
|
|
(* Reset number of launch for a given command
|
|
|
* cmd: number of the command to be reseted
|
|
|
* num: number to reset *)
|
|
|
+(* FIXME cmd is not very clear for a command number *)
|
|
|
let reset_cmd ~rc num cmd =
|
|
|
(* Debugging *)
|
|
|
[(num,"num") ; (cmd,"cmd")]
|
|
@@ -177,9 +192,9 @@ let reset_cmd ~rc num cmd =
|
|
|
let ac_log = get_accurate_log ~tmp:(init ()) () in
|
|
|
(* The command (string) corresponding to the number *)
|
|
|
let cmd_str =
|
|
|
- File_com.num_cmd2cmd ~rc cmd
|
|
|
+ rc#entry ~n:cmd
|
|
|
|> function
|
|
|
- Some s -> s
|
|
|
+ Some s -> s#command
|
|
|
| None -> failwith "Out of bound"
|
|
|
in
|
|
|
|
|
@@ -199,7 +214,7 @@ let reset_cmd ~rc num cmd =
|
|
|
|
|
|
(* Reset all commands to a number
|
|
|
* num: number to reset *)
|
|
|
-let reset2num ~rc num =
|
|
|
+let reset2num num =
|
|
|
(* Debugging *)
|
|
|
"Num: " ^ (Int.to_string num)
|
|
|
|> Messages.debug;
|