blob: 5dbc4f7501d0e7a85a9ad5f733f0a082167706a4 [file] [log] [blame]
// Copyright 2021 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.
#include "rmad/utils/crossystem_utils_impl.h"
#include <string>
#include <vboot/crossystem.h>
namespace rmad {
bool CrosSystemUtilsImpl::SetInt(const std::string& key, int value) {
return ::VbSetSystemPropertyInt(key.c_str(), value) == 0;
}
bool CrosSystemUtilsImpl::GetInt(const std::string& key, int* value) const {
int result = ::VbGetSystemPropertyInt(key.c_str());
if (result == -1) {
return false;
}
*value = result;
return true;
}
bool CrosSystemUtilsImpl::SetString(const std::string& key,
const std::string& value) {
return ::VbSetSystemPropertyString(key.c_str(), value.c_str()) == 0;
}
bool CrosSystemUtilsImpl::GetString(const std::string& key,
std::string* value) const {
char buf[VB_MAX_STRING_PROPERTY];
if (::VbGetSystemPropertyString(key.c_str(), buf, sizeof(buf)) == nullptr) {
return false;
}
*value = std::string(buf);
return true;
}
} // namespace rmad