mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-12 10:22:12 +02:00
Bios (FreeBSD): code refactor
This commit is contained in:
+18
-3
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,14 +1,6 @@
|
||||
#include "bios.h"
|
||||
|
||||
#include <kenv.h>
|
||||
|
||||
static void kenvLookup(const char* name, FFstrbuf* result)
|
||||
{
|
||||
ffStrbufEnsureFree(result, 255);
|
||||
int len = kenv(KENV_GET, name, result->chars, 256);
|
||||
if(len > 0)
|
||||
result->length = (uint32_t) len;
|
||||
}
|
||||
#include "common/settings.h"
|
||||
|
||||
void ffDetectBios(FFBiosResult* bios)
|
||||
{
|
||||
@@ -18,9 +10,8 @@ void ffDetectBios(FFBiosResult* bios)
|
||||
ffStrbufInit(&bios->biosVendor);
|
||||
ffStrbufInit(&bios->biosVersion);
|
||||
|
||||
//https://wiki.ghostbsd.org/index.php/Kenv
|
||||
kenvLookup("smbios.bios.reldate", &bios->biosDate);
|
||||
kenvLookup("smbios.system.product", &bios->biosRelease);
|
||||
kenvLookup("smbios.bios.vendor", &bios->biosVendor);
|
||||
kenvLookup("smbios.bios.version", &bios->biosVersion);
|
||||
ffSettingsGetFreeBSDKenv("smbios.bios.reldate", &bios->biosDate);
|
||||
ffSettingsGetFreeBSDKenv("smbios.bios.revision", &bios->biosRelease);
|
||||
ffSettingsGetFreeBSDKenv("smbios.bios.vendor", &bios->biosVendor);
|
||||
ffSettingsGetFreeBSDKenv("smbios.bios.version", &bios->biosVersion);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user