Documentation
¶
Overview ¶
The binp package provides parsing and printing of binary values. It is particularly suitable for parsing irregular data structures provided by e.g. kernel.
Index ¶
- type Len
- type Native
- type Parser
- func (p *Parser) Align(n int) *Parser
- func (p *Parser) AtEnd() bool
- func (p *Parser) B8(d *byte) *Parser
- func (p *Parser) B8String(d *string) *Parser
- func (p *Parser) B16(d *uint16) *Parser
- func (p *Parser) B16String(d *string) *Parser
- func (p *Parser) B32(d *uint32) *Parser
- func (p *Parser) B32Bytes(d *[]byte) *Parser
- func (p *Parser) B32String(d *string) *Parser
- func (p *Parser) B64(d *uint64) *Parser
- func (p *Parser) Byte(d *byte) *Parser
- func (p *Parser) End() error
- func (p *Parser) N8(d *byte) *Parser
- func (p *Parser) N8String(d *string) *Parser
- func (p *Parser) N16(d *uint16) *Parser
- func (p *Parser) N16String(d *string) *Parser
- func (p *Parser) N32(d *uint32) *Parser
- func (p *Parser) N32Bytes(d *[]byte) *Parser
- func (p *Parser) N32String(d *string) *Parser
- func (p *Parser) N64(d *uint64) *Parser
- func (p *Parser) NBytes(n int, d *[]byte) *Parser
- func (p *Parser) NBytesCopy(n int, d []byte) *Parser
- func (p *Parser) NBytesPeek(n int, d *[]byte) *Parser
- func (p *Parser) NString(n int, d *string) *Parser
- func (p *Parser) PeekRest(d *[]byte) *Parser
- func (p *Parser) Skip(n int) *Parser
- func (p *Parser) String0(d *string) *Parser
- type Printer
- func (p *Printer) Align(n int) *Printer
- func (p *Printer) B8(d byte) *Printer
- func (p *Printer) B8String(d string) *Printer
- func (p *Printer) B16(d uint16) *Printer
- func (p *Printer) B16String(d string) *Printer
- func (p *Printer) B32(d uint32) *Printer
- func (p *Printer) B32Bytes(d []byte) *Printer
- func (p *Printer) B32String(d string) *Printer
- func (p *Printer) B64(d uint64) *Printer
- func (p *Printer) Byte(d byte) *Printer
- func (p *Printer) Bytes(d []byte) *Printer
- func (p *Printer) LenB16(l *Len) *Printer
- func (p *Printer) LenB32(l *Len) *Printer
- func (p *Printer) LenDone(l *Len) *Printer
- func (p *Printer) LenN16(l *Len) *Printer
- func (p *Printer) LenN32(l *Len) *Printer
- func (p *Printer) LenStart(l *Len) *Printer
- func (p *Printer) LensDone(ls ...*Len) *Printer
- func (p *Printer) N8(d byte) *Printer
- func (p *Printer) N8String(d string) *Printer
- func (p *Printer) N16(d uint16) *Printer
- func (p *Printer) N16String(d string) *Printer
- func (p *Printer) N32(d uint32) *Printer
- func (p *Printer) N32Bytes(d []byte) *Printer
- func (p *Printer) N32String(d string) *Printer
- func (p *Printer) N64(d uint64) *Printer
- func (p *Printer) Out() []byte
- func (p *Printer) Skip(n int) *Printer
- func (p *Printer) String(d string) *Printer
- func (p *Printer) String0(d string) *Printer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Len ¶
type Len struct {
// contains filtered or unexported fields
}
Type for handling length fields.
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser type. Don't touch the internals.
func (*Parser) B16String ¶
Parse a string with a 2 byte bigendian length prefix to a string pointer.
func (*Parser) B32String ¶
Parse a string with a 4 byte bigendian length prefix to a string pointer.
func (*Parser) N16String ¶
Parse a string with a 2 byte native endian length prefix to a string pointer.
func (*Parser) N32Bytes ¶
Parse a string with a 4 byte native endian length prefix to a []byte pointer.
func (*Parser) N32String ¶
Parse a string with a 4 byte native endian length prefix to a string pointer.
func (*Parser) NBytes ¶
Parse n bytes from the buffer and copy to a []byte pointer that is allocated.
func (*Parser) NBytesCopy ¶
Parse n bytes from the buffer and copy to the supplied []byte.
func (*Parser) NBytesPeek ¶
Parse n bytes from the buffer to a []byte pointer that refers to the parser internal buffer.
type Printer ¶
type Printer struct {
// contains filtered or unexported fields
}
Printer type. Don't touch the internals.
func (*Printer) B8String ¶
Output a string with a 1 byte bigendian length prefix and no trailing null.
func (*Printer) B16String ¶
Output a string with a 2 byte bigendian length prefix and no trailing null.
func (*Printer) B32String ¶
Output a string with a 4 byte bigendian length prefix and no trailing null.
func (*Printer) LenB16 ¶
Add a 16 bit field at the current location that will be filled with the length.
func (*Printer) LenB32 ¶
Add a 32 bit field at the current location that will be filled with the length.
func (*Printer) LenN16 ¶
Add a 16 bit field at the current location that will be filled with the length.
func (*Printer) LenN32 ¶
Add a 32 bit field at the current location that will be filled with the length.
func (*Printer) N8String ¶
Output a string with a 1 byte native endian length prefix and no trailing null.
func (*Printer) N16String ¶
Output a string with a 2 byte native endian length prefix and no trailing null.
func (*Printer) N32Bytes ¶
Output bytes with a 4 byte native endian length prefix and no trailing null.
func (*Printer) N32String ¶
Output a string with a 4 byte native endian length prefix and no trailing null.