1# convert_history.tcl 2# 3# converts SecPanel's old history file format to new format 4# implemented for SecPanel 0.40 and newer 5 6proc ch {} { 7 global env 8 9 set hfile "$env(HOME)/.secpanel/history" 10 set hfile_backup "$env(HOME)/.secpanel/history_backup" 11 set thfile "$env(HOME)/.secpanel/history.temp" 12 13 if {! [file exists $hfile]} { 14 puts "No history-file to convert" 15 return 16 } 17 18 file copy -force $hfile $hfile_backup 19 20 set hf [open "$hfile" r] 21 set thf [open "$thfile" w] 22 23 while {[gets $hf line] >= 0} { 24 regsub " - " $line ";" newline 25 26 set type [lindex [split $newline "\#"] 0] 27 set date [lindex [split [lindex [split $newline "#"] 1] ";"] 0] 28 set action [lindex [split [lindex [split $newline "#"] 1] ";"] 1] 29 30 if [catch {set newdate [clock scan $date]} err] { 31 puts "Found history file already updated..." 32 file copy -force $hfile_backup $hfile 33 return 34 } 35 36 puts $thf "$type\#[clock scan $date]\#$action" 37 } 38 39 close $thf 40 close $hf 41 42 file copy -force $thfile $hfile 43 file delete -force $thfile 44 45 puts "Finished converting history" 46} 47 48ch 49