let update_entry (intruder_name : string) (intruder_state : string) (agent_name : string) (lab : string) (l_rec : string) : unit =
let simul_affectation unif str =
let res = ref str in
List.iter (fun (_,value,_,variable) -> res:=(replace variable value (!res))) unif;
!res
in
let aux lab l_rec l =
let(exist_match,sub) = get_unification intruder_name intruder_state l_rec agent_name intruder_state lab in
let rec aux0 lab l_rec l =
match l with [] -> ()
|(label,value,entries,lst_choices)::ls ->
(if(((exist_match=1 && l_rec<>(!value)) || l_rec="") && lab=label)
then(
List.iter (fun (entry,record,_) ->
Entry.delete_range entry ~start:(`Num 0) ~stop:`End;
Entry.insert entry ~index:(`Num 0) ~text:(transcript_receiver_for_intruder agent_name l_rec);
record:=l_rec;
) (!entries);
value:=l_rec;
)
else if((exist_match=1) && lab<>label)
then (
let unif_tmp = simul_affectation sub label in
if(label<>unif_tmp)then(
List.iter (fun (entry,record,lst) ->
let find = ref false in
let lst_contains = Listbox.get_range lst ~first:(`Num 0) ~last:`End in
Listbox.delete lst ~first:(`Num 0) ~last:`End;
Listbox.insert lst ~index:`End
~texts:(remove ""
(List.map (fun c ->
if((match_message intruder_name intruder_state (transcript_receiver_for_intruder agent_name c) agent_name intruder_state unif_tmp))
then (if((!value)=(transcript_receiver_for_intruder agent_name c)) then find:=true ; c)
else "")
lst_contains
));
if not(!find)
then (
value:="";
record:="";
Entry.delete_range entry ~start:(`Num 0) ~stop:`End;
);
) (!entries);
);
);
aux0 lab l_rec ls);
in
aux0 lab l_rec l
in
List.iter
(fun (label,_,entries,lst_choices) ->
List.iter
(fun (_,_,lst) ->
Listbox.delete lst ~first:(`Num 0) ~last:`End;
Listbox.insert lst ~index:`End
~texts:(List.map (fun c -> (transcript_receiver_for_intruder agent_name c)) lst_choices)
)
(!entries)
)
(!l_entry);
List.iter
(fun (label,value,_,_) ->
if(label<>lab && (!value)<>"")
then aux label (!value) (!l_entry)
else aux lab l_rec (!l_entry)
)
(!l_entry);