// readFrom reads the InnerHeader from an io.Reader
readFrom reads the InnerHeader from an io.Reader
// readFrom reads the InnerHeader from an io . Reader
func (ih *InnerHeader) readFrom(r io.Reader) error {
	binaryCount := 0 
ForLoop:
	for {
		var headerType byte
		var length int32
		var data []byte
		if err := binary.Read(r, binary.LittleEndian, &headerType); err != nil {
			return err
		}
		if err := binary.Read(r, binary.LittleEndian, &length); err != nil {
			return err
		}
		data = make([]byte, length)
		if err := binary.Read(r, binary.LittleEndian, &data); err != nil {
			return err
		}
		switch headerType {
		case InnerHeaderTerminator:
			break ForLoop
		case InnerHeaderIRSID:
			ih.InnerRandomStreamID = binary.LittleEndian.Uint32(data)
		case InnerHeaderIRSKey:
			ih.InnerRandomStreamKey = data
		case InnerHeaderBinary:
			var protection byte
			reader := bytes.NewReader(data)
			binary.Read(reader, binary.LittleEndian, &protection) 
			content, _ := ioutil.ReadAll(reader)                  
			ih.Binaries = append(ih.Binaries, Binary{
				ID:               binaryCount,
				MemoryProtection: protection,
				Content:          content,
			})
			binaryCount = binaryCount + 1
		default:
			return ErrUnknownInnerHeaderID(headerType)
		}
	}
	return nil
}
func ( ih * InnerHeader ) readFrom ( r io . Reader ) error { binaryCount := 0 ForLoop : for { var headerType byte var length int32 var data [ ] byte if err := binary . Read ( r , binary . LittleEndian , & headerType ) ; err != nil { return err } if err := binary . Read ( r , binary . LittleEndian , & length ) ; err != nil { return err } data = make ( [ ] byte , length ) if err := binary . Read ( r , binary . LittleEndian , & data ) ; err != nil { return err } switch headerType { case InnerHeaderTerminator : break ForLoop case InnerHeaderIRSID : ih . InnerRandomStreamID = binary . LittleEndian . Uint32 ( data ) case InnerHeaderIRSKey : ih . InnerRandomStreamKey = data case InnerHeaderBinary : var protection byte reader := bytes . NewReader ( data ) binary . Read ( reader , binary . LittleEndian , & protection ) content , _ := ioutil . ReadAll ( reader ) ih . Binaries = append ( ih . Binaries , Binary { ID : binaryCount , MemoryProtection : protection , Content : content , } ) binaryCount = binaryCount + 1 default : return ErrUnknownInnerHeaderID ( headerType ) } } return nil }
readFrom reads the InnerHeader from an io.Reader
readFrom reads the InnerHeader from an io . Reader
// Var used to count and index every binary // End of inner header // Found InnerRandomStream ID // Found InnerRandomStream Key // Found a binary // Read memory protection flag // Read content