Global: make FFinstance instance a global variable

As discussed in https://github.com/fastfetch-cli/fastfetch/discussions/473
This commit is contained in:
李通洲
2023-06-24 10:59:53 +08:00
parent 48b01c9665
commit d0f093c567
255 changed files with 2020 additions and 2064 deletions
+13 -13
View File
@@ -5,27 +5,27 @@
#define FF_KERNEL_NUM_FORMAT_ARGS 4
void ffPrintKernel(FFinstance* instance, FFKernelOptions* options)
void ffPrintKernel(FFKernelOptions* options)
{
if(options->moduleArgs.outputFormat.length == 0)
{
ffPrintLogoAndKey(instance, FF_KERNEL_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
ffStrbufWriteTo(&instance->state.platform.systemRelease, stdout);
ffPrintLogoAndKey(FF_KERNEL_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
ffStrbufWriteTo(&instance.state.platform.systemRelease, stdout);
#ifdef _WIN32
if(instance->state.platform.systemVersion.length > 0)
printf(" (%s)", instance->state.platform.systemVersion.chars);
if(instance.state.platform.systemVersion.length > 0)
printf(" (%s)", instance.state.platform.systemVersion.chars);
#endif
putchar('\n');
}
else
{
ffPrintFormat(instance, FF_KERNEL_MODULE_NAME, 0, &options->moduleArgs, FF_KERNEL_NUM_FORMAT_ARGS, (FFformatarg[]){
{FF_FORMAT_ARG_TYPE_STRBUF, &instance->state.platform.systemName},
{FF_FORMAT_ARG_TYPE_STRBUF, &instance->state.platform.systemRelease},
{FF_FORMAT_ARG_TYPE_STRBUF, &instance->state.platform.systemVersion},
{FF_FORMAT_ARG_TYPE_STRBUF, &instance->state.platform.systemArchitecture}
ffPrintFormat(FF_KERNEL_MODULE_NAME, 0, &options->moduleArgs, FF_KERNEL_NUM_FORMAT_ARGS, (FFformatarg[]){
{FF_FORMAT_ARG_TYPE_STRBUF, &instance.state.platform.systemName},
{FF_FORMAT_ARG_TYPE_STRBUF, &instance.state.platform.systemRelease},
{FF_FORMAT_ARG_TYPE_STRBUF, &instance.state.platform.systemVersion},
{FF_FORMAT_ARG_TYPE_STRBUF, &instance.state.platform.systemArchitecture}
});
}
}
@@ -51,7 +51,7 @@ void ffDestroyKernelOptions(FFKernelOptions* options)
ffOptionDestroyModuleArg(&options->moduleArgs);
}
void ffParseKernelJsonObject(FFinstance* instance, yyjson_val* module)
void ffParseKernelJsonObject(yyjson_val* module)
{
FFKernelOptions __attribute__((__cleanup__(ffDestroyKernelOptions))) options;
ffInitKernelOptions(&options);
@@ -69,9 +69,9 @@ void ffParseKernelJsonObject(FFinstance* instance, yyjson_val* module)
if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs))
continue;
ffPrintError(instance, FF_KERNEL_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
ffPrintError(FF_KERNEL_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
}
}
ffPrintKernel(instance, &options);
ffPrintKernel(&options);
}
+2 -2
View File
@@ -4,8 +4,8 @@
#define FF_KERNEL_MODULE_NAME "Kernel"
void ffPrintKernel(FFinstance* instance, FFKernelOptions* options);
void ffPrintKernel(FFKernelOptions* options);
void ffInitKernelOptions(FFKernelOptions* options);
bool ffParseKernelCommandOptions(FFKernelOptions* options, const char* key, const char* value);
void ffDestroyKernelOptions(FFKernelOptions* options);
void ffParseKernelJsonObject(FFinstance* instance, yyjson_val* module);
void ffParseKernelJsonObject(yyjson_val* module);