blob: 0b49c612454cb1957d57cfec67aa5adafd465c60 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
#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 {
// NOLINTNEXTLINE (concurrency-mt-unsafe)
char *prop = std::getenv(name);
snprintf(value, PROPERTY_VALUE_MAX, "%s",
(prop == nullptr) ? default_value : prop);
return static_cast<int>(strlen(value));
}
#endif
#endif
|