mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-12 10:22:12 +02:00
JsonConfig: simplify code
This commit is contained in:
@@ -18,7 +18,9 @@ typedef struct FFJsonLibrary
|
||||
FF_LIBRARY_SYMBOL(json_object_get_string_len)
|
||||
FF_LIBRARY_SYMBOL(json_object_get_string)
|
||||
FF_LIBRARY_SYMBOL(json_object_get_object)
|
||||
FF_LIBRARY_SYMBOL(json_object_object_del)
|
||||
FF_LIBRARY_SYMBOL(json_object_object_get)
|
||||
FF_LIBRARY_SYMBOL(json_object_object_length)
|
||||
FF_LIBRARY_SYMBOL(json_object_put)
|
||||
} FFJsonLibrary;
|
||||
|
||||
@@ -43,7 +45,9 @@ static const FFJsonLibrary* loadLibSymbols(const FFinstance* instance)
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR(libjsonc, lib, json_object_get_string_len, NULL)
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR(libjsonc, lib, json_object_get_string, NULL)
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR(libjsonc, lib, json_object_get_object, NULL)
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR(libjsonc, lib, json_object_object_del, NULL)
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR(libjsonc, lib, json_object_object_get, NULL)
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR(libjsonc, lib, json_object_object_length, NULL)
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR(libjsonc, lib, json_object_put, NULL)
|
||||
libjsonc = NULL; // don't dlclose automatically
|
||||
return &lib;
|
||||
@@ -124,12 +128,24 @@ struct lh_table *json_object_get_object(const json_object *obj)
|
||||
return ffJsonLib->ffjson_object_get_object(obj);
|
||||
}
|
||||
|
||||
void json_object_object_del(struct json_object *obj, const char *key)
|
||||
{
|
||||
assert(ffJsonLib);
|
||||
return ffJsonLib->ffjson_object_object_del(obj, key);
|
||||
}
|
||||
|
||||
struct json_object *json_object_object_get(const json_object *obj, const char *key)
|
||||
{
|
||||
assert(ffJsonLib);
|
||||
return ffJsonLib->ffjson_object_object_get(obj, key);
|
||||
}
|
||||
|
||||
int json_object_object_length(const json_object *obj)
|
||||
{
|
||||
assert(ffJsonLib);
|
||||
return ffJsonLib->ffjson_object_object_length(obj);
|
||||
}
|
||||
|
||||
int json_object_put(json_object *obj)
|
||||
{
|
||||
assert(ffJsonLib);
|
||||
|
||||
+12
-12
@@ -1251,23 +1251,23 @@ static void parseStructureCommand(FFinstance* instance, FFdata* data, const char
|
||||
|
||||
if(strcasecmp(line, "break") == 0)
|
||||
ffPrintBreak(instance);
|
||||
else if(strcasecmp(line, "title") == 0)
|
||||
else if(strcasecmp(line, FF_TITLE_MODULE_NAME) == 0)
|
||||
ffPrintTitle(instance, &instance->config.title);
|
||||
else if(strcasecmp(line, "separator") == 0)
|
||||
else if(strcasecmp(line, FF_SEPARATOR_MODULE_NAME) == 0)
|
||||
ffPrintSeparator(instance, &instance->config.separator);
|
||||
else if(strcasecmp(line, "os") == 0)
|
||||
else if(strcasecmp(line, FF_OS_MODULE_NAME) == 0)
|
||||
ffPrintOS(instance, &instance->config.os);
|
||||
else if(strcasecmp(line, "host") == 0)
|
||||
else if(strcasecmp(line, FF_HOST_MODULE_NAME) == 0)
|
||||
ffPrintHost(instance, &instance->config.host);
|
||||
else if(strcasecmp(line, "bios") == 0)
|
||||
else if(strcasecmp(line, FF_BIOS_MODULE_NAME) == 0)
|
||||
ffPrintBios(instance, &instance->config.bios);
|
||||
else if(strcasecmp(line, "board") == 0)
|
||||
else if(strcasecmp(line, FF_BOARD_MODULE_NAME) == 0)
|
||||
ffPrintBoard(instance, &instance->config.board);
|
||||
else if(strcasecmp(line, "brightness") == 0)
|
||||
else if(strcasecmp(line, FF_BRIGHTNESS_MODULE_NAME) == 0)
|
||||
ffPrintBrightness(instance, &instance->config.brightness);
|
||||
else if(strcasecmp(line, "chassis") == 0)
|
||||
ffPrintChassis(instance);
|
||||
else if(strcasecmp(line, "kernel") == 0)
|
||||
else if(strcasecmp(line, FF_KERNEL_MODULE_NAME) == 0)
|
||||
ffPrintKernel(instance, &instance->config.kernel);
|
||||
else if(strcasecmp(line, "uptime") == 0)
|
||||
ffPrintUptime(instance);
|
||||
@@ -1277,7 +1277,7 @@ static void parseStructureCommand(FFinstance* instance, FFdata* data, const char
|
||||
ffPrintPackages(instance);
|
||||
else if(strcasecmp(line, "shell") == 0)
|
||||
ffPrintShell(instance);
|
||||
else if(strcasecmp(line, "display") == 0)
|
||||
else if(strcasecmp(line, FF_DISPLAY_MODULE_NAME) == 0)
|
||||
ffPrintDisplay(instance, &instance->config.display);
|
||||
else if(strcasecmp(line, "desktopenvironment") == 0 || strcasecmp(line, "de") == 0)
|
||||
ffPrintDesktopEnvironment(instance);
|
||||
@@ -1329,7 +1329,7 @@ static void parseStructureCommand(FFinstance* instance, FFdata* data, const char
|
||||
ffPrintPlayer(instance);
|
||||
else if(strcasecmp(line, "media") == 0)
|
||||
ffPrintMedia(instance);
|
||||
else if(strcasecmp(line, "datetime") == 0)
|
||||
else if(strcasecmp(line, FF_DATETIME_MODULE_NAME) == 0)
|
||||
ffPrintDateTime(instance, &instance->config.dateTime);
|
||||
else if(strcasecmp(line, "colors") == 0)
|
||||
ffPrintColors(instance);
|
||||
@@ -1341,7 +1341,7 @@ static void parseStructureCommand(FFinstance* instance, FFdata* data, const char
|
||||
ffPrintOpenCL(instance);
|
||||
else if(strcasecmp(line, "users") == 0)
|
||||
ffPrintUsers(instance);
|
||||
else if(strcasecmp(line, "command") == 0)
|
||||
else if(strcasecmp(line, FF_COMMAND_MODULE_NAME) == 0)
|
||||
ffPrintCommand(instance, &instance->config.command);
|
||||
else if(strcasecmp(line, "bluetooth") == 0)
|
||||
ffPrintBluetooth(instance, &instance->config.bluetooth);
|
||||
@@ -1349,7 +1349,7 @@ static void parseStructureCommand(FFinstance* instance, FFdata* data, const char
|
||||
ffPrintSound(instance);
|
||||
else if(strcasecmp(line, "gamepad") == 0)
|
||||
ffPrintGamepad(instance);
|
||||
else if(strcasecmp(line, "jsonconfig") == 0)
|
||||
else if(strcasecmp(line, FF_JSONCONFIG_MODULE_NAME) == 0)
|
||||
ffPrintJsonConfig(instance);
|
||||
else
|
||||
ffPrintErrorString(instance, line, 0, NULL, NULL, "<no implementation provided>");
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#include "detection/battery/battery.h"
|
||||
#include "modules/battery/battery.h"
|
||||
|
||||
#define FF_BATTERY_MODULE_NAME "Battery"
|
||||
#define FF_BATTERY_NUM_FORMAT_ARGS 5
|
||||
|
||||
static void printBattery(FFinstance* instance, FFBatteryOptions* options, BatteryResult* result, uint8_t index)
|
||||
@@ -148,11 +147,8 @@ void ffDestroyBatteryOptions(FFBatteryOptions* options)
|
||||
}
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
bool ffParseBatteryJsonObject(FFinstance* instance, const char* type, json_object* module)
|
||||
void ffParseBatteryJsonObject(FFinstance* instance, json_object* module)
|
||||
{
|
||||
if (strcasecmp(type, FF_BATTERY_MODULE_NAME) != 0)
|
||||
return false;
|
||||
|
||||
FFBatteryOptions __attribute__((__cleanup__(ffDestroyBatteryOptions))) options;
|
||||
ffInitBatteryOptions(&options);
|
||||
|
||||
@@ -160,9 +156,6 @@ bool ffParseBatteryJsonObject(FFinstance* instance, const char* type, json_objec
|
||||
{
|
||||
json_object_object_foreach(module, key, val)
|
||||
{
|
||||
if (strcasecmp(key, "type") == 0)
|
||||
continue;
|
||||
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs))
|
||||
continue;
|
||||
|
||||
@@ -185,6 +178,5 @@ bool ffParseBatteryJsonObject(FFinstance* instance, const char* type, json_objec
|
||||
}
|
||||
|
||||
ffPrintBattery(instance, &options);
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
#include "fastfetch.h"
|
||||
|
||||
#define FF_BATTERY_MODULE_NAME "Battery"
|
||||
|
||||
void ffPrintBattery(FFinstance* instance, FFBatteryOptions* options);
|
||||
|
||||
void ffInitBatteryOptions(FFBatteryOptions* options);
|
||||
@@ -10,5 +12,5 @@ void ffDestroyBatteryOptions(FFBatteryOptions* options);
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
#include "common/jsonconfig.h"
|
||||
bool ffParseBatteryJsonObject(FFinstance* instance, const char* type, json_object* module);
|
||||
void ffParseBatteryJsonObject(FFinstance* instance, json_object* module);
|
||||
#endif
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#include "detection/bios/bios.h"
|
||||
#include "modules/bios/bios.h"
|
||||
|
||||
#define FF_BIOS_MODULE_NAME "Bios"
|
||||
#define FF_BIOS_NUM_FORMAT_ARGS 4
|
||||
|
||||
void ffPrintBios(FFinstance* instance, FFBiosOptions* options)
|
||||
@@ -68,11 +67,8 @@ void ffDestroyBiosOptions(FFBiosOptions* options)
|
||||
}
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
bool ffParseBiosJsonObject(FFinstance* instance, const char* type, json_object* module)
|
||||
void ffParseBiosJsonObject(FFinstance* instance, json_object* module)
|
||||
{
|
||||
if (strcasecmp(type, FF_BIOS_MODULE_NAME) != 0)
|
||||
return false;
|
||||
|
||||
FFBiosOptions __attribute__((__cleanup__(ffDestroyBiosOptions))) options;
|
||||
ffInitBiosOptions(&options);
|
||||
|
||||
@@ -80,9 +76,6 @@ bool ffParseBiosJsonObject(FFinstance* instance, const char* type, json_object*
|
||||
{
|
||||
json_object_object_foreach(module, key, val)
|
||||
{
|
||||
if (strcasecmp(key, "type") == 0)
|
||||
continue;
|
||||
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs))
|
||||
continue;
|
||||
|
||||
@@ -91,6 +84,5 @@ bool ffParseBiosJsonObject(FFinstance* instance, const char* type, json_object*
|
||||
}
|
||||
|
||||
ffPrintBios(instance, &options);
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
#include "fastfetch.h"
|
||||
|
||||
#define FF_BIOS_MODULE_NAME "Bios"
|
||||
|
||||
void ffPrintBios(FFinstance* instance, FFBiosOptions* options);
|
||||
void ffInitBiosOptions(FFBiosOptions* options);
|
||||
bool ffParseBiosCommandOptions(FFBiosOptions* options, const char* key, const char* value);
|
||||
@@ -9,5 +11,5 @@ void ffDestroyBiosOptions(FFBiosOptions* options);
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
#include "common/jsonconfig.h"
|
||||
bool ffParseBiosJsonObject(FFinstance* instance, const char* type, json_object* module);
|
||||
void ffParseBiosJsonObject(FFinstance* instance, json_object* module);
|
||||
#endif
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#include "detection/bluetooth/bluetooth.h"
|
||||
#include "modules/bluetooth/bluetooth.h"
|
||||
|
||||
#define FF_BLUETOOTH_MODULE_NAME "Bluetooth"
|
||||
#define FF_BLUETOOTH_NUM_FORMAT_ARGS 4
|
||||
|
||||
static void printDevice(FFinstance* instance, FFBluetoothOptions* options, const FFBluetoothDevice* device, uint8_t index)
|
||||
@@ -89,11 +88,8 @@ void ffDestroyBluetoothOptions(FFBluetoothOptions* options)
|
||||
}
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
bool ffParseBluetoothJsonObject(FFinstance* instance, const char* type, json_object* module)
|
||||
void ffParseBluetoothJsonObject(FFinstance* instance, json_object* module)
|
||||
{
|
||||
if (strcasecmp(type, FF_BLUETOOTH_MODULE_NAME) != 0)
|
||||
return false;
|
||||
|
||||
FFBluetoothOptions __attribute__((__cleanup__(ffDestroyBluetoothOptions))) options;
|
||||
ffInitBluetoothOptions(&options);
|
||||
|
||||
@@ -101,9 +97,6 @@ bool ffParseBluetoothJsonObject(FFinstance* instance, const char* type, json_obj
|
||||
{
|
||||
json_object_object_foreach(module, key, val)
|
||||
{
|
||||
if (strcasecmp(key, "type") == 0)
|
||||
continue;
|
||||
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs))
|
||||
continue;
|
||||
|
||||
@@ -118,6 +111,5 @@ bool ffParseBluetoothJsonObject(FFinstance* instance, const char* type, json_obj
|
||||
}
|
||||
|
||||
ffPrintBluetooth(instance, &options);
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
#include "fastfetch.h"
|
||||
|
||||
#define FF_BLUETOOTH_MODULE_NAME "Bluetooth"
|
||||
|
||||
void ffPrintBluetooth(FFinstance* instance, FFBluetoothOptions* options);
|
||||
void ffInitBluetoothOptions(FFBluetoothOptions* options);
|
||||
bool ffParseBluetoothCommandOptions(FFBluetoothOptions* options, const char* key, const char* value);
|
||||
@@ -9,5 +11,5 @@ void ffDestroyBluetoothOptions(FFBluetoothOptions* options);
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
#include "common/jsonconfig.h"
|
||||
bool ffParseBluetoothJsonObject(FFinstance* instance, const char* type, json_object* module);
|
||||
void ffParseBluetoothJsonObject(FFinstance* instance, json_object* module);
|
||||
#endif
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#include "detection/board/board.h"
|
||||
#include "modules/board/board.h"
|
||||
|
||||
#define FF_BOARD_MODULE_NAME "Board"
|
||||
#define FF_BOARD_NUM_FORMAT_ARGS 3
|
||||
|
||||
void ffPrintBoard(FFinstance* instance, FFBoardOptions* options)
|
||||
@@ -66,11 +65,8 @@ void ffDestroyBoardOptions(FFBoardOptions* options)
|
||||
}
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
bool ffParseBoardJsonObject(FFinstance* instance, const char* type, json_object* module)
|
||||
void ffParseBoardJsonObject(FFinstance* instance, json_object* module)
|
||||
{
|
||||
if (strcasecmp(type, FF_BOARD_MODULE_NAME) != 0)
|
||||
return false;
|
||||
|
||||
FFBoardOptions __attribute__((__cleanup__(ffDestroyBoardOptions))) options;
|
||||
ffInitBoardOptions(&options);
|
||||
|
||||
@@ -78,9 +74,6 @@ bool ffParseBoardJsonObject(FFinstance* instance, const char* type, json_object*
|
||||
{
|
||||
json_object_object_foreach(module, key, val)
|
||||
{
|
||||
if (strcasecmp(key, "type") == 0)
|
||||
continue;
|
||||
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs))
|
||||
continue;
|
||||
|
||||
@@ -89,6 +82,5 @@ bool ffParseBoardJsonObject(FFinstance* instance, const char* type, json_object*
|
||||
}
|
||||
|
||||
ffPrintBoard(instance, &options);
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
#include "fastfetch.h"
|
||||
|
||||
#define FF_BOARD_MODULE_NAME "Board"
|
||||
|
||||
void ffPrintBoard(FFinstance* instance, FFBoardOptions* options);
|
||||
void ffInitBoardOptions(FFBoardOptions* options);
|
||||
bool ffParseBoardCommandOptions(FFBoardOptions* options, const char* key, const char* value);
|
||||
@@ -9,5 +11,5 @@ void ffDestroyBoardOptions(FFBoardOptions* options);
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
#include "common/jsonconfig.h"
|
||||
bool ffParseBoardJsonObject(FFinstance* instance, const char* type, json_object* module);
|
||||
void ffParseBoardJsonObject(FFinstance* instance, json_object* module);
|
||||
#endif
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
#include "common/printing.h"
|
||||
#include "modules/break/break.h"
|
||||
|
||||
#define FF_BREAK_MODULE_NAME "Break"
|
||||
|
||||
void ffPrintBreak(FFinstance* instance)
|
||||
{
|
||||
ffLogoPrintLine(instance);
|
||||
@@ -11,12 +9,8 @@ void ffPrintBreak(FFinstance* instance)
|
||||
}
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
bool ffParseBreakJsonObject(FFinstance* instance, const char* type, FF_MAYBE_UNUSED json_object* module)
|
||||
void ffParseBreakJsonObject(FFinstance* instance, FF_MAYBE_UNUSED json_object* module)
|
||||
{
|
||||
if (strcasecmp(type, FF_BREAK_MODULE_NAME) != 0)
|
||||
return false;
|
||||
|
||||
ffPrintBreak(instance);
|
||||
return true;
|
||||
return ffPrintBreak(instance);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -2,9 +2,11 @@
|
||||
|
||||
#include "fastfetch.h"
|
||||
|
||||
#define FF_BREAK_MODULE_NAME "Break"
|
||||
|
||||
void ffPrintBreak(FFinstance* instance);
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
#include "common/jsonconfig.h"
|
||||
bool ffParseBreakJsonObject(FFinstance* instance, const char* type, json_object* module);
|
||||
void ffParseBreakJsonObject(FFinstance* instance, json_object* module);
|
||||
#endif
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#include "detection/brightness/brightness.h"
|
||||
#include "modules/brightness/brightness.h"
|
||||
|
||||
#define FF_BRIGHTNESS_MODULE_NAME "Brightness"
|
||||
#define FF_BRIGHTNESS_NUM_FORMAT_ARGS 2
|
||||
|
||||
void ffPrintBrightness(FFinstance* instance, FFBrightnessOptions* options)
|
||||
@@ -80,11 +79,8 @@ void ffDestroyBrightnessOptions(FFBrightnessOptions* options)
|
||||
}
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
bool ffParseBrightnessJsonObject(FFinstance* instance, const char* type, json_object* module)
|
||||
void ffParseBrightnessJsonObject(FFinstance* instance, json_object* module)
|
||||
{
|
||||
if (strcasecmp(type, FF_BRIGHTNESS_MODULE_NAME) != 0)
|
||||
return false;
|
||||
|
||||
FFBrightnessOptions __attribute__((__cleanup__(ffDestroyBrightnessOptions))) options;
|
||||
ffInitBrightnessOptions(&options);
|
||||
|
||||
@@ -92,9 +88,6 @@ bool ffParseBrightnessJsonObject(FFinstance* instance, const char* type, json_ob
|
||||
{
|
||||
json_object_object_foreach(module, key, val)
|
||||
{
|
||||
if (strcasecmp(key, "type") == 0)
|
||||
continue;
|
||||
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs))
|
||||
continue;
|
||||
|
||||
@@ -103,6 +96,5 @@ bool ffParseBrightnessJsonObject(FFinstance* instance, const char* type, json_ob
|
||||
}
|
||||
|
||||
ffPrintBrightness(instance, &options);
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
#include "fastfetch.h"
|
||||
|
||||
#define FF_BRIGHTNESS_MODULE_NAME "Brightness"
|
||||
|
||||
void ffPrintBrightness(FFinstance* instance, FFBrightnessOptions* options);
|
||||
void ffInitBrightnessOptions(FFBrightnessOptions* options);
|
||||
bool ffParseBrightnessCommandOptions(FFBrightnessOptions* options, const char* key, const char* value);
|
||||
@@ -9,5 +11,5 @@ void ffDestroyBrightnessOptions(FFBrightnessOptions* options);
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
#include "common/jsonconfig.h"
|
||||
bool ffParseBrightnessJsonObject(FFinstance* instance, const char* type, json_object* module);
|
||||
void ffParseBrightnessJsonObject(FFinstance* instance, json_object* module);
|
||||
#endif
|
||||
|
||||
@@ -4,8 +4,6 @@
|
||||
#include "common/processing.h"
|
||||
#include "modules/command/command.h"
|
||||
|
||||
#define FF_COMMAND_MODULE_NAME "Command"
|
||||
|
||||
void ffPrintCommand(FFinstance* instance, FFCommandOptions* options)
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY result;
|
||||
@@ -85,11 +83,8 @@ void ffDestroyCommandOptions(FFCommandOptions* options)
|
||||
}
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
bool ffParseCommandJsonObject(FFinstance* instance, const char* type, json_object* module)
|
||||
void ffParseCommandJsonObject(FFinstance* instance, json_object* module)
|
||||
{
|
||||
if (strcasecmp(type, FF_COMMAND_MODULE_NAME) != 0)
|
||||
return false;
|
||||
|
||||
FFCommandOptions __attribute__((__cleanup__(ffDestroyCommandOptions))) options;
|
||||
ffInitCommandOptions(&options);
|
||||
|
||||
@@ -97,9 +92,6 @@ bool ffParseCommandJsonObject(FFinstance* instance, const char* type, json_objec
|
||||
{
|
||||
json_object_object_foreach(module, key, val)
|
||||
{
|
||||
if (strcasecmp(key, "type") == 0)
|
||||
continue;
|
||||
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs))
|
||||
continue;
|
||||
|
||||
@@ -120,6 +112,5 @@ bool ffParseCommandJsonObject(FFinstance* instance, const char* type, json_objec
|
||||
}
|
||||
|
||||
ffPrintCommand(instance, &options);
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
#include "fastfetch.h"
|
||||
|
||||
#define FF_COMMAND_MODULE_NAME "Command"
|
||||
|
||||
void ffPrintCommand(FFinstance* instance, FFCommandOptions* options);
|
||||
void ffInitCommandOptions(FFCommandOptions* options);
|
||||
bool ffParseCommandCommandOptions(FFCommandOptions* options, const char* key, const char* value);
|
||||
@@ -9,5 +11,5 @@ void ffDestroyCommandOptions(FFCommandOptions* options);
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
#include "common/jsonconfig.h"
|
||||
bool ffParseCommandJsonObject(FFinstance* instance, const char* type, json_object* module);
|
||||
void ffParseCommandJsonObject(FFinstance* instance, json_object* module);
|
||||
#endif
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#include "detection/datetime/datetime.h"
|
||||
#include "modules/datetime/datetime.h"
|
||||
|
||||
#define FF_DATETIME_MODULE_NAME "DateTime"
|
||||
#define FF_DATETIME_DISPLAY_NAME "Date & Time"
|
||||
#define FF_DATETIME_NUM_FORMAT_ARGS 20
|
||||
|
||||
@@ -71,11 +70,8 @@ void ffDestroyDateTimeOptions(FFDateTimeOptions* options)
|
||||
}
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
bool ffParseDateTimeJsonObject(FFinstance* instance, const char* type, json_object* module)
|
||||
void ffParseDateTimeJsonObject(FFinstance* instance, json_object* module)
|
||||
{
|
||||
if (strcasecmp(type, FF_DATETIME_MODULE_NAME) != 0)
|
||||
return false;
|
||||
|
||||
FFDateTimeOptions __attribute__((__cleanup__(ffDestroyDateTimeOptions))) options;
|
||||
ffInitDateTimeOptions(&options);
|
||||
|
||||
@@ -83,9 +79,6 @@ bool ffParseDateTimeJsonObject(FFinstance* instance, const char* type, json_obje
|
||||
{
|
||||
json_object_object_foreach(module, key, val)
|
||||
{
|
||||
if (strcasecmp(key, "type") == 0)
|
||||
continue;
|
||||
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs))
|
||||
continue;
|
||||
|
||||
@@ -94,6 +87,5 @@ bool ffParseDateTimeJsonObject(FFinstance* instance, const char* type, json_obje
|
||||
}
|
||||
|
||||
ffPrintDateTime(instance, &options);
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
#include "fastfetch.h"
|
||||
|
||||
#define FF_DATETIME_MODULE_NAME "DateTime"
|
||||
|
||||
void ffPrintDateTime(FFinstance* instance, FFDateTimeOptions* options);
|
||||
void ffInitDateTimeOptions(FFDateTimeOptions* options);
|
||||
bool ffParseDateTimeCommandOptions(FFDateTimeOptions* options, const char* key, const char* value);
|
||||
@@ -9,5 +11,5 @@ void ffDestroyDateTimeOptions(FFDateTimeOptions* options);
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
#include "common/jsonconfig.h"
|
||||
bool ffParseDateTimeJsonObject(FFinstance* instance, const char* type, json_object* module);
|
||||
void ffParseDateTimeJsonObject(FFinstance* instance, json_object* module);
|
||||
#endif
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#include "detection/displayserver/displayserver.h"
|
||||
#include "modules/display/display.h"
|
||||
|
||||
#define FF_DISPLAY_MODULE_NAME "Display"
|
||||
#define FF_DISPLAY_NUM_FORMAT_ARGS 7
|
||||
|
||||
void ffPrintDisplay(FFinstance* instance, FFDisplayOptions* options)
|
||||
@@ -159,11 +158,8 @@ void ffDestroyDisplayOptions(FFDisplayOptions* options)
|
||||
}
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
bool ffParseDisplayJsonObject(FFinstance* instance, const char* type, json_object* module)
|
||||
void ffParseDisplayJsonObject(FFinstance* instance, json_object* module)
|
||||
{
|
||||
if (strcasecmp(type, FF_DISPLAY_MODULE_NAME) != 0)
|
||||
return false;
|
||||
|
||||
FFDisplayOptions __attribute__((__cleanup__(ffDestroyDisplayOptions))) options;
|
||||
ffInitDisplayOptions(&options);
|
||||
|
||||
@@ -171,9 +167,6 @@ bool ffParseDisplayJsonObject(FFinstance* instance, const char* type, json_objec
|
||||
{
|
||||
json_object_object_foreach(module, key, val)
|
||||
{
|
||||
if (strcasecmp(key, "type") == 0)
|
||||
continue;
|
||||
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs))
|
||||
continue;
|
||||
|
||||
@@ -210,6 +203,5 @@ bool ffParseDisplayJsonObject(FFinstance* instance, const char* type, json_objec
|
||||
}
|
||||
|
||||
ffPrintDisplay(instance, &options);
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
#include "fastfetch.h"
|
||||
|
||||
#define FF_DISPLAY_MODULE_NAME "Display"
|
||||
|
||||
void ffPrintDisplay(FFinstance* instance, FFDisplayOptions* options);
|
||||
void ffInitDisplayOptions(FFDisplayOptions* options);
|
||||
bool ffParseDisplayCommandOptions(FFDisplayOptions* options, const char* key, const char* value);
|
||||
@@ -9,5 +11,5 @@ void ffDestroyDisplayOptions(FFDisplayOptions* options);
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
#include "common/jsonconfig.h"
|
||||
bool ffParseDisplayJsonObject(FFinstance* instance, const char* type, json_object* module);
|
||||
void ffParseDisplayJsonObject(FFinstance* instance, json_object* module);
|
||||
#endif
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#include "detection/host/host.h"
|
||||
#include "modules/host/host.h"
|
||||
|
||||
#define FF_HOST_MODULE_NAME "Host"
|
||||
#define FF_HOST_NUM_FORMAT_ARGS 5
|
||||
|
||||
void ffPrintHost(FFinstance* instance, FFHostOptions* options)
|
||||
@@ -77,11 +76,8 @@ void ffDestroyHostOptions(FFHostOptions* options)
|
||||
}
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
bool ffParseHostJsonObject(FFinstance* instance, const char* type, json_object* module)
|
||||
void ffParseHostJsonObject(FFinstance* instance, json_object* module)
|
||||
{
|
||||
if (strcasecmp(type, FF_HOST_MODULE_NAME) != 0)
|
||||
return false;
|
||||
|
||||
FFHostOptions __attribute__((__cleanup__(ffDestroyHostOptions))) options;
|
||||
ffInitHostOptions(&options);
|
||||
|
||||
@@ -89,9 +85,6 @@ bool ffParseHostJsonObject(FFinstance* instance, const char* type, json_object*
|
||||
{
|
||||
json_object_object_foreach(module, key, val)
|
||||
{
|
||||
if (strcasecmp(key, "type") == 0)
|
||||
continue;
|
||||
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs))
|
||||
continue;
|
||||
|
||||
@@ -100,6 +93,5 @@ bool ffParseHostJsonObject(FFinstance* instance, const char* type, json_object*
|
||||
}
|
||||
|
||||
ffPrintHost(instance, &options);
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
#include "fastfetch.h"
|
||||
|
||||
#define FF_HOST_MODULE_NAME "Host"
|
||||
|
||||
void ffPrintHost(FFinstance* instance, FFHostOptions* options);
|
||||
void ffInitHostOptions(FFHostOptions* options);
|
||||
bool ffParseHostCommandOptions(FFHostOptions* options, const char* key, const char* value);
|
||||
@@ -9,5 +11,5 @@ void ffDestroyHostOptions(FFHostOptions* options);
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
#include "common/jsonconfig.h"
|
||||
bool ffParseHostJsonObject(FFinstance* instance, const char* type, json_object* module);
|
||||
void ffParseHostJsonObject(FFinstance* instance, json_object* module);
|
||||
#endif
|
||||
|
||||
@@ -9,25 +9,80 @@
|
||||
#include "modules/modules.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
|
||||
static inline bool parseModuleJsonObject(FFinstance* instance, const char* type, json_object* module)
|
||||
static inline bool tryModule(FFinstance* instance, const char* type, json_object* module, const char* moduleName, void (*const f)(FFinstance *instance, json_object *module))
|
||||
{
|
||||
return
|
||||
ffParseTitleJsonObject(instance, type, module) ||
|
||||
ffParseBatteryJsonObject(instance, type, module) ||
|
||||
ffParseBiosJsonObject(instance, type, module) ||
|
||||
ffParseBluetoothJsonObject(instance, type, module) ||
|
||||
ffParseBoardJsonObject(instance, type, module) ||
|
||||
ffParseBreakJsonObject(instance, type, module) ||
|
||||
ffParseBrightnessJsonObject(instance, type, module) ||
|
||||
ffParseCommandJsonObject(instance, type, module) ||
|
||||
ffParseDateTimeJsonObject(instance, type, module) ||
|
||||
ffParseDisplayJsonObject(instance, type, module) ||
|
||||
ffParseHostJsonObject(instance, type, module) ||
|
||||
ffParseKernelJsonObject(instance, type, module) ||
|
||||
ffParseOSJsonObject(instance, type, module) ||
|
||||
ffParseSeparatorJsonObject(instance, type, module) ||
|
||||
false;
|
||||
if (strcasecmp(type, moduleName) == 0)
|
||||
{
|
||||
if (module) json_object_object_del(module, "type"); // this line frees `type`
|
||||
f(instance, module);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool parseModuleJsonObject(FFinstance* instance, const char* type, json_object* module)
|
||||
{
|
||||
switch (toupper(type[0]))
|
||||
{
|
||||
case 'B': {
|
||||
return
|
||||
tryModule(instance, type, module, FF_BATTERY_MODULE_NAME, ffParseBatteryJsonObject) ||
|
||||
tryModule(instance, type, module, FF_BIOS_MODULE_NAME, ffParseBiosJsonObject) ||
|
||||
tryModule(instance, type, module, FF_BLUETOOTH_MODULE_NAME, ffParseBluetoothJsonObject) ||
|
||||
tryModule(instance, type, module, FF_BOARD_MODULE_NAME, ffParseBoardJsonObject) ||
|
||||
tryModule(instance, type, module, FF_BREAK_MODULE_NAME, ffParseBreakJsonObject) ||
|
||||
tryModule(instance, type, module, FF_BRIGHTNESS_MODULE_NAME, ffParseBrightnessJsonObject) ||
|
||||
false;
|
||||
}
|
||||
|
||||
case 'C': {
|
||||
return
|
||||
tryModule(instance, type, module, FF_COMMAND_MODULE_NAME, ffParseCommandJsonObject) ||
|
||||
false;
|
||||
}
|
||||
|
||||
case 'D': {
|
||||
return
|
||||
tryModule(instance, type, module, FF_DATETIME_MODULE_NAME, ffParseDateTimeJsonObject) ||
|
||||
tryModule(instance, type, module, FF_DISPLAY_MODULE_NAME, ffParseDisplayJsonObject) ||
|
||||
false;
|
||||
}
|
||||
|
||||
case 'H': {
|
||||
return
|
||||
tryModule(instance, type, module, FF_HOST_MODULE_NAME, ffParseHostJsonObject) ||
|
||||
false;
|
||||
}
|
||||
|
||||
case 'K': {
|
||||
return
|
||||
tryModule(instance, type, module, FF_KERNEL_MODULE_NAME, ffParseKernelJsonObject) ||
|
||||
false;
|
||||
}
|
||||
|
||||
case 'O': {
|
||||
return
|
||||
tryModule(instance, type, module, FF_OS_MODULE_NAME, ffParseOSJsonObject) ||
|
||||
false;
|
||||
}
|
||||
|
||||
case 'S': {
|
||||
return
|
||||
tryModule(instance, type, module, FF_SEPARATOR_MODULE_NAME, ffParseSeparatorJsonObject) ||
|
||||
false;
|
||||
}
|
||||
|
||||
case 'T': {
|
||||
return
|
||||
tryModule(instance, type, module, FF_TITLE_MODULE_NAME, ffParseTitleJsonObject) ||
|
||||
false;
|
||||
}
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static const char* parseModules(FFinstance* instance, json_object* modules)
|
||||
@@ -48,7 +103,9 @@ static const char* parseModules(FFinstance* instance, json_object* modules)
|
||||
{
|
||||
json_object* object = json_object_object_get(module, "type");
|
||||
type = json_object_get_string(object);
|
||||
if (!type) return "module object must contain a type key";
|
||||
if (!type) return "module object must contain a \"type\" key ( case sensitive )";
|
||||
if (json_object_object_length(module) == 1) // contains only Property type
|
||||
module = NULL;
|
||||
}
|
||||
else
|
||||
return "modules must be an array of strings or objects";
|
||||
|
||||
@@ -2,4 +2,6 @@
|
||||
|
||||
#include "fastfetch.h"
|
||||
|
||||
#define FF_JSONCONFIG_MODULE_NAME "JsonConfig"
|
||||
|
||||
void ffPrintJsonConfig(FFinstance* instance);
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#include "common/printing.h"
|
||||
#include "modules/kernel/kernel.h"
|
||||
|
||||
#define FF_KERNEL_MODULE_NAME "Kernel"
|
||||
#define FF_KERNEL_NUM_FORMAT_ARGS 4
|
||||
|
||||
void ffPrintKernel(FFinstance* instance, FFKernelOptions* options)
|
||||
@@ -52,11 +51,8 @@ void ffDestroyKernelOptions(FFKernelOptions* options)
|
||||
}
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
bool ffParseKernelJsonObject(FFinstance* instance, const char* type, json_object* module)
|
||||
void ffParseKernelJsonObject(FFinstance* instance, json_object* module)
|
||||
{
|
||||
if (strcasecmp(type, FF_KERNEL_MODULE_NAME) != 0)
|
||||
return false;
|
||||
|
||||
FFKernelOptions __attribute__((__cleanup__(ffDestroyKernelOptions))) options;
|
||||
ffInitKernelOptions(&options);
|
||||
|
||||
@@ -64,9 +60,6 @@ bool ffParseKernelJsonObject(FFinstance* instance, const char* type, json_object
|
||||
{
|
||||
json_object_object_foreach(module, key, val)
|
||||
{
|
||||
if (strcasecmp(key, "type") == 0)
|
||||
continue;
|
||||
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs))
|
||||
continue;
|
||||
|
||||
@@ -75,6 +68,5 @@ bool ffParseKernelJsonObject(FFinstance* instance, const char* type, json_object
|
||||
}
|
||||
|
||||
ffPrintKernel(instance, &options);
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
#include "fastfetch.h"
|
||||
#include "modules/kernel/option.h"
|
||||
|
||||
#define FF_KERNEL_MODULE_NAME "Kernel"
|
||||
|
||||
void ffPrintKernel(FFinstance* instance, FFKernelOptions* options);
|
||||
void ffInitKernelOptions(FFKernelOptions* options);
|
||||
bool ffParseKernelCommandOptions(FFKernelOptions* options, const char* key, const char* value);
|
||||
@@ -10,5 +12,5 @@ void ffDestroyKernelOptions(FFKernelOptions* options);
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
#include "common/jsonconfig.h"
|
||||
bool ffParseKernelJsonObject(FFinstance* instance, const char* type, json_object* module);
|
||||
void ffParseKernelJsonObject(FFinstance* instance, json_object* module);
|
||||
#endif
|
||||
|
||||
+1
-9
@@ -6,7 +6,6 @@
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
#define FF_OS_MODULE_NAME "OS"
|
||||
#define FF_OS_NUM_FORMAT_ARGS 12
|
||||
|
||||
static void buildOutputDefault(const FFinstance* instance, const FFOSResult* os, FFstrbuf* result)
|
||||
@@ -175,11 +174,8 @@ void ffDestroyOSOptions(FFOSOptions* options)
|
||||
}
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
bool ffParseOSJsonObject(FFinstance* instance, const char* type, json_object* module)
|
||||
void ffParseOSJsonObject(FFinstance* instance, json_object* module)
|
||||
{
|
||||
if (strcasecmp(type, FF_OS_MODULE_NAME) != 0)
|
||||
return false;
|
||||
|
||||
FFOSOptions __attribute__((__cleanup__(ffDestroyOSOptions))) options;
|
||||
ffInitOSOptions(&options);
|
||||
|
||||
@@ -187,9 +183,6 @@ bool ffParseOSJsonObject(FFinstance* instance, const char* type, json_object* mo
|
||||
{
|
||||
json_object_object_foreach(module, key, val)
|
||||
{
|
||||
if (strcasecmp(key, "type") == 0)
|
||||
continue;
|
||||
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs))
|
||||
continue;
|
||||
|
||||
@@ -206,6 +199,5 @@ bool ffParseOSJsonObject(FFinstance* instance, const char* type, json_object* mo
|
||||
}
|
||||
|
||||
ffPrintOS(instance, &options);
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
+3
-1
@@ -3,6 +3,8 @@
|
||||
#include "fastfetch.h"
|
||||
#include "modules/os/option.h"
|
||||
|
||||
#define FF_OS_MODULE_NAME "OS"
|
||||
|
||||
void ffPrintOS(FFinstance* instance, FFOSOptions* options);
|
||||
void ffInitOSOptions(FFOSOptions* options);
|
||||
bool ffParseOSCommandOptions(FFOSOptions* options, const char* key, const char* value);
|
||||
@@ -10,5 +12,5 @@ void ffDestroyOSOptions(FFOSOptions* options);
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
#include "common/jsonconfig.h"
|
||||
bool ffParseOSJsonObject(FFinstance* instance, const char* type, json_object* module);
|
||||
void ffParseOSJsonObject(FFinstance* instance, json_object* module);
|
||||
#endif
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
#include "common/printing.h"
|
||||
#include "modules/separator/separator.h"
|
||||
|
||||
#define FF_SEPARATOR_MODULE_NAME "Separator"
|
||||
|
||||
void ffPrintSeparator(FFinstance* instance, FFSeparatorOptions* options)
|
||||
{
|
||||
uint32_t titleLength = instance->state.titleLength;
|
||||
@@ -61,11 +59,8 @@ void ffDestroySeparatorOptions(FFSeparatorOptions* options)
|
||||
}
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
bool ffParseSeparatorJsonObject(FFinstance* instance, const char* type, json_object* module)
|
||||
void ffParseSeparatorJsonObject(FFinstance* instance, json_object* module)
|
||||
{
|
||||
if (strcasecmp(type, FF_SEPARATOR_MODULE_NAME) != 0)
|
||||
return false;
|
||||
|
||||
FFSeparatorOptions __attribute__((__cleanup__(ffDestroySeparatorOptions))) options;
|
||||
ffInitSeparatorOptions(&options);
|
||||
|
||||
@@ -73,9 +68,6 @@ bool ffParseSeparatorJsonObject(FFinstance* instance, const char* type, json_obj
|
||||
{
|
||||
json_object_object_foreach(module, key, val)
|
||||
{
|
||||
if (strcasecmp(key, "type") == 0)
|
||||
continue;
|
||||
|
||||
if (strcasecmp(key, "string") == 0)
|
||||
{
|
||||
ffStrbufSetS(&options.string, json_object_get_string(val));
|
||||
@@ -87,6 +79,5 @@ bool ffParseSeparatorJsonObject(FFinstance* instance, const char* type, json_obj
|
||||
}
|
||||
|
||||
ffPrintSeparator(instance, &options);
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
#include "fastfetch.h"
|
||||
#include "modules/separator/option.h"
|
||||
|
||||
#define FF_SEPARATOR_MODULE_NAME "Separator"
|
||||
|
||||
void ffPrintSeparator(FFinstance* instance, FFSeparatorOptions* options);
|
||||
void ffInitSeparatorOptions(FFSeparatorOptions* options);
|
||||
bool ffParseSeparatorCommandOptions(FFSeparatorOptions* options, const char* key, const char* value);
|
||||
@@ -10,5 +12,5 @@ void ffDestroySeparatorOptions(FFSeparatorOptions* options);
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
#include "common/jsonconfig.h"
|
||||
bool ffParseSeparatorJsonObject(FFinstance* instance, const char* type, json_object* module);
|
||||
void ffParseSeparatorJsonObject(FFinstance* instance, json_object* module);
|
||||
#endif
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
#include "util/textModifier.h"
|
||||
#include "modules/title/title.h"
|
||||
|
||||
#define FF_TITLE_MODULE_NAME "Title"
|
||||
|
||||
static inline void printTitlePart(FFinstance* instance, const FFstrbuf* content)
|
||||
{
|
||||
if(!instance->config.pipe)
|
||||
@@ -61,11 +59,8 @@ void ffDestroyTitleOptions(FFTitleOptions* options)
|
||||
}
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
bool ffParseTitleJsonObject(FFinstance* instance, const char* type, json_object* module)
|
||||
void ffParseTitleJsonObject(FFinstance* instance, json_object* module)
|
||||
{
|
||||
if (strcasecmp(type, FF_TITLE_MODULE_NAME) != 0)
|
||||
return false;
|
||||
|
||||
FFTitleOptions __attribute__((__cleanup__(ffDestroyTitleOptions))) options;
|
||||
ffInitTitleOptions(&options);
|
||||
|
||||
@@ -73,9 +68,6 @@ bool ffParseTitleJsonObject(FFinstance* instance, const char* type, json_object*
|
||||
{
|
||||
json_object_object_foreach(module, key, val)
|
||||
{
|
||||
if (strcasecmp(key, "type") == 0)
|
||||
continue;
|
||||
|
||||
if (strcasecmp(key, "fdqn") == 0)
|
||||
{
|
||||
options.fdqn = json_object_get_boolean(val);
|
||||
@@ -87,6 +79,5 @@ bool ffParseTitleJsonObject(FFinstance* instance, const char* type, json_object*
|
||||
}
|
||||
|
||||
ffPrintTitle(instance, &options);
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
#include "fastfetch.h"
|
||||
#include "modules/title/option.h"
|
||||
|
||||
#define FF_TITLE_MODULE_NAME "Title"
|
||||
|
||||
void ffPrintTitle(FFinstance* instance, FFTitleOptions* options);
|
||||
void ffInitTitleOptions(FFTitleOptions* options);
|
||||
bool ffParseTitleCommandOptions(FFTitleOptions* options, const char* key, const char* value);
|
||||
@@ -10,5 +12,5 @@ void ffDestroyTitleOptions(FFTitleOptions* options);
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
#include "common/jsonconfig.h"
|
||||
bool ffParseTitleJsonObject(FFinstance* instance, const char* type, json_object* module);
|
||||
void ffParseTitleJsonObject(FFinstance* instance, json_object* module);
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user