blob: 2ace3a1b059ed078b6fc1d1a4d50727f4fa6f168 [file] [log] [blame]
// Copyright 2016 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef LOGIN_MANAGER_CROSSYSTEM_H_
#define LOGIN_MANAGER_CROSSYSTEM_H_
#include <cstddef>
// Light-weight interface to crossystem keeping the original C semantics to make
// it an easy drop-in replacement. (C++ semantics may be added in the future.)
class Crossystem {
public:
// Recommended size for string property buffers used with
// VbGetSystemPropertyString().
static const std::size_t kVbMaxStringProperty = 8192;
// Reads a system property integer.
//
// Returns the property value, or -1 if error.
virtual int VbGetSystemPropertyInt(const char* name) = 0;
// Sets a system property integer.
//
// Returns 0 if success, -1 if error.
virtual int VbSetSystemPropertyInt(const char* name, int value) = 0;
// Reads a system property string into a destination buffer of the specified
// size. Returned string will be null-terminated. If the buffer is too
// small, the returned string will be truncated.
//
// The caller can expect an un-truncated value if the size provided is at
// least kVbMaxStringProperty.
//
// Returns the passed buffer, or nullptr if error.
virtual const char* VbGetSystemPropertyString(const char* name,
char* dest,
std::size_t size) = 0;
// Sets a system property string.
//
// The maximum length of the value accepted depends on the specific
// property, not on kVbMaxStringProperty.
//
// Returns 0 if success, -1 if error.
virtual int VbSetSystemPropertyString(const char* name,
const char* value) = 0;
};
#endif // LOGIN_MANAGER_CROSSYSTEM_H_