mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-30 00:37:23 +01:00
Modules: major code refactor
Also fix some bugs found when refactoring
This commit is contained in:
@@ -32,7 +32,7 @@ void ffPrintKernel(FFKernelOptions* options)
|
||||
|
||||
void ffInitKernelOptions(FFKernelOptions* options)
|
||||
{
|
||||
options->moduleName = FF_KERNEL_MODULE_NAME;
|
||||
ffOptionInitModuleBaseInfo(&options->moduleInfo, FF_KERNEL_MODULE_NAME, ffParseKernelCommandOptions, ffParseKernelJsonObject, ffPrintKernel);
|
||||
ffOptionInitModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
@@ -51,11 +51,8 @@ void ffDestroyKernelOptions(FFKernelOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
void ffParseKernelJsonObject(yyjson_val* module)
|
||||
void ffParseKernelJsonObject(FFKernelOptions* options, yyjson_val* module)
|
||||
{
|
||||
FFKernelOptions __attribute__((__cleanup__(ffDestroyKernelOptions))) options;
|
||||
ffInitKernelOptions(&options);
|
||||
|
||||
if (module)
|
||||
{
|
||||
yyjson_val *key_, *val;
|
||||
@@ -66,12 +63,10 @@ void ffParseKernelJsonObject(yyjson_val* module)
|
||||
if(ffStrEqualsIgnCase(key, "type"))
|
||||
continue;
|
||||
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs))
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs))
|
||||
continue;
|
||||
|
||||
ffPrintError(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(&options);
|
||||
}
|
||||
|
||||
@@ -8,4 +8,4 @@ void ffPrintKernel(FFKernelOptions* options);
|
||||
void ffInitKernelOptions(FFKernelOptions* options);
|
||||
bool ffParseKernelCommandOptions(FFKernelOptions* options, const char* key, const char* value);
|
||||
void ffDestroyKernelOptions(FFKernelOptions* options);
|
||||
void ffParseKernelJsonObject(yyjson_val* module);
|
||||
void ffParseKernelJsonObject(FFKernelOptions* options, yyjson_val* module);
|
||||
|
||||
@@ -6,6 +6,6 @@
|
||||
|
||||
typedef struct FFKernelOptions
|
||||
{
|
||||
const char* moduleName;
|
||||
FFModuleBaseInfo moduleInfo;
|
||||
FFModuleArgs moduleArgs;
|
||||
} FFKernelOptions;
|
||||
|
||||
Reference in New Issue
Block a user