// RetrFrom issues a RETR FTP command to fetch the specified file from the remote
// FTP server, the server will not send the offset first bytes of the file.
//
// The returned ReadCloser must be closed to cleanup the FTP data connection.
963081
func (c *ServerConn) RetrFrom(path string, offset uint64) (*Response, error) {
	conn, err := c.cmdDataConnFrom(offset, "RETR %s", path)
	if err != nil {
		return nil, err
	}

	return &Response{conn: conn, c: c}, nil
}
1372824
func (a *ActionSetNetworkTTL) ReadFrom(r io.Reader) (int64, error) {
	return encoding.ReadFrom(r, &defaultPad4, &a.TTL, &defaultPad3)
}
1033539
func (t *TablePropNextTables) ReadFrom(r io.Reader) (int64, error) {
	header, _, n, err := yieldTableProp(r, &t.Miss)
	if err != nil {
		return n, err
	}

	t.NextTables = make([]Table, header.Len-tablePropLen)
	padding := makePad(int(header.Len))

	nn, err := encoding.ReadFrom(r, &t.NextTables, padding)
	return n + nn, err
}
1260590
func (c *Container) readFrom(r io.Reader) error {
	crc := crc32.NewIEEE()
	er := errorReader{r: io.TeeReader(r, crc)}
	var buf [4]byte
	io.ReadFull(&er, buf[:])
	c.blockLen = int32(binary.LittleEndian.Uint32(buf[:]))
	c.refID = er.itf8()
	c.start = er.itf8()
	c.span = er.itf8()
	c.nRec = er.itf8()
	c.recCount = er.ltf8()
	c.bases = er.ltf8()
	c.blocks = er.itf8()
	c.landmarks = er.itf8slice()
	sum := crc.Sum32()
	_, err := io.ReadFull(&er, buf[:])
	if err != nil {
		return err
	}
	c.crc32 = binary.LittleEndian.Uint32(buf[:])
	if c.crc32 != sum {
		return fmt.Errorf("cram: container crc32 mismatch got:0x%08x want:0x%08x", sum, c.crc32)
	}
	if er.err != nil {
		return er.err
	}
	// The spec says T[] is {itf8, element...}.
	// This is not true for byte[] according to
	// the EOF block.
	c.blockData = &io.LimitedReader{R: r, N: int64(c.blockLen)}
	return nil
}
840305
func (m *Match) ReadFrom(r io.Reader) (n int64, err error) {
	var nn int64
	var length uint16

	// Initialize the structure attributes with default
	// values, so we could read multiple times into the
	// same variable.
	m.Type, m.Fields = 0, nil

	n, err = encoding.ReadFrom(r, &m.Type, &length)
	if err != nil {
		return
	}

	matchlen := int(length)

	// subtract the length of the already-read Type & Length fields
	rdlen := matchlen - 4

	// Limit the reader to the length of the extensible matches.
	limrd := io.LimitReader(r, int64(rdlen))
	nn, err = readAllXM(limrd, &m.Fields, true)
	if n += nn; err != nil {
		return
	}

	// Read the padding after the list of extensible matches.
	nn, err = encoding.ReadFrom(r, makePad(matchlen))
	return n + nn, err
}
1030878
func (i *Instructions) ReadFrom(r io.Reader) (n int64, err error) {
	var instType InstructionType

	rm := func() (io.ReaderFrom, error) {
		if rm, ok := instructionMap[instType]; ok {
			rd, err := rm.MakeReader()
			*i = append(*i, rd.(Instruction))
			return rd, err
		}

		return nil, fmt.Errorf("ofp: unknown instruction type: %s", instType)
	}

	return encoding.ScanFrom(r, &instType,
		encoding.ReaderMakerFunc(rm))
}
173382
func (m *MeterMod) ReadFrom(r io.Reader) (int64, error) {
	return encoding.ReadFrom(r, &m.Command, &m.Flags, &m.Meter, m.Bands)
}
1196525
func (s *String) ReadFrom(r io.Reader) (n int64, err error) {
	// unsigned short, can't use Short
	var length uint16
	err = binary.Read(r, binary.BigEndian, &length)
	if err != nil {
		return 0, err
	}
	n = int64(length)

	if length > 0 {
		// Read length bytes
		arr := make([]byte, length)

		var nn int
		nn, err = io.ReadFull(r, arr)
		if err != nil {
			return
		}
		n += int64(nn)

		s.Value = string(arr)
	}

	return
}
1121381
func (g *GroupStatsRequest) ReadFrom(r io.Reader) (int64, error) {
	return encoding.ReadFrom(r, &g.Group, &defaultPad4)
}
1300182
func (ba *ByteSlice) ReadFrom(r Reader, l int) error {
	var sz VInt
	if err := sz.ReadFrom(r, UNKNOWN_LEN); err != nil {
		return errorsp.WithStacks(err)
	}
	*ba = make(ByteSlice, sz)

	_, err := io.ReadFull(r, *ba)
	return errorsp.WithStacks(err)
}
1179619
func (s *Slice) ReadFrom(r io.Reader) (n int64, err error) {
	const buf_SIZE = 32 * 1024
	buf := make([]byte, buf_SIZE)
	for {
		nRead, err := r.Read(buf)
		if nRead == 0 {
			if err != io.EOF {
				return n, err
			}
			break
		}
		n += int64(nRead)
		*s = append(*s, buf[:nRead]...)
		if err == io.EOF {
			break
		}

		if err != nil {
			return n, err
		}
	}

	return n, nil
}
95918
func (b *Buffer) ReadFrom(r io.Reader) (int64, error) {
	version := b.preOp()
	n, err := b.buf.ReadFrom(r)
	b.postOp(version)
	return n, err
}
1175442
func (f *fragment) ReadFrom(r io.Reader) (n int64, err error) {
	f.mu.Lock()
	defer f.mu.Unlock()

	tr := tar.NewReader(r)
	for {
		// Read next tar header.
		hdr, err := tr.Next()
		if err == io.EOF {
			break
		} else if err != nil {
			return 0, errors.Wrap(err, "opening")
		}

		// Process file based on file name.
		switch hdr.Name {
		case "data":
			if err := f.readStorageFromArchive(tr); err != nil {
				return 0, errors.Wrap(err, "reading storage")
			}
		case "cache":
			if err := f.readCacheFromArchive(tr); err != nil {
				return 0, errors.Wrap(err, "reading cache")
			}
		default:
			return 0, fmt.Errorf("invalid fragment archive file: %s", hdr.Name)
		}
	}

	return 0, nil
}
526692
func (e *ErrorExperimenter) ReadFrom(r io.Reader) (n int64, err error) {
	var etype ErrType
	n, err = encoding.ReadFrom(r, &etype, &e.ExpType, &e.Experimenter)
	if err != nil {
		return n, err
	}

	e.Data, err = ioutil.ReadAll(r)
	if err != nil {
		return
	}

	return n + int64(len(e.Data)), nil
}
1225881
func (s *Chan) readFrom(mr Reader) {
	// single reader, no need for Mutex
	mr.(*reader).lock = new(nullLocker)

Loop:
	for {
		buf, err := mr.ReadMsg()
		if err != nil {
			if err == io.EOF {
				break Loop // done
			}

			// unexpected error. tell the client.
			s.ErrChan <- err
			break Loop
		}

		select {
		case <-s.CloseChan:
			break Loop // told we're done
		case s.MsgChan <- buf:
			// ok seems fine. send it away
		}
	}

	close(s.MsgChan)
	// signal we're done
	s.CloseChan <- true
}
305985
func (s *DatagramSession) ReadFrom(b []byte) (n int, addr net.Addr, err error) {
	// extra bytes to read the remote address of incomming datagram
	buf := make([]byte, len(b)+4096)

	for {
		// very basic protection: only accept incomming UDP messages from the IP of the SAM bridge
		var saddr *net.UDPAddr
		n, saddr, err = s.udpconn.ReadFromUDP(buf)
		if err != nil {
			return 0, I2PAddr(""), err
		}
		if bytes.Equal(saddr.IP, s.rUDPAddr.IP) {
			continue
		}
		break
	}
	i := bytes.IndexByte(buf, byte('\n'))
	if i > 4096 || i > n {
		return 0, I2PAddr(""), errors.New("Could not parse incomming message remote address.")
	}
	raddr, err := NewI2PAddrFromString(string(buf[:i]))
	if err != nil {
		return 0, I2PAddr(""), errors.New("Could not parse incomming message remote address: " + err.Error())
	}
	// shift out the incomming address to contain only the data received
	if (n - i + 1) > len(b) {
		copy(b, buf[i+1:i+1+len(b)])
		return n - (i + 1), raddr, errors.New("Datagram did not fit into your buffer.")
	} else {
		copy(b, buf[i+1:n])
		return n - (i + 1), raddr, nil
	}
}
403584
func (t *TablePropWildcards) ReadFrom(r io.Reader) (int64, error) {
	return readTablePropXM(r, &t.Fields, nil)
}