/tbcload

golang encode/decode for tbcload tbc file format

Primary LanguageGoMIT LicenseMIT

TBC (Tcl ByteCode) decoder

The .tbc file is generated by Tcl Pro. This repo try to add comments on .tbc file and disassemble .tbc file for human reading.
test .tbc file can be found here

Install

go get github.com/corbamico/tbcload/tbcload

Usage

Usage:
  tbcload [command]

Available Commands:
  decode      encode a string into ascii85(re-map), which tbc file used
  decompile   disassemble a .tbc file, which can be on disk/url
  encode      A brief description of your command

Example:
    tbcload encode 123456
    tbcload encode  --hex "00010203"
    tbcload decompile test.tbc  #disassemble a file named test.tbc
    tbcload decompile --detail test.tbc
    tbcload decompile http://127.0.0.1/test.tcl #disassemble from a url

    example url, can be found as https://github.com/ActiveState/teapot/raw/master/lib/tbcload/tests/tbc10/proc.tbc

Code Example

func ExampleEncode() {
    src := []byte("proc")
    dst := make([]byte, 150)
    length := Encode(dst, src)
    fmt.Printf("%s", dst[:length])
    // Output:
    // ,CHr@
}

func ExampleDecode() {
    r, _ := os.Open(uri)
    p := tbcload.NewParser(r, os.Stdout)
    p.Parse()
}

Reference

License

  • MIT

  • ActiveState/teapot/cmpWrite.c BSD-3 license Copyright (c) 2017,ActiveState Software All rights reserved.