mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-11-07 05:34:20 +01:00
Modules: major code refactor
Also fix some bugs found when refactoring
This commit is contained in:
@@ -66,7 +66,7 @@ void ffPrintMemory(FFMemoryOptions* options)
|
||||
|
||||
void ffInitMemoryOptions(FFMemoryOptions* options)
|
||||
{
|
||||
options->moduleName = FF_MEMORY_MODULE_NAME;
|
||||
ffOptionInitModuleBaseInfo(&options->moduleInfo, FF_MEMORY_MODULE_NAME, ffParseMemoryCommandOptions, ffParseMemoryJsonObject, ffPrintMemory);
|
||||
ffOptionInitModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
@@ -85,11 +85,8 @@ void ffDestroyMemoryOptions(FFMemoryOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
void ffParseMemoryJsonObject(yyjson_val* module)
|
||||
void ffParseMemoryJsonObject(FFMemoryOptions* options, yyjson_val* module)
|
||||
{
|
||||
FFMemoryOptions __attribute__((__cleanup__(ffDestroyMemoryOptions))) options;
|
||||
ffInitMemoryOptions(&options);
|
||||
|
||||
if (module)
|
||||
{
|
||||
yyjson_val *key_, *val;
|
||||
@@ -100,12 +97,10 @@ void ffParseMemoryJsonObject(yyjson_val* module)
|
||||
if(ffStrEqualsIgnCase(key, "type"))
|
||||
continue;
|
||||
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs))
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs))
|
||||
continue;
|
||||
|
||||
ffPrintError(FF_MEMORY_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
ffPrintError(FF_MEMORY_MODULE_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key);
|
||||
}
|
||||
}
|
||||
|
||||
ffPrintMemory(&options);
|
||||
}
|
||||
|
||||
@@ -8,4 +8,4 @@ void ffPrintMemory(FFMemoryOptions* options);
|
||||
void ffInitMemoryOptions(FFMemoryOptions* options);
|
||||
bool ffParseMemoryCommandOptions(FFMemoryOptions* options, const char* key, const char* value);
|
||||
void ffDestroyMemoryOptions(FFMemoryOptions* options);
|
||||
void ffParseMemoryJsonObject(yyjson_val* module);
|
||||
void ffParseMemoryJsonObject(FFMemoryOptions* options, yyjson_val* module);
|
||||
|
||||
@@ -6,6 +6,6 @@
|
||||
|
||||
typedef struct FFMemoryOptions
|
||||
{
|
||||
const char* moduleName;
|
||||
FFModuleBaseInfo moduleInfo;
|
||||
FFModuleArgs moduleArgs;
|
||||
} FFMemoryOptions;
|
||||
|
||||
Reference in New Issue
Block a user