2021-02-18 22:25:36 +01:00
|
|
|
#include "fastfetch.h"
|
2022-07-25 13:15:01 +02:00
|
|
|
#include "common/printing.h"
|
2022-10-08 18:29:23 +08:00
|
|
|
#include "detection/kernel/kernel.h"
|
2021-02-18 22:25:36 +01:00
|
|
|
|
2021-04-15 18:59:26 +02:00
|
|
|
#define FF_KERNEL_MODULE_NAME "Kernel"
|
|
|
|
|
#define FF_KERNEL_NUM_FORMAT_ARGS 3
|
|
|
|
|
|
2021-02-27 18:30:05 +01:00
|
|
|
void ffPrintKernel(FFinstance* instance)
|
2021-02-18 22:25:36 +01:00
|
|
|
{
|
2022-10-08 18:29:23 +08:00
|
|
|
FFKernelResult result;
|
|
|
|
|
ffDetectKernel(instance, &result);
|
|
|
|
|
|
|
|
|
|
if(result.error.length > 0)
|
|
|
|
|
{
|
|
|
|
|
ffPrintError(instance, FF_KERNEL_MODULE_NAME, 0, &instance->config.kernel, "%*s", result.error.length, result.error.chars);
|
|
|
|
|
goto exit;
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-17 18:15:36 +02:00
|
|
|
if(instance->config.kernel.outputFormat.length == 0)
|
2021-03-19 20:57:07 +01:00
|
|
|
{
|
2022-06-17 18:15:36 +02:00
|
|
|
ffPrintLogoAndKey(instance, FF_KERNEL_MODULE_NAME, 0, &instance->config.kernel.key);
|
2022-10-08 18:29:23 +08:00
|
|
|
ffStrbufPutTo(&result.release, stdout);
|
2021-03-19 20:57:07 +01:00
|
|
|
}
|
2021-03-27 15:39:56 +01:00
|
|
|
else
|
|
|
|
|
{
|
2022-06-17 18:15:36 +02:00
|
|
|
ffPrintFormat(instance, FF_KERNEL_MODULE_NAME, 0, &instance->config.kernel, FF_KERNEL_NUM_FORMAT_ARGS, (FFformatarg[]){
|
2022-10-08 18:29:23 +08:00
|
|
|
{FF_FORMAT_ARG_TYPE_STRBUF, &result.sysname},
|
|
|
|
|
{FF_FORMAT_ARG_TYPE_STRBUF, &result.release},
|
|
|
|
|
{FF_FORMAT_ARG_TYPE_STRBUF, &result.version}
|
2021-04-15 18:59:26 +02:00
|
|
|
});
|
2021-03-27 15:39:56 +01:00
|
|
|
}
|
2022-10-08 18:29:23 +08:00
|
|
|
|
|
|
|
|
exit:
|
|
|
|
|
ffStrbufDestroy(&result.error);
|
|
|
|
|
ffStrbufDestroy(&result.sysname);
|
|
|
|
|
ffStrbufDestroy(&result.release);
|
|
|
|
|
ffStrbufDestroy(&result.version);
|
2021-03-27 18:14:19 +01:00
|
|
|
}
|