File: mmdecode

package info (click to toggle)
tcltrf 2.1.4-dfsg3-1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 9,628 kB
  • sloc: ansic: 73,134; sh: 3,155; tcl: 1,343; makefile: 176; exp: 22
file content (42 lines) | stat: -rwxr-xr-x 738 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/local/bin/tclsh
# demonstration application, decodes the incoming byte stream from base64
package require Trf


# line buffer for parcel below.

proc join {cmd buffer} {
    #puts stderr "$cmd [string length buffer] $buffer"

    switch -- $cmd {
	create/write {
	    set line ""
	}
	delete/write {
	    set line ""
	}
	write {
	    regsub -all "\[\n\r\]" $buffer {} buffer
	    return $buffer
	}
	flush/write {
	    return ""
	}
	clear/write {
	    set line ""
	}
    }
}


fconfigure stdout -translation binary
base64    -attach stdout -mode decode
transform -attach stdout -command join

fcopy stdin stdout
close stdout

# close is *required* to flush out the internal buffers.
# This is not done during a simple exit :-(

exit