// ReadValue reads length bytes from offset in the TPM NVRAM space
422471
func (nv *NV) ReadValue(offset uint, length uint) ([]byte, error) {
	var cdata *C.BYTE
	defer C.Tspi_Context_FreeMemory(nv.context, cdata)
	err := tspiError(C.Tspi_NV_ReadValue(nv.handle, (C.UINT32)(offset), (*C.UINT32)(unsafe.Pointer(&length)), &cdata))
	if err != nil {
		return nil, err
	}
	data := C.GoBytes(unsafe.Pointer(cdata), C.int(length))
	return data, err
}
92931
func StringValue(i interface{}) string {
	var buf bytes.Buffer
	stringValue(reflect.ValueOf(i), 0, &buf)
	return buf.String()
}
683416
func (cbb *BytesBrokerWrapper) GetValue(key string) (data []byte, found bool, revision int64, err error) {
	data, found, revision, err = cbb.BytesBroker.GetValue(key)
	if err == nil {
		objData, err := cbb.decrypter.Decrypt(data, cbb.decryptFunc)
		if err != nil {
			return data, found, revision, err
		}
		outData, ok := objData.([]byte)
		if !ok {
			return data, found, revision, err
		}
		return outData, found, revision, err
	}
	return
}
664178
func readVariableValueLength(source []byte, offset ValueLength, reverse bool) ValueLength {
	length := ValueLength(0)
	p := uint(0)
	for {
		v := ValueLength(source[offset])
		length += (v & 0x7f) << p
		p += 7
		if reverse {
			offset--
		} else {
			offset++
		}
		if v&0x80 == 0 {
			break
		}
	}
	return length
}
720864
func (client *storageRESTClient) ReadFile(volume, path string, offset int64, buffer []byte, verifier *BitrotVerifier) (int64, error) {
	values := make(url.Values)
	values.Set(storageRESTVolume, volume)
	values.Set(storageRESTFilePath, path)
	values.Set(storageRESTOffset, strconv.Itoa(int(offset)))
	values.Set(storageRESTLength, strconv.Itoa(len(buffer)))
	if verifier != nil {
		values.Set(storageRESTBitrotAlgo, verifier.algorithm.String())
		values.Set(storageRESTBitrotHash, hex.EncodeToString(verifier.sum))
	} else {
		values.Set(storageRESTBitrotAlgo, "")
		values.Set(storageRESTBitrotHash, "")
	}
	respBody, err := client.call(storageRESTMethodReadFile, values, nil, -1)
	if err != nil {
		return 0, err
	}
	defer http.DrainBody(respBody)
	n, err := io.ReadFull(respBody, buffer)
	return int64(n), err
}
1357911
func (w *Writer) WriteValue(v reflect.Value) {
	valueEncoders[v.Kind()](w, v)
}
782885
func (t Times) GetValue(index int) float64 {
	return util.Time.ToFloat64(t[index])
}
403504
func writeValue(w io.Writer, v interface{}) (err error) {
	switch v := v.(type) {
	case nil:
		_, err = w.Write([]byte("null"))
	case string:
		if strings.IndexFunc(v, needsQuotedValueRune) != -1 {
			var b []byte
			b, err = json.Marshal(v)
			if err == nil {
				w.Write(b)
			}
		} else {
			_, err = w.Write([]byte(v))
		}
	case error:
		s := v.Error()
		err = writeValue(w, s)
	default:
		s := fmt.Sprint(v)
		err = writeValue(w, s)
	}
	return
}
193502
func MSPValue(mspDef *mspprotos.MSPConfig) *StandardConfigValue {
	return &StandardConfigValue{
		key:   MSPKey,
		value: mspDef,
	}
}
651699
func (s *FileSystemSize) SetValue(v int64) *FileSystemSize {
	s.Value = &v
	return s
}
322822
func encodeValue(v *statedb.VersionedValue) ([]byte, error) {
	vvMsg := &msgs.VersionedValueProto{
		VersionBytes: v.Version.ToBytes(),
		Value:        v.Value,
		Metadata:     v.Metadata,
	}
	encodedValue, err := proto.Marshal(vvMsg)
	if err != nil {
		return nil, err
	}
	encodedValue = append([]byte{0}, encodedValue...)
	return encodedValue, nil
}
1238764
func (kv *KeyValBytes) GetValue(message proto.Message) error {
	return json.Unmarshal(kv.value, message)
}
546204
func (bw *Writer) WriteValue(v wire.Value) error {
	switch v.Type() {
	case wire.TBool:
		if v.GetBool() {
			return bw.writeByte(1)
		}
		return bw.writeByte(0)

	case wire.TI8:
		return bw.writeByte(byte(v.GetI8()))

	case wire.TDouble:
		value := math.Float64bits(v.GetDouble())
		return bw.writeInt64(int64(value))

	case wire.TI16:
		return bw.writeInt16(v.GetI16())

	case wire.TI32:
		return bw.writeInt32(v.GetI32())

	case wire.TI64:
		return bw.writeInt64(v.GetI64())

	case wire.TBinary:
		b := v.GetBinary()
		if err := bw.writeInt32(int32(len(b))); err != nil {
			return err
		}
		return bw.write(b)

	case wire.TStruct:
		return bw.writeStruct(v.GetStruct())

	case wire.TMap:
		return bw.writeMap(v.GetMap())

	case wire.TSet:
		return bw.writeSet(v.GetSet())

	case wire.TList:
		return bw.writeList(v.GetList())

	default:
		return fmt.Errorf("unknown ttype %v", v.Type())
	}
}
264745
func (d *Decoder) parseValue(v reflect.Value) (bool, error) {
	// we support one level of indirection at the moment
	if v.Kind() == reflect.Ptr {
		// if the pointer is nil, allocate a new element of the type it
		// points to
		if v.IsNil() {
			v.Set(reflect.New(v.Type().Elem()))
		}
		v = v.Elem()
	}

	if d.parseUnmarshaler(v) {
		return true, nil
	}

	// common case: interface{}
	if v.Kind() == reflect.Interface && v.NumMethod() == 0 {
		iface, _ := d.parseValueInterface()
		v.Set(reflect.ValueOf(iface))
		return true, nil
	}

	b, err := d.r.ReadByte()
	if err != nil {
		panic(err)
	}
	d.Offset++

	switch b {
	case 'e':
		return false, nil
	case 'd':
		return true, d.parseDict(v)
	case 'l':
		return true, d.parseList(v)
	case 'i':
		d.parseInt(v)
		return true, nil
	default:
		if b >= '0' && b <= '9' {
			// It's a string.
			d.buf.Reset()
			// Write the first digit of the length to the buffer.
			d.buf.WriteByte(b)
			return true, d.parseString(v)
		}

		d.raiseUnknownValueType(b, d.Offset-1)
	}
	panic("unreachable")
}
1160745
func (d *Descriptor) SetValue(b []byte) {
	if d.ReadHandler != nil {
		panic("descriptor has been configured with a read handler")
	}
	d.Property |= CharRead
	d.Value = make([]byte, len(b))
	copy(d.Value, b)
}
31862
func ReadValues(data []byte) (vals Values, err error) {
	err = yaml.Unmarshal(data, &vals)
	if len(vals) == 0 {
		vals = Values{}
	}
	return
}
689828
func (c *Config) GetValue(section, name string) string {
	c.ReadList()
	conf := c.ReadList()
	for _, v := range conf {
		for key, value := range v {
			if key == section {
				return value[name]
			}
		}
	}
	return "no value"
}