1#!/usr/local/bin/tclsh 2# demonstration application, decodes the incoming byte stream from base64 3package require Trf 4 5 6# line buffer for parcel below. 7 8proc join {cmd buffer} { 9 #puts stderr "$cmd [string length buffer] $buffer" 10 11 switch -- $cmd { 12 create/write { 13 set line "" 14 } 15 delete/write { 16 set line "" 17 } 18 write { 19 regsub -all "\[\n\r\]" $buffer {} buffer 20 return $buffer 21 } 22 flush/write { 23 return "" 24 } 25 clear/write { 26 set line "" 27 } 28 } 29} 30 31 32fconfigure stdout -translation binary 33base64 -attach stdout -mode decode 34transform -attach stdout -command join 35 36fcopy stdin stdout 37close stdout 38 39# close is *required* to flush out the internal buffers. 40# This is not done during a simple exit :-( 41 42exit 43