timeFormat ""
timeFormatDefault "%H:%M:%S "
myaddr localhost
+ maxlinelen 160
}
# variables to save across runs
state(fontSize)
state(showsockname)
state(myaddr)
+ state(maxlinelen)
extract(client)
extract(server)
extract(meta2)
array set prefix {meta = meta2 = client > server <}
if {$time == ""} { ;# If not set, then set to now
- set time [clock seconds]
+ set time [clock seconds]
}
set timestamp [timestamp $time]
DoExtract $who $data $timestamp ;# Display any extracted data
if {! $force && ! $state(capture)} return ;# No display w/o capture on
lappend state(playback) $who $data $time ;# Save for redraw and saving
-
+
if {$state(ascii) || [regexp {^meta2?$} $who] } {
- regsub -all \r $data "" data
- foreach line [split $data \n] {
- set line [printable $line]
- set tag $who
- if {$tag == "client" && [regexp -nocase {^get |^post } $line]} {
- lappend tag client2
- }
- if {$state(gui)} {
- .out insert end "$timestamp" time_$tag \
+ regsub -all \r $data "" data
+ foreach line [split $data \n] {
+ set line [printable $line]
+ if {[string length $line] > $state(maxlinelen)} {
+ set indent [string repeat " " [string length $timestamp]]
+ for {set ndx 0} {$ndx < [string length $line]} {incr ndx $state(maxlinelen)} {
+ append line2 [string range $line $ndx [expr {$ndx + $state(maxlinelen) - 1}]]\n$indent
+ }
+ set line $line2; unset line2
+ }
+ set tag $who
+ if {$tag == "client" && [regexp -nocase {^get |^post } $line]} {
+ lappend tag client2
+ }
+ if {$state(gui)} {
+ .out insert end "$timestamp" time_$tag \
"$sockname " [concat $tag sockname] \
- "$line\n" $tag
- } else {
- puts "$timestamp$prefix($who)$line"
- }
- }
- } else { ;# Hex output
- while {[string length $data]} {
- set line [string range $data 0 15]
- set data [string range $data [string length $line] end]
- binary scan $line H* hex
- regsub -all {([0-9a-f][0-9a-f])} $hex {\1 } hex
- set line [format "%-48.48s %-16.16s\n" $hex [printable $line 1]]
- if {$state(gui)} {
- .out insert end "$timestamp" time_$who \
+ "$line" $tag \
+ "\n" $tag
+ } else {
+ puts "$timestamp$prefix($who)${line}"
+ }
+ }
+ } else { ;# Hex output
+ while {[string length $data]} {
+ set line [string range $data 0 15]
+ set data [string range $data [string length $line] end]
+ binary scan $line H* hex
+ regsub -all {([0-9a-f][0-9a-f])} $hex {\1 } hex
+ set line [format "%-48.48s %-16.16s\n" $hex [printable $line 1]]
+ if {$state(gui)} {
+ .out insert end "$timestamp" time_$who \
"$sockname " [list $who sockname] \
"$line" $who
- } else {
- puts "$timestamp$prefix(who)$line"
- }
- }
+ } else {
+ puts "$timestamp$prefix(who)$line"
+ }
+ }
}
if {$state(autoscroll) && $state(gui)} {
- .out see end
+ .out see end
}
}
##+##########################################################################