2021-02-18 22:25:36 +01:00
|
|
|
#include "fastfetch.h"
|
2022-07-25 13:15:01 +02:00
|
|
|
#include "common/printing.h"
|
2022-07-25 13:36:58 +02:00
|
|
|
#include "common/caching.h"
|
2022-09-04 12:43:30 +02:00
|
|
|
#include "detection/host/host.h"
|
2022-01-10 15:20:51 +01:00
|
|
|
|
2021-04-15 18:59:26 +02:00
|
|
|
#define FF_HOST_MODULE_NAME "Host"
|
2022-06-14 17:10:46 +02:00
|
|
|
#define FF_HOST_NUM_FORMAT_ARGS 15
|
2021-04-15 18:59:26 +02:00
|
|
|
|
2021-02-27 18:30:05 +01:00
|
|
|
void ffPrintHost(FFinstance* instance)
|
2021-02-18 22:25:36 +01:00
|
|
|
{
|
2022-06-17 18:15:36 +02:00
|
|
|
if(ffPrintFromCache(instance, FF_HOST_MODULE_NAME, &instance->config.host, FF_HOST_NUM_FORMAT_ARGS))
|
2021-02-22 16:52:51 +01:00
|
|
|
return;
|
|
|
|
|
|
2022-09-04 12:43:30 +02:00
|
|
|
const FFHostResult* host = ffDetectHost();
|
2021-06-16 10:50:16 +02:00
|
|
|
|
2022-09-04 12:43:30 +02:00
|
|
|
if(host->productFamily.length == 0 && host->productName.length == 0)
|
2021-04-03 21:51:50 +02:00
|
|
|
{
|
2022-06-17 18:15:36 +02:00
|
|
|
ffPrintError(instance, FF_HOST_MODULE_NAME, 0, &instance->config.host, "neither product_family nor product_name is set by O.E.M.");
|
2021-04-03 21:51:50 +02:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-04 12:43:30 +02:00
|
|
|
FFstrbuf output;
|
|
|
|
|
ffStrbufInit(&output);
|
2021-03-19 20:57:07 +01:00
|
|
|
|
2022-09-04 12:43:30 +02:00
|
|
|
if(host->productName.length > 0)
|
|
|
|
|
ffStrbufAppend(&output, &host->productName);
|
2021-03-23 19:48:52 +01:00
|
|
|
else
|
2022-09-04 12:43:30 +02:00
|
|
|
ffStrbufAppend(&output, &host->productFamily);
|
2021-04-15 18:59:26 +02:00
|
|
|
|
2022-09-04 12:43:30 +02:00
|
|
|
if(host->productVersion.length > 0)
|
2021-06-16 10:50:16 +02:00
|
|
|
{
|
2022-09-04 12:43:30 +02:00
|
|
|
ffStrbufAppendC(&output, ' ');
|
|
|
|
|
ffStrbufAppend(&output, &host->productVersion);
|
2021-03-23 19:48:52 +01:00
|
|
|
}
|
2021-02-22 16:52:51 +01:00
|
|
|
|
2022-09-04 12:43:30 +02:00
|
|
|
ffPrintAndWriteToCache(instance, FF_HOST_MODULE_NAME, &instance->config.host, &output, FF_HOST_NUM_FORMAT_ARGS, (FFformatarg[]) {
|
|
|
|
|
{FF_FORMAT_ARG_TYPE_STRBUF, &host->productFamily},
|
|
|
|
|
{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->biosDate},
|
|
|
|
|
{FF_FORMAT_ARG_TYPE_STRBUF, &host->biosRelease},
|
|
|
|
|
{FF_FORMAT_ARG_TYPE_STRBUF, &host->biosVendor},
|
|
|
|
|
{FF_FORMAT_ARG_TYPE_STRBUF, &host->biosVersion},
|
|
|
|
|
{FF_FORMAT_ARG_TYPE_STRBUF, &host->boardName},
|
|
|
|
|
{FF_FORMAT_ARG_TYPE_STRBUF, &host->boardVendor},
|
|
|
|
|
{FF_FORMAT_ARG_TYPE_STRBUF, &host->boardVersion},
|
|
|
|
|
{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}
|
2021-04-15 18:59:26 +02:00
|
|
|
});
|
2022-09-18 16:30:26 +02:00
|
|
|
|
|
|
|
|
ffStrbufDestroy(&output);
|
2021-03-27 18:14:19 +01:00
|
|
|
}
|