blob: 8d883eb14d9b5d55aee2ce44fae8f3351d690d51 [file] [log] [blame]
#ifndef UTILS_PROPERTIES_H_
#define UTILS_PROPERTIES_H_
#ifdef ANDROID
#include <cutils/properties.h>
#else
#include <cstdio>
#include <cstdlib>
#include <cstring>
// NOLINTNEXTLINE(readability-identifier-naming)
constexpr int PROPERTY_VALUE_MAX = 92;
// NOLINTNEXTLINE(readability-identifier-naming)
auto inline property_get(const char *name, char *value,
const char *default_value) -> int {
char *prop = std::getenv(name);
if (prop == nullptr) {
snprintf(value, PROPERTY_VALUE_MAX, "%s", default_value);
}
return static_cast<int>(strlen(value));
}
#endif
#endif