2011-06-17 15:44:59 +00:00
|
|
|
// This work is subject to the CC0 1.0 Universal (CC0 1.0) Public Domain Dedication
|
|
|
|
// license. Its contents can be found at:
|
|
|
|
// http://creativecommons.org/publicdomain/zero/1.0/
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"io"
|
|
|
|
)
|
|
|
|
|
2012-06-22 12:12:15 +00:00
|
|
|
var newline = []byte{'\n'}
|
2012-06-07 21:34:34 +00:00
|
|
|
|
2012-06-22 12:12:15 +00:00
|
|
|
type ByteWriter struct {
|
2011-06-17 15:44:59 +00:00
|
|
|
io.Writer
|
|
|
|
c int
|
|
|
|
}
|
|
|
|
|
2012-06-22 12:12:15 +00:00
|
|
|
func (w *ByteWriter) Write(p []byte) (n int, err error) {
|
2011-06-17 15:44:59 +00:00
|
|
|
if len(p) == 0 {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
for n = range p {
|
2012-06-22 12:12:15 +00:00
|
|
|
if w.c%12 == 0 {
|
|
|
|
w.Writer.Write(newline)
|
2011-12-07 12:49:06 +00:00
|
|
|
w.c = 0
|
2011-06-17 15:44:59 +00:00
|
|
|
}
|
|
|
|
|
2012-06-22 12:12:15 +00:00
|
|
|
fmt.Fprintf(w.Writer, "0x%02x,", p[n])
|
2011-12-07 12:49:06 +00:00
|
|
|
w.c++
|
2011-06-17 15:44:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|