mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-29 16:26:39 +01:00
Global: drop json-c and switch to yyjson
This commit is contained in:
+14
-10
@@ -1,5 +1,5 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/printing.h"
|
||||
#include "common/jsonconfig.h"
|
||||
#include "common/parsing.h"
|
||||
#include "common/bar.h"
|
||||
#include "detection/disk/disk.h"
|
||||
@@ -222,28 +222,33 @@ void ffDestroyDiskOptions(FFDiskOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
void ffParseDiskJsonObject(FFinstance* instance, json_object* module)
|
||||
void ffParseDiskJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
{
|
||||
FFDiskOptions __attribute__((__cleanup__(ffDestroyDiskOptions))) options;
|
||||
ffInitDiskOptions(&options);
|
||||
|
||||
if (module)
|
||||
{
|
||||
json_object_object_foreach(module, key, val)
|
||||
yyjson_val *key_, *val;
|
||||
size_t idx, max;
|
||||
yyjson_obj_foreach(module, idx, max, key_, val)
|
||||
{
|
||||
const char* key = yyjson_get_str(key_);
|
||||
if(strcasecmp(key, "type") == 0)
|
||||
continue;
|
||||
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs))
|
||||
continue;
|
||||
|
||||
if (strcasecmp(key, "folders") == 0)
|
||||
{
|
||||
ffStrbufSetS(&options.folders, json_object_get_string(val));
|
||||
ffStrbufSetS(&options.folders, yyjson_get_str(val));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (strcasecmp(key, "showRemovable") == 0)
|
||||
{
|
||||
if (json_object_get_boolean(val))
|
||||
if (yyjson_get_bool(val))
|
||||
options.showTypes |= FF_DISK_TYPE_EXTERNAL_BIT;
|
||||
else
|
||||
options.showTypes &= ~FF_DISK_TYPE_EXTERNAL_BIT;
|
||||
@@ -252,7 +257,7 @@ void ffParseDiskJsonObject(FFinstance* instance, json_object* module)
|
||||
|
||||
if (strcasecmp(key, "showHidden") == 0)
|
||||
{
|
||||
if (json_object_get_boolean(val))
|
||||
if (yyjson_get_bool(val))
|
||||
options.showTypes |= FF_DISK_TYPE_HIDDEN_BIT;
|
||||
else
|
||||
options.showTypes &= ~FF_DISK_TYPE_HIDDEN_BIT;
|
||||
@@ -261,7 +266,7 @@ void ffParseDiskJsonObject(FFinstance* instance, json_object* module)
|
||||
|
||||
if (strcasecmp(key, "showSubvolumes") == 0)
|
||||
{
|
||||
if (json_object_get_boolean(val))
|
||||
if (yyjson_get_bool(val))
|
||||
options.showTypes |= FF_DISK_TYPE_SUBVOLUME_BIT;
|
||||
else
|
||||
options.showTypes &= ~FF_DISK_TYPE_SUBVOLUME_BIT;
|
||||
@@ -270,7 +275,7 @@ void ffParseDiskJsonObject(FFinstance* instance, json_object* module)
|
||||
|
||||
if (strcasecmp(key, "show-unknown") == 0)
|
||||
{
|
||||
if (json_object_get_boolean(val))
|
||||
if (yyjson_get_bool(val))
|
||||
options.showTypes |= FF_DISK_TYPE_UNKNOWN_BIT;
|
||||
else
|
||||
options.showTypes &= ~FF_DISK_TYPE_UNKNOWN_BIT;
|
||||
@@ -283,4 +288,3 @@ void ffParseDiskJsonObject(FFinstance* instance, json_object* module)
|
||||
|
||||
ffPrintDisk(instance, &options);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "fastfetch.h"
|
||||
#include <yyjson.h>
|
||||
|
||||
#define FF_DISK_MODULE_NAME "Disk"
|
||||
|
||||
@@ -8,8 +9,4 @@ void ffPrintDisk(FFinstance* instance, FFDiskOptions* options);
|
||||
void ffInitDiskOptions(FFDiskOptions* options);
|
||||
bool ffParseDiskCommandOptions(FFDiskOptions* options, const char* key, const char* value);
|
||||
void ffDestroyDiskOptions(FFDiskOptions* options);
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
#include "common/jsonconfig.h"
|
||||
void ffParseDiskJsonObject(FFinstance* instance, json_object* module);
|
||||
#endif
|
||||
void ffParseDiskJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
|
||||
Reference in New Issue
Block a user