icons on message box buttons
[kdenetwork.git] / kppp / convlog.tcl
blobd5e97a1bc29ecc2963c9093f1f2fd8b752f0e6a8
1 #!/usr/bin/tclsh
3 proc err { msg } {
4 global argv0
6 puts stderr "[lindex $argv0 0]: $msg"
9 foreach i [glob -nocomplain ~/.kde/share/apps/kppp/Log/*-199?] {
11 if {[catch { set fin [open $i "r"] }]} {
12 err "cannot open $i for reading"
13 continue
16 if {[catch { set fout [open ${i}.log "a"] }]} {
17 err "cannot open ${i}.log for writing"
18 continue
21 puts -nonewline "converting $i... "
22 flush stdout
24 set PHASE 1
25 while {[eof $fin] == 0} {
26 gets $fin line
28 if {[regexp {(.*:.*:.*):.*:(.*):.*} $line s s1 s2]} {
29 set date [clock scan $s1]
30 if {$PHASE == 2} {
31 # newline
32 puts $fout ""
34 puts -nonewline $fout "$date:$s2"
35 set PHASE 2
36 } else {
37 set PHASE 1
38 if {[regexp {(.*:.*:.*):} $line s s1]} {
39 set date [clock scan $s1]
41 gets $fin line1
42 gets $fin line2
43 regexp {.*:\ *([0-9.]+)\ *(.*)} $line1 s s1 s2
44 regexp {.*:\ *([0-9.]+)\ *(.*)} $line2 s s3 s4
45 puts $fout ":$s2:$date:$s1:$s3:-1:-1"
49 close $fin
50 close $fout
52 # remove duplicate entries
53 if {[catch { exec cat ${i}.log | sort -n | uniq | egrep {^[0-9]} > ${i}.log.new} ret]} {
54 err "cannot sort ${i}.log $ret"
55 } else {
56 catch { exec mv ${i}.log.new ${i}.log }
59 catch {
60 exec chmod 600 ${i}.log
63 puts "done"