// readPstring reads a pstring from an io.Reader
480309
func readPstring(r io.Reader) (*pstring, error) {
	var length int8
	e := binary.Read(r, byteOrder, &length)
	if e != nil {
		return nil, e
	}
	s := make([]byte, length)
	read, e := r.Read(s)
	if e != nil {
		return nil, e
	}
	if read != int(length) {
		return nil, fmt.Errorf("could not read %d bytes", length)
	}
	ps := pstring{
		length,
		bytes.NewBuffer(s).String(),
	}
	return &ps, nil
}
1321381
func (r *Reader) ReadRestString(encoding byte) (string, error) {
	b, err := r.ReadRest()
	if err != nil {
		return "", err
	}

	return Decoders[encoding].ConvertString(string(b))
}
1092320
func readLengthEncodedString(b []byte) ([]byte, bool, int, error) {
	// Get length
	num, isNull, n := readLengthEncodedInteger(b)
	if num < 1 {
		return b[n:n], isNull, n, nil
	}

	n += int(num)

	// Check data length
	if len(b) >= n {
		return b[n-int(num) : n], false, n, nil
	}
	return nil, false, n, io.EOF
}
435462
func (in *Input) ReadWord() (s string, err error) {
	in.mu.Lock()
	defer in.mu.Unlock()
	if in.eof {
		return "", io.EOF
	}
	if !in.inited {
		in.fill()
		in.inited = true
	}
LoopSkipWhiteAtBeginOfString:
	for isWhiteChar(in.buf[in.r]) {
		for ; in.r < in.w; in.r++ {
			if !isWhiteChar(in.buf[in.r]) {
				break LoopSkipWhiteAtBeginOfString
			}
		}
		if err = in.fill(); err != nil {
			if err == io.EOF {
				in.buf = nil
				in.rd = nil
				in.eof = true
			}
			return "", err
		}
	}
	offset := 0
	filled := false
	pos := in.r + offset
	for {
		for pos < in.w {
			if isWhiteChar(in.buf[pos]) {
				s := string(in.buf[in.r:pos])
				in.r = pos
				return s, nil
			}
			offset++
			pos = in.r + offset
		}
		if filled {
			if in.eof {
				s := string(in.buf[in.r:pos])
				in.r = pos
				in.buf = nil
				in.rd = nil
				return s, io.EOF
			}
			return "", errBufforFull
		}
		filled = true
		if err = in.fill(); err != nil {
			if err == io.EOF {
				in.eof = true
			} else {
				return "", err
			}
		}
		pos = in.r + offset
	}
}
1134175
func (kea *KamEvapi) readNetstring() ([]byte, error) {
	contentLenStr, err := kea.rcvBuffer.ReadString(':')
	if err != nil {
		return nil, err
	}
	cntLen, err := strconv.Atoi(contentLenStr[:len(contentLenStr)-1])
	if err != nil {
		return nil, err
	}
	bytesRead := make([]byte, cntLen)
	for i := 0; i < cntLen; i++ {
		byteRead, err := kea.rcvBuffer.ReadByte()
		if err != nil {
			return nil, err
		}
		bytesRead[i] = byteRead
	}
	if byteRead, err := kea.rcvBuffer.ReadByte(); err != nil { // Crosscheck that our received content ends in , which is standard for netstrings
		return nil, err
	} else if byteRead != ',' {
		return nil, fmt.Errorf("Crosschecking netstring failed, no comma in the end but: %s", string(byteRead))
	}
	return bytesRead, nil
}
754051
func (c *ConfigParser) ReadString(s string) (err error) {
	r := strings.NewReader(s)
	return c.Read(r)
}
102897
func stringStringMapParser(rd *proto.Reader, n int64) (interface{}, error) {
	m := make(map[string]string, n/2)
	for i := int64(0); i < n; i += 2 {
		key, err := rd.ReadString()
		if err != nil {
			return nil, err
		}

		value, err := rd.ReadString()
		if err != nil {
			return nil, err
		}

		m[key] = value
	}
	return m, nil
}
1053776
func ParseString(cfg API, input string) *Iterator {
	return ParseBytes(cfg, []byte(input))
}
445876
func (p Property) TypeString() string {
	switch p.Type.(type) {
	case string:
		return p.Type.(string)
	case Type:
		if p._type == nil {
			panic(fmt.Errorf("property '%v' has no parent type", p.Name))
		}
		return p._type.Name + p.Name
	default:
		return "string"
	}
}
362583
func (c *Conn) ReadString(delim byte) (string, error) {
	bytes, err := c.ReadBytes(delim)
	return string(bytes), err
}
798504
func readSystemProperty(key string) (string, error) {
	keyPath := strings.Replace(key, ".", "/", -1)
	value, err := ioutil.ReadFile(path.Join("/proc/sys", keyPath))
	if err != nil {
		return "", err
	}
	return strings.TrimSpace(string(value)), nil
}
640095
func (r *Reader) ReadNullTermString(encoding byte) (string, error) {
	atIndex, afterIndex := nullIndex(r.data[r.index:], encoding)
	b, err := r.ReadNumBytes(afterIndex)
	if err != nil {
		return "", err
	}

	return Decoders[encoding].ConvertString(string(b[:atIndex]))
}
1339021
func (f *Parser) ParseString(feed string) (*Feed, error) {
	return f.Parse(strings.NewReader(feed))
}
775404
func readLPString(buf []byte, t Type) (string, int, error) {
	if len(buf) < 2 {
		return "", 0, makeError(t, "insufficient buffer size, expected 2, got %d", len(buf))
	}

	n, total := 0, 0

	n = int(binary.BigEndian.Uint16(buf))
	total += 2
	total += n

	if len(buf) < total {
		return "", total, makeError(t, "insufficient buffer size, expected %d, got %d", total, len(buf))
	}

	return string(buf[2:total]), total, nil
}
972768
func (p *parser) parseString() (result string, err error) {
	i := p.i
	if len(p.s) < i+2 {
		return "", errors.New("expected string, found EOF instead")
	}

	quote := p.s[i]
	i++

loop:
	for i < len(p.s) {
		switch p.s[i] {
		case '\\':
			if len(p.s) > i+1 {
				switch c := p.s[i+1]; c {
				case '\r':
					if len(p.s) > i+2 && p.s[i+2] == '\n' {
						i += 3
						continue loop
					}
					fallthrough
				case '\n', '\f':
					i += 2
					continue loop
				}
			}
			p.i = i
			val, err := p.parseEscape()
			if err != nil {
				return "", err
			}
			i = p.i
			result += val
		case quote:
			break loop
		case '\r', '\n', '\f':
			return "", errors.New("unexpected end of line in string")
		default:
			start := i
			for i < len(p.s) {
				if c := p.s[i]; c == quote || c == '\\' || c == '\r' || c == '\n' || c == '\f' {
					break
				}
				i++
			}
			result += p.s[start:i]
		}
	}

	if i >= len(p.s) {
		return "", errors.New("EOF in string")
	}

	// Consume the final quote.
	i++

	p.i = i
	return result, nil
}
58085
func (sc *StringConstraint) RegexpString(pat string) *StringConstraint {
	return sc.Regexp(regexp.MustCompile(pat))
}
647941
func ReadFromString(configString string) (*FileConfig, error) {
	data, err := base64.StdEncoding.DecodeString(configString)
	if err != nil {
		return nil, trace.BadParameter(
			"confiugraion should be base64 encoded: %v", err)
	}
	return ReadConfig(bytes.NewBuffer(data))
}