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
+9 -9
View File
@@ -54,7 +54,7 @@ static void printIp(FFLocalIpResult* ip)
}
}
void ffPrintLocalIp(FFinstance* instance, FFLocalIpOptions* options)
void ffPrintLocalIp(FFLocalIpOptions* options)
{
FF_LIST_AUTO_DESTROY results = ffListCreate(sizeof(FFLocalIpResult));
@@ -62,13 +62,13 @@ void ffPrintLocalIp(FFinstance* instance, FFLocalIpOptions* options)
if(error)
{
ffPrintError(instance, FF_LOCALIP_DISPLAY_NAME, 0, &options->moduleArgs, "%s", error);
ffPrintError(FF_LOCALIP_DISPLAY_NAME, 0, &options->moduleArgs, "%s", error);
return;
}
if(results.length == 0)
{
ffPrintError(instance, FF_LOCALIP_DISPLAY_NAME, 0, &options->moduleArgs, "Failed to detect any IPs");
ffPrintError(FF_LOCALIP_DISPLAY_NAME, 0, &options->moduleArgs, "Failed to detect any IPs");
return;
}
@@ -76,7 +76,7 @@ void ffPrintLocalIp(FFinstance* instance, FFLocalIpOptions* options)
if (options->showType & FF_LOCALIP_TYPE_COMPACT_BIT)
{
ffPrintLogoAndKey(instance, FF_LOCALIP_DISPLAY_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
ffPrintLogoAndKey(FF_LOCALIP_DISPLAY_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
FF_LIST_FOR_EACH(FFLocalIpResult, ip, results)
{
@@ -94,13 +94,13 @@ void ffPrintLocalIp(FFinstance* instance, FFLocalIpOptions* options)
formatKey(options, ip, &key);
if(options->moduleArgs.outputFormat.length == 0)
{
ffPrintLogoAndKey(instance, key.chars, 0, NULL, &options->moduleArgs.keyColor);
ffPrintLogoAndKey(key.chars, 0, NULL, &options->moduleArgs.keyColor);
printIp(ip);
putchar('\n');
}
else
{
ffPrintFormatString(instance, key.chars, 0, NULL, &options->moduleArgs.keyColor, &options->moduleArgs.outputFormat, FF_LOCALIP_NUM_FORMAT_ARGS, (FFformatarg[]){
ffPrintFormatString(key.chars, 0, NULL, &options->moduleArgs.keyColor, &options->moduleArgs.outputFormat, FF_LOCALIP_NUM_FORMAT_ARGS, (FFformatarg[]){
{FF_FORMAT_ARG_TYPE_STRBUF, &ip->ipv4},
{FF_FORMAT_ARG_TYPE_STRBUF, &ip->ipv6},
{FF_FORMAT_ARG_TYPE_STRBUF, &ip->mac},
@@ -195,7 +195,7 @@ void ffDestroyLocalIpOptions(FFLocalIpOptions* options)
ffStrbufDestroy(&options->namePrefix);
}
void ffParseLocalIpJsonObject(FFinstance* instance, yyjson_val* module)
void ffParseLocalIpJsonObject(yyjson_val* module)
{
FFLocalIpOptions __attribute__((__cleanup__(ffDestroyLocalIpOptions))) options;
ffInitLocalIpOptions(&options);
@@ -264,9 +264,9 @@ void ffParseLocalIpJsonObject(FFinstance* instance, yyjson_val* module)
continue;
}
ffPrintError(instance, FF_LOCALIP_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
ffPrintError(FF_LOCALIP_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
}
}
ffPrintLocalIp(instance, &options);
ffPrintLocalIp(&options);
}
+2 -2
View File
@@ -4,8 +4,8 @@
#define FF_LOCALIP_MODULE_NAME "LocalIp"
void ffPrintLocalIp(FFinstance* instance, FFLocalIpOptions* options);
void ffPrintLocalIp(FFLocalIpOptions* options);
void ffInitLocalIpOptions(FFLocalIpOptions* options);
bool ffParseLocalIpCommandOptions(FFLocalIpOptions* options, const char* key, const char* value);
void ffDestroyLocalIpOptions(FFLocalIpOptions* options);
void ffParseLocalIpJsonObject(FFinstance* instance, yyjson_val* module);
void ffParseLocalIpJsonObject(yyjson_val* module);