mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-31 18:13:38 +01:00
Chassis: seperate module
It's only supported on Linux
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/printing.h"
|
||||
#include "detection/chassis/chassis.h"
|
||||
|
||||
#define FF_CHASSIS_MODULE_NAME "Chassis"
|
||||
#define FF_CHASSIS_NUM_FORMAT_ARGS 3
|
||||
|
||||
void ffPrintChassis(FFinstance* instance)
|
||||
{
|
||||
FFChassisResult result;
|
||||
ffDetectChassis(&result);
|
||||
|
||||
if(result.error.length > 0)
|
||||
{
|
||||
ffPrintError(instance, FF_CHASSIS_MODULE_NAME, 0, &instance->config.chassis, "%*s", result.error.length, result.error.chars);
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if(result.chassisType.length == 0)
|
||||
{
|
||||
ffPrintError(instance, FF_CHASSIS_MODULE_NAME, 0, &instance->config.host, "chassis_type is not set by O.E.M.");
|
||||
return;
|
||||
}
|
||||
|
||||
if(instance->config.chassis.outputFormat.length == 0)
|
||||
{
|
||||
ffPrintLogoAndKey(instance, FF_CHASSIS_MODULE_NAME, 0, &instance->config.host.key);
|
||||
|
||||
FFstrbuf output;
|
||||
ffStrbufInitCopy(&output, &result.chassisType);
|
||||
|
||||
if(result.chassisVersion.length > 0)
|
||||
ffStrbufAppendF(&output, " (%s)", &result.chassisVersion);
|
||||
|
||||
ffStrbufPutTo(&output, stdout);
|
||||
|
||||
ffStrbufDestroy(&output);
|
||||
}
|
||||
else
|
||||
{
|
||||
ffPrintFormat(instance, FF_CHASSIS_MODULE_NAME, 0, &instance->config.chassis, FF_CHASSIS_NUM_FORMAT_ARGS, (FFformatarg[]) {
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result.chassisType},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result.chassisVendor},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result.chassisVersion},
|
||||
});
|
||||
}
|
||||
|
||||
exit:
|
||||
ffStrbufDestroy(&result.chassisType);
|
||||
ffStrbufDestroy(&result.chassisVendor);
|
||||
ffStrbufDestroy(&result.chassisVersion);
|
||||
ffStrbufDestroy(&result.error);
|
||||
}
|
||||
+1
-4
@@ -3,7 +3,7 @@
|
||||
#include "detection/host/host.h"
|
||||
|
||||
#define FF_HOST_MODULE_NAME "Host"
|
||||
#define FF_HOST_NUM_FORMAT_ARGS 8
|
||||
#define FF_HOST_NUM_FORMAT_ARGS 5
|
||||
|
||||
void ffPrintHost(FFinstance* instance)
|
||||
{
|
||||
@@ -49,9 +49,6 @@ void ffPrintHost(FFinstance* instance)
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &host->productName},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &host->productVersion},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &host->productSku},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &host->chassisType},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &host->chassisVendor},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &host->chassisVersion},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &host->sysVendor}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user