mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-30 00:37:23 +01:00
Host: don't use singleton
This commit is contained in:
@@ -1,11 +0,0 @@
|
||||
#include "host.h"
|
||||
#include "detection/internal.h"
|
||||
|
||||
void ffDetectHostImpl(FFHostResult* host);
|
||||
|
||||
const FFHostResult* ffDetectHost()
|
||||
{
|
||||
FF_DETECTION_INTERNAL_GUARD(FFHostResult,
|
||||
ffDetectHostImpl(&result)
|
||||
);
|
||||
}
|
||||
@@ -12,9 +12,8 @@ typedef struct FFHostResult
|
||||
FFstrbuf productVersion;
|
||||
FFstrbuf productSku;
|
||||
FFstrbuf sysVendor;
|
||||
FFstrbuf error;
|
||||
} FFHostResult;
|
||||
|
||||
const FFHostResult* ffDetectHost();
|
||||
const char* ffDetectHost(FFHostResult* result);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -2,10 +2,8 @@
|
||||
#include "common/settings.h"
|
||||
#include <ctype.h>
|
||||
|
||||
void ffDetectHostImpl(FFHostResult* host)
|
||||
const char* ffDetectHost(FFHostResult* host)
|
||||
{
|
||||
ffStrbufInit(&host->error);
|
||||
|
||||
//Family
|
||||
|
||||
ffStrbufInit(&host->productFamily);
|
||||
@@ -16,7 +14,8 @@ void ffDetectHostImpl(FFHostResult* host)
|
||||
ffStrbufInit(&host->productName);
|
||||
|
||||
ffSettingsGetAndroidProperty("ro.product.brand", &host->productName);
|
||||
if(host->productName.length > 0){
|
||||
if(host->productName.length > 0)
|
||||
{
|
||||
host->productName.chars[0] = (char) toupper(host->productName.chars[0]);
|
||||
ffStrbufAppendC(&host->productName, ' ');
|
||||
}
|
||||
@@ -34,4 +33,6 @@ void ffDetectHostImpl(FFHostResult* host)
|
||||
|
||||
ffStrbufInit(&host->productVersion);
|
||||
ffStrbufInit(&host->productSku);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -155,17 +155,16 @@ static const char* getProductName(const FFstrbuf* hwModel)
|
||||
return hwModel->chars;
|
||||
}
|
||||
|
||||
void ffDetectHostImpl(FFHostResult* host)
|
||||
const char* ffDetectHost(FFHostResult* host)
|
||||
{
|
||||
ffStrbufInit(&host->error);
|
||||
|
||||
ffStrbufInit(&host->productName);
|
||||
ffStrbufInit(&host->productFamily);
|
||||
ffStrbufInit(&host->productVersion);
|
||||
ffStrbufInit(&host->productSku);
|
||||
ffStrbufInitS(&host->sysVendor, "Apple");
|
||||
|
||||
ffStrbufAppendS(&host->error, ffSysctlGetString("hw.model", &host->productFamily));
|
||||
if(host->error.length == 0)
|
||||
ffStrbufAppendS(&host->productName, getProductName(&host->productFamily));
|
||||
const char* error = ffSysctlGetString("hw.model", &host->productFamily);
|
||||
if (error) return error;
|
||||
ffStrbufAppendS(&host->productName, getProductName(&host->productFamily));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
#include "host.h"
|
||||
#include "common/sysctl.h"
|
||||
|
||||
void ffDetectHostImpl(FFHostResult* host)
|
||||
const char* ffDetectHost(FFHostResult* host)
|
||||
{
|
||||
ffStrbufInit(&host->error);
|
||||
|
||||
ffStrbufInit(&host->productName);
|
||||
ffStrbufInit(&host->productFamily);
|
||||
ffStrbufInit(&host->productVersion);
|
||||
ffStrbufInit(&host->productSku);
|
||||
ffStrbufInit(&host->sysVendor);
|
||||
|
||||
ffStrbufAppendS(&host->error, ffSysctlGetString("hw.fdt.model", &host->productName));
|
||||
return ffSysctlGetString("hw.fdt.model", &host->productName);
|
||||
}
|
||||
|
||||
@@ -59,10 +59,8 @@ static void getHostProductName(FFstrbuf* name)
|
||||
ffStrbufClear(name);
|
||||
}
|
||||
|
||||
void ffDetectHostImpl(FFHostResult* host)
|
||||
const char* ffDetectHost(FFHostResult* host)
|
||||
{
|
||||
ffStrbufInit(&host->error);
|
||||
|
||||
ffStrbufInit(&host->productFamily);
|
||||
getHostValue("/sys/devices/virtual/dmi/id/product_family", "/sys/class/dmi/id/product_family", &host->productFamily);
|
||||
|
||||
@@ -107,4 +105,6 @@ void ffDetectHostImpl(FFHostResult* host)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
#include "host.h"
|
||||
#include "util/windows/registry.h"
|
||||
|
||||
void ffDetectHostImpl(FFHostResult* host)
|
||||
const char* ffDetectHost(FFHostResult* host)
|
||||
{
|
||||
ffStrbufInit(&host->error);
|
||||
|
||||
ffStrbufInit(&host->productName);
|
||||
ffStrbufInit(&host->productFamily);
|
||||
ffStrbufInit(&host->productVersion);
|
||||
@@ -13,12 +11,14 @@ void ffDetectHostImpl(FFHostResult* host)
|
||||
|
||||
FF_HKEY_AUTO_DESTROY hKey = NULL;
|
||||
|
||||
if(!ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, L"HARDWARE\\DESCRIPTION\\System\\BIOS", &hKey, &host->error))
|
||||
return;
|
||||
if(!ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, L"HARDWARE\\DESCRIPTION\\System\\BIOS", &hKey, NULL))
|
||||
return "ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, L\"HARDWARE\\DESCRIPTION\\System\\BIOS\", &hKey, NULL) failed";
|
||||
|
||||
ffRegReadStrbuf(hKey, L"SystemProductName", &host->productName, NULL);
|
||||
ffRegReadStrbuf(hKey, L"SystemFamily", &host->productFamily, NULL);
|
||||
ffRegReadStrbuf(hKey, L"SystemVersion", &host->productVersion, NULL);
|
||||
ffRegReadStrbuf(hKey, L"SystemSKU", &host->productSku, NULL);
|
||||
ffRegReadStrbuf(hKey, L"SystemManufacturer", &host->sysVendor, NULL);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user