Пример #1
0
func iovecRead(r io.Reader, count uint64, bits int, endian binary.ByteOrder) []Iovec64 {
	ret := make([]Iovec64, 0, count)
	for i := uint64(0); i < count; i++ {
		if bits == 64 {
			var iovec Iovec64
			struc.UnpackWithOrder(r, &iovec, endian)
			ret = append(ret, iovec)
		} else {
			var iv32 Iovec32
			struc.UnpackWithOrder(r, &iv32, endian)
			ret = append(ret, Iovec64{uint64(iv32.Base), uint64(iv32.Len)})
		}
	}
	return ret
}
Пример #2
0
func iovecIter(r io.Reader, count uint64, bits int, endian binary.ByteOrder) <-chan Iovec64 {
	ret := make(chan Iovec64)
	go func() {
		for i := uint64(0); i < count; i++ {
			if bits == 64 {
				var iovec Iovec64
				struc.UnpackWithOrder(r, &iovec, endian)
				ret <- iovec
			} else {
				var iv32 Iovec32
				struc.UnpackWithOrder(r, &iv32, endian)
				ret <- Iovec64{uint64(iv32.Base), uint64(iv32.Len)}
			}
		}
		close(ret)
	}()
	return ret
}
Пример #3
0
func (s *StrucStream) Unpack(i interface{}) error {
	return struc.UnpackWithOrder(s.Stream, i, s.Order)
}