File tree 3 files changed +499
-1
lines changed
3 files changed +499
-1
lines changed Original file line number Diff line number Diff line change
1
+ package main
2
+
3
+ import (
4
+ "fmt"
5
+ "io"
6
+ "log"
7
+ "os"
8
+
9
+ tcobs "github.com/rokath/tcobs/Cv2"
10
+ "github.com/spf13/afero"
11
+ )
12
+
13
+ var (
14
+ // do not initialize, goreleaser will handle that
15
+ version string
16
+
17
+ // do not initialize, goreleaser will handle that
18
+ commit string
19
+
20
+ // do not initialize, goreleaser will handle that
21
+ date string
22
+ )
23
+
24
+ // main is the entry point.
25
+ func main () {
26
+ fSys := & afero.Afero {Fs : afero .NewOsFs ()} // os.DirFS("")
27
+ doit (os .Stdout , fSys )
28
+ }
29
+
30
+ func doit (w io.Writer , fSys * afero.Afero ) {
31
+
32
+ if len (os .Args ) != 1 {
33
+ fmt .Fprintln (w , version , commit , date )
34
+ fmt .Fprintln (w , "Feed with a space separated byte sequence to convert it in a TCOBSv1 sequence." )
35
+ fmt .Fprintln (w , "Example: `echo 0xaa 123 0b1010 44 44 44 | TCOBSv1Encode` will return `170 123 10 44 132`" )
36
+ return
37
+ }
38
+
39
+ var i []byte
40
+ o := make ([]byte , 16 * 1024 )
41
+ var pos int
42
+ for {
43
+ var n byte
44
+ _ , err := fmt .Scan (& n )
45
+ if err == io .EOF {
46
+ if len (i )+ 31 / len (i ) > len (o ) {
47
+ log .Fatal ("len of internal buffer too small" )
48
+ }
49
+ count := tcobs .CEncode (o , i )
50
+ o = o [:count ]
51
+ for _ , b := range o {
52
+ fmt .Fprintf (w , "%d " , b )
53
+ }
54
+ return
55
+ }
56
+ if err != nil {
57
+ log .Fatal (err , " at position " , pos )
58
+ }
59
+ i = append (i , n )
60
+ pos ++
61
+ }
62
+ }
Original file line number Diff line number Diff line change @@ -3,12 +3,14 @@ module github.com/rokath/tcobs
3
3
go 1.19
4
4
5
5
require (
6
+ github.com/spf13/afero v1.9.5
6
7
github.com/stretchr/testify v1.8.1
7
8
github.com/tj/assert v0.0.3
8
9
)
9
10
10
11
require (
11
12
github.com/davecgh/go-spew v1.1.1 // indirect
12
13
github.com/pmezard/go-difflib v1.0.0 // indirect
14
+ golang.org/x/text v0.3.7 // indirect
13
15
gopkg.in/yaml.v3 v3.0.1 // indirect
14
16
)
You can’t perform that action at this time.
0 commit comments