2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2020-02-23 05:21:06 +08:00
|
|
|
* Copyright (C) 2017-2020 Intel Corporation
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
2018-09-18 15:11:08 +08:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/os_interface/linux/debug_env_reader.h"
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
namespace NEO {
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-09-02 18:04:22 +08:00
|
|
|
SettingsReader *SettingsReader::createOsReader(bool userScope, const std::string ®Key) {
|
2017-12-21 07:45:38 +08:00
|
|
|
return new EnvironmentVariableReader;
|
|
|
|
}
|
|
|
|
|
2018-10-10 22:02:19 +08:00
|
|
|
const char *EnvironmentVariableReader::appSpecificLocation(const std::string &name) {
|
|
|
|
return name.c_str();
|
|
|
|
}
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
bool EnvironmentVariableReader::getSetting(const char *settingName, bool defaultValue) {
|
|
|
|
return getSetting(settingName, static_cast<int32_t>(defaultValue)) ? true : false;
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t EnvironmentVariableReader::getSetting(const char *settingName, int32_t defaultValue) {
|
|
|
|
int32_t value = defaultValue;
|
|
|
|
char *envValue;
|
|
|
|
|
|
|
|
envValue = getenv(settingName);
|
|
|
|
if (envValue) {
|
|
|
|
value = atoi(envValue);
|
|
|
|
}
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string EnvironmentVariableReader::getSetting(const char *settingName, const std::string &value) {
|
|
|
|
char *envValue;
|
|
|
|
std::string keyValue;
|
|
|
|
keyValue.assign(value);
|
|
|
|
|
|
|
|
envValue = getenv(settingName);
|
|
|
|
if (envValue) {
|
|
|
|
keyValue.assign(envValue);
|
|
|
|
}
|
|
|
|
return keyValue;
|
|
|
|
}
|
2019-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|