Bios (FreeBSD): code refactor

This commit is contained in:
李通洲
2023-06-15 10:03:12 +08:00
parent a18073f5de
commit 16181b7272
3 changed files with 25 additions and 17 deletions
+18 -3
View File
@@ -403,9 +403,24 @@ bool ffSettingsGetSQLite3String(const FFinstance* instance, const char* dbPath,
#ifdef __ANDROID__
#include <sys/system_properties.h>
void ffSettingsGetAndroidProperty(const char* propName, FFstrbuf* result) {
bool ffSettingsGetAndroidProperty(const char* propName, FFstrbuf* result) {
ffStrbufEnsureFree(result, PROP_VALUE_MAX);
result->length += (uint32_t) __system_property_get(propName, result->chars + result->length);
int len = __system_property_get(propName, result->chars + result->length);
if (len <= 0) return false;
result->length += (uint32_t) len;
result->chars[result->length] = '\0';
return true;
}
#endif //__ANDROID__
#elif defined(__FreeBSD__)
#include <kenv.h>
bool ffSettingsGetFreeBSDKenv(const char* propName, FFstrbuf* result)
{
//https://wiki.ghostbsd.org/index.php/Kenv
ffStrbufEnsureFree(result, KENV_MVALLEN);
int len = kenv(KENV_GET, propName, result->chars + result->length, KENV_MVALLEN);
if (len <= 0) return false;
result->length += (uint32_t) len;
result->chars[result->length] = '\0';
return true;
}
#endif
+2
View File
@@ -35,6 +35,8 @@ bool ffSettingsGetSQLite3String(const FFinstance* instance, const char* dbPath,
#ifdef __ANDROID__
void ffSettingsGetAndroidProperty(const char* propName, FFstrbuf* result);
#elif defined(__FreeBSD__)
bool ffSettingsGetFreeBSDKenv(const char* propName, FFstrbuf* result);
#endif
#endif