JsonConfig: simplify code

This commit is contained in:
李通洲
2023-03-15 16:54:50 +08:00
parent dca9ce4b2d
commit ff721218f5
32 changed files with 162 additions and 172 deletions
+1 -9
View File
@@ -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
+3 -1
View File
@@ -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