blob: 607cbc5ce2fa8ebd8d4ab678cb26b5cfb33789f6 [file] [log] [blame]
Roman Stratiienkod518a052021-02-25 19:15:14 +02001#ifndef UTILS_PROPERTIES_H_
2#define UTILS_PROPERTIES_H_
3
4#ifdef ANDROID
5
6#include <cutils/properties.h>
7
8#else
9
10#include <cstdio>
11#include <cstdlib>
12#include <cstring>
13
14// NOLINTNEXTLINE(readability-identifier-naming)
15constexpr int PROPERTY_VALUE_MAX = 92;
16
17auto inline property_get(const char *name, char *value,
18 const char *default_value) -> int {
19 char *prop = std::getenv(name);
20 if (prop == nullptr) {
21 snprintf(value, PROPERTY_VALUE_MAX, "%s", default_value);
22 }
23 return strlen(value);
24}
25
26#endif
27
28#endif