mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-12 10:22:12 +02:00
Global: drop json-c and switch to yyjson
This commit is contained in:
@@ -21,7 +21,7 @@ jobs:
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: install required packages
|
||||
run: sudo apt-get update && sudo apt-get install -y libpci-dev libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libmagickcore-dev libxfconf-0-dev libsqlite3-dev rpm librpm-dev libzstd-dev libegl-dev libglx-dev libosmesa6-dev ocl-icd-opencl-dev libnm-dev libpulse-dev libjson-c-dev
|
||||
run: sudo apt-get update && sudo apt-get install -y libpci-dev libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libmagickcore-dev libxfconf-0-dev libsqlite3-dev rpm librpm-dev libzstd-dev libegl-dev libglx-dev libosmesa6-dev ocl-icd-opencl-dev libnm-dev libpulse-dev
|
||||
|
||||
- name: configure project
|
||||
env:
|
||||
@@ -53,7 +53,7 @@ jobs:
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: install required packages
|
||||
run: sudo apt-get update && sudo apt-get install -y libpci-dev libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libmagickcore-dev libxfconf-0-dev libsqlite3-dev rpm librpm-dev libzstd-dev libegl-dev libglx-dev libosmesa6-dev ocl-icd-opencl-dev libnm-dev libpulse-dev libjson-c-dev
|
||||
run: sudo apt-get update && sudo apt-get install -y libpci-dev libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libmagickcore-dev libxfconf-0-dev libsqlite3-dev rpm librpm-dev libzstd-dev libegl-dev libglx-dev libosmesa6-dev ocl-icd-opencl-dev libnm-dev libpulse-dev
|
||||
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v2
|
||||
@@ -183,7 +183,7 @@ jobs:
|
||||
with:
|
||||
msystem: CLANG64
|
||||
update: true
|
||||
install: git zip mingw-w64-clang-x86_64-cmake mingw-w64-clang-x86_64-clang mingw-w64-clang-x86_64-vulkan-loader mingw-w64-clang-x86_64-opencl-icd mingw-w64-clang-x86_64-json-c
|
||||
install: git zip mingw-w64-clang-x86_64-cmake mingw-w64-clang-x86_64-clang mingw-w64-clang-x86_64-vulkan-loader mingw-w64-clang-x86_64-opencl-icd
|
||||
|
||||
- name: print msys version
|
||||
run: uname -a
|
||||
@@ -203,7 +203,7 @@ jobs:
|
||||
uses: github/codeql-action/analyze@v2
|
||||
|
||||
- name: copy necessary dlls
|
||||
run: cp /clang64/bin/{libjson-c*,OpenCL,vulkan-1}.dll .
|
||||
run: cp /clang64/bin/{OpenCL,vulkan-1}.dll .
|
||||
|
||||
- name: list features
|
||||
run: ./fastfetch --list-features
|
||||
@@ -244,7 +244,7 @@ jobs:
|
||||
with:
|
||||
msystem: CLANG32
|
||||
update: true
|
||||
install: git zip mingw-w64-clang-i686-cmake mingw-w64-clang-i686-clang mingw-w64-clang-i686-vulkan-loader mingw-w64-clang-i686-opencl-icd mingw-w64-clang-i686-json-c
|
||||
install: git zip mingw-w64-clang-i686-cmake mingw-w64-clang-i686-clang mingw-w64-clang-i686-vulkan-loader mingw-w64-clang-i686-opencl-icd
|
||||
|
||||
- name: print msys version
|
||||
run: uname -a
|
||||
@@ -264,7 +264,7 @@ jobs:
|
||||
uses: github/codeql-action/analyze@v2
|
||||
|
||||
- name: copy necessary dlls
|
||||
run: cp /clang32/bin/{libjson-c*,OpenCL,vulkan-1}.dll .
|
||||
run: cp /clang32/bin/{OpenCL,vulkan-1}.dll .
|
||||
|
||||
- name: run fastfetch
|
||||
run: time ./fastfetch --disable-linewrap false --hide-cursor false --show-errors true --load-config presets/all
|
||||
|
||||
+7
-3
@@ -1,3 +1,10 @@
|
||||
# 2.0.0
|
||||
|
||||
This release introduces a new configuration file format: JSON config
|
||||
|
||||
Changes:
|
||||
* Drop the dependency of cJSON. We now use [yyjson](https://ibireme.github.io/yyjson/doc/doxygen/html/index.html) to parse JSON documents.
|
||||
|
||||
# 1.11.3
|
||||
|
||||
Bugfixes:
|
||||
@@ -68,9 +75,6 @@ Bugfixes:
|
||||
* Don't exit if libpci is failed to init (GPU, Linux, #433)
|
||||
* Names of most well-known gamepads are correctly printed instead of `Wireless Controller` on Windows
|
||||
|
||||
Changes:
|
||||
* Use json-c to parse JSON strings for comments support, instead of using unmaintained cJSON
|
||||
|
||||
Logo:
|
||||
* Small update for nobara logo (#435, @regulargvy13)
|
||||
|
||||
|
||||
+2
-6
@@ -78,7 +78,6 @@ cmake_dependent_option(ENABLE_OPENCL "Enable opencl" ON "LINUX OR BSD OR WIN32"
|
||||
cmake_dependent_option(ENABLE_LIBNM "Enable libnm" ON "LINUX" OFF)
|
||||
cmake_dependent_option(ENABLE_FREETYPE "Enable freetype" ON "ANDROID" OFF)
|
||||
cmake_dependent_option(ENABLE_PULSE "Enable pulse" ON "LINUX OR BSD" OFF)
|
||||
cmake_dependent_option(ENABLE_JSONC "Enable json-c" ON "LINUX OR APPLE OR BSD OR WIN32 OR ANDROID" OFF)
|
||||
cmake_dependent_option(ENABLE_THREADS "Enable multithreading" ON "Threads_FOUND" OFF)
|
||||
cmake_dependent_option(ENABLE_BUFFER "Enable stdout buffer" ON "LINUX OR APPLE OR BSD OR WIN32 OR ANDROID" OFF)
|
||||
|
||||
@@ -239,7 +238,6 @@ set(LIBFASTFETCH_SRC
|
||||
src/common/font.c
|
||||
src/common/format.c
|
||||
src/common/init.c
|
||||
src/common/json.c
|
||||
src/common/jsonconfig.c
|
||||
src/common/library.c
|
||||
src/common/option.c
|
||||
@@ -710,10 +708,6 @@ ff_lib_enable(PULSE
|
||||
"libpulse"
|
||||
"Pulse"
|
||||
)
|
||||
ff_lib_enable(JSONC
|
||||
"json-c"
|
||||
"json-c"
|
||||
)
|
||||
|
||||
if(ENABLE_THREADS)
|
||||
target_compile_definitions(libfastfetch PRIVATE FF_HAVE_THREADS)
|
||||
@@ -784,6 +778,7 @@ target_compile_definitions(fastfetch
|
||||
)
|
||||
target_link_libraries(fastfetch
|
||||
PRIVATE libfastfetch
|
||||
PRIVATE yyjson
|
||||
)
|
||||
|
||||
add_executable(flashfetch
|
||||
@@ -794,6 +789,7 @@ target_compile_definitions(flashfetch
|
||||
)
|
||||
target_link_libraries(flashfetch
|
||||
PRIVATE libfastfetch
|
||||
PRIVATE yyjson
|
||||
)
|
||||
|
||||
if(ENABLE_BUFFER) # FF_ENABLE_BUFFER is used in fastfetch.c
|
||||
|
||||
@@ -53,7 +53,6 @@ The following libraries are used if present at runtime:
|
||||
* [`libXFConf`](https://gitlab.xfce.org/xfce/xfconf): Needed for XFWM theme and XFCE Terminal font.
|
||||
* [`libsqlite3`](https://www.sqlite.org/index.html): Needed for pkg & rpm package count.
|
||||
* [`librpm`](http://rpm.org/): Slower fallback for rpm package count. Needed on openSUSE.
|
||||
* [`json-c`](https://github.com/json-c/json-c): Needed for Windows Terminal font ( WSL ).
|
||||
* [`libnm`](https://networkmanager.dev/docs/libnm/latest/): Used for Wifi detection.
|
||||
* [`libpulse`](https://freedesktop.org/software/pulseaudio/doxygen/): Used for Sound detection.
|
||||
|
||||
@@ -71,7 +70,6 @@ For the image logo, iTerm with iterm image protocol should work. Apple Terminal
|
||||
### Windows
|
||||
|
||||
* [`wlanapi`](https://learn.microsoft.com/en-us/windows/win32/api/wlanapi/): A system dll which isn't supported by Windows Server by default. Used for Wifi info detection.
|
||||
* [`json-c`](https://github.com/json-c/json-c): Used for Windows Terminal font detection. [`json-c`](https://github.com/msys2/MINGW-packages/tree/master/mingw-w64-json-c)
|
||||
* [`libvulkan`](https://www.vulkan.org/): Vulkan module. Usually has been provided by GPU drivers. [`vulkan-loader`](https://github.com/msys2/MINGW-packages/tree/master/mingw-w64-vulkan-loader) [`vulkan-headers`](https://github.com/msys2/MINGW-packages/tree/master/mingw-w64-vulkan-headers)
|
||||
* [`libOpenCL`](https://www.khronos.org/opencl/): OpenCL module. [`opencl-icd`](https://github.com/msys2/MINGW-packages/tree/master/mingw-w64-opencl-icd)
|
||||
|
||||
@@ -138,7 +136,7 @@ Currently GCC or clang is required (MSVC is not supported). MSYS2 with CLANG64 s
|
||||
1. Open `MSYS2 / CLANG64` (not `MSYS2 / MSYS`, which targets cygwin C runtime)
|
||||
1. Install dependencies
|
||||
```bash
|
||||
pacman -Syu mingw-w64-clang-x86_64-cmake mingw-w64-clang-x86_64-pkgconf mingw-w64-clang-x86_64-clang mingw-w64-clang-x86_64-json-c mingw-w64-clang-x86_64-vulkan-loader mingw-w64-clang-x86_64-opencl-icd
|
||||
pacman -Syu mingw-w64-clang-x86_64-cmake mingw-w64-clang-x86_64-pkgconf mingw-w64-clang-x86_64-clang mingw-w64-clang-x86_64-vulkan-loader mingw-w64-clang-x86_64-opencl-icd
|
||||
```
|
||||
|
||||
Follow the building instructions of Linux next.
|
||||
|
||||
@@ -119,7 +119,6 @@ static void defaultConfig(FFinstance* instance)
|
||||
ffStrbufInit(&instance->config.libGLX);
|
||||
ffStrbufInit(&instance->config.libOSMesa);
|
||||
ffStrbufInit(&instance->config.libOpenCL);
|
||||
ffStrbufInit(&instance->config.libJSONC);
|
||||
ffStrbufInit(&instance->config.libfreetype);
|
||||
ffStrbufInit(&instance->config.libPulse);
|
||||
ffStrbufInit(&instance->config.libwlanapi);
|
||||
@@ -323,7 +322,6 @@ static void destroyConfig(FFinstance* instance)
|
||||
ffStrbufDestroy(&instance->config.libGLX);
|
||||
ffStrbufDestroy(&instance->config.libOSMesa);
|
||||
ffStrbufDestroy(&instance->config.libOpenCL);
|
||||
ffStrbufDestroy(&instance->config.libJSONC);
|
||||
ffStrbufDestroy(&instance->config.libfreetype);
|
||||
ffStrbufDestroy(&instance->config.libPulse);
|
||||
ffStrbufDestroy(&instance->config.libwlanapi);
|
||||
@@ -411,9 +409,6 @@ void ffListFeatures()
|
||||
#ifdef FF_HAVE_OPENCL
|
||||
"opencl\n"
|
||||
#endif
|
||||
#ifdef FF_HAVE_LIBJSONC
|
||||
"json-c\n"
|
||||
#endif
|
||||
#ifdef FF_HAVE_FREETYPE
|
||||
"freetype\n"
|
||||
#endif
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
#include "common/json.h"
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
|
||||
#include "common/thread.h"
|
||||
|
||||
static const FFJsonLibrary* loadLibSymbols(const FFinstance* instance)
|
||||
{
|
||||
assert(instance);
|
||||
|
||||
static FFJsonLibrary lib;
|
||||
FF_LIBRARY_LOAD(libjsonc, &instance->config.libJSONC, NULL,
|
||||
#ifdef _WIN32
|
||||
"libjson-c-5" FF_LIBRARY_EXTENSION, -1
|
||||
#else
|
||||
"libjson-c" FF_LIBRARY_EXTENSION, 5
|
||||
#endif
|
||||
)
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR(libjsonc, lib, json_tokener_parse, NULL)
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR(libjsonc, lib, json_object_is_type, NULL)
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR(libjsonc, lib, json_object_get_array, NULL)
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR(libjsonc, lib, json_object_get_boolean, NULL)
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR(libjsonc, lib, json_object_get_double, NULL)
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR(libjsonc, lib, json_object_get_int, NULL)
|
||||
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;
|
||||
}
|
||||
|
||||
const FFJsonLibrary* ffJsonLib = NULL;
|
||||
bool ffJsonLoadLibrary(const FFinstance* instance)
|
||||
{
|
||||
static bool loaded = false;
|
||||
static FFThreadMutex mutex = FF_THREAD_MUTEX_INITIALIZER;
|
||||
|
||||
if (!loaded)
|
||||
{
|
||||
ffThreadMutexLock(&mutex);
|
||||
|
||||
if(!loaded)
|
||||
{
|
||||
loaded = true;
|
||||
ffJsonLib = loadLibSymbols(instance);
|
||||
}
|
||||
|
||||
ffThreadMutexUnlock(&mutex);
|
||||
}
|
||||
return !!ffJsonLib;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,130 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
|
||||
#include "fastfetch.h"
|
||||
#include "common/library.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <json-c/json.h>
|
||||
|
||||
typedef struct FFJsonLibrary
|
||||
{
|
||||
FF_LIBRARY_SYMBOL(json_tokener_parse)
|
||||
FF_LIBRARY_SYMBOL(json_object_is_type)
|
||||
FF_LIBRARY_SYMBOL(json_object_get_array)
|
||||
FF_LIBRARY_SYMBOL(json_object_get_boolean)
|
||||
FF_LIBRARY_SYMBOL(json_object_get_double)
|
||||
FF_LIBRARY_SYMBOL(json_object_get_int)
|
||||
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;
|
||||
|
||||
extern const FFJsonLibrary* ffJsonLib;
|
||||
|
||||
bool ffJsonLoadLibrary(const FFinstance* instance);
|
||||
|
||||
static inline void wrapJsoncFree(json_object** root)
|
||||
{
|
||||
assert(root);
|
||||
if (*root)
|
||||
json_object_put(*root);
|
||||
}
|
||||
|
||||
extern inline __attribute__((__gnu_inline__, __always_inline__))
|
||||
struct json_object *json_tokener_parse(const char *str)
|
||||
{
|
||||
assert(ffJsonLib);
|
||||
return ffJsonLib->ffjson_tokener_parse(str);
|
||||
}
|
||||
|
||||
extern inline __attribute__((__gnu_inline__, __always_inline__))
|
||||
int json_object_is_type(const json_object *obj, enum json_type type)
|
||||
{
|
||||
assert(ffJsonLib);
|
||||
return ffJsonLib->ffjson_object_is_type(obj, type);
|
||||
}
|
||||
|
||||
extern inline __attribute__((__gnu_inline__, __always_inline__))
|
||||
struct array_list *json_object_get_array(const json_object *obj)
|
||||
{
|
||||
assert(ffJsonLib);
|
||||
return ffJsonLib->ffjson_object_get_array(obj);
|
||||
}
|
||||
|
||||
extern inline __attribute__((__gnu_inline__, __always_inline__))
|
||||
json_bool json_object_get_boolean(const json_object *obj)
|
||||
{
|
||||
assert(ffJsonLib);
|
||||
return ffJsonLib->ffjson_object_get_boolean(obj);
|
||||
}
|
||||
|
||||
extern inline __attribute__((__gnu_inline__, __always_inline__))
|
||||
double json_object_get_double(const json_object *obj)
|
||||
{
|
||||
assert(ffJsonLib);
|
||||
return ffJsonLib->ffjson_object_get_double(obj);
|
||||
}
|
||||
|
||||
extern inline __attribute__((__gnu_inline__, __always_inline__))
|
||||
int32_t json_object_get_int(const json_object *obj)
|
||||
{
|
||||
assert(ffJsonLib);
|
||||
return ffJsonLib->ffjson_object_get_int(obj);
|
||||
}
|
||||
|
||||
extern inline __attribute__((__gnu_inline__, __always_inline__))
|
||||
int json_object_get_string_len(const json_object *obj)
|
||||
{
|
||||
assert(ffJsonLib);
|
||||
return ffJsonLib->ffjson_object_get_string_len(obj);
|
||||
}
|
||||
|
||||
extern inline __attribute__((__gnu_inline__, __always_inline__))
|
||||
const char *json_object_get_string(json_object *obj)
|
||||
{
|
||||
assert(ffJsonLib);
|
||||
return ffJsonLib->ffjson_object_get_string(obj);
|
||||
}
|
||||
|
||||
extern inline __attribute__((__gnu_inline__, __always_inline__))
|
||||
struct lh_table *json_object_get_object(const json_object *obj)
|
||||
{
|
||||
assert(ffJsonLib);
|
||||
return ffJsonLib->ffjson_object_get_object(obj);
|
||||
}
|
||||
|
||||
extern inline __attribute__((__gnu_inline__, __always_inline__))
|
||||
void json_object_object_del(struct json_object *obj, const char *key)
|
||||
{
|
||||
assert(ffJsonLib);
|
||||
return ffJsonLib->ffjson_object_object_del(obj, key);
|
||||
}
|
||||
|
||||
extern inline __attribute__((__gnu_inline__, __always_inline__))
|
||||
struct json_object *json_object_object_get(const json_object *obj, const char *key)
|
||||
{
|
||||
assert(ffJsonLib);
|
||||
return ffJsonLib->ffjson_object_object_get(obj, key);
|
||||
}
|
||||
|
||||
extern inline __attribute__((__gnu_inline__, __always_inline__))
|
||||
int json_object_object_length(const json_object *obj)
|
||||
{
|
||||
assert(ffJsonLib);
|
||||
return ffJsonLib->ffjson_object_object_length(obj);
|
||||
}
|
||||
|
||||
extern inline __attribute__((__gnu_inline__, __always_inline__))
|
||||
int json_object_put(json_object *obj)
|
||||
{
|
||||
assert(ffJsonLib);
|
||||
return ffJsonLib->ffjson_object_put(obj);
|
||||
}
|
||||
|
||||
#endif
|
||||
+9
-13
@@ -1,33 +1,31 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/jsonconfig.h"
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
|
||||
bool ffJsonConfigParseModuleArgs(const char* key, json_object* val, FFModuleArgs* moduleArgs)
|
||||
bool ffJsonConfigParseModuleArgs(const char* key, yyjson_val* val, FFModuleArgs* moduleArgs)
|
||||
{
|
||||
if(strcasecmp(key, "key") == 0)
|
||||
{
|
||||
ffStrbufSetNS(&moduleArgs->key, (uint32_t) json_object_get_string_len(val), json_object_get_string(val));
|
||||
ffStrbufSetNS(&moduleArgs->key, (uint32_t) yyjson_get_len(val), yyjson_get_str(val));
|
||||
return true;
|
||||
}
|
||||
else if(strcasecmp(key, "format") == 0)
|
||||
{
|
||||
ffStrbufSetNS(&moduleArgs->outputFormat, (uint32_t) json_object_get_string_len(val), json_object_get_string(val));
|
||||
ffStrbufSetNS(&moduleArgs->outputFormat, (uint32_t) yyjson_get_len(val), yyjson_get_str(val));
|
||||
return true;
|
||||
}
|
||||
else if(strcasecmp(key, "error") == 0)
|
||||
{
|
||||
ffStrbufSetNS(&moduleArgs->errorFormat, (uint32_t) json_object_get_string_len(val), json_object_get_string(val));
|
||||
ffStrbufSetNS(&moduleArgs->errorFormat, (uint32_t) yyjson_get_len(val), yyjson_get_str(val));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
const char* ffJsonConfigParseEnum(json_object* val, int* result, FFKeyValuePair pairs[])
|
||||
const char* ffJsonConfigParseEnum(yyjson_val* val, int* result, FFKeyValuePair pairs[])
|
||||
{
|
||||
if (json_object_is_type(val, json_type_int))
|
||||
if (yyjson_is_int(val))
|
||||
{
|
||||
int intVal = json_object_get_int(val);
|
||||
int intVal = yyjson_get_int(val);
|
||||
|
||||
for (const FFKeyValuePair* pPair = pairs; pPair->key; ++pPair)
|
||||
{
|
||||
@@ -40,9 +38,9 @@ const char* ffJsonConfigParseEnum(json_object* val, int* result, FFKeyValuePair
|
||||
|
||||
return "Invalid enum integer";
|
||||
}
|
||||
else if (json_object_is_type(val, json_type_string))
|
||||
else if (yyjson_is_str(val))
|
||||
{
|
||||
const char* strVal = json_object_get_string(val);
|
||||
const char* strVal = yyjson_get_str(val);
|
||||
for (const FFKeyValuePair* pPair = pairs; pPair->key; ++pPair)
|
||||
{
|
||||
if (strcasecmp(strVal, pPair->key) == 0)
|
||||
@@ -57,5 +55,3 @@ const char* ffJsonConfigParseEnum(json_object* val, int* result, FFKeyValuePair
|
||||
else
|
||||
return "Invalid enum value type; must be a string or integer";
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
#include <yyjson.h>
|
||||
|
||||
#include "common/json.h"
|
||||
|
||||
bool ffJsonConfigParseModuleArgs(const char* key, json_object* val, FFModuleArgs* moduleArgs);
|
||||
const char* ffJsonConfigParseEnum(json_object* val, int* result, FFKeyValuePair pairs[]);
|
||||
|
||||
#endif
|
||||
bool ffJsonConfigParseModuleArgs(const char* key, yyjson_val* val, FFModuleArgs* moduleArgs);
|
||||
const char* ffJsonConfigParseEnum(yyjson_val* val, int* result, FFKeyValuePair pairs[]);
|
||||
|
||||
@@ -456,6 +456,5 @@
|
||||
#--lib-glx /usr/lib/libGLX.so
|
||||
#--lib-osmesa /usr/lib/libOSMesa.so
|
||||
#--lib-opencl /usr/lib/libOpenCL.so
|
||||
#--lib-jsonc /usr/lib/libjson-c.so
|
||||
#--lib-freetype /data/data/com.termux/files/usr/lib
|
||||
#--lib-pulse /usr/lib/libpulse.so
|
||||
|
||||
@@ -97,7 +97,6 @@ Library options: Set the path of a library to load
|
||||
--lib-glx <path>
|
||||
--lib-osmesa <path>
|
||||
--lib-opencl <path>
|
||||
--lib-jsonc <path>
|
||||
--lib-pulse <path>
|
||||
--lib-freetype <path>
|
||||
|
||||
|
||||
@@ -15,9 +15,6 @@
|
||||
#include "util/windows/getline.h"
|
||||
#endif
|
||||
|
||||
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
||||
|
||||
#include "common/jsonconfig.h"
|
||||
#include "modules/modules.h"
|
||||
|
||||
typedef struct CustomValue
|
||||
@@ -1038,8 +1035,6 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con
|
||||
optionParseString(key, value, &instance->config.libOSMesa);
|
||||
else if(strcasecmp(subkey, "-opencl") == 0)
|
||||
optionParseString(key, value, &instance->config.libOpenCL);
|
||||
else if(strcasecmp(subkey, "-jsonc") == 0)
|
||||
optionParseString(key, value, &instance->config.libJSONC);
|
||||
else if(strcasecmp(subkey, "-wlanapi") == 0)
|
||||
optionParseString(key, value, &instance->config.libwlanapi);
|
||||
else if(strcasecmp(key, "-pulse") == 0)
|
||||
|
||||
@@ -117,7 +117,6 @@ typedef struct FFconfig
|
||||
FFstrbuf libGLX;
|
||||
FFstrbuf libOSMesa;
|
||||
FFstrbuf libOpenCL;
|
||||
FFstrbuf libJSONC;
|
||||
FFstrbuf libfreetype;
|
||||
FFstrbuf libPulse;
|
||||
FFstrbuf libwlanapi;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/printing.h"
|
||||
#include "common/jsonconfig.h"
|
||||
#include "common/bar.h"
|
||||
#include "detection/battery/battery.h"
|
||||
#include "modules/battery/battery.h"
|
||||
@@ -139,35 +139,41 @@ bool ffParseBatteryCommandOptions(FFBatteryOptions* options, const char* key, co
|
||||
void ffDestroyBatteryOptions(FFBatteryOptions* options)
|
||||
{
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
|
||||
#ifdef __linux__
|
||||
ffStrbufDestroy(&options->dir);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
void ffParseBatteryJsonObject(FFinstance* instance, json_object* module)
|
||||
void ffParseBatteryJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
{
|
||||
FFBatteryOptions __attribute__((__cleanup__(ffDestroyBatteryOptions))) options;
|
||||
ffInitBatteryOptions(&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;
|
||||
|
||||
#ifdef __linux__
|
||||
if (strcasecmp(key, "dir") == 0)
|
||||
{
|
||||
ffStrbufSetS(&options.dir, json_object_get_string(val));
|
||||
ffStrbufSetS(&options.dir, yyjson_get_str(val));
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (strcasecmp(key, "temp") == 0)
|
||||
{
|
||||
options.temp = (bool) json_object_get_boolean(val);
|
||||
options.temp = yyjson_get_bool(val);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -177,4 +183,3 @@ void ffParseBatteryJsonObject(FFinstance* instance, json_object* module)
|
||||
|
||||
ffPrintBattery(instance, &options);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "fastfetch.h"
|
||||
#include <yyjson.h>
|
||||
|
||||
#define FF_BATTERY_MODULE_NAME "Battery"
|
||||
|
||||
@@ -9,8 +10,4 @@ void ffPrintBattery(FFinstance* instance, FFBatteryOptions* options);
|
||||
void ffInitBatteryOptions(FFBatteryOptions* options);
|
||||
bool ffParseBatteryCommandOptions(FFBatteryOptions* options, const char* key, const char* value);
|
||||
void ffDestroyBatteryOptions(FFBatteryOptions* options);
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
#include "common/jsonconfig.h"
|
||||
void ffParseBatteryJsonObject(FFinstance* instance, json_object* module);
|
||||
#endif
|
||||
void ffParseBatteryJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/printing.h"
|
||||
#include "common/jsonconfig.h"
|
||||
#include "detection/bios/bios.h"
|
||||
#include "modules/bios/bios.h"
|
||||
|
||||
@@ -66,16 +66,21 @@ void ffDestroyBiosOptions(FFBiosOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
void ffParseBiosJsonObject(FFinstance* instance, json_object* module)
|
||||
void ffParseBiosJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
{
|
||||
FFBiosOptions __attribute__((__cleanup__(ffDestroyBiosOptions))) options;
|
||||
ffInitBiosOptions(&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;
|
||||
|
||||
@@ -85,4 +90,3 @@ void ffParseBiosJsonObject(FFinstance* instance, json_object* module)
|
||||
|
||||
ffPrintBios(instance, &options);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "fastfetch.h"
|
||||
#include <yyjson.h>
|
||||
|
||||
#define FF_BIOS_MODULE_NAME "Bios"
|
||||
|
||||
@@ -8,8 +9,4 @@ void ffPrintBios(FFinstance* instance, FFBiosOptions* options);
|
||||
void ffInitBiosOptions(FFBiosOptions* options);
|
||||
bool ffParseBiosCommandOptions(FFBiosOptions* options, const char* key, const char* value);
|
||||
void ffDestroyBiosOptions(FFBiosOptions* options);
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
#include "common/jsonconfig.h"
|
||||
void ffParseBiosJsonObject(FFinstance* instance, json_object* module);
|
||||
#endif
|
||||
void ffParseBiosJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "common/printing.h"
|
||||
#include "common/jsonconfig.h"
|
||||
#include "detection/bluetooth/bluetooth.h"
|
||||
#include "modules/bluetooth/bluetooth.h"
|
||||
|
||||
@@ -84,22 +85,27 @@ void ffDestroyBluetoothOptions(FFBluetoothOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
void ffParseBluetoothJsonObject(FFinstance* instance, json_object* module)
|
||||
void ffParseBluetoothJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
{
|
||||
FFBluetoothOptions __attribute__((__cleanup__(ffDestroyBluetoothOptions))) options;
|
||||
ffInitBluetoothOptions(&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, "showConnected") == 0)
|
||||
{
|
||||
options.showDisconnected = json_object_get_boolean(val);
|
||||
options.showDisconnected = yyjson_get_bool(val);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -109,4 +115,3 @@ void ffParseBluetoothJsonObject(FFinstance* instance, json_object* module)
|
||||
|
||||
ffPrintBluetooth(instance, &options);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "fastfetch.h"
|
||||
#include <yyjson.h>
|
||||
|
||||
#define FF_BLUETOOTH_MODULE_NAME "Bluetooth"
|
||||
|
||||
@@ -8,8 +9,4 @@ void ffPrintBluetooth(FFinstance* instance, FFBluetoothOptions* options);
|
||||
void ffInitBluetoothOptions(FFBluetoothOptions* options);
|
||||
bool ffParseBluetoothCommandOptions(FFBluetoothOptions* options, const char* key, const char* value);
|
||||
void ffDestroyBluetoothOptions(FFBluetoothOptions* options);
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
#include "common/jsonconfig.h"
|
||||
void ffParseBluetoothJsonObject(FFinstance* instance, json_object* module);
|
||||
#endif
|
||||
void ffParseBluetoothJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/printing.h"
|
||||
#include "common/jsonconfig.h"
|
||||
#include "detection/board/board.h"
|
||||
#include "modules/board/board.h"
|
||||
|
||||
@@ -64,16 +64,21 @@ void ffDestroyBoardOptions(FFBoardOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
void ffParseBoardJsonObject(FFinstance* instance, json_object* module)
|
||||
void ffParseBoardJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
{
|
||||
FFBoardOptions __attribute__((__cleanup__(ffDestroyBoardOptions))) options;
|
||||
ffInitBoardOptions(&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;
|
||||
|
||||
@@ -83,4 +88,3 @@ void ffParseBoardJsonObject(FFinstance* instance, json_object* module)
|
||||
|
||||
ffPrintBoard(instance, &options);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "fastfetch.h"
|
||||
#include <yyjson.h>
|
||||
|
||||
#define FF_BOARD_MODULE_NAME "Board"
|
||||
|
||||
@@ -8,8 +9,4 @@ void ffPrintBoard(FFinstance* instance, FFBoardOptions* options);
|
||||
void ffInitBoardOptions(FFBoardOptions* options);
|
||||
bool ffParseBoardCommandOptions(FFBoardOptions* options, const char* key, const char* value);
|
||||
void ffDestroyBoardOptions(FFBoardOptions* options);
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
#include "common/jsonconfig.h"
|
||||
void ffParseBoardJsonObject(FFinstance* instance, json_object* module);
|
||||
#endif
|
||||
void ffParseBoardJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/printing.h"
|
||||
#include "modules/break/break.h"
|
||||
|
||||
@@ -8,9 +7,7 @@ void ffPrintBreak(FFinstance* instance)
|
||||
putchar('\n');
|
||||
}
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
void ffParseBreakJsonObject(FFinstance* instance, FF_MAYBE_UNUSED json_object* module)
|
||||
void ffParseBreakJsonObject(FFinstance* instance, FF_MAYBE_UNUSED yyjson_val* module)
|
||||
{
|
||||
return ffPrintBreak(instance);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "fastfetch.h"
|
||||
#include <yyjson.h>
|
||||
|
||||
#define FF_BREAK_MODULE_NAME "Break"
|
||||
|
||||
void ffPrintBreak(FFinstance* instance);
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
#include "common/jsonconfig.h"
|
||||
void ffParseBreakJsonObject(FFinstance* instance, json_object* module);
|
||||
#endif
|
||||
void ffParseBreakJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/printing.h"
|
||||
#include "common/jsonconfig.h"
|
||||
#include "detection/brightness/brightness.h"
|
||||
#include "modules/brightness/brightness.h"
|
||||
|
||||
@@ -77,16 +77,21 @@ void ffDestroyBrightnessOptions(FFBrightnessOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
void ffParseBrightnessJsonObject(FFinstance* instance, json_object* module)
|
||||
void ffParseBrightnessJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
{
|
||||
FFBrightnessOptions __attribute__((__cleanup__(ffDestroyBrightnessOptions))) options;
|
||||
ffInitBrightnessOptions(&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;
|
||||
|
||||
@@ -96,4 +101,3 @@ void ffParseBrightnessJsonObject(FFinstance* instance, json_object* module)
|
||||
|
||||
ffPrintBrightness(instance, &options);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "fastfetch.h"
|
||||
#include <yyjson.h>
|
||||
|
||||
#define FF_BRIGHTNESS_MODULE_NAME "Brightness"
|
||||
|
||||
@@ -8,8 +9,4 @@ void ffPrintBrightness(FFinstance* instance, FFBrightnessOptions* options);
|
||||
void ffInitBrightnessOptions(FFBrightnessOptions* options);
|
||||
bool ffParseBrightnessCommandOptions(FFBrightnessOptions* options, const char* key, const char* value);
|
||||
void ffDestroyBrightnessOptions(FFBrightnessOptions* options);
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
#include "common/jsonconfig.h"
|
||||
void ffParseBrightnessJsonObject(FFinstance* instance, json_object* module);
|
||||
#endif
|
||||
void ffParseBrightnessJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/printing.h"
|
||||
#include "common/jsonconfig.h"
|
||||
#include "detection/chassis/chassis.h"
|
||||
#include "modules/chassis/chassis.h"
|
||||
|
||||
@@ -70,16 +70,21 @@ void ffDestroyChassisOptions(FFChassisOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
void ffParseChassisJsonObject(FFinstance* instance, json_object* module)
|
||||
void ffParseChassisJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
{
|
||||
FFChassisOptions __attribute__((__cleanup__(ffDestroyChassisOptions))) options;
|
||||
ffInitChassisOptions(&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;
|
||||
|
||||
@@ -89,4 +94,3 @@ void ffParseChassisJsonObject(FFinstance* instance, json_object* module)
|
||||
|
||||
ffPrintChassis(instance, &options);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "fastfetch.h"
|
||||
#include <yyjson.h>
|
||||
|
||||
#define FF_CHASSIS_MODULE_NAME "Chassis"
|
||||
|
||||
@@ -8,8 +9,4 @@ void ffPrintChassis(FFinstance* instance, FFChassisOptions* options);
|
||||
void ffInitChassisOptions(FFChassisOptions* options);
|
||||
bool ffParseChassisCommandOptions(FFChassisOptions* options, const char* key, const char* value);
|
||||
void ffDestroyChassisOptions(FFChassisOptions* options);
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
#include "common/jsonconfig.h"
|
||||
void ffParseChassisJsonObject(FFinstance* instance, json_object* module);
|
||||
#endif
|
||||
void ffParseChassisJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/printing.h"
|
||||
#include "common/jsonconfig.h"
|
||||
#include "util/textModifier.h"
|
||||
#include "modules/colors/colors.h"
|
||||
|
||||
@@ -30,9 +30,7 @@ void ffPrintColors(FFinstance* instance)
|
||||
puts(FASTFETCH_TEXT_MODIFIER_RESET);
|
||||
}
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
void ffParseColorsJsonObject(FFinstance* instance, FF_MAYBE_UNUSED json_object* module)
|
||||
void ffParseColorsJsonObject(FFinstance* instance, FF_MAYBE_UNUSED yyjson_val* module)
|
||||
{
|
||||
return ffPrintColors(instance);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "fastfetch.h"
|
||||
#include <yyjson.h>
|
||||
|
||||
#define FF_COLORS_MODULE_NAME "Colors"
|
||||
|
||||
void ffPrintColors(FFinstance* instance);
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
#include "common/jsonconfig.h"
|
||||
void ffParseColorsJsonObject(FFinstance* instance, json_object* module);
|
||||
#endif
|
||||
void ffParseColorsJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#include "fastfetch.h"
|
||||
|
||||
#include "common/printing.h"
|
||||
#include "common/jsonconfig.h"
|
||||
#include "common/processing.h"
|
||||
#include "modules/command/command.h"
|
||||
|
||||
@@ -81,28 +80,33 @@ void ffDestroyCommandOptions(FFCommandOptions* options)
|
||||
ffStrbufDestroy(&options->text);
|
||||
}
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
void ffParseCommandJsonObject(FFinstance* instance, json_object* module)
|
||||
void ffParseCommandJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
{
|
||||
FFCommandOptions __attribute__((__cleanup__(ffDestroyCommandOptions))) options;
|
||||
ffInitCommandOptions(&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, "shell") == 0)
|
||||
{
|
||||
ffStrbufSetS(&options.shell, json_object_get_string(val));
|
||||
ffStrbufSetS(&options.shell, yyjson_get_str(val));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (strcasecmp(key, "text") == 0)
|
||||
{
|
||||
ffStrbufSetS(&options.text, json_object_get_string(val));
|
||||
ffStrbufSetS(&options.text, yyjson_get_str(val));
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -112,4 +116,3 @@ void ffParseCommandJsonObject(FFinstance* instance, json_object* module)
|
||||
|
||||
ffPrintCommand(instance, &options);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "fastfetch.h"
|
||||
#include <yyjson.h>
|
||||
|
||||
#define FF_COMMAND_MODULE_NAME "Command"
|
||||
|
||||
@@ -8,8 +9,4 @@ void ffPrintCommand(FFinstance* instance, FFCommandOptions* options);
|
||||
void ffInitCommandOptions(FFCommandOptions* options);
|
||||
bool ffParseCommandCommandOptions(FFCommandOptions* options, const char* key, const char* value);
|
||||
void ffDestroyCommandOptions(FFCommandOptions* options);
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
#include "common/jsonconfig.h"
|
||||
void ffParseCommandJsonObject(FFinstance* instance, json_object* module);
|
||||
#endif
|
||||
void ffParseCommandJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
|
||||
+10
-6
@@ -1,5 +1,5 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/printing.h"
|
||||
#include "common/jsonconfig.h"
|
||||
#include "detection/cpu/cpu.h"
|
||||
#include "modules/cpu/cpu.h"
|
||||
|
||||
@@ -83,22 +83,27 @@ void ffDestroyCPUOptions(FFCPUOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
void ffParseCPUJsonObject(FFinstance* instance, json_object* module)
|
||||
void ffParseCPUJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
{
|
||||
FFCPUOptions __attribute__((__cleanup__(ffDestroyCPUOptions))) options;
|
||||
ffInitCPUOptions(&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, "temp") == 0)
|
||||
{
|
||||
options.temp = (bool) json_object_get_boolean(val);
|
||||
options.temp = yyjson_get_bool(val);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -108,4 +113,3 @@ void ffParseCPUJsonObject(FFinstance* instance, json_object* module)
|
||||
|
||||
ffPrintCPU(instance, &options);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "fastfetch.h"
|
||||
#include <yyjson.h>
|
||||
|
||||
#define FF_CPU_MODULE_NAME "CPU"
|
||||
|
||||
@@ -8,8 +9,4 @@ void ffPrintCPU(FFinstance* instance, FFCPUOptions* options);
|
||||
void ffInitCPUOptions(FFCPUOptions* options);
|
||||
bool ffParseCPUCommandOptions(FFCPUOptions* options, const char* key, const char* value);
|
||||
void ffDestroyCPUOptions(FFCPUOptions* options);
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
#include "common/jsonconfig.h"
|
||||
void ffParseCPUJsonObject(FFinstance* instance, json_object* module);
|
||||
#endif
|
||||
void ffParseCPUJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/printing.h"
|
||||
#include "common/jsonconfig.h"
|
||||
#include "common/bar.h"
|
||||
#include "detection/cpuusage/cpuusage.h"
|
||||
#include "modules/cpuusage/cpuusage.h"
|
||||
@@ -62,16 +62,21 @@ void ffDestroyCPUUsageOptions(FFCPUUsageOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
void ffParseCPUUsageJsonObject(FFinstance* instance, json_object* module)
|
||||
void ffParseCPUUsageJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
{
|
||||
FFCPUUsageOptions __attribute__((__cleanup__(ffDestroyCPUUsageOptions))) options;
|
||||
ffInitCPUUsageOptions(&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;
|
||||
|
||||
@@ -81,4 +86,3 @@ void ffParseCPUUsageJsonObject(FFinstance* instance, json_object* module)
|
||||
|
||||
ffPrintCPUUsage(instance, &options);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "fastfetch.h"
|
||||
#include <yyjson.h>
|
||||
|
||||
#define FF_CPUUSAGE_MODULE_NAME "CPUUsage"
|
||||
|
||||
void ffPrepareCPUUsage();
|
||||
@@ -8,8 +11,4 @@ void ffPrintCPUUsage(FFinstance* instance, FFCPUUsageOptions* options);
|
||||
void ffInitCPUUsageOptions(FFCPUUsageOptions* options);
|
||||
bool ffParseCPUUsageCommandOptions(FFCPUUsageOptions* options, const char* key, const char* value);
|
||||
void ffDestroyCPUUsageOptions(FFCPUUsageOptions* options);
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
#include "common/jsonconfig.h"
|
||||
void ffParseCPUUsageJsonObject(FFinstance* instance, json_object* module);
|
||||
#endif
|
||||
void ffParseCPUUsageJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#include "fastfetch.h"
|
||||
|
||||
#include "common/printing.h"
|
||||
#include "common/jsonconfig.h"
|
||||
#include "detection/cursor/cursor.h"
|
||||
#include "modules/cursor/cursor.h"
|
||||
|
||||
@@ -71,16 +70,21 @@ void ffDestroyCursorOptions(FFCursorOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
void ffParseCursorJsonObject(FFinstance* instance, json_object* module)
|
||||
void ffParseCursorJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
{
|
||||
FFCursorOptions __attribute__((__cleanup__(ffDestroyCursorOptions))) options;
|
||||
ffInitCursorOptions(&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;
|
||||
|
||||
@@ -90,4 +94,3 @@ void ffParseCursorJsonObject(FFinstance* instance, json_object* module)
|
||||
|
||||
ffPrintCursor(instance, &options);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "fastfetch.h"
|
||||
#include <yyjson.h>
|
||||
|
||||
#define FF_CURSOR_MODULE_NAME "Cursor"
|
||||
|
||||
@@ -8,8 +9,4 @@ void ffPrintCursor(FFinstance* instance, FFCursorOptions* options);
|
||||
void ffInitCursorOptions(FFCursorOptions* options);
|
||||
bool ffParseCursorCommandOptions(FFCursorOptions* options, const char* key, const char* value);
|
||||
void ffDestroyCursorOptions(FFCursorOptions* options);
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
#include "common/jsonconfig.h"
|
||||
void ffParseCursorJsonObject(FFinstance* instance, json_object* module);
|
||||
#endif
|
||||
void ffParseCursorJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/printing.h"
|
||||
#include "common/jsonconfig.h"
|
||||
#include "modules/custom/custom.h"
|
||||
#include "util/textModifier.h"
|
||||
|
||||
@@ -37,16 +37,21 @@ void ffDestroyCustomOptions(FFCustomOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
void ffParseCustomJsonObject(FFinstance* instance, json_object* module)
|
||||
void ffParseCustomJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
{
|
||||
FFCustomOptions __attribute__((__cleanup__(ffDestroyCustomOptions))) options;
|
||||
ffInitCustomOptions(&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;
|
||||
|
||||
@@ -56,4 +61,3 @@ void ffParseCustomJsonObject(FFinstance* instance, json_object* module)
|
||||
|
||||
ffPrintCustom(instance, &options);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "fastfetch.h"
|
||||
#include <yyjson.h>
|
||||
|
||||
#define FF_CUSTOM_MODULE_NAME "Custom"
|
||||
|
||||
@@ -8,8 +9,4 @@ void ffPrintCustom(FFinstance* instance, FFCustomOptions* options);
|
||||
void ffInitCustomOptions(FFCustomOptions* options);
|
||||
bool ffParseCustomCommandOptions(FFCustomOptions* options, const char* key, const char* value);
|
||||
void ffDestroyCustomOptions(FFCustomOptions* options);
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
#include "common/jsonconfig.h"
|
||||
void ffParseCustomJsonObject(FFinstance* instance, json_object* module);
|
||||
#endif
|
||||
void ffParseCustomJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/printing.h"
|
||||
#include "common/jsonconfig.h"
|
||||
#include "detection/datetime/datetime.h"
|
||||
#include "modules/datetime/datetime.h"
|
||||
|
||||
@@ -69,16 +69,21 @@ void ffDestroyDateTimeOptions(FFDateTimeOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
void ffParseDateTimeJsonObject(FFinstance* instance, json_object* module)
|
||||
void ffParseDateTimeJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
{
|
||||
FFDateTimeOptions __attribute__((__cleanup__(ffDestroyDateTimeOptions))) options;
|
||||
ffInitDateTimeOptions(&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;
|
||||
|
||||
@@ -88,4 +93,3 @@ void ffParseDateTimeJsonObject(FFinstance* instance, json_object* module)
|
||||
|
||||
ffPrintDateTime(instance, &options);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "fastfetch.h"
|
||||
#include <yyjson.h>
|
||||
|
||||
#define FF_DATETIME_MODULE_NAME "DateTime"
|
||||
|
||||
@@ -8,8 +9,4 @@ void ffPrintDateTime(FFinstance* instance, FFDateTimeOptions* options);
|
||||
void ffInitDateTimeOptions(FFDateTimeOptions* options);
|
||||
bool ffParseDateTimeCommandOptions(FFDateTimeOptions* options, const char* key, const char* value);
|
||||
void ffDestroyDateTimeOptions(FFDateTimeOptions* options);
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
#include "common/jsonconfig.h"
|
||||
void ffParseDateTimeJsonObject(FFinstance* instance, json_object* module);
|
||||
#endif
|
||||
void ffParseDateTimeJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
|
||||
+9
-5
@@ -1,5 +1,5 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/printing.h"
|
||||
#include "common/jsonconfig.h"
|
||||
#include "detection/displayserver/displayserver.h"
|
||||
#include "modules/de/de.h"
|
||||
|
||||
@@ -60,16 +60,21 @@ void ffDestroyDEOptions(FFDEOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
void ffParseDEJsonObject(FFinstance* instance, json_object* module)
|
||||
void ffParseDEJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
{
|
||||
FFDEOptions __attribute__((__cleanup__(ffDestroyDEOptions))) options;
|
||||
ffInitDEOptions(&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;
|
||||
|
||||
@@ -79,4 +84,3 @@ void ffParseDEJsonObject(FFinstance* instance, json_object* module)
|
||||
|
||||
ffPrintDE(instance, &options);
|
||||
}
|
||||
#endif
|
||||
|
||||
+2
-5
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "fastfetch.h"
|
||||
#include <yyjson.h>
|
||||
|
||||
#define FF_DE_MODULE_NAME "DE"
|
||||
|
||||
@@ -8,8 +9,4 @@ void ffPrintDE(FFinstance* instance, FFDEOptions* options);
|
||||
void ffInitDEOptions(FFDEOptions* options);
|
||||
bool ffParseDECommandOptions(FFDEOptions* options, const char* key, const char* value);
|
||||
void ffDestroyDEOptions(FFDEOptions* options);
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
#include "common/jsonconfig.h"
|
||||
void ffParseDEJsonObject(FFinstance* instance, json_object* module);
|
||||
#endif
|
||||
void ffParseDEJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
|
||||
+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);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/printing.h"
|
||||
#include "common/jsonconfig.h"
|
||||
#include "detection/displayserver/displayserver.h"
|
||||
#include "modules/display/display.h"
|
||||
|
||||
@@ -155,17 +155,21 @@ void ffDestroyDisplayOptions(FFDisplayOptions* options)
|
||||
{
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
void ffParseDisplayJsonObject(FFinstance* instance, json_object* module)
|
||||
void ffParseDisplayJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
{
|
||||
FFDisplayOptions __attribute__((__cleanup__(ffDestroyDisplayOptions))) options;
|
||||
ffInitDisplayOptions(&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;
|
||||
|
||||
@@ -187,13 +191,13 @@ void ffParseDisplayJsonObject(FFinstance* instance, json_object* module)
|
||||
|
||||
if (strcasecmp(key, "detectName") == 0)
|
||||
{
|
||||
options.detectName = json_object_get_boolean(val);
|
||||
options.detectName = yyjson_get_bool(val);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (strcasecmp(key, "preciseRefreshRate") == 0)
|
||||
{
|
||||
options.preciseRefreshRate = json_object_get_boolean(val);
|
||||
options.preciseRefreshRate = yyjson_get_bool(val);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -203,4 +207,3 @@ void ffParseDisplayJsonObject(FFinstance* instance, json_object* module)
|
||||
|
||||
ffPrintDisplay(instance, &options);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "fastfetch.h"
|
||||
#include <yyjson.h>
|
||||
|
||||
#define FF_DISPLAY_MODULE_NAME "Display"
|
||||
|
||||
@@ -8,8 +9,4 @@ void ffPrintDisplay(FFinstance* instance, FFDisplayOptions* options);
|
||||
void ffInitDisplayOptions(FFDisplayOptions* options);
|
||||
bool ffParseDisplayCommandOptions(FFDisplayOptions* options, const char* key, const char* value);
|
||||
void ffDestroyDisplayOptions(FFDisplayOptions* options);
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
#include "common/jsonconfig.h"
|
||||
void ffParseDisplayJsonObject(FFinstance* instance, json_object* module);
|
||||
#endif
|
||||
void ffParseDisplayJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/printing.h"
|
||||
#include "common/jsonconfig.h"
|
||||
#include "detection/font/font.h"
|
||||
#include "modules/font/font.h"
|
||||
|
||||
@@ -53,16 +53,21 @@ void ffDestroyFontOptions(FFFontOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
void ffParseFontJsonObject(FFinstance* instance, json_object* module)
|
||||
void ffParseFontJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
{
|
||||
FFFontOptions __attribute__((__cleanup__(ffDestroyFontOptions))) options;
|
||||
ffInitFontOptions(&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;
|
||||
|
||||
@@ -72,4 +77,3 @@ void ffParseFontJsonObject(FFinstance* instance, json_object* module)
|
||||
|
||||
ffPrintFont(instance, &options);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "fastfetch.h"
|
||||
#include <yyjson.h>
|
||||
|
||||
#define FF_FONT_MODULE_NAME "Font"
|
||||
|
||||
@@ -8,8 +9,4 @@ void ffPrintFont(FFinstance* instance, FFFontOptions* options);
|
||||
void ffInitFontOptions(FFFontOptions* options);
|
||||
bool ffParseFontCommandOptions(FFFontOptions* options, const char* key, const char* value);
|
||||
void ffDestroyFontOptions(FFFontOptions* options);
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
#include "common/jsonconfig.h"
|
||||
void ffParseFontJsonObject(FFinstance* instance, json_object* module);
|
||||
#endif
|
||||
void ffParseFontJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "common/printing.h"
|
||||
#include "common/jsonconfig.h"
|
||||
#include "detection/gamepad/gamepad.h"
|
||||
#include "modules/gamepad/gamepad.h"
|
||||
|
||||
@@ -68,16 +69,21 @@ void ffDestroyGamepadOptions(FFGamepadOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
void ffParseGamepadJsonObject(FFinstance* instance, json_object* module)
|
||||
void ffParseGamepadJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
{
|
||||
FFGamepadOptions __attribute__((__cleanup__(ffDestroyGamepadOptions))) options;
|
||||
ffInitGamepadOptions(&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;
|
||||
|
||||
@@ -87,4 +93,3 @@ void ffParseGamepadJsonObject(FFinstance* instance, json_object* module)
|
||||
|
||||
ffPrintGamepad(instance, &options);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "fastfetch.h"
|
||||
#include <yyjson.h>
|
||||
|
||||
#define FF_GAMEPAD_MODULE_NAME "Gamepad"
|
||||
|
||||
@@ -8,8 +9,4 @@ void ffPrintGamepad(FFinstance* instance, FFGamepadOptions* options);
|
||||
void ffInitGamepadOptions(FFGamepadOptions* options);
|
||||
bool ffParseGamepadCommandOptions(FFGamepadOptions* options, const char* key, const char* value);
|
||||
void ffDestroyGamepadOptions(FFGamepadOptions* options);
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
#include "common/jsonconfig.h"
|
||||
void ffParseGamepadJsonObject(FFinstance* instance, json_object* module);
|
||||
#endif
|
||||
void ffParseGamepadJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
|
||||
+11
-7
@@ -1,7 +1,7 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/bar.h"
|
||||
#include "common/parsing.h"
|
||||
#include "common/printing.h"
|
||||
#include "common/jsonconfig.h"
|
||||
#include "detection/host/host.h"
|
||||
#include "detection/gpu/gpu.h"
|
||||
#include "modules/gpu/gpu.h"
|
||||
@@ -145,28 +145,33 @@ void ffDestroyGPUOptions(FFGPUOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
void ffParseGPUJsonObject(FFinstance* instance, json_object* module)
|
||||
void ffParseGPUJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
{
|
||||
FFGPUOptions __attribute__((__cleanup__(ffDestroyGPUOptions))) options;
|
||||
ffInitGPUOptions(&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, "temp") == 0)
|
||||
{
|
||||
options.temp = (bool) json_object_get_boolean(val);
|
||||
options.temp = yyjson_get_bool(val);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (strcasecmp(key, "forceVulkan") == 0)
|
||||
{
|
||||
options.forceVulkan = (bool) json_object_get_boolean(val);
|
||||
options.forceVulkan = yyjson_get_bool(val);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -192,4 +197,3 @@ void ffParseGPUJsonObject(FFinstance* instance, json_object* module)
|
||||
|
||||
ffPrintGPU(instance, &options);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include "fastfetch.h"
|
||||
#include <yyjson.h>
|
||||
|
||||
#define FF_GPU_MODULE_NAME "GPU"
|
||||
|
||||
void ffPrintGPU(FFinstance* instance, FFGPUOptions* options);
|
||||
void ffInitGPUOptions(FFGPUOptions* options);
|
||||
bool ffParseGPUCommandOptions(FFGPUOptions* options, const char* key, const char* value);
|
||||
void ffDestroyGPUOptions(FFGPUOptions* options);
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
#include "common/jsonconfig.h"
|
||||
void ffParseGPUJsonObject(FFinstance* instance, json_object* module);
|
||||
#endif
|
||||
void ffParseGPUJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/printing.h"
|
||||
#include "common/jsonconfig.h"
|
||||
#include "detection/host/host.h"
|
||||
#include "modules/host/host.h"
|
||||
|
||||
@@ -72,16 +72,21 @@ void ffDestroyHostOptions(FFHostOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
void ffParseHostJsonObject(FFinstance* instance, json_object* module)
|
||||
void ffParseHostJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
{
|
||||
FFHostOptions __attribute__((__cleanup__(ffDestroyHostOptions))) options;
|
||||
ffInitHostOptions(&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;
|
||||
|
||||
@@ -91,4 +96,3 @@ void ffParseHostJsonObject(FFinstance* instance, json_object* module)
|
||||
|
||||
ffPrintHost(instance, &options);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "fastfetch.h"
|
||||
#include <yyjson.h>
|
||||
|
||||
#define FF_HOST_MODULE_NAME "Host"
|
||||
|
||||
@@ -8,8 +9,4 @@ void ffPrintHost(FFinstance* instance, FFHostOptions* options);
|
||||
void ffInitHostOptions(FFHostOptions* options);
|
||||
bool ffParseHostCommandOptions(FFHostOptions* options, const char* key, const char* value);
|
||||
void ffDestroyHostOptions(FFHostOptions* options);
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
#include "common/jsonconfig.h"
|
||||
void ffParseHostJsonObject(FFinstance* instance, json_object* module);
|
||||
#endif
|
||||
void ffParseHostJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/printing.h"
|
||||
#include "common/jsonconfig.h"
|
||||
#include "detection/icons/icons.h"
|
||||
#include "modules/icons/icons.h"
|
||||
|
||||
@@ -50,16 +50,21 @@ void ffDestroyIconsOptions(FFIconsOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
void ffParseIconsJsonObject(FFinstance* instance, json_object* module)
|
||||
void ffParseIconsJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
{
|
||||
FFIconsOptions __attribute__((__cleanup__(ffDestroyIconsOptions))) options;
|
||||
ffInitIconsOptions(&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;
|
||||
|
||||
@@ -69,4 +74,3 @@ void ffParseIconsJsonObject(FFinstance* instance, json_object* module)
|
||||
|
||||
ffPrintIcons(instance, &options);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "fastfetch.h"
|
||||
#include <yyjson.h>
|
||||
|
||||
#define FF_ICONS_MODULE_NAME "Icons"
|
||||
|
||||
@@ -8,8 +9,4 @@ void ffPrintIcons(FFinstance* instance, FFIconsOptions* options);
|
||||
void ffInitIconsOptions(FFIconsOptions* options);
|
||||
bool ffParseIconsCommandOptions(FFIconsOptions* options, const char* key, const char* value);
|
||||
void ffDestroyIconsOptions(FFIconsOptions* options);
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
#include "common/jsonconfig.h"
|
||||
void ffParseIconsJsonObject(FFinstance* instance, json_object* module);
|
||||
#endif
|
||||
void ffParseIconsJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
|
||||
@@ -1,28 +1,23 @@
|
||||
#include "modules/jsonconfig/jsonconfig.h"
|
||||
#include "common/jsonconfig.h"
|
||||
#include "common/printing.h"
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
|
||||
#include "common/jsonconfig.h"
|
||||
#include "common/io/io.h"
|
||||
#include "common/json.h"
|
||||
#include "modules/jsonconfig/jsonconfig.h"
|
||||
#include "modules/modules.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
|
||||
static inline bool tryModule(FFinstance* instance, const char* type, json_object* module, const char* moduleName, void (*const f)(FFinstance *instance, json_object *module))
|
||||
static inline bool tryModule(FFinstance* instance, const char* type, yyjson_val* module, const char* moduleName, void (*const f)(FFinstance *instance, yyjson_val *module))
|
||||
{
|
||||
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)
|
||||
static bool parseModuleJsonObject(FFinstance* instance, const char* type, yyjson_val* module)
|
||||
{
|
||||
switch (toupper(type[0]))
|
||||
{
|
||||
@@ -167,26 +162,52 @@ static bool parseModuleJsonObject(FFinstance* instance, const char* type, json_o
|
||||
}
|
||||
}
|
||||
|
||||
static const char* parseModules(FFinstance* instance, json_object* modules)
|
||||
static inline void wrapYyjsonFree(yyjson_doc** doc)
|
||||
{
|
||||
array_list* list = json_object_get_array(modules);
|
||||
if (!list) return "modules must be an array of strings or objects";
|
||||
assert(doc);
|
||||
if (*doc)
|
||||
yyjson_doc_free(*doc);
|
||||
}
|
||||
|
||||
for (size_t idx = 0; idx < list->length; ++idx)
|
||||
static const char* printJsonConfig(FFinstance* instance)
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY content = ffStrbufCreate();
|
||||
FF_LIST_FOR_EACH(FFstrbuf, filename, instance->state.platform.configDirs)
|
||||
{
|
||||
json_object* module = (json_object*) list->array[idx];
|
||||
const char* type = NULL;
|
||||
if (json_object_is_type(module, json_type_string))
|
||||
{
|
||||
type = json_object_get_string(module);
|
||||
uint32_t oldLength = filename->length;
|
||||
ffStrbufAppendS(filename, "fastfetch/config.jsonc");
|
||||
bool success = ffAppendFileBuffer(filename->chars, &content);
|
||||
ffStrbufSubstrBefore(filename, oldLength);
|
||||
if (success) break;
|
||||
}
|
||||
|
||||
yyjson_doc* __attribute__((__cleanup__(wrapYyjsonFree))) doc = yyjson_read_opts(content.chars, content.length, YYJSON_READ_ALLOW_COMMENTS | YYJSON_READ_ALLOW_TRAILING_COMMAS | YYJSON_READ_ALLOW_INF_AND_NAN, NULL, NULL);
|
||||
if (!doc)
|
||||
return "Failed to parse JSON config file";
|
||||
|
||||
yyjson_val* const root = yyjson_doc_get_root(doc);
|
||||
assert(root);
|
||||
|
||||
if (!yyjson_is_obj(root))
|
||||
return "Invalid JSON config format. Root value must be an object";
|
||||
|
||||
yyjson_val* modules = yyjson_obj_get(root, "modules");
|
||||
if (!modules) return "Property 'modules' is not found";
|
||||
if (!yyjson_is_arr(modules)) return "modules must be an array of strings or objects";
|
||||
|
||||
yyjson_val* item;
|
||||
size_t idx, max;
|
||||
yyjson_arr_foreach(modules, idx, max, item)
|
||||
{
|
||||
yyjson_val* module = item;
|
||||
const char* type = yyjson_get_str(module);
|
||||
if (type)
|
||||
module = NULL;
|
||||
}
|
||||
else if (json_object_is_type(module, json_type_object))
|
||||
else if (yyjson_is_obj(module))
|
||||
{
|
||||
json_object* object = json_object_object_get(module, "type");
|
||||
type = json_object_get_string(object);
|
||||
type = yyjson_get_str(yyjson_obj_get(module, "type"));
|
||||
if (!type) return "module object must contain a \"type\" key ( case sensitive )";
|
||||
if (json_object_object_length(module) == 1) // contains only Property type
|
||||
if (yyjson_obj_size(module) == 1) // contains only Property type
|
||||
module = NULL;
|
||||
}
|
||||
else
|
||||
@@ -199,56 +220,6 @@ static const char* parseModules(FFinstance* instance, json_object* modules)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static const char* printJsonConfig(FFinstance* instance)
|
||||
{
|
||||
if (!ffJsonLoadLibrary(instance))
|
||||
return "Failed to load json-c library";
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY content = ffStrbufCreate();
|
||||
FF_LIST_FOR_EACH(FFstrbuf, filename, instance->state.platform.configDirs)
|
||||
{
|
||||
uint32_t oldLength = filename->length;
|
||||
ffStrbufAppendS(filename, "fastfetch/config.jsonc");
|
||||
bool success = ffAppendFileBuffer(filename->chars, &content);
|
||||
ffStrbufSubstrBefore(filename, oldLength);
|
||||
if (success) break;
|
||||
}
|
||||
|
||||
json_object* __attribute__((__cleanup__(wrapJsoncFree))) root = json_tokener_parse(content.chars);
|
||||
if (!root)
|
||||
return "Failed to parse JSON config file";
|
||||
|
||||
lh_table* rootObject = json_object_get_object(root);
|
||||
if (!rootObject)
|
||||
return "Invalid JSON config format. Root value must be an object";
|
||||
|
||||
struct lh_entry* entry;
|
||||
lh_foreach(rootObject, entry)
|
||||
{
|
||||
const char* key = (const char *)lh_entry_k(entry);
|
||||
json_object* val = (json_object *)lh_entry_v(entry);
|
||||
|
||||
if (strcmp(key, "modules") == 0)
|
||||
{
|
||||
const char* error = parseModules(instance, val);
|
||||
if (error) return error;
|
||||
}
|
||||
else
|
||||
return "Unknown JSON config key in root object";
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static const char* printJsonConfig(FF_MAYBE_UNUSED FFinstance* instance)
|
||||
{
|
||||
return "Fastfetch was compiled without json-c support";
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void ffPrintJsonConfig(FFinstance* instance)
|
||||
{
|
||||
const char* error = printJsonConfig(instance);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/printing.h"
|
||||
#include "common/jsonconfig.h"
|
||||
#include "modules/kernel/kernel.h"
|
||||
|
||||
#define FF_KERNEL_NUM_FORMAT_ARGS 4
|
||||
@@ -50,16 +50,21 @@ void ffDestroyKernelOptions(FFKernelOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
void ffParseKernelJsonObject(FFinstance* instance, json_object* module)
|
||||
void ffParseKernelJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
{
|
||||
FFKernelOptions __attribute__((__cleanup__(ffDestroyKernelOptions))) options;
|
||||
ffInitKernelOptions(&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;
|
||||
|
||||
@@ -69,4 +74,3 @@ void ffParseKernelJsonObject(FFinstance* instance, json_object* module)
|
||||
|
||||
ffPrintKernel(instance, &options);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "fastfetch.h"
|
||||
#include "modules/kernel/option.h"
|
||||
#include <yyjson.h>
|
||||
|
||||
#define FF_KERNEL_MODULE_NAME "Kernel"
|
||||
|
||||
@@ -9,8 +9,4 @@ void ffPrintKernel(FFinstance* instance, FFKernelOptions* options);
|
||||
void ffInitKernelOptions(FFKernelOptions* options);
|
||||
bool ffParseKernelCommandOptions(FFKernelOptions* options, const char* key, const char* value);
|
||||
void ffDestroyKernelOptions(FFKernelOptions* options);
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
#include "common/jsonconfig.h"
|
||||
void ffParseKernelJsonObject(FFinstance* instance, json_object* module);
|
||||
#endif
|
||||
void ffParseKernelJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/printing.h"
|
||||
#include "common/jsonconfig.h"
|
||||
#include "detection/locale/locale.h"
|
||||
#include "modules/locale/locale.h"
|
||||
|
||||
@@ -50,16 +50,21 @@ void ffDestroyLocaleOptions(FFLocaleOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
void ffParseLocaleJsonObject(FFinstance* instance, json_object* module)
|
||||
void ffParseLocaleJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
{
|
||||
FFLocaleOptions __attribute__((__cleanup__(ffDestroyLocaleOptions))) options;
|
||||
ffInitLocaleOptions(&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;
|
||||
|
||||
@@ -69,4 +74,3 @@ void ffParseLocaleJsonObject(FFinstance* instance, json_object* module)
|
||||
|
||||
ffPrintLocale(instance, &options);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "fastfetch.h"
|
||||
#include <yyjson.h>
|
||||
|
||||
#define FF_LOCALE_MODULE_NAME "Locale"
|
||||
|
||||
@@ -8,8 +9,4 @@ void ffPrintLocale(FFinstance* instance, FFLocaleOptions* options);
|
||||
void ffInitLocaleOptions(FFLocaleOptions* options);
|
||||
bool ffParseLocaleCommandOptions(FFLocaleOptions* options, const char* key, const char* value);
|
||||
void ffDestroyLocaleOptions(FFLocaleOptions* options);
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
#include "common/jsonconfig.h"
|
||||
void ffParseLocaleJsonObject(FFinstance* instance, json_object* module);
|
||||
#endif
|
||||
void ffParseLocaleJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/printing.h"
|
||||
#include "common/jsonconfig.h"
|
||||
#include "detection/localip/localip.h"
|
||||
#include "modules/localip/localip.h"
|
||||
|
||||
@@ -194,22 +194,27 @@ void ffDestroyLocalIpOptions(FFLocalIpOptions* options)
|
||||
ffStrbufDestroy(&options->namePrefix);
|
||||
}
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
void ffParseLocalIpJsonObject(FFinstance* instance, json_object* module)
|
||||
void ffParseLocalIpJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
{
|
||||
FFLocalIpOptions __attribute__((__cleanup__(ffDestroyLocalIpOptions))) options;
|
||||
ffInitLocalIpOptions(&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, "showIpv4") == 0)
|
||||
{
|
||||
if (json_object_get_boolean(val))
|
||||
if (yyjson_get_bool(val))
|
||||
options.showType |= FF_LOCALIP_TYPE_IPV4_BIT;
|
||||
else
|
||||
options.showType &= ~FF_LOCALIP_TYPE_IPV4_BIT;
|
||||
@@ -218,7 +223,7 @@ void ffParseLocalIpJsonObject(FFinstance* instance, json_object* module)
|
||||
|
||||
if (strcasecmp(key, "showIpv6") == 0)
|
||||
{
|
||||
if (json_object_get_boolean(val))
|
||||
if (yyjson_get_bool(val))
|
||||
options.showType |= FF_LOCALIP_TYPE_IPV6_BIT;
|
||||
else
|
||||
options.showType &= ~FF_LOCALIP_TYPE_IPV6_BIT;
|
||||
@@ -227,7 +232,7 @@ void ffParseLocalIpJsonObject(FFinstance* instance, json_object* module)
|
||||
|
||||
if (strcasecmp(key, "showMac") == 0)
|
||||
{
|
||||
if (json_object_get_boolean(val))
|
||||
if (yyjson_get_bool(val))
|
||||
options.showType |= FF_LOCALIP_TYPE_MAC_BIT;
|
||||
else
|
||||
options.showType &= ~FF_LOCALIP_TYPE_MAC_BIT;
|
||||
@@ -236,7 +241,7 @@ void ffParseLocalIpJsonObject(FFinstance* instance, json_object* module)
|
||||
|
||||
if (strcasecmp(key, "showLoop") == 0)
|
||||
{
|
||||
if (json_object_get_boolean(val))
|
||||
if (yyjson_get_bool(val))
|
||||
options.showType |= FF_LOCALIP_TYPE_LOOP_BIT;
|
||||
else
|
||||
options.showType &= ~FF_LOCALIP_TYPE_LOOP_BIT;
|
||||
@@ -245,7 +250,7 @@ void ffParseLocalIpJsonObject(FFinstance* instance, json_object* module)
|
||||
|
||||
if (strcasecmp(key, "compact") == 0)
|
||||
{
|
||||
if (json_object_get_boolean(val))
|
||||
if (yyjson_get_bool(val))
|
||||
options.showType |= FF_LOCALIP_TYPE_COMPACT_BIT;
|
||||
else
|
||||
options.showType &= ~FF_LOCALIP_TYPE_COMPACT_BIT;
|
||||
@@ -254,7 +259,7 @@ void ffParseLocalIpJsonObject(FFinstance* instance, json_object* module)
|
||||
|
||||
if (strcasecmp(key, "namePrefix") == 0)
|
||||
{
|
||||
ffStrbufSetS(&options.namePrefix, json_object_get_string(val));
|
||||
ffStrbufSetS(&options.namePrefix, yyjson_get_str(val));
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -264,4 +269,3 @@ void ffParseLocalIpJsonObject(FFinstance* instance, json_object* module)
|
||||
|
||||
ffPrintLocalIp(instance, &options);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "fastfetch.h"
|
||||
#include <yyjson.h>
|
||||
|
||||
#define FF_LOCALIP_MODULE_NAME "LocalIp"
|
||||
|
||||
@@ -8,8 +9,4 @@ void ffPrintLocalIp(FFinstance* instance, FFLocalIpOptions* options);
|
||||
void ffInitLocalIpOptions(FFLocalIpOptions* options);
|
||||
bool ffParseLocalIpCommandOptions(FFLocalIpOptions* options, const char* key, const char* value);
|
||||
void ffDestroyLocalIpOptions(FFLocalIpOptions* options);
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
#include "common/jsonconfig.h"
|
||||
void ffParseLocalIpJsonObject(FFinstance* instance, json_object* module);
|
||||
#endif
|
||||
void ffParseLocalIpJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/printing.h"
|
||||
#include "common/jsonconfig.h"
|
||||
#include "detection/media/media.h"
|
||||
#include "modules/media/media.h"
|
||||
|
||||
@@ -125,16 +125,21 @@ void ffDestroyMediaOptions(FFMediaOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
void ffParseMediaJsonObject(FFinstance* instance, json_object* module)
|
||||
void ffParseMediaJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
{
|
||||
FFMediaOptions __attribute__((__cleanup__(ffDestroyMediaOptions))) options;
|
||||
ffInitMediaOptions(&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;
|
||||
|
||||
@@ -144,4 +149,3 @@ void ffParseMediaJsonObject(FFinstance* instance, json_object* module)
|
||||
|
||||
ffPrintMedia(instance, &options);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "fastfetch.h"
|
||||
#include <yyjson.h>
|
||||
|
||||
#define FF_MEDIA_MODULE_NAME "Media"
|
||||
|
||||
@@ -8,8 +9,4 @@ void ffPrintMedia(FFinstance* instance, FFMediaOptions* options);
|
||||
void ffInitMediaOptions(FFMediaOptions* options);
|
||||
bool ffParseMediaCommandOptions(FFMediaOptions* options, const char* key, const char* value);
|
||||
void ffDestroyMediaOptions(FFMediaOptions* options);
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
#include "common/jsonconfig.h"
|
||||
void ffParseMediaJsonObject(FFinstance* instance, json_object* module);
|
||||
#endif
|
||||
void ffParseMediaJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
|
||||
@@ -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/memory/memory.h"
|
||||
@@ -84,16 +84,21 @@ void ffDestroyMemoryOptions(FFMemoryOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
void ffParseMemoryJsonObject(FFinstance* instance, json_object* module)
|
||||
void ffParseMemoryJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
{
|
||||
FFMemoryOptions __attribute__((__cleanup__(ffDestroyMemoryOptions))) options;
|
||||
ffInitMemoryOptions(&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;
|
||||
|
||||
@@ -103,4 +108,3 @@ void ffParseMemoryJsonObject(FFinstance* instance, json_object* module)
|
||||
|
||||
ffPrintMemory(instance, &options);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "fastfetch.h"
|
||||
#include <yyjson.h>
|
||||
|
||||
#define FF_MEMORY_MODULE_NAME "Memory"
|
||||
|
||||
@@ -8,8 +9,4 @@ void ffPrintMemory(FFinstance* instance, FFMemoryOptions* options);
|
||||
void ffInitMemoryOptions(FFMemoryOptions* options);
|
||||
bool ffParseMemoryCommandOptions(FFMemoryOptions* options, const char* key, const char* value);
|
||||
void ffDestroyMemoryOptions(FFMemoryOptions* options);
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
#include "common/jsonconfig.h"
|
||||
void ffParseMemoryJsonObject(FFinstance* instance, json_object* module);
|
||||
#endif
|
||||
void ffParseMemoryJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/printing.h"
|
||||
#include "common/jsonconfig.h"
|
||||
#include "detection/opencl/opencl.h"
|
||||
#include "modules/opencl/opencl.h"
|
||||
|
||||
@@ -59,16 +59,21 @@ void ffDestroyOpenCLOptions(FFOpenCLOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
void ffParseOpenCLJsonObject(FFinstance* instance, json_object* module)
|
||||
void ffParseOpenCLJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
{
|
||||
FFOpenCLOptions __attribute__((__cleanup__(ffDestroyOpenCLOptions))) options;
|
||||
ffInitOpenCLOptions(&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;
|
||||
|
||||
@@ -78,4 +83,3 @@ void ffParseOpenCLJsonObject(FFinstance* instance, json_object* module)
|
||||
|
||||
ffPrintOpenCL(instance, &options);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "fastfetch.h"
|
||||
#include <yyjson.h>
|
||||
|
||||
#define FF_OPENCL_MODULE_NAME "OpenCL"
|
||||
|
||||
@@ -8,8 +9,4 @@ void ffPrintOpenCL(FFinstance* instance, FFOpenCLOptions* options);
|
||||
void ffInitOpenCLOptions(FFOpenCLOptions* options);
|
||||
bool ffParseOpenCLCommandOptions(FFOpenCLOptions* options, const char* key, const char* value);
|
||||
void ffDestroyOpenCLOptions(FFOpenCLOptions* options);
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
#include "common/jsonconfig.h"
|
||||
void ffParseOpenCLJsonObject(FFinstance* instance, json_object* module);
|
||||
#endif
|
||||
void ffParseOpenCLJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/printing.h"
|
||||
#include "common/jsonconfig.h"
|
||||
#include "detection/opengl/opengl.h"
|
||||
#include "modules/opengl/opengl.h"
|
||||
|
||||
@@ -76,16 +76,21 @@ void ffDestroyOpenGLOptions(FFOpenGLOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
void ffParseOpenGLJsonObject(FFinstance* instance, json_object* module)
|
||||
void ffParseOpenGLJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
{
|
||||
FFOpenGLOptions __attribute__((__cleanup__(ffDestroyOpenGLOptions))) options;
|
||||
ffInitOpenGLOptions(&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;
|
||||
|
||||
@@ -114,4 +119,3 @@ void ffParseOpenGLJsonObject(FFinstance* instance, json_object* module)
|
||||
|
||||
ffPrintOpenGL(instance, &options);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "fastfetch.h"
|
||||
#include <yyjson.h>
|
||||
|
||||
#define FF_OPENGL_MODULE_NAME "OpenGL"
|
||||
|
||||
@@ -8,8 +9,4 @@ void ffPrintOpenGL(FFinstance* instance, FFOpenGLOptions* options);
|
||||
void ffInitOpenGLOptions(FFOpenGLOptions* options);
|
||||
bool ffParseOpenGLCommandOptions(FFOpenGLOptions* options, const char* key, const char* value);
|
||||
void ffDestroyOpenGLOptions(FFOpenGLOptions* options);
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
#include "common/jsonconfig.h"
|
||||
void ffParseOpenGLJsonObject(FFinstance* instance, json_object* module);
|
||||
#endif
|
||||
void ffParseOpenGLJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
|
||||
+10
-6
@@ -1,5 +1,5 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/printing.h"
|
||||
#include "common/jsonconfig.h"
|
||||
#include "common/option.h"
|
||||
#include "detection/os/os.h"
|
||||
#include "modules/os/os.h"
|
||||
@@ -172,23 +172,28 @@ void ffDestroyOSOptions(FFOSOptions* options)
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
void ffParseOSJsonObject(FFinstance* instance, json_object* module)
|
||||
void ffParseOSJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
{
|
||||
FFOSOptions __attribute__((__cleanup__(ffDestroyOSOptions))) options;
|
||||
ffInitOSOptions(&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 defined(__linux__) || defined(__FreeBSD__)
|
||||
if (strcasecmp(key, "file") == 0)
|
||||
{
|
||||
ffStrbufSetS(&options.file, json_object_get_string(val));
|
||||
ffStrbufSetS(&options.file, yyjson_get_str(val));
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
@@ -199,4 +204,3 @@ void ffParseOSJsonObject(FFinstance* instance, json_object* module)
|
||||
|
||||
ffPrintOS(instance, &options);
|
||||
}
|
||||
#endif
|
||||
|
||||
+2
-6
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "fastfetch.h"
|
||||
#include "modules/os/option.h"
|
||||
#include <yyjson.h>
|
||||
|
||||
#define FF_OS_MODULE_NAME "OS"
|
||||
|
||||
@@ -9,8 +9,4 @@ void ffPrintOS(FFinstance* instance, FFOSOptions* options);
|
||||
void ffInitOSOptions(FFOSOptions* options);
|
||||
bool ffParseOSCommandOptions(FFOSOptions* options, const char* key, const char* value);
|
||||
void ffDestroyOSOptions(FFOSOptions* options);
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
#include "common/jsonconfig.h"
|
||||
void ffParseOSJsonObject(FFinstance* instance, json_object* module);
|
||||
#endif
|
||||
void ffParseOSJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/printing.h"
|
||||
#include "common/jsonconfig.h"
|
||||
#include "detection/packages/packages.h"
|
||||
#include "modules/packages/packages.h"
|
||||
|
||||
@@ -112,16 +112,21 @@ void ffDestroyPackagesOptions(FFPackagesOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
void ffParsePackagesJsonObject(FFinstance* instance, json_object* module)
|
||||
void ffParsePackagesJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
{
|
||||
FFPackagesOptions __attribute__((__cleanup__(ffDestroyPackagesOptions))) options;
|
||||
ffInitPackagesOptions(&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;
|
||||
|
||||
@@ -131,4 +136,3 @@ void ffParsePackagesJsonObject(FFinstance* instance, json_object* module)
|
||||
|
||||
ffPrintPackages(instance, &options);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "fastfetch.h"
|
||||
#include "modules/packages/option.h"
|
||||
#include <yyjson.h>
|
||||
|
||||
#define FF_PACKAGES_MODULE_NAME "Packages"
|
||||
|
||||
@@ -9,8 +9,4 @@ void ffPrintPackages(FFinstance* instance, FFPackagesOptions* options);
|
||||
void ffInitPackagesOptions(FFPackagesOptions* options);
|
||||
bool ffParsePackagesCommandOptions(FFPackagesOptions* options, const char* key, const char* value);
|
||||
void ffDestroyPackagesOptions(FFPackagesOptions* options);
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
#include "common/jsonconfig.h"
|
||||
void ffParsePackagesJsonObject(FFinstance* instance, json_object* module);
|
||||
#endif
|
||||
void ffParsePackagesJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/printing.h"
|
||||
#include "common/jsonconfig.h"
|
||||
#include "detection/media/media.h"
|
||||
#include "modules/player/player.h"
|
||||
|
||||
@@ -97,16 +97,21 @@ void ffDestroyPlayerOptions(FFPlayerOptions* options)
|
||||
ffStrbufDestroy(&options->name);
|
||||
}
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
void ffParsePlayerJsonObject(FFinstance* instance, json_object* module)
|
||||
void ffParsePlayerJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
{
|
||||
FFPlayerOptions __attribute__((__cleanup__(ffDestroyPlayerOptions))) options;
|
||||
ffInitPlayerOptions(&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;
|
||||
|
||||
@@ -116,4 +121,3 @@ void ffParsePlayerJsonObject(FFinstance* instance, json_object* module)
|
||||
|
||||
ffPrintPlayer(instance, &options);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "fastfetch.h"
|
||||
#include <yyjson.h>
|
||||
|
||||
#define FF_PLAYER_MODULE_NAME "Player"
|
||||
|
||||
@@ -9,8 +10,4 @@ void ffPrintPlayer(FFinstance* instance, FFPlayerOptions* options);
|
||||
void ffInitPlayerOptions(FFPlayerOptions* options);
|
||||
bool ffParsePlayerCommandOptions(FFPlayerOptions* options, const char* key, const char* value);
|
||||
void ffDestroyPlayerOptions(FFPlayerOptions* options);
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
#include "common/jsonconfig.h"
|
||||
void ffParsePlayerJsonObject(FFinstance* instance, json_object* module);
|
||||
#endif
|
||||
void ffParsePlayerJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/printing.h"
|
||||
#include "common/jsonconfig.h"
|
||||
#include "detection/poweradapter/poweradapter.h"
|
||||
#include "modules/poweradapter/poweradapter.h"
|
||||
|
||||
@@ -83,16 +83,21 @@ void ffDestroyPowerAdapterOptions(FFPowerAdapterOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
void ffParsePowerAdapterJsonObject(FFinstance* instance, json_object* module)
|
||||
void ffParsePowerAdapterJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
{
|
||||
FFPowerAdapterOptions __attribute__((__cleanup__(ffDestroyPowerAdapterOptions))) options;
|
||||
ffInitPowerAdapterOptions(&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;
|
||||
|
||||
@@ -102,4 +107,3 @@ void ffParsePowerAdapterJsonObject(FFinstance* instance, json_object* module)
|
||||
|
||||
ffPrintPowerAdapter(instance, &options);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "fastfetch.h"
|
||||
#include <yyjson.h>
|
||||
|
||||
#define FF_POWERADAPTER_MODULE_NAME "PowerAdapter"
|
||||
|
||||
@@ -8,8 +9,4 @@ void ffPrintPowerAdapter(FFinstance* instance, FFPowerAdapterOptions* options);
|
||||
void ffInitPowerAdapterOptions(FFPowerAdapterOptions* options);
|
||||
bool ffParsePowerAdapterCommandOptions(FFPowerAdapterOptions* options, const char* key, const char* value);
|
||||
void ffDestroyPowerAdapterOptions(FFPowerAdapterOptions* options);
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
#include "common/jsonconfig.h"
|
||||
void ffParsePowerAdapterJsonObject(FFinstance* instance, json_object* module);
|
||||
#endif
|
||||
void ffParsePowerAdapterJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/printing.h"
|
||||
#include "common/jsonconfig.h"
|
||||
#include "detection/processes/processes.h"
|
||||
#include "modules/processes/processes.h"
|
||||
|
||||
@@ -51,16 +51,21 @@ void ffDestroyProcessesOptions(FFProcessesOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
void ffParseProcessesJsonObject(FFinstance* instance, json_object* module)
|
||||
void ffParseProcessesJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
{
|
||||
FFProcessesOptions __attribute__((__cleanup__(ffDestroyProcessesOptions))) options;
|
||||
ffInitProcessesOptions(&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;
|
||||
|
||||
@@ -70,4 +75,3 @@ void ffParseProcessesJsonObject(FFinstance* instance, json_object* module)
|
||||
|
||||
ffPrintProcesses(instance, &options);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "fastfetch.h"
|
||||
#include <yyjson.h>
|
||||
|
||||
#define FF_PROCESSES_MODULE_NAME "Processes"
|
||||
|
||||
@@ -8,8 +9,4 @@ void ffPrintProcesses(FFinstance* instance, FFProcessesOptions* options);
|
||||
void ffInitProcessesOptions(FFProcessesOptions* options);
|
||||
bool ffParseProcessesCommandOptions(FFProcessesOptions* options, const char* key, const char* value);
|
||||
void ffDestroyProcessesOptions(FFProcessesOptions* options);
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
#include "common/jsonconfig.h"
|
||||
void ffParseProcessesJsonObject(FFinstance* instance, json_object* module);
|
||||
#endif
|
||||
void ffParseProcessesJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/printing.h"
|
||||
#include "common/jsonconfig.h"
|
||||
#include "common/networking.h"
|
||||
#include "modules/publicip/publicip.h"
|
||||
|
||||
@@ -103,28 +103,33 @@ void ffDestroyPublicIpOptions(FFPublicIpOptions* options)
|
||||
ffStrbufDestroy(&options->url);
|
||||
}
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
void ffParsePublicIpJsonObject(FFinstance* instance, json_object* module)
|
||||
void ffParsePublicIpJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
{
|
||||
FFPublicIpOptions __attribute__((__cleanup__(ffDestroyPublicIpOptions))) options;
|
||||
ffInitPublicIpOptions(&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, "url") == 0)
|
||||
{
|
||||
ffStrbufSetS(&options.url, json_object_get_string(val));
|
||||
ffStrbufSetS(&options.url, yyjson_get_str(val));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (strcasecmp(key, "timeout") == 0)
|
||||
{
|
||||
options.timeout = (uint32_t) json_object_get_int(val);
|
||||
options.timeout = (uint32_t) yyjson_get_uint(val);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -134,4 +139,3 @@ void ffParsePublicIpJsonObject(FFinstance* instance, json_object* module)
|
||||
|
||||
ffPrintPublicIp(instance, &options);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "fastfetch.h"
|
||||
#include <yyjson.h>
|
||||
|
||||
#define FF_PUBLICIP_MODULE_NAME "PublicIp"
|
||||
|
||||
@@ -10,8 +11,4 @@ void ffPrintPublicIp(FFinstance* instance, FFPublicIpOptions* options);
|
||||
void ffInitPublicIpOptions(FFPublicIpOptions* options);
|
||||
bool ffParsePublicIpCommandOptions(FFPublicIpOptions* options, const char* key, const char* value);
|
||||
void ffDestroyPublicIpOptions(FFPublicIpOptions* options);
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
#include "common/jsonconfig.h"
|
||||
void ffParsePublicIpJsonObject(FFinstance* instance, json_object* module);
|
||||
#endif
|
||||
void ffParsePublicIpJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/printing.h"
|
||||
#include "common/jsonconfig.h"
|
||||
#include "modules/separator/separator.h"
|
||||
|
||||
void ffPrintSeparator(FFinstance* instance, FFSeparatorOptions* options)
|
||||
@@ -58,19 +58,24 @@ void ffDestroySeparatorOptions(FFSeparatorOptions* options)
|
||||
ffStrbufDestroy(&options->string);
|
||||
}
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
void ffParseSeparatorJsonObject(FFinstance* instance, json_object* module)
|
||||
void ffParseSeparatorJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
{
|
||||
FFSeparatorOptions __attribute__((__cleanup__(ffDestroySeparatorOptions))) options;
|
||||
ffInitSeparatorOptions(&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 (strcasecmp(key, "string") == 0)
|
||||
{
|
||||
ffStrbufSetS(&options.string, json_object_get_string(val));
|
||||
ffStrbufSetS(&options.string, yyjson_get_str(val));
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -80,4 +85,3 @@ void ffParseSeparatorJsonObject(FFinstance* instance, json_object* module)
|
||||
|
||||
ffPrintSeparator(instance, &options);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "fastfetch.h"
|
||||
#include "modules/separator/option.h"
|
||||
#include <yyjson.h>
|
||||
|
||||
#define FF_SEPARATOR_MODULE_NAME "Separator"
|
||||
|
||||
@@ -9,8 +9,4 @@ void ffPrintSeparator(FFinstance* instance, FFSeparatorOptions* options);
|
||||
void ffInitSeparatorOptions(FFSeparatorOptions* options);
|
||||
bool ffParseSeparatorCommandOptions(FFSeparatorOptions* options, const char* key, const char* value);
|
||||
void ffDestroySeparatorOptions(FFSeparatorOptions* options);
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
#include "common/jsonconfig.h"
|
||||
void ffParseSeparatorJsonObject(FFinstance* instance, json_object* module);
|
||||
#endif
|
||||
void ffParseSeparatorJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/printing.h"
|
||||
#include "common/jsonconfig.h"
|
||||
#include "detection/terminalshell/terminalshell.h"
|
||||
#include "modules/shell/shell.h"
|
||||
|
||||
@@ -71,22 +71,27 @@ void ffDestroyShellOptions(FFShellOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
void ffParseShellJsonObject(FFinstance* instance, json_object* module)
|
||||
void ffParseShellJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
{
|
||||
FFShellOptions __attribute__((__cleanup__(ffDestroyShellOptions))) options;
|
||||
ffInitShellOptions(&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, "version") == 0)
|
||||
{
|
||||
options.version = (bool) json_object_get_boolean(val);
|
||||
options.version = yyjson_get_bool(val);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -96,4 +101,3 @@ void ffParseShellJsonObject(FFinstance* instance, json_object* module)
|
||||
|
||||
ffPrintShell(instance, &options);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "fastfetch.h"
|
||||
#include <yyjson.h>
|
||||
|
||||
#define FF_SHELL_MODULE_NAME "Shell"
|
||||
|
||||
@@ -8,8 +9,4 @@ void ffPrintShell(FFinstance* instance, FFShellOptions* options);
|
||||
void ffInitShellOptions(FFShellOptions* options);
|
||||
bool ffParseShellCommandOptions(FFShellOptions* options, const char* key, const char* value);
|
||||
void ffDestroyShellOptions(FFShellOptions* options);
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
#include "common/jsonconfig.h"
|
||||
void ffParseShellJsonObject(FFinstance* instance, json_object* module);
|
||||
#endif
|
||||
void ffParseShellJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "common/printing.h"
|
||||
#include "common/jsonconfig.h"
|
||||
#include "detection/sound/sound.h"
|
||||
#include "modules/sound/sound.h"
|
||||
|
||||
@@ -115,16 +116,21 @@ void ffDestroySoundOptions(FFSoundOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
void ffParseSoundJsonObject(FFinstance* instance, json_object* module)
|
||||
void ffParseSoundJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
{
|
||||
FFSoundOptions __attribute__((__cleanup__(ffDestroySoundOptions))) options;
|
||||
ffInitSoundOptions(&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;
|
||||
|
||||
@@ -150,4 +156,3 @@ void ffParseSoundJsonObject(FFinstance* instance, json_object* module)
|
||||
|
||||
ffPrintSound(instance, &options);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "fastfetch.h"
|
||||
#include "modules/title/option.h"
|
||||
#include <yyjson.h>
|
||||
|
||||
#define FF_SOUND_MODULE_NAME "Sound"
|
||||
|
||||
@@ -9,8 +9,4 @@ void ffPrintSound(FFinstance* instance, FFSoundOptions* options);
|
||||
void ffInitSoundOptions(FFSoundOptions* options);
|
||||
bool ffParseSoundCommandOptions(FFSoundOptions* options, const char* key, const char* value);
|
||||
void ffDestroySoundOptions(FFSoundOptions* options);
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
#include "common/jsonconfig.h"
|
||||
void ffParseSoundJsonObject(FFinstance* instance, json_object* module);
|
||||
#endif
|
||||
void ffParseSoundJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
|
||||
@@ -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/swap/swap.h"
|
||||
@@ -84,16 +84,21 @@ void ffDestroySwapOptions(FFSwapOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
void ffParseSwapJsonObject(FFinstance* instance, json_object* module)
|
||||
void ffParseSwapJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
{
|
||||
FFSwapOptions __attribute__((__cleanup__(ffDestroySwapOptions))) options;
|
||||
ffInitSwapOptions(&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;
|
||||
|
||||
@@ -103,4 +108,3 @@ void ffParseSwapJsonObject(FFinstance* instance, json_object* module)
|
||||
|
||||
ffPrintSwap(instance, &options);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "fastfetch.h"
|
||||
#include <yyjson.h>
|
||||
|
||||
#define FF_SWAP_MODULE_NAME "Swap"
|
||||
|
||||
@@ -8,8 +9,4 @@ void ffPrintSwap(FFinstance* instance, FFSwapOptions* options);
|
||||
void ffInitSwapOptions(FFSwapOptions* options);
|
||||
bool ffParseSwapCommandOptions(FFSwapOptions* options, const char* key, const char* value);
|
||||
void ffDestroySwapOptions(FFSwapOptions* options);
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
#include "common/jsonconfig.h"
|
||||
void ffParseSwapJsonObject(FFinstance* instance, json_object* module);
|
||||
#endif
|
||||
void ffParseSwapJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/printing.h"
|
||||
#include "common/jsonconfig.h"
|
||||
#include "detection/terminalshell/terminalshell.h"
|
||||
#include "modules/terminal/terminal.h"
|
||||
|
||||
@@ -72,22 +72,27 @@ void ffDestroyTerminalOptions(FFTerminalOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
void ffParseTerminalJsonObject(FFinstance* instance, json_object* module)
|
||||
void ffParseTerminalJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
{
|
||||
FFTerminalOptions __attribute__((__cleanup__(ffDestroyTerminalOptions))) options;
|
||||
ffInitTerminalOptions(&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, "version") == 0)
|
||||
{
|
||||
options.version = (bool) json_object_get_boolean(val);
|
||||
options.version = yyjson_get_bool(val);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -97,4 +102,3 @@ void ffParseTerminalJsonObject(FFinstance* instance, json_object* module)
|
||||
|
||||
ffPrintTerminal(instance, &options);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "fastfetch.h"
|
||||
#include <yyjson.h>
|
||||
|
||||
#define FF_TERMINAL_MODULE_NAME "Terminal"
|
||||
|
||||
@@ -8,8 +9,4 @@ void ffPrintTerminal(FFinstance* instance, FFTerminalOptions* options);
|
||||
void ffInitTerminalOptions(FFTerminalOptions* options);
|
||||
bool ffParseTerminalCommandOptions(FFTerminalOptions* options, const char* key, const char* value);
|
||||
void ffDestroyTerminalOptions(FFTerminalOptions* options);
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
#include "common/jsonconfig.h"
|
||||
void ffParseTerminalJsonObject(FFinstance* instance, json_object* module);
|
||||
#endif
|
||||
void ffParseTerminalJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/printing.h"
|
||||
#include "common/jsonconfig.h"
|
||||
#include "detection/terminalfont/terminalfont.h"
|
||||
#include "modules/terminalfont/terminalfont.h"
|
||||
|
||||
@@ -53,16 +53,21 @@ void ffDestroyTerminalFontOptions(FFTerminalFontOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
void ffParseTerminalFontJsonObject(FFinstance* instance, json_object* module)
|
||||
void ffParseTerminalFontJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
{
|
||||
FFTerminalFontOptions __attribute__((__cleanup__(ffDestroyTerminalFontOptions))) options;
|
||||
ffInitTerminalFontOptions(&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;
|
||||
|
||||
@@ -72,4 +77,3 @@ void ffParseTerminalFontJsonObject(FFinstance* instance, json_object* module)
|
||||
|
||||
ffPrintTerminalFont(instance, &options);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "fastfetch.h"
|
||||
#include <yyjson.h>
|
||||
|
||||
#define FF_TERMINALFONT_MODULE_NAME "TerminalFont"
|
||||
|
||||
@@ -8,8 +9,4 @@ void ffPrintTerminalFont(FFinstance* instance, FFTerminalFontOptions* options);
|
||||
void ffInitTerminalFontOptions(FFTerminalFontOptions* options);
|
||||
bool ffParseTerminalFontCommandOptions(FFTerminalFontOptions* options, const char* key, const char* value);
|
||||
void ffDestroyTerminalFontOptions(FFTerminalFontOptions* options);
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
#include "common/jsonconfig.h"
|
||||
void ffParseTerminalFontJsonObject(FFinstance* instance, json_object* module);
|
||||
#endif
|
||||
void ffParseTerminalFontJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/printing.h"
|
||||
#include "common/jsonconfig.h"
|
||||
#include "detection/theme/theme.h"
|
||||
#include "modules/theme/theme.h"
|
||||
|
||||
@@ -50,16 +50,21 @@ void ffDestroyThemeOptions(FFThemeOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
void ffParseThemeJsonObject(FFinstance* instance, json_object* module)
|
||||
void ffParseThemeJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
{
|
||||
FFThemeOptions __attribute__((__cleanup__(ffDestroyThemeOptions))) options;
|
||||
ffInitThemeOptions(&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;
|
||||
|
||||
@@ -69,4 +74,3 @@ void ffParseThemeJsonObject(FFinstance* instance, json_object* module)
|
||||
|
||||
ffPrintTheme(instance, &options);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "fastfetch.h"
|
||||
#include <yyjson.h>
|
||||
|
||||
#define FF_THEME_MODULE_NAME "Theme"
|
||||
|
||||
@@ -8,8 +9,4 @@ void ffPrintTheme(FFinstance* instance, FFThemeOptions* options);
|
||||
void ffInitThemeOptions(FFThemeOptions* options);
|
||||
bool ffParseThemeCommandOptions(FFThemeOptions* options, const char* key, const char* value);
|
||||
void ffDestroyThemeOptions(FFThemeOptions* options);
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
#include "common/jsonconfig.h"
|
||||
void ffParseThemeJsonObject(FFinstance* instance, json_object* module);
|
||||
#endif
|
||||
void ffParseThemeJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/printing.h"
|
||||
#include "common/jsonconfig.h"
|
||||
#include "util/textModifier.h"
|
||||
#include "modules/title/title.h"
|
||||
|
||||
@@ -58,19 +58,24 @@ void ffDestroyTitleOptions(FFTitleOptions* options)
|
||||
FF_UNUSED(options);
|
||||
}
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
void ffParseTitleJsonObject(FFinstance* instance, json_object* module)
|
||||
void ffParseTitleJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
{
|
||||
FFTitleOptions __attribute__((__cleanup__(ffDestroyTitleOptions))) options;
|
||||
ffInitTitleOptions(&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 (strcasecmp(key, "fdqn") == 0)
|
||||
{
|
||||
options.fdqn = json_object_get_boolean(val);
|
||||
options.fdqn = yyjson_get_bool(val);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -80,4 +85,3 @@ void ffParseTitleJsonObject(FFinstance* instance, json_object* module)
|
||||
|
||||
ffPrintTitle(instance, &options);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "fastfetch.h"
|
||||
#include "modules/title/option.h"
|
||||
#include <yyjson.h>
|
||||
|
||||
#define FF_TITLE_MODULE_NAME "Title"
|
||||
|
||||
@@ -9,8 +9,4 @@ void ffPrintTitle(FFinstance* instance, FFTitleOptions* options);
|
||||
void ffInitTitleOptions(FFTitleOptions* options);
|
||||
bool ffParseTitleCommandOptions(FFTitleOptions* options, const char* key, const char* value);
|
||||
void ffDestroyTitleOptions(FFTitleOptions* options);
|
||||
|
||||
#ifdef FF_HAVE_JSONC
|
||||
#include "common/jsonconfig.h"
|
||||
void ffParseTitleJsonObject(FFinstance* instance, json_object* module);
|
||||
#endif
|
||||
void ffParseTitleJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user