1 #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) 15 constexpr int PROPERTY_VALUE_MAX = 92; 16 17 // NOLINTNEXTLINE(readability-identifier-naming) 18 auto inline property_get(const char *name, char *value, 19 const char *default_value) -> int { 20 // NOLINTNEXTLINE (concurrency-mt-unsafe) 21 char *prop = std::getenv(name); 22 snprintf(value, PROPERTY_VALUE_MAX, "%s", 23 (prop == nullptr) ? default_value : prop); 24 return static_cast<int>(strlen(value)); 25 } 26 27 #endif 28 29 #endif