blob: 38a27627f3e8cf8bada7e8d483464b9893923853 [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 }
Roman Stratiienkod26619b2021-08-04 19:55:37 +030023 return static_cast<int>(strlen(value));
Roman Stratiienkod518a052021-02-25 19:15:14 +020024}
25
26#endif
27
28#endif