diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cdaff52751..461d96127d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -456,7 +456,7 @@ jobs: with: msystem: CLANG64 update: true - install: git mingw-w64-clang-x86_64-7zip mingw-w64-clang-x86_64-cmake mingw-w64-clang-x86_64-clang mingw-w64-clang-x86_64-vulkan-loader mingw-w64-clang-x86_64-vulkan-headers mingw-w64-clang-x86_64-opencl-icd mingw-w64-clang-x86_64-opencl-headers mingw-w64-clang-x86_64-cppwinrt + install: git mingw-w64-clang-x86_64-7zip mingw-w64-clang-x86_64-cmake mingw-w64-clang-x86_64-clang mingw-w64-clang-x86_64-vulkan-loader mingw-w64-clang-x86_64-vulkan-headers mingw-w64-clang-x86_64-opencl-icd mingw-w64-clang-x86_64-opencl-headers mingw-w64-clang-x86_64-cppwinrt mingw-w64-clang-x86_64-imagemagick - name: print msys version run: uname -a diff --git a/CHANGELOG.md b/CHANGELOG.md index 358c99164d..647b07c0db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,33 @@ +# 2.24.0 + +Changes: +* Support of `--lib-XXX` is removed + * If fastfetch fails to load some `.so` `.dylib` libraries, `LD_LIBRARY_PATH` should be used. + +Features: +* Support sixel image protocol on Windows (Logo, Windows) + * Requires imagemagick7 to be installed. MSYS2 is recommended. +* Improve terminal query on Windows (Windows) + * TerminalSize, TerminalTheme +* Detect more ARM microarchitectures and SOC names (CPU, Linux) +* Detect the number of online cores (CPU, FreeBSD) +* Support board name detection for Asahi Linux (Board, Linux) +* Add new option `--command-param` to customize the parameters when running shell +* Support syntax of sub string in `---format`: `{variable~startIndex,endIndex}` + * See `fastfetch -h format` for detail + +Bugfixes: +* Fix tests building when system yyjson is used (#1244) +* Fix dinit detection; support dinit version detection (#1245, InitSystem, Linux) +* Fix signal quality, refresh rate and maybe others in custom format (#1241) +* Fix boot time calculation (#1249, Uptime, Linux) +* Fix custom format for boolean values + * `{?false-value}This should not print{?}{?true-value}This should print{?}` will print `This should print` +* Fix possible hanging when running fastfetch in screen 5.0 (TerminalTheme, macOS) + +Logos: +* Add Lliurex + # 2.23.0 Features: diff --git a/CMakeLists.txt b/CMakeLists.txt index 712250b8cb..7efcfde89d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.12.0) # target_link_libraries with OBJECT libs & project homepage url project(fastfetch - VERSION 2.23.0 + VERSION 2.24.0 LANGUAGES C DESCRIPTION "Fast neofetch-like system information tool" HOMEPAGE_URL "https://github.com/fastfetch-cli/fastfetch" @@ -69,7 +69,7 @@ cmake_dependent_option(ENABLE_FREETYPE "Enable freetype" ON "ANDROID" OFF) cmake_dependent_option(ENABLE_PULSE "Enable pulse" ON "LINUX OR SunOS" OFF) cmake_dependent_option(ENABLE_DDCUTIL "Enable ddcutil" ON "LINUX" OFF) cmake_dependent_option(ENABLE_DIRECTX_HEADERS "Enable DirectX headers for WSL" ON "LINUX" OFF) -cmake_dependent_option(ENABLE_ELF "Enable libelf" ON "LINUX OR FreeBSD OR ANDROID" OFF) +cmake_dependent_option(ENABLE_ELF "Enable libelf" ON "LINUX OR ANDROID" OFF) cmake_dependent_option(ENABLE_THREADS "Enable multithreading" ON "Threads_FOUND" OFF) cmake_dependent_option(ENABLE_LIBZFS "Enable libzfs" ON "LINUX OR FreeBSD OR SunOS" OFF) @@ -398,7 +398,6 @@ set(LIBFASTFETCH_SRC src/options/modules.c src/options/logo.c src/options/general.c - src/options/library.c src/util/edidHelper.c src/util/base64.c src/util/FFlist.c @@ -1348,6 +1347,9 @@ if (BUILD_TESTS) target_link_libraries(fastfetch-test-format PRIVATE libfastfetch ) + if(yyjson_FOUND) + target_compile_definitions(fastfetch-test-format PRIVATE FF_USE_SYSTEM_YYJSON) + endif() enable_testing() add_test(NAME test-strbuf COMMAND fastfetch-test-strbuf) diff --git a/README.md b/README.md index 036e028e6f..362773418f 100644 --- a/README.md +++ b/README.md @@ -81,7 +81,7 @@ See Wiki: https://github.com/fastfetch-cli/fastfetch/wiki/Building ## Usage * Run it with default configuration: `fastfetch` -* Run it with [all supported modules](https://github.com/fastfetch-cli/fastfetch/wiki/Support+Status#available-modules) and find what you interest: `fastfetch -c all.jsonc` +* Run it with [all supported modules](https://github.com/fastfetch-cli/fastfetch/wiki/Support+Status#available-modules) and find what interests you: `fastfetch -c all.jsonc` * Find all data that fastfetch detects: `fastfetch -s --format json` * Display help messages: `fastfetch --help` * Generate config file based on command line arguments: `fastfetch --arg1 --arg2 --gen-config` diff --git a/debian/changelog b/debian/changelog index d647181de7..bb2ff4cd8b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +fastfetch (2.23.0) jammy; urgency=medium + + * Update to 2.23.0 + + -- Carter Li Tue, 03 Sep 2024 18:44:11 +0800 + fastfetch (2.22.0) jammy; urgency=medium * Update to 2.22.0 diff --git a/debian/files b/debian/files index 19482ef876..5c6a37a05f 100644 --- a/debian/files +++ b/debian/files @@ -1 +1 @@ -fastfetch_2.22.0_source.buildinfo universe/utils optional +fastfetch_2.23.0_source.buildinfo universe/utils optional diff --git a/doc/json_schema.json b/doc/json_schema.json index 9829f034dd..db9e587b53 100644 --- a/doc/json_schema.json +++ b/doc/json_schema.json @@ -638,113 +638,6 @@ } } }, - "library": { - "description": "Set the path of a library to load", - "type": "object", - "additionalProperties": false, - "properties": { - "vulkan": { - "type": "string", - "description": "Vulkan module & fallback for GPU output" - }, - "freetype": { - "type": "string", - "description": "Used for Termux font detection (Android)" - }, - "wayland": { - "type": "string", - "description": "Better display performance and output in wayland sessions.\nSupports different refresh rates per monitor.\n(Linux, FreeBSD)" - }, - "xcbRandr": { - "type": "string", - "description": "X11 sessions for better display detection and faster WM detection.\nThe *randr ones provide multi monitor support The libxcb* ones usually have better performance.\n (Linux, FreeBSD, SunOS)" - }, - "xcb": { - "type": "string", - "description": "X11 sessions for better display detection and faster WM detection.\nThe *randr ones provide multi monitor support The libxcb* ones usually have better performance.\n (Linux, FreeBSD, SunOS)" - }, - "xrandr": { - "type": "string", - "description": "X11 sessions for better display detection and faster WM detection.\nThe *randr ones provide multi monitor support The libxcb* ones usually have better performance.\n (Linux, FreeBSD, SunOS)" - }, - "x11": { - "type": "string", - "description": "X11 sessions for better display detection and faster WM detection.\nThe *randr ones provide multi monitor support The libxcb* ones usually have better performance.\n (Linux, FreeBSD, SunOS)" - }, - "drm": { - "type": "string", - "description": "Used for fast resolution and refresh rate detection (Linux, FreeBSD)" - }, - "gio": { - "type": "string", - "description": "Needed for values that are only stored GSettings (Linux, FreeBSD, SunOS)" - }, - "dconf": { - "type": "string", - "description": "Needed for values that are only stored in DConf + Fallback for GSettings (Linux, FreeBSD, SunOS)" - }, - "dbus": { - "type": "string", - "description": "Bluetooth, Player & Media detection (Linux, FreeBSD, SunOS)" - }, - "xfconf": { - "type": "string", - "description": "Needed for XFWM theme and XFCE Terminal font (Linux, FreeBSD, SunOS)" - }, - "sqlite3": { - "type": "string", - "description": "Needed for pkg & rpm package count (Linux, FreeBSD)" - }, - "rpm": { - "type": "string", - "description": "Slower fallback for rpm package count. Needed on openSUSE & old CentOS / Redhat. (Linux)" - }, - "imagemagick": { - "type": "string", - "description": "Images in terminal using sixel or kitty graphics protocol (Linux, FreeBSD, SunOS, macOS)" - }, - "z": { - "description": "Libz. Faster image output when using kitty graphics protocol (Linux, FreeBSD, SunOS, macOS)", - "type": "string" - }, - "chafa": { - "type": "string", - "description": "Image output as ascii art (Linux, FreeBSD, SunOS, macOS)" - }, - "egl": { - "type": "string", - "description": "Library used by the OpenGL module for gl context creation (Linux, FreeBSD, SunOS, Windows)" - }, - "glx": { - "type": "string", - "description": "Library used by the OpenGL module for gl context creation (Linux, FreeBSD, SunOS)" - }, - "osmesa": { - "type": "string", - "description": "Library used by the OpenGL module for gl context creation (Linux, FreeBSD, SunOS)" - }, - "opencl": { - "type": "string", - "description": "OpenCL module (Linux, FreeBSD, SunOS, Windows)" - }, - "pulse": { - "description": "Pulseaudio. Used for Sound detection (Linux, FreeBSD, SunOS)", - "type": "string" - }, - "nm": { - "description": "NetworkManager. Used for Wifi detection (Linux)", - "type": "string" - }, - "ddcutil": { - "description": "Used for brightness detection of external displays (Linux)", - "type": "string" - }, - "elf": { - "description": "Used for st terminal font detection and systemd version detection (Linux)", - "type": "string" - } - } - }, "modules": { "description": "Fastfetch modules to run", "type": "array", @@ -1343,6 +1236,10 @@ "description": "Set the shell program to execute the command text\nDefault: cmd for Windows, /bin/sh for *nix", "type": "string" }, + "param": { + "description": "Set the parameter used when starting the shell\nDefault: /c for Windows, -c for *nix", + "type": "string" + }, "text": { "description": "Set the command text to be executed", "type": "string" diff --git a/presets/examples/9.jsonc b/presets/examples/9.jsonc index a67954de6b..eda3d0eff7 100644 --- a/presets/examples/9.jsonc +++ b/presets/examples/9.jsonc @@ -25,7 +25,10 @@ "type": "disk", "folders": "/" }, - "battery", + { + "type": "battery", + "key": "Battery" + }, { "type": "colors", "paddingLeft": 10, diff --git a/src/common/dbus.c b/src/common/dbus.c index 553d7eff70..636cce7a6d 100644 --- a/src/common/dbus.c +++ b/src/common/dbus.c @@ -7,7 +7,7 @@ static bool loadLibSymbols(FFDBusLibrary* lib) { - FF_LIBRARY_LOAD(dbus, &instance.config.library.libDBus, false, "libdbus-1" FF_LIBRARY_EXTENSION, 4); + FF_LIBRARY_LOAD(dbus, false, "libdbus-1" FF_LIBRARY_EXTENSION, 4); FF_LIBRARY_LOAD_SYMBOL_PTR(dbus, lib, dbus_bus_get, false) FF_LIBRARY_LOAD_SYMBOL_PTR(dbus, lib, dbus_message_new_method_call, false) FF_LIBRARY_LOAD_SYMBOL_PTR(dbus, lib, dbus_message_append_args, false) diff --git a/src/common/format.c b/src/common/format.c index 74f59d865a..1e8c927020 100644 --- a/src/common/format.c +++ b/src/common/format.c @@ -8,39 +8,53 @@ void ffFormatAppendFormatArg(FFstrbuf* buffer, const FFformatarg* formatarg) { - if(formatarg->type == FF_FORMAT_ARG_TYPE_INT) - ffStrbufAppendF(buffer, "%i", *(int*)formatarg->value); - else if(formatarg->type == FF_FORMAT_ARG_TYPE_UINT) - ffStrbufAppendF(buffer, "%" PRIu32, *(uint32_t*)formatarg->value); - else if(formatarg->type == FF_FORMAT_ARG_TYPE_UINT64) - ffStrbufAppendF(buffer, "%" PRIu64, *(uint64_t*)formatarg->value); - else if(formatarg->type == FF_FORMAT_ARG_TYPE_UINT16) - ffStrbufAppendF(buffer, "%" PRIu16, *(uint16_t*)formatarg->value); - else if(formatarg->type == FF_FORMAT_ARG_TYPE_UINT8) - ffStrbufAppendF(buffer, "%" PRIu8, *(uint8_t*)formatarg->value); - else if(formatarg->type == FF_FORMAT_ARG_TYPE_STRING) - ffStrbufAppendS(buffer, (const char*)formatarg->value); - else if(formatarg->type == FF_FORMAT_ARG_TYPE_STRBUF) - ffStrbufAppend(buffer, (FFstrbuf*)formatarg->value); - else if(formatarg->type == FF_FORMAT_ARG_TYPE_FLOAT) - ffStrbufAppendF(buffer, "%f", *(float*)formatarg->value); - else if(formatarg->type == FF_FORMAT_ARG_TYPE_DOUBLE) - ffStrbufAppendF(buffer, "%g", *(double*)formatarg->value); - else if(formatarg->type == FF_FORMAT_ARG_TYPE_BOOL) - ffStrbufAppendS(buffer, *(bool*)formatarg->value ? "true" : "false"); - else if(formatarg->type == FF_FORMAT_ARG_TYPE_LIST) + switch(formatarg->type) { - const FFlist* list = formatarg->value; - for(uint32_t i = 0; i < list->length; i++) + case FF_FORMAT_ARG_TYPE_INT: + ffStrbufAppendF(buffer, "%" PRIi32, *(int32_t*)formatarg->value); + break; + case FF_FORMAT_ARG_TYPE_UINT: + ffStrbufAppendF(buffer, "%" PRIu32, *(uint32_t*)formatarg->value); + break; + case FF_FORMAT_ARG_TYPE_UINT64: + ffStrbufAppendF(buffer, "%" PRIu64, *(uint64_t*)formatarg->value); + break; + case FF_FORMAT_ARG_TYPE_UINT16: + ffStrbufAppendF(buffer, "%" PRIu16, *(uint16_t*)formatarg->value); + break; + case FF_FORMAT_ARG_TYPE_UINT8: + ffStrbufAppendF(buffer, "%" PRIu8, *(uint8_t*)formatarg->value); + break; + case FF_FORMAT_ARG_TYPE_STRING: + ffStrbufAppendS(buffer, (const char*)formatarg->value); + break; + case FF_FORMAT_ARG_TYPE_STRBUF: + ffStrbufAppend(buffer, (FFstrbuf*)formatarg->value); + break; + case FF_FORMAT_ARG_TYPE_FLOAT: + ffStrbufAppendF(buffer, "%f", *(float*)formatarg->value); + break; + case FF_FORMAT_ARG_TYPE_DOUBLE: + ffStrbufAppendF(buffer, "%g", *(double*)formatarg->value); + break; + case FF_FORMAT_ARG_TYPE_BOOL: + ffStrbufAppendS(buffer, *(bool*)formatarg->value ? "true" : "false"); + break; + case FF_FORMAT_ARG_TYPE_LIST: { - ffStrbufAppend(buffer, ffListGet(list, i)); - if(i < list->length - 1) - ffStrbufAppendS(buffer, ", "); + const FFlist* list = formatarg->value; + for(uint32_t i = 0; i < list->length; i++) + { + ffStrbufAppend(buffer, ffListGet(list, i)); + if(i < list->length - 1) + ffStrbufAppendS(buffer, ", "); + } + break; } - } - else if(formatarg->type != FF_FORMAT_ARG_TYPE_NULL) - { - fprintf(stderr, "Error: format string \"%s\": argument is not implemented: %i\n", buffer->chars, formatarg->type); + default: + if(formatarg->type != FF_FORMAT_ARG_TYPE_NULL) + fprintf(stderr, "Error: format string \"%s\": argument is not implemented: %i\n", buffer->chars, formatarg->type); + break; } } @@ -100,7 +114,8 @@ static inline bool formatArgSet(const FFformatarg* arg) (arg->type == FF_FORMAT_ARG_TYPE_UINT8 && *(uint8_t*)arg->value > 0) || (arg->type == FF_FORMAT_ARG_TYPE_UINT16 && *(uint16_t*)arg->value > 0) || (arg->type == FF_FORMAT_ARG_TYPE_UINT && *(uint32_t*)arg->value > 0) || - (arg->type == FF_FORMAT_ARG_TYPE_BOOL && arg->value != NULL) + (arg->type == FF_FORMAT_ARG_TYPE_BOOL && *(bool*)arg->value) || + (arg->type == FF_FORMAT_ARG_TYPE_LIST && ((FFlist*)arg->value)->length > 0) ); } @@ -265,34 +280,18 @@ void ffParseFormatString(FFstrbuf* buffer, const FFstrbuf* formatstr, uint32_t n continue; } - int32_t truncLength = 0; - char align = '\0'; - char* pSep = memchr(placeholderValue.chars, ':', placeholderValue.length); - if (pSep) - align = ':'; - else + char* pSep = placeholderValue.chars; + char cSep = '\0'; + while (*pSep && *pSep != ':' && *pSep != '<' && *pSep != '>' && *pSep != '~') + ++pSep; + if (*pSep) { - pSep = memchr(placeholderValue.chars, '<', placeholderValue.length); - if (pSep) - align = '<'; - else - { - pSep = memchr(placeholderValue.chars, '>', placeholderValue.length); - if (pSep) - align = '>'; - } + cSep = *pSep; + *pSep = '\0'; } - - if (pSep) + else { - char* pEnd = NULL; - truncLength = (int32_t) strtol(pSep + 1, &pEnd, 10); - if (*pEnd != '\0') - { - appendInvalidPlaceholder(buffer, "{", &placeholderValue, i, formatstr->length); - continue; - } - *pSep = '\0'; + pSep = NULL; } uint32_t index = getArgumentIndex(placeholderValue.chars, numArgs, arguments); @@ -303,53 +302,97 @@ void ffParseFormatString(FFstrbuf* buffer, const FFstrbuf* formatstr, uint32_t n if (index > numArgs) { - if (pSep) *pSep = align; + if (pSep) *pSep = cSep; appendInvalidPlaceholder(buffer, "{", &placeholderValue, i, formatstr->length); continue; } - bool ellipsis = false; - if (truncLength < 0) + if (!cSep) + ffFormatAppendFormatArg(buffer, &arguments[index - 1]); + else if (cSep == '~') { - ellipsis = true; - truncLength = -truncLength; - } + FF_STRBUF_AUTO_DESTROY tempString = ffStrbufCreate(); + ffFormatAppendFormatArg(&tempString, &arguments[index - 1]); - if (!align) - ffFormatAppendFormatArg(buffer, &arguments[index - 1]); + char* pEnd = NULL; + int32_t start = (int32_t) strtol(pSep + 1, &pEnd, 10); + if (start < 0) + start = (int32_t) tempString.length + start; + if (start >= 0 && (uint32_t) start < tempString.length) + { + if (*pEnd == '\0') + ffStrbufAppendNS(buffer, tempString.length - (uint32_t) start, &tempString.chars[start]); + else if (*pEnd == ',') + { + int32_t end = (int32_t) strtol(pEnd + 1, &pEnd, 10); + if (!*pEnd) + { + if (end < 0) + end = (int32_t) tempString.length + end; + if ((uint32_t) end > tempString.length) + end = (int32_t) tempString.length; + if (end > start) + ffStrbufAppendNS(buffer, (uint32_t) (end - start), &tempString.chars[start]); + } + } + } + + if (*pEnd) + { + *pSep = cSep; + appendInvalidPlaceholder(buffer, "{", &placeholderValue, i, formatstr->length); + continue; + } + } else { - ffStrbufClear(&placeholderValue); - ffFormatAppendFormatArg(&placeholderValue, &arguments[index - 1]); - if (placeholderValue.length == (uint32_t) truncLength) - ffStrbufAppend(buffer, &placeholderValue); - else if (placeholderValue.length > (uint32_t) truncLength) + char* pEnd = NULL; + int32_t truncLength = (int32_t) strtol(pSep + 1, &pEnd, 10); + if (*pEnd != '\0') + { + *pSep = cSep; + appendInvalidPlaceholder(buffer, "{", &placeholderValue, i, formatstr->length); + continue; + } + + bool ellipsis = false; + if (truncLength < 0) + { + ellipsis = true; + truncLength = -truncLength; + } + + FF_STRBUF_AUTO_DESTROY tempString = ffStrbufCreate(); + ffFormatAppendFormatArg(&tempString, &arguments[index - 1]); + if (tempString.length == (uint32_t) truncLength) + ffStrbufAppend(buffer, &tempString); + else if (tempString.length > (uint32_t) truncLength) { - if (align == ':') + if (cSep == ':') { - ffStrbufSubstrBefore(&placeholderValue, (uint32_t) truncLength); - ffStrbufTrimRightSpace(&placeholderValue); + ffStrbufSubstrBefore(&tempString, (uint32_t) truncLength); + ffStrbufTrimRightSpace(&tempString); } else - ffStrbufSubstrBefore(&placeholderValue, (uint32_t) (!ellipsis? truncLength : truncLength - 1)); - ffStrbufAppend(buffer, &placeholderValue); + ffStrbufSubstrBefore(&tempString, (uint32_t) (!ellipsis? truncLength : truncLength - 1)); + ffStrbufAppend(buffer, &tempString); if (ellipsis) ffStrbufAppendS(buffer, "…"); } - else if (align == ':') - ffStrbufAppend(buffer, &placeholderValue); + else if (cSep == ':') + ffStrbufAppend(buffer, &tempString); else { - if (align == '<') + if (cSep == '<') { - ffStrbufAppend(buffer, &placeholderValue); - ffStrbufAppendNC(buffer, (uint32_t) truncLength - placeholderValue.length, ' '); + ffStrbufAppend(buffer, &tempString); + ffStrbufAppendNC(buffer, (uint32_t) truncLength - tempString.length, ' '); } else { - ffStrbufAppendNC(buffer, (uint32_t) truncLength - placeholderValue.length, ' '); - ffStrbufAppend(buffer, &placeholderValue); + ffStrbufAppendNC(buffer, (uint32_t) truncLength - tempString.length, ' '); + ffStrbufAppend(buffer, &tempString); } } } diff --git a/src/common/format.h b/src/common/format.h index f1b1aede0f..580fc06c2c 100644 --- a/src/common/format.h +++ b/src/common/format.h @@ -2,7 +2,7 @@ #include "util/FFstrbuf.h" -typedef enum FFformatargtype +typedef enum FFformatArgType { FF_FORMAT_ARG_TYPE_NULL = 0, FF_FORMAT_ARG_TYPE_UINT, @@ -16,11 +16,26 @@ typedef enum FFformatargtype FF_FORMAT_ARG_TYPE_DOUBLE, FF_FORMAT_ARG_TYPE_LIST, FF_FORMAT_ARG_TYPE_BOOL -} FFformatargtype; +} FFformatArgType; + +#define FF_FORMAT_ARG(variable, var_name) { _Generic((variable), \ + uint32_t: FF_FORMAT_ARG_TYPE_UINT, \ + uint64_t: FF_FORMAT_ARG_TYPE_UINT64, \ + uint16_t: FF_FORMAT_ARG_TYPE_UINT16, \ + uint8_t: FF_FORMAT_ARG_TYPE_UINT8, \ + int32_t: FF_FORMAT_ARG_TYPE_INT, \ + char*: FF_FORMAT_ARG_TYPE_STRING, \ + const char*: FF_FORMAT_ARG_TYPE_STRING, \ + FFstrbuf: FF_FORMAT_ARG_TYPE_STRBUF, \ + float: FF_FORMAT_ARG_TYPE_FLOAT, \ + double: FF_FORMAT_ARG_TYPE_DOUBLE, \ + FFlist: FF_FORMAT_ARG_TYPE_LIST, \ + bool: FF_FORMAT_ARG_TYPE_BOOL \ + ), _Generic((variable), char*: (variable), const char*: (variable), default: &(variable) ), (var_name) } typedef struct FFformatarg { - FFformatargtype type; + FFformatArgType type; const void* value; const char* name; // argument name, must start with an alphabet } FFformatarg; diff --git a/src/common/init.c b/src/common/init.c index ba569c829c..8bf6f60e11 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -43,7 +43,6 @@ static void defaultConfig(void) ffOptionsInitGeneral(&instance.config.general); ffOptionsInitModules(&instance.config.modules); ffOptionsInitDisplay(&instance.config.display); - ffOptionsInitLibrary(&instance.config.library); } void ffInitInstance(void) @@ -148,7 +147,6 @@ static void destroyConfig(void) ffOptionsDestroyGeneral(&instance.config.general); ffOptionsDestroyModules(&instance.config.modules); ffOptionsDestroyDisplay(&instance.config.display); - ffOptionsDestroyLibrary(&instance.config.library); } static void destroyState(void) @@ -244,7 +242,7 @@ void ffListFeatures(void) #if FF_HAVE_DDCUTIL "libddcutil\n" #endif - #if FF_HAVE_ELF + #if FF_HAVE_ELF || __sun || __FreeBSD__ "libelf\n" #endif #if FF_HAVE_LIBZFS diff --git a/src/common/io/io.h b/src/common/io/io.h index 2958ac4545..9a76838f4f 100644 --- a/src/common/io/io.h +++ b/src/common/io/io.h @@ -130,8 +130,8 @@ bool ffPathExpandEnv(const char* in, FFstrbuf* out); #define FF_IO_TERM_RESP_WAIT_MS 100 // #554 -FF_C_SCANF(2, 3) -const char* ffGetTerminalResponse(const char* request, const char* format, ...); +FF_C_SCANF(3, 4) +const char* ffGetTerminalResponse(const char* request, int nParams, const char* format, ...); // Not thread safe! bool ffSuppressIO(bool suppress); diff --git a/src/common/io/io_unix.c b/src/common/io/io_unix.c index edd740ba50..facc03a56f 100644 --- a/src/common/io/io_unix.c +++ b/src/common/io/io_unix.c @@ -4,9 +4,13 @@ #include #include -#include #include #include +#ifndef __APPLE__ +#include +#else +#include +#endif #if FF_HAVE_WORDEXP #include @@ -140,11 +144,11 @@ void restoreTerm(void) tcsetattr(ftty, TCSAFLUSH, &oldTerm); } -const char* ffGetTerminalResponse(const char* request, const char* format, ...) +const char* ffGetTerminalResponse(const char* request, int nParams, const char* format, ...) { if (ftty < 0) { - ftty = open("/dev/tty", O_RDWR | O_NOCTTY | O_CLOEXEC | O_NONBLOCK); + ftty = open("/dev/tty", O_RDWR | O_NOCTTY | O_CLOEXEC); if (ftty < 0) return "open(\"/dev/tty\", O_RDWR | O_NOCTTY | O_CLOEXEC) failed"; @@ -161,20 +165,44 @@ const char* ffGetTerminalResponse(const char* request, const char* format, ...) ffWriteFDData(ftty, strlen(request), request); //Give the terminal some time to respond + #ifndef __APPLE__ if(poll(&(struct pollfd) { .fd = ftty, .events = POLLIN }, 1, FF_IO_TERM_RESP_WAIT_MS) <= 0) - return "poll() timeout or failed"; - - char buffer[512]; - ssize_t bytesRead = read(ftty, buffer, sizeof(buffer) - 1); - - if(bytesRead <= 0) - return "read(STDIN_FILENO, buffer, sizeof(buffer) - 1) failed"; + return "poll(/dev/tty) timeout or failed"; + #else + { + // On macOS, poll(/dev/tty) always returns immediately + // See also https://nathancraddock.com/blog/macos-dev-tty-polling/ + fd_set rd; + FD_ZERO(&rd); + FD_SET(ftty, &rd); + if(select(ftty + 1, &rd, NULL, NULL, &(struct timeval) { .tv_sec = FF_IO_TERM_RESP_WAIT_MS / 1000, .tv_usec = (FF_IO_TERM_RESP_WAIT_MS % 1000) * 1000 }) <= 0) + return "select(/dev/tty) timeout or failed"; + } + #endif - buffer[bytesRead] = '\0'; + char buffer[1024]; + size_t bytesRead = 0; va_list args; va_start(args, format); - vsscanf(buffer, format, args); + + while (true) + { + ssize_t nRead = read(ftty, buffer + bytesRead, sizeof(buffer) - bytesRead - 1); + + if (nRead <= 0) + return "read(STDIN_FILENO, buffer, sizeof(buffer) - 1) failed"; + + bytesRead += (size_t) nRead; + buffer[bytesRead] = '\0'; + + int ret = vsscanf(buffer, format, args); + if (ret <= 0) + return "vsscanf(buffer, format, args) failed"; + if (ret >= nParams) + break; + } + va_end(args); return NULL; diff --git a/src/common/io/io_windows.c b/src/common/io/io_windows.c index 0af70bd0b6..6f2465da64 100644 --- a/src/common/io/io_windows.c +++ b/src/common/io/io_windows.c @@ -205,7 +205,7 @@ void ffListFilesRecursively(const char* path, bool pretty) listFilesRecursively(folder.length, &folder, 0, NULL, pretty); } -const char* ffGetTerminalResponse(const char* request, const char* format, ...) +const char* ffGetTerminalResponse(const char* request, int nParams, const char* format, ...) { HANDLE hInput = GetStdHandle(STD_INPUT_HANDLE); FF_AUTO_CLOSE_FD HANDLE hConin = INVALID_HANDLE_VALUE; @@ -256,20 +256,30 @@ const char* ffGetTerminalResponse(const char* request, const char* format, ...) ReadConsoleInputW(hInput, &record, 1, &len); } - char buffer[512]; - DWORD bytes = 0; - ReadFile(hInput, buffer, sizeof(buffer) - 1, &bytes, NULL); + va_list args; + va_start(args, format); - SetConsoleMode(hInput, inputMode); + char buffer[1024]; + uint32_t bytesRead = 0; - if(bytes <= 0) - return "ReadFile() failed"; + while (true) + { + DWORD bytes = 0; + if (!ReadFile(hInput, buffer, sizeof(buffer) - 1, &bytes, NULL) || bytes == 0) + return "ReadFile() failed"; - buffer[bytes] = '\0'; + bytesRead += bytes; + buffer[bytesRead] = '\0'; + + int ret = vsscanf(buffer, format, args); + if (ret <= 0) + return "vsscanf(buffer, format, args) failed"; + if (ret >= nParams) + break; + } + + SetConsoleMode(hInput, inputMode); - va_list args; - va_start(args, format); - vsscanf(buffer, format, args); va_end(args); return NULL; diff --git a/src/common/library.c b/src/common/library.c index e8ade19da0..7bb30c14bf 100644 --- a/src/common/library.c +++ b/src/common/library.c @@ -55,28 +55,28 @@ static void* libraryLoad(const char* path, int maxVersion) return result; } -void* ffLibraryLoad(const FFstrbuf* userProvidedName, ...) +void* ffLibraryLoad(const char* path, int maxVersion, ...) { - if(userProvidedName != NULL && userProvidedName->length > 0) - return dlopen(userProvidedName->chars, FF_DLOPEN_FLAGS); + void* result = libraryLoad(path, maxVersion); - va_list defaultNames; - va_start(defaultNames, userProvidedName); + if (!result) + { + va_list defaultNames; + va_start(defaultNames, maxVersion); - void* result = NULL; + do + { + const char* pathRest = va_arg(defaultNames, const char*); + if(pathRest == NULL) + break; - while(result == NULL) - { - const char* path = va_arg(defaultNames, const char*); - if(path == NULL) - break; + int maxVersionRest = va_arg(defaultNames, int); + result = libraryLoad(pathRest, maxVersionRest); + } while (!result); - int maxVersion = va_arg(defaultNames, int); - result = libraryLoad(path, maxVersion); + va_end(defaultNames); } - va_end(defaultNames); - return result; } diff --git a/src/common/library.h b/src/common/library.h index 8a5e8b34e0..1f9154bd21 100644 --- a/src/common/library.h +++ b/src/common/library.h @@ -33,8 +33,8 @@ static inline void ffLibraryUnload(void** handle) #define FF_LIBRARY_SYMBOL(symbolName) \ __typeof__(&symbolName) ff ## symbolName; -#define FF_LIBRARY_LOAD(libraryObjectName, userLibraryName, returnValue, ...) \ - void* __attribute__((__cleanup__(ffLibraryUnload))) libraryObjectName = ffLibraryLoad(userLibraryName, __VA_ARGS__, NULL);\ +#define FF_LIBRARY_LOAD(libraryObjectName, returnValue, ...) \ + void* __attribute__((__cleanup__(ffLibraryUnload))) libraryObjectName = ffLibraryLoad(__VA_ARGS__, NULL);\ if(libraryObjectName == NULL) \ return returnValue; @@ -72,7 +72,7 @@ static inline void ffLibraryUnload(void** handle) #define FF_LIBRARY_LOAD_SYMBOL_PTR(library, varName, symbolName, returnValue) \ FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, (varName)->ff ## symbolName, symbolName, returnValue); -void* ffLibraryLoad(const FFstrbuf* userProvidedName, ...); +void* ffLibraryLoad(const char* path, int maxVersion, ...); #else @@ -81,7 +81,7 @@ void* ffLibraryLoad(const FFstrbuf* userProvidedName, ...); #define FF_LIBRARY_SYMBOL(symbolName) \ __typeof__(&symbolName) ff ## symbolName; -#define FF_LIBRARY_LOAD(libraryObjectName, userLibraryName, returnValue, ...) \ +#define FF_LIBRARY_LOAD(libraryObjectName, returnValue, ...) \ FF_MAYBE_UNUSED void* libraryObjectName = NULL; // Placeholder #define FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, symbolMapping, symbolName, returnValue) \ diff --git a/src/common/printing.c b/src/common/printing.c index 89725b2c22..c2112b6b03 100644 --- a/src/common/printing.c +++ b/src/common/printing.c @@ -51,8 +51,8 @@ void ffPrintLogoAndKey(const char* moduleName, uint8_t moduleIndex, const FFModu { FF_STRBUF_AUTO_DESTROY key = ffStrbufCreate(); FF_PARSE_FORMAT_STRING_CHECKED(&key, &moduleArgs->key, 2, ((FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_UINT8, &moduleIndex, "index"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &moduleArgs->keyIcon, "icon"}, + FF_FORMAT_ARG(moduleIndex, "index"), + FF_FORMAT_ARG(moduleArgs->keyIcon, "icon"), })); ffStrbufWriteTo(&key, stdout); } diff --git a/src/common/settings.c b/src/common/settings.c index 8d6e6e47fd..63623d550a 100644 --- a/src/common/settings.c +++ b/src/common/settings.c @@ -60,7 +60,7 @@ static const GSettingsData* getGSettingsData(void) if (!data.inited) { data.inited = true; - FF_LIBRARY_LOAD(libgsettings, &instance.config.library.libGIO, NULL, "libgio-2.0" FF_LIBRARY_EXTENSION, 1); + FF_LIBRARY_LOAD(libgsettings, NULL, "libgio-2.0" FF_LIBRARY_EXTENSION, 1); FF_LIBRARY_LOAD_SYMBOL_VAR(libgsettings, data, g_settings_schema_source_lookup, NULL) FF_LIBRARY_LOAD_SYMBOL_VAR(libgsettings, data, g_settings_schema_has_key, NULL) FF_LIBRARY_LOAD_SYMBOL_VAR(libgsettings, data, g_settings_new_full, NULL) @@ -141,7 +141,7 @@ static const DConfData* getDConfData(void) { data.inited = true; - FF_LIBRARY_LOAD(libdconf, &instance.config.library.libDConf, NULL, "libdconf" FF_LIBRARY_EXTENSION, 2); + FF_LIBRARY_LOAD(libdconf, NULL, "libdconf" FF_LIBRARY_EXTENSION, 2); FF_LIBRARY_LOAD_SYMBOL_VAR(libdconf, data, dconf_client_read_full, NULL) FF_LIBRARY_LOAD_SYMBOL_VAR(libdconf, data, dconf_client_new, NULL) FF_LIBRARY_LOAD_SYMBOL_VAR(libdconf, data.variantGetters, g_variant_dup_string, NULL) @@ -218,7 +218,7 @@ static const XFConfData* getXFConfData(void) if (!data.inited) { data.inited = true; - FF_LIBRARY_LOAD(libxfconf, &instance.config.library.libXFConf, NULL, "libxfconf-0" FF_LIBRARY_EXTENSION, 4); + FF_LIBRARY_LOAD(libxfconf, NULL, "libxfconf-0" FF_LIBRARY_EXTENSION, 4); FF_LIBRARY_LOAD_SYMBOL_VAR(libxfconf, data, xfconf_channel_get, NULL) FF_LIBRARY_LOAD_SYMBOL_VAR(libxfconf, data, xfconf_channel_has_property, NULL) @@ -292,7 +292,7 @@ static const SQLiteData* getSQLiteData(void) if (!data.inited) { data.inited = true; - FF_LIBRARY_LOAD(libsqlite, &instance.config.library.libSQLite3, NULL, "libsqlite3" FF_LIBRARY_EXTENSION, 1); + FF_LIBRARY_LOAD(libsqlite, NULL, "libsqlite3" FF_LIBRARY_EXTENSION, 1); FF_LIBRARY_LOAD_SYMBOL_VAR(libsqlite, data, sqlite3_open_v2, NULL) FF_LIBRARY_LOAD_SYMBOL_VAR(libsqlite, data, sqlite3_prepare_v2, NULL) FF_LIBRARY_LOAD_SYMBOL_VAR(libsqlite, data, sqlite3_step, NULL) diff --git a/src/data/help.json b/src/data/help.json index 43d501209f..f6c1ffc2fa 100644 --- a/src/data/help.json +++ b/src/data/help.json @@ -766,184 +766,6 @@ } } ], - "Library path": [ - { - "long": "lib-vulkan", - "desc": "Vulkan module & fallback for GPU output", - "arg": { - "type": "path" - } - }, - { - "long": "lib-wayland", - "desc": "Better display performance and output in wayland sessions", - "arg": { - "type": "path" - } - }, - { - "long": "lib-xcb-randr", - "desc": "X11 sessions for better display detection and faster WM detection", - "arg": { - "type": "path" - } - }, - { - "long": "lib-xcb", - "desc": "X11 sessions for better display detection and faster WM detection", - "arg": { - "type": "path" - } - }, - { - "long": "lib-xrandr", - "desc": "X11 sessions for better display detection and faster WM detection", - "arg": { - "type": "path" - } - }, - { - "long": "lib-x11", - "desc": "X11 sessions for better display detection and faster WM detection", - "arg": { - "type": "path" - } - }, - { - "long": "lib-drm", - "desc": "Used for fast resolution and refresh rate detection", - "remark": "Linux only", - "arg": { - "type": "path" - } - }, - { - "long": "lib-gio", - "desc": "Needed for values that are only stored GSettings", - "arg": { - "type": "path" - } - }, - { - "long": "lib-dconf", - "desc": "Needed for values that are only stored in DConf + Fallback for GSettings", - "arg": { - "type": "path" - } - }, - { - "long": "lib-dbus", - "desc": "Bluetooth, Player & Media detection", - "arg": { - "type": "path" - } - }, - { - "long": "lib-xfconf", - "desc": "Needed for XFWM theme and XFCE Terminal font", - "arg": { - "type": "path" - } - }, - { - "long": "lib-sqlite3", - "desc": "Needed for pkg & rpm package count", - "arg": { - "type": "path" - } - }, - { - "long": "lib-rpm", - "desc": "Slower fallback for rpm package count", - "arg": { - "type": "path" - } - }, - { - "long": "lib-imagemagick", - "desc": "Images in terminal using sixel or kitty graphics protocol", - "arg": { - "type": "path" - } - }, - { - "long": "lib-z", - "desc": "Libz. Faster image output when using kitty graphics protocol", - "arg": { - "type": "path" - } - }, - { - "long": "lib-chafa", - "desc": "Image output as ascii art", - "arg": { - "type": "path" - } - }, - { - "long": "lib-egl", - "desc": "Needed by the OpenGL module for gl context creation", - "arg": { - "type": "path" - } - }, - { - "long": "lib-glx", - "desc": "Needed by the OpenGL module for gl context creation", - "arg": { - "type": "path" - } - }, - { - "long": "lib-osmesa", - "desc": "Needed by the OpenGL module for gl context creation", - "arg": { - "type": "path" - } - }, - { - "long": "lib-opencl", - "desc": "OpenCL module", - "arg": { - "type": "path" - } - }, - { - "long": "lib-pulse", - "desc": "Pulseaudio. Used for Sound detection", - "arg": { - "type": "path" - } - }, - { - "long": "lib-nm", - "desc": "NetworkManager. Used for Wifi detection", - "arg": { - "type": "path" - } - }, - { - "long": "lib-freetype", - "desc": "Used for Termux font detection", - "arg": { - "type": "path" - } - }, - { - "long": "lib-ddcutil", - "desc": "Used for brightness detection of external displays", - "arg": { - "type": "path" - } - }, - { - "long": "lib-elf", - "desc": "Used for st terminal font detection and systemd version detection", - "arg": { - "type": "path" - } - } - ], "Module specific": [ { "long": "title-fqdn", @@ -1554,6 +1376,15 @@ "default": "\"cmd\" for Windows; \"/bin/sh\" for *nix" } }, + { + "long": "command-param", + "desc": "Set the parameter used when starting the shell", + "remark": "Due to the difference of how OSes handle command line parameters, Windows will parse whitespaces as param separators, while *nix will not", + "arg": { + "type": "str", + "default": "\"/c\" for Windows; \"-c\" for *nix" + } + }, { "long": "command-key", "desc": "Set the module key to display", diff --git a/src/data/help_format.txt b/src/data/help_format.txt index 9d84e61381..0c77ba8632 100644 --- a/src/data/help_format.txt +++ b/src/data/help_format.txt @@ -17,6 +17,10 @@ In 2.23.0 or newer, `<` or `>` can be specified instead of `:` to set a left or For example: "--title-format '{user-name<20}'" will generate ` `; "--title-format '{user-name>20}'" will generate ` ` +In 2.24.0 or newer, `{~startIndex,endIndex}` can be specified to slice a string. Negative index counts back from the end of the string. +If an index is omitted, 0 is used. For example, both `{~,0}` `{~0,}` and `{~,}` are same as `{~0,0}` and will always generate a empty string. +If `,endIndex` is omitted or greater than the length of the string, the length of string is used. + If the value index is missing, meaning the placeholder is "{}", an internal counter sets the value index. This means that the format string "Values: {1} ({2})" is equivalent to "Values: {} ({})". Note that this counter only counts empty placeholders, so the format string "{2} {} {}" will contain the second value, then the first, and then the second again. diff --git a/src/detection/bluetooth/bluetooth_windows.c b/src/detection/bluetooth/bluetooth_windows.c index 58322be190..acb2f4bb48 100644 --- a/src/detection/bluetooth/bluetooth_windows.c +++ b/src/detection/bluetooth/bluetooth_windows.c @@ -10,7 +10,7 @@ const char* ffDetectBluetooth(FFlist* devices /* FFBluetoothResult */) { // Actually bluetoothapis.dll, but it's missing on Windows 7 - FF_LIBRARY_LOAD(bluetoothapis, NULL, "dlopen bthprops.cpl failed", "bthprops.cpl", 1) + FF_LIBRARY_LOAD(bluetoothapis, "dlopen bthprops.cpl failed", "bthprops.cpl", 1) FF_LIBRARY_LOAD_SYMBOL_MESSAGE(bluetoothapis, BluetoothFindFirstDevice) FF_LIBRARY_LOAD_SYMBOL_MESSAGE(bluetoothapis, BluetoothFindNextDevice) FF_LIBRARY_LOAD_SYMBOL_MESSAGE(bluetoothapis, BluetoothFindDeviceClose) diff --git a/src/detection/bluetoothradio/bluetoothradio_windows.c b/src/detection/bluetoothradio/bluetoothradio_windows.c index 6e6f9461b0..c8471d442b 100644 --- a/src/detection/bluetoothradio/bluetoothradio_windows.c +++ b/src/detection/bluetoothradio/bluetoothradio_windows.c @@ -54,7 +54,7 @@ static_assert(sizeof(BTH_LOCAL_RADIO_INFO) == 292, "BTH_LOCAL_RADIO_INFO should const char* ffDetectBluetoothRadio(FFlist* devices /* FFBluetoothRadioResult */) { // Actually bluetoothapis.dll, but it's missing on Windows 7 - FF_LIBRARY_LOAD(bluetoothapis, NULL, "dlopen bthprops.cpl failed", "bthprops.cpl", 1) + FF_LIBRARY_LOAD(bluetoothapis, "dlopen bthprops.cpl failed", "bthprops.cpl", 1) FF_LIBRARY_LOAD_SYMBOL_MESSAGE(bluetoothapis, BluetoothFindFirstRadio) FF_LIBRARY_LOAD_SYMBOL_MESSAGE(bluetoothapis, BluetoothFindNextRadio) FF_LIBRARY_LOAD_SYMBOL_MESSAGE(bluetoothapis, BluetoothFindRadioClose) diff --git a/src/detection/board/board_linux.c b/src/detection/board/board_linux.c index 380db6c14e..0165df2e1f 100644 --- a/src/detection/board/board_linux.c +++ b/src/detection/board/board_linux.c @@ -6,9 +6,21 @@ const char* ffDetectBoard(FFBoardResult* board) { - ffGetSmbiosValue("/sys/devices/virtual/dmi/id/board_name", "/sys/class/dmi/id/board_name", &board->name); - ffGetSmbiosValue("/sys/devices/virtual/dmi/id/board_serial", "/sys/class/dmi/id/board_serial", &board->serial); - ffGetSmbiosValue("/sys/devices/virtual/dmi/id/board_vendor", "/sys/class/dmi/id/board_vendor", &board->vendor); - ffGetSmbiosValue("/sys/devices/virtual/dmi/id/board_version", "/sys/class/dmi/id/board_version", &board->version); + if (ffGetSmbiosValue("/sys/devices/virtual/dmi/id/board_name", "/sys/class/dmi/id/board_name", &board->name)) + { + ffGetSmbiosValue("/sys/devices/virtual/dmi/id/board_serial", "/sys/class/dmi/id/board_serial", &board->serial); + ffGetSmbiosValue("/sys/devices/virtual/dmi/id/board_vendor", "/sys/class/dmi/id/board_vendor", &board->vendor); + ffGetSmbiosValue("/sys/devices/virtual/dmi/id/board_version", "/sys/class/dmi/id/board_version", &board->version); + } + else if (ffReadFileBuffer("/proc/device-tree/compatible", &board->vendor)) + { + // use model name as board name + uint32_t comma = ffStrbufFirstIndexC(&board->vendor, ','); + if (comma < board->vendor.length) + { + ffStrbufSetS(&board->name, board->vendor.chars + comma + 1); + ffStrbufSubstrBefore(&board->vendor, comma); + } + } return NULL; } diff --git a/src/detection/brightness/brightness_linux.c b/src/detection/brightness/brightness_linux.c index 435f4e11b8..e5d4e608ad 100644 --- a/src/detection/brightness/brightness_linux.c +++ b/src/detection/brightness/brightness_linux.c @@ -101,7 +101,7 @@ DDCA_Status ddca_init(const char *libopts, int syslog_level, int opts); static const char* detectWithDdcci(FFBrightnessOptions* options, FFlist* result) { - FF_LIBRARY_LOAD(libddcutil, &instance.config.library.libDdcutil, "dlopen ddcutil failed", "libddcutil" FF_LIBRARY_EXTENSION, 5); + FF_LIBRARY_LOAD(libddcutil, "dlopen ddcutil failed", "libddcutil" FF_LIBRARY_EXTENSION, 5); FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libddcutil, ddca_get_display_info_list2) FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libddcutil, ddca_open_display2) FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libddcutil, ddca_get_any_vcp_value_using_explicit_type) diff --git a/src/detection/brightness/brightness_windows.cpp b/src/detection/brightness/brightness_windows.cpp index acf6340e65..fbbcf6e35e 100644 --- a/src/detection/brightness/brightness_windows.cpp +++ b/src/detection/brightness/brightness_windows.cpp @@ -39,7 +39,7 @@ static const char* detectWithWmi(FFlist* result) static const char* detectWithDdcci(const FFDisplayServerResult* displayServer, FFlist* result) { - FF_LIBRARY_LOAD(dxva2, NULL, "dlopen dxva2" FF_LIBRARY_EXTENSION " failed", "dxva2" FF_LIBRARY_EXTENSION, 1) + FF_LIBRARY_LOAD(dxva2, "dlopen dxva2" FF_LIBRARY_EXTENSION " failed", "dxva2" FF_LIBRARY_EXTENSION, 1) FF_LIBRARY_LOAD_SYMBOL_MESSAGE(dxva2, GetPhysicalMonitorsFromHMONITOR) FF_LIBRARY_LOAD_SYMBOL_MESSAGE(dxva2, GetMonitorBrightness) diff --git a/src/detection/camera/camera_windows.cpp b/src/detection/camera/camera_windows.cpp index d84dd0c410..b0f9112f2e 100644 --- a/src/detection/camera/camera_windows.cpp +++ b/src/detection/camera/camera_windows.cpp @@ -21,9 +21,9 @@ struct on_scope_exit { extern "C" const char* ffDetectCamera(FF_MAYBE_UNUSED FFlist* result) { - FF_LIBRARY_LOAD(mfplat, NULL, "dlopen mfplat" FF_LIBRARY_EXTENSION " failed", "mfplat" FF_LIBRARY_EXTENSION, 1) + FF_LIBRARY_LOAD(mfplat, "dlopen mfplat" FF_LIBRARY_EXTENSION " failed", "mfplat" FF_LIBRARY_EXTENSION, 1) FF_LIBRARY_LOAD_SYMBOL_MESSAGE(mfplat, MFCreateAttributes) - FF_LIBRARY_LOAD(mf, NULL, "dlopen mf" FF_LIBRARY_EXTENSION " failed", "mf" FF_LIBRARY_EXTENSION, 1) + FF_LIBRARY_LOAD(mf, "dlopen mf" FF_LIBRARY_EXTENSION " failed", "mf" FF_LIBRARY_EXTENSION, 1) FF_LIBRARY_LOAD_SYMBOL_MESSAGE(mf, MFEnumDeviceSources) const char* error = ffInitCom(); diff --git a/src/detection/cpu/cpu.c b/src/detection/cpu/cpu.c index dc27da241d..298eb5bfe6 100644 --- a/src/detection/cpu/cpu.c +++ b/src/detection/cpu/cpu.c @@ -37,6 +37,19 @@ const char* ffCPUAppleCodeToName(uint32_t code) case 6031: case 6034: return "Apple M3 Max"; case 8132: return "Apple M4"; - default: return "Apple Silicon"; + default: return NULL; + } +} + +const char* ffCPUQualcommCodeToName(uint32_t code) +{ + // https://github.com/AsahiLinux/docs/wiki/Codenames + switch (code) + { + case 7180: return "Qualcomm Snapdragon 7c"; + case 7280: return "Qualcomm Snapdragon 7c+ Gen 3"; + case 8180: return "Qualcomm Snapdragon 8cx Gen 2 5G"; + case 8280: return "Qualcomm Snapdragon 8cx Gen 3"; + default: return NULL; } } diff --git a/src/detection/cpu/cpu.h b/src/detection/cpu/cpu.h index dd2d178ed2..9ddc00300b 100644 --- a/src/detection/cpu/cpu.h +++ b/src/detection/cpu/cpu.h @@ -30,7 +30,7 @@ typedef struct FFCPUResult const char* ffDetectCPU(const FFCPUOptions* options, FFCPUResult* cpu); const char* ffCPUAppleCodeToName(uint32_t code); - +const char* ffCPUQualcommCodeToName(uint32_t code); #if defined(__x86_64__) || defined(__i386__) diff --git a/src/detection/cpu/cpu_arm.h b/src/detection/cpu/cpu_arm.h index 4e882ae525..3ff408cd7c 100644 --- a/src/detection/cpu/cpu_arm.h +++ b/src/detection/cpu/cpu_arm.h @@ -106,6 +106,9 @@ static const char* armPartId2name(uint32_t partId) case 0xd80: return "Cortex-A520"; case 0xd81: return "Cortex-A720"; case 0xd82: return "Cortex-X4"; + case 0xd84: return "Neoverse-V3"; + case 0xd85: return "Cortex-X925"; + case 0xd87: return "Cortex-A725"; default: return NULL; } } diff --git a/src/detection/cpu/cpu_bsd.c b/src/detection/cpu/cpu_bsd.c index 0b17d595d9..c7b3cec44e 100644 --- a/src/detection/cpu/cpu_bsd.c +++ b/src/detection/cpu/cpu_bsd.c @@ -9,7 +9,7 @@ const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu) cpu->coresPhysical = (uint16_t) ffSysctlGetInt("hw.ncpu", 1); cpu->coresLogical = cpu->coresPhysical; - cpu->coresOnline = cpu->coresPhysical; + cpu->coresOnline = (uint16_t) ffSysctlGetInt("kern.smp.cpus", cpu->coresLogical); FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate(); if (ffSysctlGetString("kern.sched.topology_spec", &buffer) == NULL && buffer.length > 0) diff --git a/src/detection/cpu/cpu_linux.c b/src/detection/cpu/cpu_linux.c index 7e9d92f7a4..4dc9c38010 100644 --- a/src/detection/cpu/cpu_linux.c +++ b/src/detection/cpu/cpu_linux.c @@ -15,6 +15,8 @@ static void detectQualcomm(FFCPUResult* cpu) { + // https://en.wikipedia.org/wiki/List_of_Qualcomm_Snapdragon_systems_on_chips + if (ffStrbufEqualS(&cpu->name, "SM8635")) ffStrbufSetStatic(&cpu->name, "Qualcomm Snapdragon 8s Gen 3 [SM8635]"); else if (ffStrbufEqualS(&cpu->name, "SM8650-AC")) @@ -32,6 +34,8 @@ static void detectQualcomm(FFCPUResult* cpu) else if (ffStrbufEqualS(&cpu->name, "SM7675")) ffStrbufSetStatic(&cpu->name, "Qualcomm Snapdragon 7+ Gen 3 [SM7675]"); + else if (ffStrbufEqualS(&cpu->name, "SM7635")) + ffStrbufSetStatic(&cpu->name, "Qualcomm Snapdragon 7s Gen 3 [SM7635]"); else if (ffStrbufEqualS(&cpu->name, "SM7550")) ffStrbufSetStatic(&cpu->name, "Qualcomm Snapdragon 7 Gen 3 [SM7550]"); else if (ffStrbufEqualS(&cpu->name, "SM7475")) @@ -43,6 +47,10 @@ static void detectQualcomm(FFCPUResult* cpu) else if (ffStrbufEqualS(&cpu->name, "SM6375-AC")) ffStrbufSetStatic(&cpu->name, "Qualcomm Snapdragon 6s Gen 3 [SM6375-AC]"); + else if (ffStrbufEqualS(&cpu->name, "SM6475")) + ffStrbufSetStatic(&cpu->name, "Qualcomm Snapdragon 6 Gen 3 [SM6475]"); + else if (ffStrbufEqualS(&cpu->name, "SM6115")) + ffStrbufSetStatic(&cpu->name, "Qualcomm Snapdragon 6s Gen 1 [SM6115]"); else if (ffStrbufEqualS(&cpu->name, "SM6450")) ffStrbufSetStatic(&cpu->name, "Qualcomm Snapdragon 6 Gen 1 [SM6450]"); @@ -311,25 +319,51 @@ FF_MAYBE_UNUSED static void parseIsa(FFstrbuf* cpuIsa) } } -FF_MAYBE_UNUSED static void detectAsahi(FFCPUResult* cpu) +FF_MAYBE_UNUSED static void detectArmSoc(FFCPUResult* cpu) { - // In Asahi Linux, reading /proc/device-tree/compatible gives - // information on the device model. It consists of 3 NUL terminated - // strings, the second of which gives the actual SoC model. But it - // is not the marketing name, i.e. for M2 there is "apple,t8112" in - // the compatible string. - if (cpu->name.length == 0 && ffStrbufEqualS(&cpu->vendor, "Apple")) - { - char content[32]; - ssize_t length = ffReadFileData("/proc/device-tree/compatible", sizeof(content), content); - if (length <= 0) return; + if (cpu->name.length > 0) + return; + + // device-vendor,device-model\0soc-vendor,soc-model\0 + char content[64]; + ssize_t length = ffReadFileData("/proc/device-tree/compatible", sizeof(content), content); + if (length <= 2) return; + + // get the second NUL terminated string + char* modelName = memchr(content, '\0', (size_t) length) + 1; + if (!modelName || modelName - content >= length) return; - // get the second NUL terminated string - char* modelName = memchr(content, '\0', (size_t) length) + 1; - if (modelName - content < length && ffStrStartsWith(modelName, "apple,t")) + if (ffStrStartsWith(modelName, "apple,t")) + { + // https://elixir.bootlin.com/linux/v6.11-rc7/source/arch/arm64/boot/dts/apple + const char* code = modelName + strlen("apple,t"); + uint32_t deviceId = (uint32_t) strtoul(code, NULL, 10); + ffStrbufSetStatic(&cpu->name, ffCPUAppleCodeToName(deviceId)); + if (!cpu->name.length) { - uint32_t deviceId = (uint32_t) strtoul(modelName + strlen("apple,t"), NULL, 10); - ffStrbufSetStatic(&cpu->name, ffCPUAppleCodeToName(deviceId)); + ffStrbufAppendS(&cpu->name, "Apple Silicon T"); + ffStrbufAppendS(&cpu->name, code); + } + } + else if (ffStrStartsWith(modelName, "qcom,")) + { + // https://elixir.bootlin.com/linux/v6.11-rc7/source/arch/arm64/boot/dts/qcom + if (ffStrStartsWith(modelName + strlen("qcom,"), "x")) + { + ffStrbufSetS(&cpu->name, "Qualcomm Snapdragon X Elite "); + for (const char* p = modelName + strlen("qcom,"); *p; ++p) + ffStrbufAppendC(&cpu->name, (char) toupper(*p)); + } + else if (ffStrStartsWith(modelName + strlen("qcom,"), "sc")) + { + const char* code = modelName + strlen("qcom,sc"); + uint32_t deviceId = (uint32_t) strtoul(code, NULL, 10); + ffStrbufSetStatic(&cpu->name, ffCPUQualcommCodeToName(deviceId)); + if (!cpu->name.length) + { + ffStrbufAppendS(&cpu->name, "Qualcomm Snapdragon SC"); + ffStrbufAppendS(&cpu->name, code); + } } } } @@ -384,7 +418,7 @@ const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu) #if __ANDROID__ detectAndroid(cpu); #elif __aarch64__ - detectAsahi(cpu); + detectArmSoc(cpu); #endif if (cpu->name.length == 0) diff --git a/src/detection/de/de_linux.c b/src/detection/de/de_linux.c index c31d10b944..a1bb98480c 100644 --- a/src/detection/de/de_linux.c +++ b/src/detection/de/de_linux.c @@ -121,7 +121,7 @@ static const char* getXfce4ByLib(FFstrbuf* result) { #ifndef FF_DISABLE_DLOPEN const char* xfce_version_string(void); // from `xfce4/libxfce4util/xfce-misutils.h - FF_LIBRARY_LOAD(xfce4util, NULL, "dlopen libxfce4util" FF_LIBRARY_EXTENSION "failed", "libxfce4util" FF_LIBRARY_EXTENSION, 7); + FF_LIBRARY_LOAD(xfce4util, "dlopen libxfce4util" FF_LIBRARY_EXTENSION "failed", "libxfce4util" FF_LIBRARY_EXTENSION, 7); FF_LIBRARY_LOAD_SYMBOL_MESSAGE(xfce4util, xfce_version_string); ffStrbufSetS(result, ffxfce_version_string()); return NULL; diff --git a/src/detection/displayserver/linux/displayserver_linux.h b/src/detection/displayserver/linux/displayserver_linux.h index 2a97e70080..99cad927fb 100644 --- a/src/detection/displayserver/linux/displayserver_linux.h +++ b/src/detection/displayserver/linux/displayserver_linux.h @@ -9,13 +9,13 @@ bool ffdsMatchDrmConnector(const char* connName, FFstrbuf* edidName); const char* ffdsConnectWayland(FFDisplayServerResult* result); -void ffdsConnectXcbRandr(FFDisplayServerResult* result); -void ffdsConnectXcb(FFDisplayServerResult* result); +const char* ffdsConnectXcbRandr(FFDisplayServerResult* result); +const char* ffdsConnectXcb(FFDisplayServerResult* result); -void ffdsConnectXrandr(FFDisplayServerResult* result); -void ffdsConnectXlib(FFDisplayServerResult* result); +const char* ffdsConnectXrandr(FFDisplayServerResult* result); +const char* ffdsConnectXlib(FFDisplayServerResult* result); -void ffdsConnectDrm(FFDisplayServerResult* result); +const char* ffdsConnectDrm(FFDisplayServerResult* result); void ffdsDetectWMDE(FFDisplayServerResult* result); diff --git a/src/detection/displayserver/linux/drm.c b/src/detection/displayserver/linux/drm.c index c43d5f7e5e..1533b4990b 100644 --- a/src/detection/displayserver/linux/drm.c +++ b/src/detection/displayserver/linux/drm.c @@ -199,7 +199,7 @@ static const char* drmGetNameByConnId(uint32_t connId, FFstrbuf* name) static const char* drmConnectLibdrm(FFDisplayServerResult* result) { - FF_LIBRARY_LOAD(libdrm, &instance.config.library.libdrm, "dlopen libdrm" FF_LIBRARY_EXTENSION " failed", "libdrm" FF_LIBRARY_EXTENSION, 2) + FF_LIBRARY_LOAD(libdrm, "dlopen libdrm" FF_LIBRARY_EXTENSION " failed", "libdrm" FF_LIBRARY_EXTENSION, 2) FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libdrm, drmGetDevices) FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libdrm, drmModeGetResources) FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libdrm, drmModeGetConnectorCurrent) @@ -376,17 +376,19 @@ static const char* drmConnectLibdrm(FFDisplayServerResult* result) #endif -void ffdsConnectDrm(FFDisplayServerResult* result) +const char* ffdsConnectDrm(FFDisplayServerResult* result) { #ifdef FF_HAVE_DRM if (instance.config.general.dsForceDrm != FF_DS_FORCE_DRM_TYPE_SYSFS_ONLY) { if (drmConnectLibdrm(result) == NULL) - return; + return NULL; } #endif #ifdef __linux__ - drmParseSysfs(result); + return drmParseSysfs(result); #endif + + return "fastfetch was compiled without drm support"; } diff --git a/src/detection/displayserver/linux/wayland/wayland.c b/src/detection/displayserver/linux/wayland/wayland.c index 71671a74d5..a0472ae742 100644 --- a/src/detection/displayserver/linux/wayland/wayland.c +++ b/src/detection/displayserver/linux/wayland/wayland.c @@ -150,7 +150,7 @@ const char* ffdsConnectWayland(FFDisplayServerResult* result) if (getenv("XDG_RUNTIME_DIR") == NULL) return "Wayland requires $XDG_RUNTIME_DIR being set"; - FF_LIBRARY_LOAD(wayland, &instance.config.library.libWayland, false, "libwayland-client" FF_LIBRARY_EXTENSION, 1) + FF_LIBRARY_LOAD(wayland, false, "libwayland-client" FF_LIBRARY_EXTENSION, 1) FF_LIBRARY_LOAD_SYMBOL_MESSAGE(wayland, wl_display_connect) FF_LIBRARY_LOAD_SYMBOL_MESSAGE(wayland, wl_display_get_fd) diff --git a/src/detection/displayserver/linux/xcb.c b/src/detection/displayserver/linux/xcb.c index a64e55bd8b..6bf82e14bc 100644 --- a/src/detection/displayserver/linux/xcb.c +++ b/src/detection/displayserver/linux/xcb.c @@ -82,21 +82,21 @@ static void xcbDetectWMfromEWMH(XcbPropertyData* data, xcb_connection_t* connect ffStrbufSetS(&result->wmProcessName, wmName); } -void ffdsConnectXcb(FFDisplayServerResult* result) +const char* ffdsConnectXcb(FFDisplayServerResult* result) { - FF_LIBRARY_LOAD(xcb, &instance.config.library.libXcb, , "libxcb" FF_LIBRARY_EXTENSION, 2) - FF_LIBRARY_LOAD_SYMBOL(xcb, xcb_connect,) - FF_LIBRARY_LOAD_SYMBOL(xcb, xcb_get_setup,) - FF_LIBRARY_LOAD_SYMBOL(xcb, xcb_setup_roots_iterator,) - FF_LIBRARY_LOAD_SYMBOL(xcb, xcb_screen_next,) - FF_LIBRARY_LOAD_SYMBOL(xcb, xcb_disconnect,) + FF_LIBRARY_LOAD(xcb, "dlopen lbxcb failed", "libxcb" FF_LIBRARY_EXTENSION, 2) + FF_LIBRARY_LOAD_SYMBOL_MESSAGE(xcb, xcb_connect) + FF_LIBRARY_LOAD_SYMBOL_MESSAGE(xcb, xcb_get_setup) + FF_LIBRARY_LOAD_SYMBOL_MESSAGE(xcb, xcb_setup_roots_iterator) + FF_LIBRARY_LOAD_SYMBOL_MESSAGE(xcb, xcb_screen_next) + FF_LIBRARY_LOAD_SYMBOL_MESSAGE(xcb, xcb_disconnect) XcbPropertyData propertyData; bool propertyDataInitialized = xcbInitPropertyData(xcb, &propertyData); xcb_connection_t* connection = ffxcb_connect(NULL, NULL); if(connection == NULL) - return; + return "xcb_connect failed"; xcb_screen_iterator_t iterator = ffxcb_setup_roots_iterator(ffxcb_get_setup(connection)); @@ -128,14 +128,17 @@ void ffdsConnectXcb(FFDisplayServerResult* result) //If wayland hasn't set this, connection failed for it. So we are running only a X Server, not XWayland. if(result->wmProtocolName.length == 0) ffStrbufSetS(&result->wmProtocolName, FF_WM_PROTOCOL_X11); + + return NULL; } #else -void ffdsConnectXcb(FFDisplayServerResult* result) +const char* ffdsConnectXcb(FFDisplayServerResult* result) { //Do nothing. There are other implementations coming FF_UNUSED(result) + return "Fastfetch was compiled without XCB support"; } #endif @@ -388,45 +391,45 @@ static void xcbRandrHandleScreen(XcbRandrData* data, xcb_screen_t* screen) ); } -void ffdsConnectXcbRandr(FFDisplayServerResult* result) +const char* ffdsConnectXcbRandr(FFDisplayServerResult* result) { - FF_LIBRARY_LOAD(xcbRandr, &instance.config.library.libXcbRandr, , "libxcb-randr" FF_LIBRARY_EXTENSION, 1) - FF_LIBRARY_LOAD_SYMBOL(xcbRandr, xcb_connect,) - FF_LIBRARY_LOAD_SYMBOL(xcbRandr, xcb_get_setup,) - FF_LIBRARY_LOAD_SYMBOL(xcbRandr, xcb_setup_roots_iterator,) - FF_LIBRARY_LOAD_SYMBOL(xcbRandr, xcb_screen_next,) - FF_LIBRARY_LOAD_SYMBOL(xcbRandr, xcb_disconnect,) + FF_LIBRARY_LOAD(xcbRandr, "dlopen lbxcb-randr failed", "libxcb-randr" FF_LIBRARY_EXTENSION, 1) + FF_LIBRARY_LOAD_SYMBOL_MESSAGE(xcbRandr, xcb_connect) + FF_LIBRARY_LOAD_SYMBOL_MESSAGE(xcbRandr, xcb_get_setup) + FF_LIBRARY_LOAD_SYMBOL_MESSAGE(xcbRandr, xcb_setup_roots_iterator) + FF_LIBRARY_LOAD_SYMBOL_MESSAGE(xcbRandr, xcb_screen_next) + FF_LIBRARY_LOAD_SYMBOL_MESSAGE(xcbRandr, xcb_disconnect) XcbRandrData data; - FF_LIBRARY_LOAD_SYMBOL_VAR(xcbRandr, data, xcb_intern_atom,) - FF_LIBRARY_LOAD_SYMBOL_VAR(xcbRandr, data, xcb_intern_atom_reply,) - FF_LIBRARY_LOAD_SYMBOL_VAR(xcbRandr, data, xcb_randr_get_screen_resources_current,) - FF_LIBRARY_LOAD_SYMBOL_VAR(xcbRandr, data, xcb_randr_get_screen_resources_current_reply,) - FF_LIBRARY_LOAD_SYMBOL_VAR(xcbRandr, data, xcb_randr_get_screen_resources_current_modes_iterator,) - FF_LIBRARY_LOAD_SYMBOL_VAR(xcbRandr, data, xcb_randr_mode_info_next,) - FF_LIBRARY_LOAD_SYMBOL_VAR(xcbRandr, data, xcb_randr_get_monitors,) - FF_LIBRARY_LOAD_SYMBOL_VAR(xcbRandr, data, xcb_randr_get_monitors_reply,) - FF_LIBRARY_LOAD_SYMBOL_VAR(xcbRandr, data, xcb_randr_get_monitors_monitors_iterator,) - FF_LIBRARY_LOAD_SYMBOL_VAR(xcbRandr, data, xcb_randr_monitor_info_next,) - FF_LIBRARY_LOAD_SYMBOL_VAR(xcbRandr, data, xcb_randr_monitor_info_outputs_length,) - FF_LIBRARY_LOAD_SYMBOL_VAR(xcbRandr, data, xcb_randr_monitor_info_outputs,) - FF_LIBRARY_LOAD_SYMBOL_VAR(xcbRandr, data, xcb_randr_output_next,) - FF_LIBRARY_LOAD_SYMBOL_VAR(xcbRandr, data, xcb_randr_get_output_info,) - FF_LIBRARY_LOAD_SYMBOL_VAR(xcbRandr, data, xcb_randr_get_output_info_reply,) - FF_LIBRARY_LOAD_SYMBOL_VAR(xcbRandr, data, xcb_randr_get_output_property,) - FF_LIBRARY_LOAD_SYMBOL_VAR(xcbRandr, data, xcb_randr_get_output_property_reply,) - FF_LIBRARY_LOAD_SYMBOL_VAR(xcbRandr, data, xcb_randr_get_output_property_data,) - FF_LIBRARY_LOAD_SYMBOL_VAR(xcbRandr, data, xcb_randr_get_output_property_data_length,) - FF_LIBRARY_LOAD_SYMBOL_VAR(xcbRandr, data, xcb_randr_get_crtc_info,) - FF_LIBRARY_LOAD_SYMBOL_VAR(xcbRandr, data, xcb_randr_get_crtc_info_reply,) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xcbRandr, data, xcb_intern_atom) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xcbRandr, data, xcb_intern_atom_reply) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xcbRandr, data, xcb_randr_get_screen_resources_current) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xcbRandr, data, xcb_randr_get_screen_resources_current_reply) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xcbRandr, data, xcb_randr_get_screen_resources_current_modes_iterator) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xcbRandr, data, xcb_randr_mode_info_next) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xcbRandr, data, xcb_randr_get_monitors) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xcbRandr, data, xcb_randr_get_monitors_reply) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xcbRandr, data, xcb_randr_get_monitors_monitors_iterator) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xcbRandr, data, xcb_randr_monitor_info_next) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xcbRandr, data, xcb_randr_monitor_info_outputs_length) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xcbRandr, data, xcb_randr_monitor_info_outputs) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xcbRandr, data, xcb_randr_output_next) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xcbRandr, data, xcb_randr_get_output_info) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xcbRandr, data, xcb_randr_get_output_info_reply) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xcbRandr, data, xcb_randr_get_output_property) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xcbRandr, data, xcb_randr_get_output_property_reply) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xcbRandr, data, xcb_randr_get_output_property_data) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xcbRandr, data, xcb_randr_get_output_property_data_length) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xcbRandr, data, xcb_randr_get_crtc_info) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xcbRandr, data, xcb_randr_get_crtc_info_reply) bool propertyDataInitialized = xcbInitPropertyData(xcbRandr, &data.propData); data.connection = ffxcb_connect(NULL, NULL); if(data.connection == NULL) - return; + return "xcb_connect failed"; data.result = result; @@ -450,14 +453,17 @@ void ffdsConnectXcbRandr(FFDisplayServerResult* result) //If wayland hasn't set this, connection failed for it. So we are running only a X Server, not XWayland. if(result->wmProtocolName.length == 0) ffStrbufSetS(&result->wmProtocolName, FF_WM_PROTOCOL_X11); + + return NULL; } #else -void ffdsConnectXcbRandr(FFDisplayServerResult* result) +const char* ffdsConnectXcbRandr(FFDisplayServerResult* result) { //Do nothing. There are other implementations coming FF_UNUSED(result) + return "Fastfetch was compiled without libxcb-randr support"; } #endif diff --git a/src/detection/displayserver/linux/xlib.c b/src/detection/displayserver/linux/xlib.c index ac06f499d0..4a6a370802 100644 --- a/src/detection/displayserver/linux/xlib.c +++ b/src/detection/displayserver/linux/xlib.c @@ -58,18 +58,18 @@ static void x11DetectWMFromEWMH(X11PropertyData* data, Display* display, FFDispl data->ffXFree(wmWindow); } -void ffdsConnectXlib(FFDisplayServerResult* result) +const char* ffdsConnectXlib(FFDisplayServerResult* result) { - FF_LIBRARY_LOAD(x11, &instance.config.library.libX11, , "libX11" FF_LIBRARY_EXTENSION, 7, "libX11-xcb" FF_LIBRARY_EXTENSION, 2) - FF_LIBRARY_LOAD_SYMBOL(x11, XOpenDisplay,) - FF_LIBRARY_LOAD_SYMBOL(x11, XCloseDisplay,) + FF_LIBRARY_LOAD(x11, "dlopen libX11 failed", "libX11" FF_LIBRARY_EXTENSION, 7, "libX11-xcb" FF_LIBRARY_EXTENSION, 2) + FF_LIBRARY_LOAD_SYMBOL_MESSAGE(x11, XOpenDisplay) + FF_LIBRARY_LOAD_SYMBOL_MESSAGE(x11, XCloseDisplay) X11PropertyData propertyData; bool propertyDataInitialized = x11InitPropertyData(x11, &propertyData); Display* display = ffXOpenDisplay(x11); if(display == NULL) - return; + return "XOpenDisplay failed"; if(propertyDataInitialized && ScreenCount(display) > 0) x11DetectWMFromEWMH(&propertyData, display, result); @@ -98,14 +98,17 @@ void ffdsConnectXlib(FFDisplayServerResult* result) //If wayland hasn't set this, connection failed for it. So we are running only a X Server, not XWayland. if(result->wmProtocolName.length == 0) ffStrbufSetS(&result->wmProtocolName, FF_WM_PROTOCOL_X11); + + return NULL; } #else -void ffdsConnectXlib(FFDisplayServerResult* result) +const char* ffdsConnectXlib(FFDisplayServerResult* result) { //Do nothing. WM / DE detection will use environment vars to detect as much as possible. FF_UNUSED(result); + return "Fastfetch was compiled without libX11 support"; } #endif //FF_HAVE_X11 @@ -308,34 +311,34 @@ static void xrandrHandleScreen(XrandrData* data, Screen* screen) ); } -void ffdsConnectXrandr(FFDisplayServerResult* result) +const char* ffdsConnectXrandr(FFDisplayServerResult* result) { - FF_LIBRARY_LOAD(xrandr, &instance.config.library.libXrandr, , "libXrandr" FF_LIBRARY_EXTENSION, 3) + FF_LIBRARY_LOAD(xrandr, "dlopen libXrandr failed", "libXrandr" FF_LIBRARY_EXTENSION, 3) - FF_LIBRARY_LOAD_SYMBOL(xrandr, XOpenDisplay,) - FF_LIBRARY_LOAD_SYMBOL(xrandr, XCloseDisplay,) + FF_LIBRARY_LOAD_SYMBOL_MESSAGE(xrandr, XOpenDisplay) + FF_LIBRARY_LOAD_SYMBOL_MESSAGE(xrandr, XCloseDisplay) XrandrData data; - FF_LIBRARY_LOAD_SYMBOL_VAR(xrandr, data, XInternAtom,); - FF_LIBRARY_LOAD_SYMBOL_VAR(xrandr, data, XGetAtomName,); - FF_LIBRARY_LOAD_SYMBOL_VAR(xrandr, data, XFree,); - FF_LIBRARY_LOAD_SYMBOL_VAR(xrandr, data, XRRGetMonitors,); - FF_LIBRARY_LOAD_SYMBOL_VAR(xrandr, data, XRRGetScreenResourcesCurrent,); - FF_LIBRARY_LOAD_SYMBOL_VAR(xrandr, data, XRRGetOutputInfo,); - FF_LIBRARY_LOAD_SYMBOL_VAR(xrandr, data, XRRGetOutputProperty,); - FF_LIBRARY_LOAD_SYMBOL_VAR(xrandr, data, XRRGetCrtcInfo,); - FF_LIBRARY_LOAD_SYMBOL_VAR(xrandr, data, XRRFreeCrtcInfo,); - FF_LIBRARY_LOAD_SYMBOL_VAR(xrandr, data, XRRFreeOutputInfo,); - FF_LIBRARY_LOAD_SYMBOL_VAR(xrandr, data, XRRFreeScreenResources,); - FF_LIBRARY_LOAD_SYMBOL_VAR(xrandr, data, XRRFreeMonitors,); + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xrandr, data, XInternAtom); + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xrandr, data, XGetAtomName); + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xrandr, data, XFree); + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xrandr, data, XRRGetMonitors); + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xrandr, data, XRRGetScreenResourcesCurrent); + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xrandr, data, XRRGetOutputInfo); + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xrandr, data, XRRGetOutputProperty); + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xrandr, data, XRRGetCrtcInfo); + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xrandr, data, XRRFreeCrtcInfo); + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xrandr, data, XRRFreeOutputInfo); + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xrandr, data, XRRFreeScreenResources); + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xrandr, data, XRRFreeMonitors); X11PropertyData propertyData; bool propertyDataInitialized = x11InitPropertyData(xrandr, &propertyData); data.display = ffXOpenDisplay(NULL); if(data.display == NULL) - return; + return "XOpenDisplay() failed"; if(propertyDataInitialized && ScreenCount(data.display) > 0) x11DetectWMFromEWMH(&propertyData, data.display, result); @@ -350,14 +353,17 @@ void ffdsConnectXrandr(FFDisplayServerResult* result) //If wayland hasn't set this, connection failed for it. So we are running only a X Server, not XWayland. if(result->wmProtocolName.length == 0) ffStrbufSetS(&result->wmProtocolName, FF_WM_PROTOCOL_X11); + + return NULL; } #else -void ffdsConnectXrandr(FFDisplayServerResult* result) +const char* ffdsConnectXrandr(FFDisplayServerResult* result) { //Do nothing here. There are more x11 implementations to come. FF_UNUSED(result); + return "Fastfetch was compiled without libXrandr support"; } #endif // FF_HAVE_XRANDR diff --git a/src/detection/gpu/gpu_amd.c b/src/detection/gpu/gpu_amd.c index d50451ef46..1510019ea0 100644 --- a/src/detection/gpu/gpu_amd.c +++ b/src/detection/gpu/gpu_amd.c @@ -17,7 +17,7 @@ const char* ffDetectAmdGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverResu if (!inited) { inited = true; - FF_LIBRARY_LOAD(libags, NULL, "dlopen amd_ags failed", soName , 1); + FF_LIBRARY_LOAD(libags, "dlopen amd_ags failed", soName , 1); FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libags, agsInitialize) struct AGSContext* apiHandle; diff --git a/src/detection/gpu/gpu_intel.c b/src/detection/gpu/gpu_intel.c index 3d4638cd3f..1b4da5ed81 100644 --- a/src/detection/gpu/gpu_intel.c +++ b/src/detection/gpu/gpu_intel.c @@ -34,7 +34,7 @@ const char* ffDetectIntelGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverRe if (!igclData.inited) { igclData.inited = true; - FF_LIBRARY_LOAD(libigcl, NULL, "dlopen igcl (ControlLib) failed", soName , 1); + FF_LIBRARY_LOAD(libigcl, "dlopen igcl (ControlLib) failed", soName , 1); FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libigcl, ctlInit) FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libigcl, igclData, ctlClose) FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libigcl, igclData, ctlEnumerateDevices) diff --git a/src/detection/gpu/gpu_linux.c b/src/detection/gpu/gpu_linux.c index 3b3995abbd..cb038989ec 100644 --- a/src/detection/gpu/gpu_linux.c +++ b/src/detection/gpu/gpu_linux.c @@ -407,6 +407,8 @@ FF_MAYBE_UNUSED static const char* detectAsahi(FFlist* gpus, FFstrbuf* buffer, F FFGPUResult* gpu = (FFGPUResult*)ffListAdd(gpus); gpu->deviceId = strtoul(buffer->chars + index, NULL, 10); ffStrbufInitStatic(&gpu->name, ffCPUAppleCodeToName((uint32_t) gpu->deviceId)); + if (!gpu->name.length) + ffStrbufAppendF(&gpu->name, "Apple Silicon T%u", (uint32_t) gpu->deviceId); ffStrbufInitStatic(&gpu->vendor, FF_GPU_VENDOR_NAME_APPLE); ffStrbufInit(&gpu->driver); ffStrbufInitF(&gpu->platformApi, "DRM (%s)", drmKey); diff --git a/src/detection/gpu/gpu_mthreads.c b/src/detection/gpu/gpu_mthreads.c index aefc1d9da6..0104518fc9 100644 --- a/src/detection/gpu/gpu_mthreads.c +++ b/src/detection/gpu/gpu_mthreads.c @@ -41,7 +41,7 @@ const char *ffDetectMthreadsGpuInfo(const FFGpuDriverCondition *cond, FFGpuDrive if (!mtmlData.inited) { mtmlData.inited = true; - FF_LIBRARY_LOAD(libmtml, NULL, "dlopen mtml failed", soName, 1); + FF_LIBRARY_LOAD(libmtml, "dlopen mtml failed", soName, 1); FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libmtml, mtmlLibraryInit) FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libmtml, mtmlData, mtmlDeviceGetBrand) FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libmtml, mtmlData, mtmlDeviceGetIndex) diff --git a/src/detection/gpu/gpu_nvidia.c b/src/detection/gpu/gpu_nvidia.c index 42ed09d91a..fdd88f6ce2 100644 --- a/src/detection/gpu/gpu_nvidia.c +++ b/src/detection/gpu/gpu_nvidia.c @@ -26,7 +26,7 @@ const char* ffDetectNvidiaGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverR if (!nvmlData.inited) { nvmlData.inited = true; - FF_LIBRARY_LOAD(libnvml, NULL, "dlopen nvml failed", soName , 1); + FF_LIBRARY_LOAD(libnvml, "dlopen nvml failed", soName , 1); FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libnvml, nvmlInit_v2) FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libnvml, nvmlShutdown) FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libnvml, nvmlData, nvmlDeviceGetCount_v2) diff --git a/src/detection/gpu/gpu_wsl.cpp b/src/detection/gpu/gpu_wsl.cpp index bc41d351dc..ae144aca9b 100644 --- a/src/detection/gpu/gpu_wsl.cpp +++ b/src/detection/gpu/gpu_wsl.cpp @@ -28,7 +28,7 @@ struct on_scope_exit { extern "C" const char* ffGPUDetectByDirectX(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist* gpus) { - FF_LIBRARY_LOAD(libdxcore, nullptr, "dlopen libdxcore.so failed", "/usr/lib/wsl/lib/libdxcore" FF_LIBRARY_EXTENSION, 4) + FF_LIBRARY_LOAD(libdxcore, "dlopen libdxcore.so failed", "/usr/lib/wsl/lib/libdxcore" FF_LIBRARY_EXTENSION, 4) // DXCoreCreateAdapterFactory is a reloaded function, so we can't use FF_LIBRARY_LOAD_SYMBOL_MESSAGE here typedef HRESULT (*DXCoreCreateAdapterFactory_t)(REFIID riid, void** ppvFactory); diff --git a/src/detection/initsystem/initsystem_linux.c b/src/detection/initsystem/initsystem_linux.c index 328c7694a6..6776ef7584 100644 --- a/src/detection/initsystem/initsystem_linux.c +++ b/src/detection/initsystem/initsystem_linux.c @@ -3,6 +3,7 @@ #include "util/binary.h" #include "util/stringUtils.h" +#include #include FF_MAYBE_UNUSED static bool extractSystemdVersion(const char* str, uint32_t len, void* userdata) @@ -39,7 +40,10 @@ const char* ffDetectInitSystem(FFInitSystemResult* result) // In some old system, /sbin/init is a symlink char buf[PATH_MAX]; if (realpath(result->exe.chars, buf)) + { ffStrbufSetS(&result->exe, buf); + ffStrbufSetS(&result->name, basename(result->exe.chars)); + } } if (instance.config.general.detectVersion) @@ -66,6 +70,20 @@ const char* ffDetectInitSystem(FFInitSystemResult* result) } } } + else if (ffStrbufEqualS(&result->name, "dinit")) + { + if (ffProcessAppendStdOut(&result->version, (char* const[]) { + ffStrbufEndsWithS(&result->exe, "/dinit") ? result->exe.chars : "dinit", + "--version", + NULL, + }) == NULL && result->version.length) + { + // Dinit version 0.18.0. + ffStrbufSubstrBeforeFirstC(&result->version, '\n'); + ffStrbufTrimRight(&result->version, '.'); + ffStrbufSubstrAfterLastC(&result->version, ' '); + } + } #elif __APPLE__ if (ffStrbufEqualS(&result->name, "launchd")) { diff --git a/src/detection/lm/lm_linux.c b/src/detection/lm/lm_linux.c index c2cf8d27f3..cfb64b9a4a 100644 --- a/src/detection/lm/lm_linux.c +++ b/src/detection/lm/lm_linux.c @@ -54,7 +54,7 @@ static const char* getSshdVersion(FFstrbuf* version) static const char* getSddmVersion(FFstrbuf* version) { - FF_LIBRARY_LOAD(zlib, &instance.config.library.libZ, "dlopen libz failed", "libz" FF_LIBRARY_EXTENSION, 2) + FF_LIBRARY_LOAD(zlib, "dlopen libz failed", "libz" FF_LIBRARY_EXTENSION, 2) FF_LIBRARY_LOAD_SYMBOL_MESSAGE(zlib, gzopen) FF_LIBRARY_LOAD_SYMBOL_MESSAGE(zlib, gzread) FF_LIBRARY_LOAD_SYMBOL_MESSAGE(zlib, gzerror) diff --git a/src/detection/media/media_windows.c b/src/detection/media/media_windows.c index ed0ed97ced..cf040f983b 100644 --- a/src/detection/media/media_windows.c +++ b/src/detection/media/media_windows.c @@ -5,7 +5,7 @@ static const char* getMedia(FFMediaResult* media) { - FF_LIBRARY_LOAD(libffwinrt, NULL, "dlopen libffwinrt" FF_LIBRARY_EXTENSION " failed", "libffwinrt" FF_LIBRARY_EXTENSION, 0) + FF_LIBRARY_LOAD(libffwinrt, "dlopen libffwinrt" FF_LIBRARY_EXTENSION " failed", "libffwinrt" FF_LIBRARY_EXTENSION, 0) FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libffwinrt, ffWinrtDetectMedia) libffwinrt = NULL; // Don't close libffwinrt or it may crash diff --git a/src/detection/monitor/monitor_linux.c b/src/detection/monitor/monitor_linux.c index d5c0e4fe3f..ecf3bef34b 100644 --- a/src/detection/monitor/monitor_linux.c +++ b/src/detection/monitor/monitor_linux.c @@ -135,7 +135,7 @@ static const char* xrandrHandleMonitors(XrandrData* data, Screen* screen, FFlist static const char* detectByXrandr(FFlist* results) { - FF_LIBRARY_LOAD(xrandr, &instance.config.library.libXrandr, "dlopen libXrandr" FF_LIBRARY_EXTENSION " failed", "libXrandr" FF_LIBRARY_EXTENSION, 3) + FF_LIBRARY_LOAD(xrandr, "dlopen libXrandr" FF_LIBRARY_EXTENSION " failed", "libXrandr" FF_LIBRARY_EXTENSION, 3) FF_LIBRARY_LOAD_SYMBOL_MESSAGE(xrandr, XOpenDisplay) FF_LIBRARY_LOAD_SYMBOL_MESSAGE(xrandr, XCloseDisplay) diff --git a/src/detection/opencl/opencl.c b/src/detection/opencl/opencl.c index 7da61a23ad..9254816a17 100644 --- a/src/detection/opencl/opencl.c +++ b/src/detection/opencl/opencl.c @@ -148,7 +148,7 @@ static const char* detectOpenCL(FFOpenCLResult* result) #ifndef __APPLE__ - FF_LIBRARY_LOAD(opencl, &instance.config.library.libOpenCL, "dlopen libOpenCL" FF_LIBRARY_EXTENSION" failed", + FF_LIBRARY_LOAD(opencl, "dlopen libOpenCL" FF_LIBRARY_EXTENSION" failed", #ifdef _WIN32 "OpenCL"FF_LIBRARY_EXTENSION, -1, #endif diff --git a/src/detection/opengl/opengl_apple.c b/src/detection/opengl/opengl_apple.c index c6b56f07f3..63751d6b86 100644 --- a/src/detection/opengl/opengl_apple.c +++ b/src/detection/opengl/opengl_apple.c @@ -34,7 +34,7 @@ static const char* cglHandlePixelFormat(FFOpenGLResult* result, CGLPixelFormatOb return error; } -const char* ffDetectOpenGL(FF_MAYBE_UNUSED FFOpenGLOptions* options, FFOpenGLResult* result) +const char* cglDetectOpenGL(FFOpenGLResult* result) { CGLPixelFormatObj pixelFormat; CGLPixelFormatAttribute attrs[] = { @@ -51,3 +51,20 @@ const char* ffDetectOpenGL(FF_MAYBE_UNUSED FFOpenGLOptions* options, FFOpenGLRes CGLDestroyPixelFormat(pixelFormat); return error; } + +const char* ffDetectOpenGL(FFOpenGLOptions* options, FFOpenGLResult* result) +{ + if (options->library == FF_OPENGL_LIBRARY_AUTO) + return cglDetectOpenGL(result); + else if (options->library == FF_OPENGL_LIBRARY_EGL) + { + #if __has_include() + const char* ffOpenGLDetectByEGL(FFOpenGLResult* result); + return ffOpenGLDetectByEGL(result); + #else + return "fastfetch was compiled without egl support"; + #endif + } + else + return "Unsupported OpenGL library"; +} diff --git a/src/detection/opengl/opengl_linux.c b/src/detection/opengl/opengl_linux.c index 4a417bace7..051107bece 100644 --- a/src/detection/opengl/opengl_linux.c +++ b/src/detection/opengl/opengl_linux.c @@ -120,7 +120,7 @@ static const char* detectByGlx(FFOpenGLResult* result) { GLXData data; - FF_LIBRARY_LOAD(glx, &instance.config.library.libGLX, "dlopen glx failed", "libGLX" FF_LIBRARY_EXTENSION, 1); + FF_LIBRARY_LOAD(glx, "dlopen glx failed", "libGLX" FF_LIBRARY_EXTENSION, 1); FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(glx, data, glXGetProcAddress); FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(glx, data, glXQueryVersion); FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(glx, data, XOpenDisplay); @@ -189,7 +189,7 @@ static const char* detectByOsMesa(FFOpenGLResult* result) { OSMesaData data; - FF_LIBRARY_LOAD(osmesa, &instance.config.library.libOSMesa, "dlopen osmesa failed", "libOSMesa" FF_LIBRARY_EXTENSION, 8); + FF_LIBRARY_LOAD(osmesa, "dlopen osmesa failed", "libOSMesa" FF_LIBRARY_EXTENSION, 8); FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(osmesa, data, OSMesaGetProcAddress); FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(osmesa, data, OSMesaCreateContext); FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(osmesa, data, OSMesaMakeCurrent); diff --git a/src/detection/opengl/opengl_shared.c b/src/detection/opengl/opengl_shared.c index f8e190dc36..66021a2272 100644 --- a/src/detection/opengl/opengl_shared.c +++ b/src/detection/opengl/opengl_shared.c @@ -74,14 +74,8 @@ static const char* eglHandleSurface(FFOpenGLResult* result, EGLData* data) static const char* eglHandleDisplay(FFOpenGLResult* result, EGLData* data) { - if(data->ffeglBindAPI( - #ifdef _WIN32 - EGL_OPENGL_ES_API - #else - EGL_OPENGL_API - #endif - ) != EGL_TRUE) - return "eglBindAPI returned EGL_FALSE"; + // try use OpenGL API. If failed, use the default API (usually OpenGL ES) + data->ffeglBindAPI(EGL_OPENGL_API); EGLint eglConfigCount; data->ffeglGetConfigs(data->display, &data->config, 1, &eglConfigCount); @@ -121,11 +115,12 @@ static const char* eglHandleData(FFOpenGLResult* result, EGLData* data) return error; } + const char* ffOpenGLDetectByEGL(FFOpenGLResult* result) { EGLData eglData; - FF_LIBRARY_LOAD(egl, &instance.config.library.libEGL, "dlopen egl failed", "libEGL" FF_LIBRARY_EXTENSION, 1); + FF_LIBRARY_LOAD(egl, "dlopen libEGL" FF_LIBRARY_EXTENSION " failed", "libEGL" FF_LIBRARY_EXTENSION, 1); FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(egl, eglData, eglGetProcAddress); FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(egl, eglData, eglGetDisplay); FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(egl, eglData, eglQueryString); diff --git a/src/detection/opengl/opengl_windows.c b/src/detection/opengl/opengl_windows.c index 3984c93098..529e841acf 100644 --- a/src/detection/opengl/opengl_windows.c +++ b/src/detection/opengl/opengl_windows.c @@ -81,7 +81,7 @@ static LRESULT CALLBACK wglHandleWndProc(HWND hWnd, UINT message, WPARAM wParam, static const char* wglDetectOpenGL(FFOpenGLResult* result) { - FF_LIBRARY_LOAD(opengl32, NULL, "dlopen opengl32" FF_LIBRARY_EXTENSION " failed", "opengl32" FF_LIBRARY_EXTENSION, 1); + FF_LIBRARY_LOAD(opengl32, "dlopen opengl32" FF_LIBRARY_EXTENSION " failed", "opengl32" FF_LIBRARY_EXTENSION, 1); WGLData data = { .result = result }; diff --git a/src/detection/os/os_linux.c b/src/detection/os/os_linux.c index c37de86473..af6b37ba45 100644 --- a/src/detection/os/os_linux.c +++ b/src/detection/os/os_linux.c @@ -132,6 +132,15 @@ static void getUbuntuFlavour(FFOSResult* result) ffStrbufSetS(&result->idLike, "ubuntu"); return; } + + if(ffStrContains(xdgConfigDirs, "lliurex")) + { + ffStrbufSetS(&result->name, "LliureX"); + ffStrbufSetS(&result->prettyName, "LliureX"); + ffStrbufSetS(&result->id, "lliurex"); + ffStrbufSetS(&result->idLike, "ubuntu"); + return; + } } static void getDebianVersion(FFOSResult* result) diff --git a/src/detection/os/os_windows.cpp b/src/detection/os/os_windows.cpp index 117be1ed0e..ef93ff40ce 100644 --- a/src/detection/os/os_windows.cpp +++ b/src/detection/os/os_windows.cpp @@ -31,7 +31,7 @@ PWSTR WINAPI BrandingFormatString(PCWSTR format); static const char* getOsNameByWinbrand(FFstrbuf* osName) { //https://dennisbabkin.com/blog/?t=how-to-tell-the-real-version-of-windows-your-app-is-running-on#ver_string - FF_LIBRARY_LOAD(winbrand, nullptr, "dlopen winbrand" FF_LIBRARY_EXTENSION " failed", "winbrand" FF_LIBRARY_EXTENSION, 1); + FF_LIBRARY_LOAD(winbrand, "dlopen winbrand" FF_LIBRARY_EXTENSION " failed", "winbrand" FF_LIBRARY_EXTENSION, 1); FF_LIBRARY_LOAD_SYMBOL_MESSAGE(winbrand, BrandingFormatString); const wchar_t* rawName = ffBrandingFormatString(L"%WINDOWS_LONG%"); diff --git a/src/detection/packages/packages_linux.c b/src/detection/packages/packages_linux.c index ab07ff07b6..e1bd54cdf0 100644 --- a/src/detection/packages/packages_linux.c +++ b/src/detection/packages/packages_linux.c @@ -322,7 +322,7 @@ static uint32_t getSnap(FFstrbuf* baseDir) static uint32_t getRpmFromLibrpm(void) { - FF_LIBRARY_LOAD(rpm, &instance.config.library.librpm, 0, "librpm" FF_LIBRARY_EXTENSION, 12) + FF_LIBRARY_LOAD(rpm, 0, "librpm" FF_LIBRARY_EXTENSION, 12) FF_LIBRARY_LOAD_SYMBOL(rpm, rpmReadConfigFiles, 0) FF_LIBRARY_LOAD_SYMBOL(rpm, rpmtsCreate, 0) FF_LIBRARY_LOAD_SYMBOL(rpm, rpmtsInitIterator, 0) diff --git a/src/detection/sound/sound_linux.c b/src/detection/sound/sound_linux.c index 906792cc7e..a66fb0a596 100644 --- a/src/detection/sound/sound_linux.c +++ b/src/detection/sound/sound_linux.c @@ -41,7 +41,7 @@ static void paServerInfoCallback(pa_context *c, const pa_server_info *i, void *u static const char* detectSound(FFlist* devices) { - FF_LIBRARY_LOAD(pulse, &instance.config.library.libPulse, "Failed to load libpulse" FF_LIBRARY_EXTENSION, "libpulse" FF_LIBRARY_EXTENSION, 0) + FF_LIBRARY_LOAD(pulse, "Failed to load libpulse" FF_LIBRARY_EXTENSION, "libpulse" FF_LIBRARY_EXTENSION, 0) FF_LIBRARY_LOAD_SYMBOL_MESSAGE(pulse, pa_mainloop_new) FF_LIBRARY_LOAD_SYMBOL_MESSAGE(pulse, pa_mainloop_get_api) FF_LIBRARY_LOAD_SYMBOL_MESSAGE(pulse, pa_mainloop_iterate) diff --git a/src/detection/terminalfont/terminalfont.c b/src/detection/terminalfont/terminalfont.c index eb176b1806..0a531b285d 100644 --- a/src/detection/terminalfont/terminalfont.c +++ b/src/detection/terminalfont/terminalfont.c @@ -72,35 +72,32 @@ FF_MAYBE_UNUSED static void detectTTY(FFTerminalFontResult* terminalFont) ffStrbufAppendS(&terminalFont->error, "Couldn't find Font in "FASTFETCH_TARGET_DIR_ETC"/vconsole.conf"); } -static bool queryKittyTerm(const char* query, FFstrbuf* res) +FF_MAYBE_UNUSED static bool detectKitty(const FFstrbuf* exe, FFTerminalFontResult* result) { + FF_STRBUF_AUTO_DESTROY fontName = ffStrbufCreate(); + FF_STRBUF_AUTO_DESTROY fontSize = ffStrbufCreate(); + + char fontHex[512] = "", sizeHex[512] = ""; // https://github.com/fastfetch-cli/fastfetch/discussions/1030#discussioncomment-9845233 - char buffer[256] = ""; if (ffGetTerminalResponse( - query, // kitty-query-font_family;kitty-query-font_size - "\eP1+r%*[^=]=%255[^\e]\e\\", buffer) == NULL) + "\eP+q6b697474792d71756572792d666f6e745f66616d696c79;6b697474792d71756572792d666f6e745f73697a65\e\\", // kitty-query-font_family;kitty-query-font_size + 2, + "\eP1+r%*[^=]=%64[^\e]\e\\\eP1+r%*[^=]=%64[^\e]\e\\", fontHex, sizeHex) == NULL && *fontHex && *sizeHex) { // decode hex string - for (const char* p = buffer; p[0] && p[1]; p += 2) + for (const char* p = fontHex; p[0] && p[1]; p += 2) + { + unsigned value; + if (sscanf(p, "%2x", &value) == 1) + ffStrbufAppendC(&fontName, (char) value); + } + for (const char* p = sizeHex; p[0] && p[1]; p += 2) { unsigned value; if (sscanf(p, "%2x", &value) == 1) - ffStrbufAppendC(res, (char) value); + ffStrbufAppendC(&fontSize, (char) value); } - return true; } - return false; -} - -FF_MAYBE_UNUSED static bool detectKitty(const FFstrbuf* exe, FFTerminalFontResult* result) -{ - FF_STRBUF_AUTO_DESTROY fontName = ffStrbufCreate(); - FF_STRBUF_AUTO_DESTROY fontSize = ffStrbufCreate(); - - // Kitty generates response independently even if we query font family and size in one query - // which may result in short read in `ffGetTerminalResponse` - if (queryKittyTerm("\eP+q6b697474792d71756572792d666f6e745f66616d696c79\e\\", &fontName)) // kitty-query-font_family - queryKittyTerm("\eP+q6b697474792d71756572792d666f6e745f73697a65\e\\", &fontSize); // kitty-query-font_size else { FF_STRBUF_AUTO_DESTROY buf = ffStrbufCreate(); diff --git a/src/detection/terminalfont/terminalfont_android.c b/src/detection/terminalfont/terminalfont_android.c index fef9ad24a0..318c321f2e 100644 --- a/src/detection/terminalfont/terminalfont_android.c +++ b/src/detection/terminalfont/terminalfont_android.c @@ -15,7 +15,7 @@ const char* detectTermux(FFTerminalFontResult* terminalFont) { #ifdef FF_HAVE_FREETYPE - FF_LIBRARY_LOAD(freetype, &instance.config.library.libfreetype, "dlopen libfreetype"FF_LIBRARY_EXTENSION " failed", "libfreetype"FF_LIBRARY_EXTENSION, 2) + FF_LIBRARY_LOAD(freetype, "dlopen libfreetype"FF_LIBRARY_EXTENSION " failed", "libfreetype"FF_LIBRARY_EXTENSION, 2) FF_LIBRARY_LOAD_SYMBOL_MESSAGE(freetype, FT_Init_FreeType); FF_LIBRARY_LOAD_SYMBOL_MESSAGE(freetype, FT_New_Face); FF_LIBRARY_LOAD_SYMBOL_MESSAGE(freetype, FT_Done_Face); diff --git a/src/detection/terminalshell/terminalshell.c b/src/detection/terminalshell/terminalshell.c index b397f7159c..c44ecc32c2 100644 --- a/src/detection/terminalshell/terminalshell.c +++ b/src/detection/terminalshell/terminalshell.c @@ -375,6 +375,9 @@ FF_MAYBE_UNUSED static bool getTerminalVersionFoot(FFstrbuf* exe, FFstrbuf* vers FF_MAYBE_UNUSED static bool getTerminalVersionMateTerminal(FFstrbuf* exe, FFstrbuf* version) { + ffBinaryExtractStrings(exe->chars, extractGeneralVersion, version, (uint32_t) strlen("0.0.0")); + if (version->length > 0) return true; + if(!getExeVersionRaw(exe, version)) return false; //MATE Terminal 1.26.1 @@ -580,6 +583,7 @@ static bool getTerminalVersionKitty(FFstrbuf* exe, FFstrbuf* version) // https://github.com/fastfetch-cli/fastfetch/discussions/1030#discussioncomment-9845233 if (ffGetTerminalResponse( "\eP+q6b697474792d71756572792d76657273696f6e\e\\", // kitty-query-version + 1, "\eP1+r%*[^=]=%63[^\e]\e\\\\", versionHex) == NULL) { // decode hex string diff --git a/src/detection/terminalsize/terminalsize_linux.c b/src/detection/terminalsize/terminalsize_linux.c index b5016045dc..70c29d558e 100644 --- a/src/detection/terminalsize/terminalsize_linux.c +++ b/src/detection/terminalsize/terminalsize_linux.c @@ -14,10 +14,10 @@ bool ffDetectTerminalSize(FFTerminalSizeResult* result) ioctl(STDOUT_FILENO, TIOCGWINSZ, &winsize); if (winsize.ws_row == 0 || winsize.ws_col == 0) - ffGetTerminalResponse("\e[18t", "\e[8;%hu;%hut", &winsize.ws_row, &winsize.ws_col); + ffGetTerminalResponse("\e[18t", 2, "\e[8;%hu;%hut", &winsize.ws_row, &winsize.ws_col); if (winsize.ws_ypixel == 0 || winsize.ws_xpixel == 0) - ffGetTerminalResponse("\e[14t", "\e[4;%hu;%hut", &winsize.ws_ypixel, &winsize.ws_xpixel); + ffGetTerminalResponse("\e[14t", 2, "\e[4;%hu;%hut", &winsize.ws_ypixel, &winsize.ws_xpixel); if (winsize.ws_row == 0 && winsize.ws_col == 0) return false; diff --git a/src/detection/terminalsize/terminalsize_windows.c b/src/detection/terminalsize/terminalsize_windows.c index 1264f03218..ae9970eb9d 100644 --- a/src/detection/terminalsize/terminalsize_windows.c +++ b/src/detection/terminalsize/terminalsize_windows.c @@ -24,7 +24,8 @@ bool ffDetectTerminalSize(FFTerminalSizeResult* result) } else { - ffGetTerminalResponse("\e[18t", "\e[8;%hu;%hut", &result->rows, &result->columns); + // Windows Terminal doesn't report `\e` for some reason + ffGetTerminalResponse("\e[18t", 2, "%*[^;];%hu;%hut", &result->rows, &result->columns); } } @@ -38,12 +39,10 @@ bool ffDetectTerminalSize(FFTerminalSizeResult* result) result->width = result->columns * (uint16_t) cfi.dwFontSize.X; result->height = result->rows * (uint16_t) cfi.dwFontSize.Y; } - else + if (result->width == 0 || result->height == 0) { - // Pending https://github.com/microsoft/terminal/issues/8581 - // if (result->width == 0 && result->height == 0) - // ffGetTerminalResponse("\033[14t", "\033[4;%hu;%hut", &result->height, &result->width); - return false; + // Windows Terminal doesn't report `\e` for some reason + ffGetTerminalResponse("\e[14t", 2, "%*[^;];%hu;%hut", &result->height, &result->width); } } diff --git a/src/detection/terminaltheme/terminaltheme.c b/src/detection/terminaltheme/terminaltheme.c index 192864bb3d..b42b61a072 100644 --- a/src/detection/terminaltheme/terminaltheme.c +++ b/src/detection/terminaltheme/terminaltheme.c @@ -6,22 +6,15 @@ static bool detectByEscapeCode(FFTerminalThemeResult* result) { - int command = 0; - - if (ffGetTerminalResponse("\e]10;?\e\\", "\e]%d;rgb:%" SCNx16 "/%" SCNx16 "/%" SCNx16 "\e\\", &command, &result->fg.r, &result->fg.g, &result->fg.b) == NULL) + // Windows Terminal removes all `\e`s in its output + if (ffGetTerminalResponse("\e]10;?\e\\" /*fg*/ "\e]11;?\e\\" /*bg*/, + 6, + "%*[^0-9]10;rgb:%" SCNx16 "/%" SCNx16 "/%" SCNx16 /*"\e\\"*/ "%*[^0-9]11;rgb:%" SCNx16 "/%" SCNx16 "/%" SCNx16 /*"\e\\"*/, + &result->fg.r, &result->fg.g, &result->fg.b, + &result->bg.r, &result->bg.g, &result->bg.b) == NULL) { - if (command != 10) - return false; if (result->fg.r > 0x0100 || result->fg.g > 0x0100 || result->fg.b > 0x0100) result->fg.r /= 0x0100, result->fg.g /= 0x0100, result->fg.b /= 0x0100; - } - else - return false; - - if (ffGetTerminalResponse("\e]11;?\e\\", "\e]%d;rgb:%" SCNx16 "/%" SCNx16 "/%" SCNx16 "\e\\", &command, &result->bg.r, &result->bg.g, &result->bg.b) == NULL) - { - if (command != 11) - return false; if (result->bg.r > 0x0100 || result->bg.g > 0x0100 || result->bg.b > 0x0100) result->bg.r /= 0x0100, result->bg.g /= 0x0100, result->bg.b /= 0x0100; } diff --git a/src/detection/uptime/uptime_linux.c b/src/detection/uptime/uptime_linux.c index ab85dd87a7..0e45324921 100644 --- a/src/detection/uptime/uptime_linux.c +++ b/src/detection/uptime/uptime_linux.c @@ -20,7 +20,7 @@ const char* ffDetectUptime(FFUptimeResult* result) if(err != buf) { result->uptime = (uint64_t) (sec * 1000); - result->bootTime = ffTimeGetNow() + result->uptime; + result->bootTime = ffTimeGetNow() - result->uptime; return NULL; } } @@ -32,7 +32,7 @@ const char* ffDetectUptime(FFUptimeResult* result) return "clock_gettime(CLOCK_BOOTTIME) failed"; result->uptime = (uint64_t) uptime.tv_sec * 1000 + (uint64_t) uptime.tv_nsec / 1000000; - result->bootTime = ffTimeGetNow() + result->uptime; + result->bootTime = ffTimeGetNow() - result->uptime; return NULL; } diff --git a/src/detection/vulkan/vulkan.c b/src/detection/vulkan/vulkan.c index dc3b42089e..1d49ec5844 100644 --- a/src/detection/vulkan/vulkan.c +++ b/src/detection/vulkan/vulkan.c @@ -39,7 +39,7 @@ static void applyDriverName(VkPhysicalDeviceDriverPropertiesKHR* properties, FFs static const char* detectVulkan(FFVulkanResult* result) { - FF_LIBRARY_LOAD(vulkan, &instance.config.library.libVulkan, "dlopen libvulkan"FF_LIBRARY_EXTENSION " failed", + FF_LIBRARY_LOAD(vulkan, "dlopen libvulkan"FF_LIBRARY_EXTENSION " failed", #ifdef __APPLE__ "libMoltenVK"FF_LIBRARY_EXTENSION, -1 #elif defined(_WIN32) diff --git a/src/detection/wifi/wifi_windows.c b/src/detection/wifi/wifi_windows.c index 0508a72d44..18262f2810 100644 --- a/src/detection/wifi/wifi_windows.c +++ b/src/detection/wifi/wifi_windows.c @@ -43,7 +43,7 @@ static void convertIfStateToString(WLAN_INTERFACE_STATE state, FFstrbuf* result) const char* ffDetectWifi(FFlist* result) { - FF_LIBRARY_LOAD(wlanapi, NULL, "dlopen wlanapi"FF_LIBRARY_EXTENSION" failed", "wlanapi"FF_LIBRARY_EXTENSION, 1) + FF_LIBRARY_LOAD(wlanapi, "dlopen wlanapi" FF_LIBRARY_EXTENSION " failed", "wlanapi" FF_LIBRARY_EXTENSION, 1) FF_LIBRARY_LOAD_SYMBOL_MESSAGE(wlanapi, WlanOpenHandle) FF_LIBRARY_LOAD_SYMBOL_MESSAGE(wlanapi, WlanEnumInterfaces) FF_LIBRARY_LOAD_SYMBOL_MESSAGE(wlanapi, WlanQueryInterface) diff --git a/src/detection/zpool/zpool_linux.c b/src/detection/zpool/zpool_linux.c index e62febbd0a..c183c37857 100644 --- a/src/detection/zpool/zpool_linux.c +++ b/src/detection/zpool/zpool_linux.c @@ -78,7 +78,7 @@ static int enumZpoolCallback(zpool_handle_t* zpool, void* param) const char* ffDetectZpool(FFlist* result /* list of FFZpoolResult */) { - FF_LIBRARY_LOAD(libzfs, NULL, "dlopen libzfs" FF_LIBRARY_EXTENSION " failed", "libzfs" FF_LIBRARY_EXTENSION, 4); + FF_LIBRARY_LOAD(libzfs, "dlopen libzfs" FF_LIBRARY_EXTENSION " failed", "libzfs" FF_LIBRARY_EXTENSION, 4); FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libzfs, libzfs_init); libzfs_handle_t* handle = fflibzfs_init(); diff --git a/src/fastfetch.c b/src/fastfetch.c index 2f4a56e32f..23a00611d9 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -353,7 +353,6 @@ static bool parseJsoncFile(const char* path) (error = ffOptionsParseLogoJsonConfig(&instance.config.logo, root)) || (error = ffOptionsParseGeneralJsonConfig(&instance.config.general, root)) || (error = ffOptionsParseDisplayJsonConfig(&instance.config.display, root)) || - (error = ffOptionsParseLibraryJsonConfig(&instance.config.library, root)) || false ) { fprintf(stderr, "JsonConfig Error: %s\n", error); @@ -596,7 +595,6 @@ static void parseOption(FFdata* data, const char* key, const char* value) ffOptionsParseGeneralCommandLine(&instance.config.general, key, value) || ffOptionsParseLogoCommandLine(&instance.config.logo, key, value) || ffOptionsParseDisplayCommandLine(&instance.config.display, key, value) || - ffOptionsParseLibraryCommandLine(&instance.config.library, key, value) || ffParseModuleOptions(key, value) ) {} @@ -688,7 +686,6 @@ static void writeConfigFile(FFdata* data, const FFstrbuf* filename) ffOptionsGenerateLogoJsonConfig(&instance.config.logo, doc); ffOptionsGenerateDisplayJsonConfig(&instance.config.display, doc); ffOptionsGenerateGeneralJsonConfig(&instance.config.general, doc); - ffOptionsGenerateLibraryJsonConfig(&instance.config.library, doc); ffMigrateCommandOptionToJsonc(data, doc); if (ffStrbufEqualS(filename, "-")) diff --git a/src/fastfetch.h b/src/fastfetch.h index ebf44b50a3..dfc736434a 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -27,7 +27,6 @@ #include "options/logo.h" #include "options/display.h" #include "options/general.h" -#include "options/library.h" typedef struct FFconfig { @@ -35,7 +34,6 @@ typedef struct FFconfig FFOptionsDisplay display; FFOptionsGeneral general; FFOptionsModules modules; - FFOptionsLibrary library; } FFconfig; typedef struct FFstate diff --git a/src/logo/ascii/lliurex.txt b/src/logo/ascii/lliurex.txt new file mode 100644 index 0000000000..27bad815d0 --- /dev/null +++ b/src/logo/ascii/lliurex.txt @@ -0,0 +1,16 @@ + ~. ........ + ::~~ +=: ~:========:~ + ..~:+oo===oo:.~+oooooooooooo+~ + .:+==ooooooooooo==ooooooooooooooo: + .:=oooooooooooooooooooooooooooooooo= +.. .=oooooooooooooooooooooooooooooooooo= +==. .+ooooooooooooooooooooooooooooooooooo= +~+:~:oooooooooooooooooooooooooooooooooooo: + ~ooooooooooooooooooooooooooooooooooooo=: + ~oooooooooooooooooooooooooooooooooo==:. + .+oooooooooooooooooooooooooo=~::::~.. + ~+oooooooooooooooooooooooo=: + .:=ooooooooooooooooooooo=: + .:==ooooooooooooooo==:. + ~~:===oooooo==+:~ + ...~~:~::.. diff --git a/src/logo/builtin.c b/src/logo/builtin.c index 5ee4830d94..0280693163 100644 --- a/src/logo/builtin.c +++ b/src/logo/builtin.c @@ -2295,6 +2295,16 @@ static const FFlogo K[] = { }; static const FFlogo L[] = { + // LainOS + { + .names = {"LainOS"}, + .lines = FASTFETCH_DATATEXT_LOGO_LAINOS, + .colors = { + FF_COLOR_FG_BLUE, + FF_COLOR_FG_256 "14", + FF_COLOR_FG_WHITE, + }, + }, // LangitKetujuh { .names = {"langitketujuh", "l7"}, @@ -2469,6 +2479,16 @@ static const FFlogo L[] = { .colorKeys = FF_COLOR_FG_YELLOW, .colorTitle = FF_COLOR_FG_WHITE, }, + // LliureX + { + .names = {"LliureX"}, + .lines = FASTFETCH_DATATEXT_LOGO_LLIUREX, + .colors = { + FF_COLOR_FG_BLUE, + }, + .colorKeys = FF_COLOR_FG_WHITE, + .colorTitle = FF_COLOR_FG_BLUE, + }, // LMDE { .names = {"LMDE"}, @@ -2480,16 +2500,6 @@ static const FFlogo L[] = { .colorKeys = FF_COLOR_FG_GREEN, .colorTitle = FF_COLOR_FG_WHITE, }, - // LainOS - { - .names = {"LainOS"}, - .lines = FASTFETCH_DATATEXT_LOGO_LAINOS, - .colors = { - FF_COLOR_FG_BLUE, - FF_COLOR_FG_256 "14", - FF_COLOR_FG_WHITE, - }, - }, // Loc-OS { .names = {"locos", "loc-os", "Loc-OS Linux"}, diff --git a/src/logo/image/im6.c b/src/logo/image/im6.c index 9694a797b4..cee4ace6e1 100644 --- a/src/logo/image/im6.c +++ b/src/logo/image/im6.c @@ -14,7 +14,7 @@ static void* logoResize(const void* image, size_t width, size_t height, void* ex FFLogoImageResult ffLogoPrintImageIM6(FFLogoRequestData* requestData) { - FF_LIBRARY_LOAD(imageMagick, &instance.config.library.libImageMagick, FF_LOGO_IMAGE_RESULT_INIT_ERROR, "libMagickCore-6.Q16HDRI" FF_LIBRARY_EXTENSION, 8, "libMagickCore-6.Q16" FF_LIBRARY_EXTENSION, 8) + FF_LIBRARY_LOAD(imageMagick, FF_LOGO_IMAGE_RESULT_INIT_ERROR, "libMagickCore-6.Q16HDRI" FF_LIBRARY_EXTENSION, 8, "libMagickCore-6.Q16" FF_LIBRARY_EXTENSION, 8) FF_LIBRARY_LOAD_SYMBOL_ADDRESS(imageMagick, ffResizeImage, ResizeImage, FF_LOGO_IMAGE_RESULT_INIT_ERROR); FFLogoImageResult result = ffLogoPrintImageImpl(requestData, &(FFIMData) { diff --git a/src/logo/image/im7.c b/src/logo/image/im7.c index b0eeed2dc6..45451f1d0b 100644 --- a/src/logo/image/im7.c +++ b/src/logo/image/im7.c @@ -14,7 +14,7 @@ static void* logoResize(const void* image, size_t width, size_t height, void* ex FFLogoImageResult ffLogoPrintImageIM7(FFLogoRequestData* requestData) { - FF_LIBRARY_LOAD(imageMagick, &instance.config.library.libImageMagick, FF_LOGO_IMAGE_RESULT_INIT_ERROR, + FF_LIBRARY_LOAD(imageMagick, FF_LOGO_IMAGE_RESULT_INIT_ERROR, "libMagickCore-7.Q16HDRI" FF_LIBRARY_EXTENSION, 11, "libMagickCore-7.Q16" FF_LIBRARY_EXTENSION, 11, "libMagickCore-7.Q16HDRI-10" FF_LIBRARY_EXTENSION, -1 // Required for Windows diff --git a/src/logo/image/image.c b/src/logo/image/image.c index c73fca10c2..25cca39f2b 100644 --- a/src/logo/image/image.c +++ b/src/logo/image/image.c @@ -3,6 +3,7 @@ #include "common/printing.h" #include "util/stringUtils.h" #include "util/base64.h" +#include "detection/terminalsize/terminalsize.h" #include #include @@ -77,7 +78,7 @@ static bool printImageIterm(bool printError) if (options->position == FF_LOGO_POSITION_LEFT || options->position == FF_LOGO_POSITION_RIGHT) { uint16_t X = 0, Y = 0; - const char* error = ffGetTerminalResponse("\e[6n", "\e[%hu;%huR", &Y, &X); + const char* error = ffGetTerminalResponse("\e[6n", 2, "%*[^0-9]%hu;%huR", &Y, &X); if (error) { fprintf(stderr, "\nLogo (iterm): fail to query cursor position: %s\n", error); @@ -202,7 +203,7 @@ static bool printImageKittyDirect(bool printError) if (options->position == FF_LOGO_POSITION_LEFT || options->position == FF_LOGO_POSITION_RIGHT) { uint16_t X = 0, Y = 0; - const char* error = ffGetTerminalResponse("\e[6n", "\e[%hu;%huR", &Y, &X); + const char* error = ffGetTerminalResponse("\e[6n", 2, "%*[^0-9]%hu;%huR", &Y, &X); if (error) { if (printError) @@ -304,7 +305,7 @@ static inline char* realpath(const char* restrict file_name, char* restrict reso static bool compressBlob(void** blob, size_t* length) { - FF_LIBRARY_LOAD(zlib, &instance.config.library.libZ, false, "libz" FF_LIBRARY_EXTENSION, 2) + FF_LIBRARY_LOAD(zlib, false, "libz" FF_LIBRARY_EXTENSION, 2) FF_LIBRARY_LOAD_SYMBOL(zlib, compressBound, false) FF_LIBRARY_LOAD_SYMBOL(zlib, compress2, false) @@ -489,7 +490,7 @@ static bool printImageKitty(FFLogoRequestData* requestData, const ImageData* ima #include static bool printImageChafa(FFLogoRequestData* requestData, const ImageData* imageData) { - FF_LIBRARY_LOAD(chafa, &instance.config.library.libChafa, false, + FF_LIBRARY_LOAD(chafa, false, "libchafa" FF_LIBRARY_EXTENSION, 1, "libchafa-0" FF_LIBRARY_EXTENSION, -1 // Required for Windows ) @@ -835,38 +836,25 @@ static bool printCached(FFLogoRequestData* requestData) static bool getCharacterPixelDimensions(FFLogoRequestData* requestData) { - #ifndef _WIN32 - - struct winsize winsize; - - //Initialize every member to 0, because it isn't guaranteed that every terminal sets them all - memset(&winsize, 0, sizeof(struct winsize)); - - ioctl(STDOUT_FILENO, TIOCGWINSZ, &winsize); - - if(winsize.ws_row == 0 || winsize.ws_col == 0) - ffGetTerminalResponse("\033[18t", "\033[8;%hu;%hut", &winsize.ws_row, &winsize.ws_col); - - if(winsize.ws_row == 0 || winsize.ws_col == 0) - return false; - - if(winsize.ws_ypixel == 0 || winsize.ws_xpixel == 0) - ffGetTerminalResponse("\033[14t", "\033[4;%hu;%hut", &winsize.ws_ypixel, &winsize.ws_xpixel); - - requestData->characterPixelWidth = winsize.ws_xpixel / (double) winsize.ws_col; - requestData->characterPixelHeight = winsize.ws_ypixel / (double) winsize.ws_row; - - #else + #ifdef _WIN32 CONSOLE_FONT_INFO cfi; - if(GetCurrentConsoleFont(GetStdHandle(STD_OUTPUT_HANDLE), FALSE, &cfi) == FALSE) // Only works for ConHost - return false; - - requestData->characterPixelWidth = cfi.dwFontSize.X; - requestData->characterPixelHeight = cfi.dwFontSize.Y; - + if(GetCurrentConsoleFont(GetStdHandle(STD_OUTPUT_HANDLE), FALSE, &cfi)) // Only works for ConHost + { + requestData->characterPixelWidth = cfi.dwFontSize.X; + requestData->characterPixelHeight = cfi.dwFontSize.Y; + } + if (requestData->characterPixelWidth > 1.0 && requestData->characterPixelHeight > 1.0) + return true; #endif + FFTerminalSizeResult termSize = {}; + if (ffDetectTerminalSize(&termSize)) + { + requestData->characterPixelWidth = termSize.width / (double) termSize.columns; + requestData->characterPixelHeight = termSize.height / (double) termSize.rows; + } + return requestData->characterPixelWidth > 1.0 && requestData->characterPixelHeight > 1.0; } diff --git a/src/logo/logo.c b/src/logo/logo.c index e4c36c14db..26da1eed7d 100644 --- a/src/logo/logo.c +++ b/src/logo/logo.c @@ -40,7 +40,7 @@ static bool ffLogoPrintCharsRaw(const char* data, size_t length, bool printError if (!options->width) { if (printError) - fputs("Logo (iterm): Must set logo width when using position right\n", stderr); + fputs("Logo (image-raw): Must set logo width when using position right\n", stderr); return false; } ffStrbufAppendF(&buf, "\e[2J\e[3J\e[%u;9999999H\e[%uD", (unsigned) options->paddingTop + 1, (unsigned) options->paddingRight + options->width); @@ -51,7 +51,8 @@ static bool ffLogoPrintCharsRaw(const char* data, size_t length, bool printError if (options->position == FF_LOGO_POSITION_LEFT || options->position == FF_LOGO_POSITION_RIGHT) { uint16_t X = 0, Y = 0; - const char* error = ffGetTerminalResponse("\e[6n", "\e[%hu;%huR", &Y, &X); + // Windows Terminal doesn't report `\e` for some reason + const char* error = ffGetTerminalResponse("\e[6n", 2, "%*[^0-9]%hu;%huR", &Y, &X); // %*[^0-9]: ignore optional \e[ if (error) { if (printError) @@ -59,7 +60,11 @@ static bool ffLogoPrintCharsRaw(const char* data, size_t length, bool printError return true; } if (options->position == FF_LOGO_POSITION_LEFT) + { + if (options->width + options->paddingLeft > X) + X = (uint16_t) (options->width + options->paddingLeft); instance.state.logoWidth = X + instance.config.logo.paddingRight - 1; + } instance.state.logoHeight = Y; fputs("\e[H", stdout); } diff --git a/src/modules/battery/battery.c b/src/modules/battery/battery.c index 43b9573863..743c098e29 100644 --- a/src/modules/battery/battery.c +++ b/src/modules/battery/battery.c @@ -23,8 +23,8 @@ static void printBattery(FFBatteryOptions* options, FFBatteryResult* result, uin { ffStrbufClear(&key); FF_PARSE_FORMAT_STRING_CHECKED(&key, &options->moduleArgs.key, 2, ((FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_UINT8, &index, "index"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result->modelName, "name"}, + FF_FORMAT_ARG(index, "index"), + FF_FORMAT_ARG(result->modelName, "name"), })); } @@ -81,16 +81,16 @@ static void printBattery(FFBatteryOptions* options, FFBatteryResult* result, uin FF_STRBUF_AUTO_DESTROY tempStr = ffStrbufCreate(); ffTempsAppendNum(result->temperature, &tempStr, options->tempConfig, &options->moduleArgs); FF_PRINT_FORMAT_CHECKED(key.chars, index, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_BATTERY_NUM_FORMAT_ARGS, ((FFformatarg[]) { - {FF_FORMAT_ARG_TYPE_STRBUF, &result->manufacturer, "manufacturer"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result->modelName, "model-name"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result->technology, "technology"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &capacityNum, "capacity"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result->status, "status"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &tempStr, "temperature"}, - {FF_FORMAT_ARG_TYPE_UINT, &result->cycleCount, "cycle-count"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result->serial, "serial"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result->manufactureDate, "manufacture-date"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &capacityBar, "capacity-bar"}, + FF_FORMAT_ARG(result->manufacturer, "manufacturer"), + FF_FORMAT_ARG(result->modelName, "model-name"), + FF_FORMAT_ARG(result->technology, "technology"), + FF_FORMAT_ARG(capacityNum, "capacity"), + FF_FORMAT_ARG(result->status, "status"), + FF_FORMAT_ARG(tempStr, "temperature"), + FF_FORMAT_ARG(result->cycleCount, "cycle-count"), + FF_FORMAT_ARG(result->serial, "serial"), + FF_FORMAT_ARG(result->manufactureDate, "manufacture-date"), + FF_FORMAT_ARG(capacityBar, "capacity-bar"), })); } } diff --git a/src/modules/bios/bios.c b/src/modules/bios/bios.c index ae1e6c7af0..6e4e81dd4f 100644 --- a/src/modules/bios/bios.c +++ b/src/modules/bios/bios.c @@ -44,8 +44,8 @@ void ffPrintBios(FFBiosOptions* options) { ffStrbufClear(&key); FF_PARSE_FORMAT_STRING_CHECKED(&key, &options->moduleArgs.key, 2, ((FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_STRBUF, &bios.type, "type"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &options->moduleArgs.keyIcon, "icon"}, + FF_FORMAT_ARG(bios.type, "type"), + FF_FORMAT_ARG(options->moduleArgs.keyIcon, "icon"), })); } @@ -61,11 +61,11 @@ void ffPrintBios(FFBiosOptions* options) else { FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_BIOS_NUM_FORMAT_ARGS, ((FFformatarg[]) { - {FF_FORMAT_ARG_TYPE_STRBUF, &bios.date, "date"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &bios.release, "release"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &bios.vendor, "vendor"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &bios.version, "version"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &bios.type, "type"}, + FF_FORMAT_ARG(bios.date, "date"), + FF_FORMAT_ARG(bios.release, "release"), + FF_FORMAT_ARG(bios.vendor, "vendor"), + FF_FORMAT_ARG(bios.version, "version"), + FF_FORMAT_ARG(bios.type, "type"), })); } diff --git a/src/modules/bluetooth/bluetooth.c b/src/modules/bluetooth/bluetooth.c index 037ca6335e..a6bca3bce3 100644 --- a/src/modules/bluetooth/bluetooth.c +++ b/src/modules/bluetooth/bluetooth.c @@ -35,12 +35,12 @@ static void printDevice(FFBluetoothOptions* options, const FFBluetoothResult* de ffPercentAppendBar(&percentageBar, device->battery, options->percent, &options->moduleArgs); FF_PRINT_FORMAT_CHECKED(FF_BLUETOOTH_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_BLUETOOTH_NUM_FORMAT_ARGS, ((FFformatarg[]) { - {FF_FORMAT_ARG_TYPE_STRBUF, &device->name, "name"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &device->address, "address"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &device->type, "type"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &percentageNum, "battery-percentage"}, - {FF_FORMAT_ARG_TYPE_BOOL, &device->connected, "connected"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &percentageBar, "battery-percentage-bar"}, + FF_FORMAT_ARG(device->name, "name"), + FF_FORMAT_ARG(device->address, "address"), + FF_FORMAT_ARG(device->type, "type"), + FF_FORMAT_ARG(percentageNum, "battery-percentage"), + FF_FORMAT_ARG(device->connected, "connected"), + FF_FORMAT_ARG(percentageBar, "battery-percentage-bar"), })); } } diff --git a/src/modules/bluetoothradio/bluetoothradio.c b/src/modules/bluetoothradio/bluetoothradio.c index 455c06df2d..8782c4aca6 100644 --- a/src/modules/bluetoothradio/bluetoothradio.c +++ b/src/modules/bluetoothradio/bluetoothradio.c @@ -18,9 +18,9 @@ static void printDevice(FFBluetoothRadioOptions* options, const FFBluetoothRadio else { FF_PARSE_FORMAT_STRING_CHECKED(&key, &options->moduleArgs.key, 3, ((FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_UINT, &index, "index"}, - {FF_FORMAT_ARG_TYPE_STRING, radio->name.chars, "name"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &options->moduleArgs.keyIcon, "icon"}, + FF_FORMAT_ARG(index, "index"), + FF_FORMAT_ARG(radio->name, "name"), + FF_FORMAT_ARG(options->moduleArgs.keyIcon, "icon"), })); } @@ -56,14 +56,14 @@ static void printDevice(FFBluetoothRadioOptions* options, const FFBluetoothRadio else { FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_BLUETOOTHRADIO_NUM_FORMAT_ARGS, ((FFformatarg[]) { - {FF_FORMAT_ARG_TYPE_STRBUF, &radio->name, "name"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &radio->address, "address"}, - {FF_FORMAT_ARG_TYPE_INT, &radio->lmpVersion, "lmp-version"}, - {FF_FORMAT_ARG_TYPE_INT, &radio->lmpSubversion, "lmp-subversion"}, - {FF_FORMAT_ARG_TYPE_STRING, version, "version"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &radio->vendor, "vendor"}, - {FF_FORMAT_ARG_TYPE_BOOL, &radio->discoverable, "discoverable"}, - {FF_FORMAT_ARG_TYPE_BOOL, &radio->connectable, "connectable"}, + FF_FORMAT_ARG(radio->name, "name"), + FF_FORMAT_ARG(radio->address, "address"), + FF_FORMAT_ARG(radio->lmpVersion, "lmp-version"), + FF_FORMAT_ARG(radio->lmpSubversion, "lmp-subversion"), + FF_FORMAT_ARG(version, "version"), + FF_FORMAT_ARG(radio->vendor, "vendor"), + FF_FORMAT_ARG(radio->discoverable, "discoverable"), + FF_FORMAT_ARG(radio->connectable, "connectable"), })); } } diff --git a/src/modules/board/board.c b/src/modules/board/board.c index c40f4da331..58d841b0e6 100644 --- a/src/modules/board/board.c +++ b/src/modules/board/board.c @@ -38,10 +38,10 @@ void ffPrintBoard(FFBoardOptions* options) else { FF_PRINT_FORMAT_CHECKED(FF_BOARD_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_BOARD_NUM_FORMAT_ARGS, ((FFformatarg[]) { - {FF_FORMAT_ARG_TYPE_STRBUF, &result.name, "name"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result.vendor, "vendor"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result.version, "version"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result.serial, "serial"}, + FF_FORMAT_ARG(result.name, "name"), + FF_FORMAT_ARG(result.vendor, "vendor"), + FF_FORMAT_ARG(result.version, "version"), + FF_FORMAT_ARG(result.serial, "serial"), })); } diff --git a/src/modules/bootmgr/bootmgr.c b/src/modules/bootmgr/bootmgr.c index fed105cb46..960da0e436 100644 --- a/src/modules/bootmgr/bootmgr.c +++ b/src/modules/bootmgr/bootmgr.c @@ -40,10 +40,10 @@ void ffPrintBootmgr(FFBootmgrOptions* options) else { FF_PRINT_FORMAT_CHECKED(FF_BOOTMGR_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_BOOTMGR_NUM_FORMAT_ARGS, ((FFformatarg[]) { - {FF_FORMAT_ARG_TYPE_STRBUF, &bootmgr.name, "name"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &bootmgr.firmware, "firmware-path"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &firmwareName, "firmware-name"}, - {FF_FORMAT_ARG_TYPE_BOOL, &bootmgr.secureBoot, "secure-boot"}, + FF_FORMAT_ARG(bootmgr.name, "name"), + FF_FORMAT_ARG(bootmgr.firmware, "firmware-path"), + FF_FORMAT_ARG(firmwareName, "firmware-name"), + FF_FORMAT_ARG(bootmgr.secureBoot, "secure-boot"), })); } diff --git a/src/modules/brightness/brightness.c b/src/modules/brightness/brightness.c index bb79e0a799..ca989d35b5 100644 --- a/src/modules/brightness/brightness.c +++ b/src/modules/brightness/brightness.c @@ -38,9 +38,9 @@ void ffPrintBrightness(FFBrightnessOptions* options) { uint32_t moduleIndex = result.length == 1 ? 0 : index + 1; FF_PARSE_FORMAT_STRING_CHECKED(&key, &options->moduleArgs.key, 3, ((FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_UINT, &moduleIndex, "index"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &item->name, "name"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &options->moduleArgs.keyIcon, "icon"}, + FF_FORMAT_ARG(moduleIndex, "index"), + FF_FORMAT_ARG(item->name, "name"), + FF_FORMAT_ARG(options->moduleArgs.keyIcon, "icon"), })); } @@ -73,12 +73,12 @@ void ffPrintBrightness(FFBrightnessOptions* options) FF_STRBUF_AUTO_DESTROY valueBar = ffStrbufCreate(); ffPercentAppendBar(&valueBar, percent, options->percent, &options->moduleArgs); FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_BRIGHTNESS_NUM_FORMAT_ARGS, ((FFformatarg[]) { - {FF_FORMAT_ARG_TYPE_STRBUF, &valueNum, "percentage"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &item->name, "name"}, - {FF_FORMAT_ARG_TYPE_DOUBLE, &item->max, "max"}, - {FF_FORMAT_ARG_TYPE_DOUBLE, &item->min, "min"}, - {FF_FORMAT_ARG_TYPE_DOUBLE, &item->current, "current"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &item->current, "percentage-bar"}, + FF_FORMAT_ARG(valueNum, "percentage"), + FF_FORMAT_ARG(item->name, "name"), + FF_FORMAT_ARG(item->max, "max"), + FF_FORMAT_ARG(item->min, "min"), + FF_FORMAT_ARG(item->current, "current"), + FF_FORMAT_ARG(item->current, "percentage-bar"), })); } diff --git a/src/modules/camera/camera.c b/src/modules/camera/camera.c index 6a9b22d543..4615dc7e18 100644 --- a/src/modules/camera/camera.c +++ b/src/modules/camera/camera.c @@ -28,12 +28,12 @@ static void printDevice(FFCameraOptions* options, const FFCameraResult* device, else { FF_PRINT_FORMAT_CHECKED(FF_CAMERA_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_CAMERA_NUM_FORMAT_ARGS, (((FFformatarg[]) { - {FF_FORMAT_ARG_TYPE_STRBUF, &device->name, "name"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &device->vendor, "vendor"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &device->colorspace, "colorspace"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &device->id, "id"}, - {FF_FORMAT_ARG_TYPE_UINT, &device->width, "width"}, - {FF_FORMAT_ARG_TYPE_UINT, &device->height, "height"}, + FF_FORMAT_ARG(device->name, "name"), + FF_FORMAT_ARG(device->vendor, "vendor"), + FF_FORMAT_ARG(device->colorspace, "colorspace"), + FF_FORMAT_ARG(device->id, "id"), + FF_FORMAT_ARG(device->width, "width"), + FF_FORMAT_ARG(device->height, "height"), }))); } } diff --git a/src/modules/chassis/chassis.c b/src/modules/chassis/chassis.c index 4e1e6c7679..d87b4ad46e 100644 --- a/src/modules/chassis/chassis.c +++ b/src/modules/chassis/chassis.c @@ -39,10 +39,10 @@ void ffPrintChassis(FFChassisOptions* options) else { FF_PRINT_FORMAT_CHECKED(FF_CHASSIS_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_CHASSIS_NUM_FORMAT_ARGS, ((FFformatarg[]) { - {FF_FORMAT_ARG_TYPE_STRBUF, &result.type, "type"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result.vendor, "vendor"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result.version, "version"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result.serial, "serial"}, + FF_FORMAT_ARG(result.type, "type"), + FF_FORMAT_ARG(result.vendor, "vendor"), + FF_FORMAT_ARG(result.version, "version"), + FF_FORMAT_ARG(result.serial, "serial"), })); } diff --git a/src/modules/command/command.c b/src/modules/command/command.c index 6fa23c4cf5..0db07b4bd3 100644 --- a/src/modules/command/command.c +++ b/src/modules/command/command.c @@ -9,13 +9,13 @@ void ffPrintCommand(FFCommandOptions* options) { FF_STRBUF_AUTO_DESTROY result = ffStrbufCreate(); - const char* error = ffProcessAppendStdOut(&result, (char* const[]){ + const char* error = ffProcessAppendStdOut(&result, options->param.length ? (char* const[]){ + options->shell.chars, + options->param.chars, + options->text.chars, + NULL + } : (char* const[]){ options->shell.chars, - #ifdef _WIN32 - "/c", - #else - "-c", - #endif options->text.chars, NULL }); @@ -40,7 +40,7 @@ void ffPrintCommand(FFCommandOptions* options) else { FF_PRINT_FORMAT_CHECKED(FF_COMMAND_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_COMMAND_NUM_FORMAT_ARGS, ((FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_STRBUF, &result, "result"} + FF_FORMAT_ARG(result, "result") })); } } @@ -58,6 +58,12 @@ bool ffParseCommandCommandOptions(FFCommandOptions* options, const char* key, co return true; } + if(ffStrEqualsIgnCase(subKey, "param")) + { + ffOptionParseString(key, value, &options->param); + return true; + } + if(ffStrEqualsIgnCase(subKey, "text")) { ffOptionParseString(key, value, &options->text); @@ -86,6 +92,12 @@ void ffParseCommandJsonObject(FFCommandOptions* options, yyjson_val* module) continue; } + if (ffStrEqualsIgnCase(key, "param")) + { + ffStrbufSetS(&options->param, yyjson_get_str(val)); + continue; + } + if (ffStrEqualsIgnCase(key, "text")) { ffStrbufSetS(&options->text, yyjson_get_str(val)); @@ -106,6 +118,9 @@ void ffGenerateCommandJsonConfig(FFCommandOptions* options, yyjson_mut_doc* doc, if (!ffStrbufEqual(&defaultOptions.shell, &options->shell)) yyjson_mut_obj_add_strbuf(doc, module, "shell", &options->shell); + if (!ffStrbufEqual(&defaultOptions.param, &options->param)) + yyjson_mut_obj_add_strbuf(doc, module, "param", &options->param); + if (!ffStrbufEqual(&defaultOptions.text, &options->text)) yyjson_mut_obj_add_strbuf(doc, module, "text", &options->text); } @@ -113,13 +128,13 @@ void ffGenerateCommandJsonConfig(FFCommandOptions* options, yyjson_mut_doc* doc, void ffGenerateCommandJsonResult(FF_MAYBE_UNUSED FFCommandOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { FF_STRBUF_AUTO_DESTROY result = ffStrbufCreate(); - const char* error = ffProcessAppendStdOut(&result, (char* const[]){ + const char* error = ffProcessAppendStdOut(&result, options->param.length ? (char* const[]){ + options->shell.chars, + options->param.chars, + options->text.chars, + NULL + } : (char* const[]){ options->shell.chars, - #ifdef _WIN32 - "/c", - #else - "-c", - #endif options->text.chars, NULL }); @@ -168,7 +183,13 @@ void ffInitCommandOptions(FFCommandOptions* options) "/bin/sh" #endif ); - + ffStrbufInitStatic(&options->param, + #ifdef _WIN32 + "/c" + #else + "-c" + #endif + ); ffStrbufInit(&options->text); } @@ -176,5 +197,6 @@ void ffDestroyCommandOptions(FFCommandOptions* options) { ffOptionDestroyModuleArg(&options->moduleArgs); ffStrbufDestroy(&options->shell); + ffStrbufDestroy(&options->param); ffStrbufDestroy(&options->text); } diff --git a/src/modules/command/option.h b/src/modules/command/option.h index 6aab8a3c2d..d30c51ea87 100644 --- a/src/modules/command/option.h +++ b/src/modules/command/option.h @@ -10,5 +10,6 @@ typedef struct FFCommandOptions FFModuleArgs moduleArgs; FFstrbuf shell; + FFstrbuf param; FFstrbuf text; } FFCommandOptions; diff --git a/src/modules/cpu/cpu.c b/src/modules/cpu/cpu.c index 65503eb9a7..6bf2de570d 100644 --- a/src/modules/cpu/cpu.c +++ b/src/modules/cpu/cpu.c @@ -102,16 +102,16 @@ void ffPrintCPU(FFCPUOptions* options) FF_STRBUF_AUTO_DESTROY tempStr = ffStrbufCreate(); ffTempsAppendNum(cpu.temperature, &tempStr, options->tempConfig, &options->moduleArgs); FF_PRINT_FORMAT_CHECKED(FF_CPU_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_CPU_NUM_FORMAT_ARGS, ((FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_STRBUF, &cpu.name, "name"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &cpu.vendor, "vendor"}, - {FF_FORMAT_ARG_TYPE_UINT16, &cpu.coresPhysical, "cores-physical"}, - {FF_FORMAT_ARG_TYPE_UINT16, &cpu.coresLogical, "cores-logical"}, - {FF_FORMAT_ARG_TYPE_UINT16, &cpu.coresOnline, "cores-online"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &freqBase, "freq-base"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &freqMax, "freq-max"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &tempStr, "temperature"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &coreTypes, "core-types"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &freqBioslimit, "freq-bios-limit"}, + FF_FORMAT_ARG(cpu.name, "name"), + FF_FORMAT_ARG(cpu.vendor, "vendor"), + FF_FORMAT_ARG(cpu.coresPhysical, "cores-physical"), + FF_FORMAT_ARG(cpu.coresLogical, "cores-logical"), + FF_FORMAT_ARG(cpu.coresOnline, "cores-online"), + FF_FORMAT_ARG(freqBase, "freq-base"), + FF_FORMAT_ARG(freqMax, "freq-max"), + FF_FORMAT_ARG(tempStr, "temperature"), + FF_FORMAT_ARG(coreTypes, "core-types"), + FF_FORMAT_ARG(freqBioslimit, "freq-bios-limit"), })); } } diff --git a/src/modules/cpucache/cpucache.c b/src/modules/cpucache/cpucache.c index ef6820617c..f52ec5cfb7 100644 --- a/src/modules/cpucache/cpucache.c +++ b/src/modules/cpucache/cpucache.c @@ -23,9 +23,9 @@ static void printCPUCacheNormal(const FFCPUCacheResult* result, FFCPUCacheOption { uint32_t index = i + 1; FF_PARSE_FORMAT_STRING_CHECKED(&key, &options->moduleArgs.key, 3, ((FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_UINT, &index, "index"}, - {FF_FORMAT_ARG_TYPE_STRING, levelStr, "level"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &options->moduleArgs.keyIcon, "icon"}, + FF_FORMAT_ARG(index, "index"), + FF_FORMAT_ARG(levelStr, "level"), + FF_FORMAT_ARG(options->moduleArgs.keyIcon, "icon"), })); } @@ -62,8 +62,8 @@ static void printCPUCacheNormal(const FFCPUCacheResult* result, FFCPUCacheOption FF_STRBUF_AUTO_DESTROY buffer2 = ffStrbufCreate(); ffParseSize(sum, &buffer2); FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_CPUCACHE_NUM_FORMAT_ARGS, ((FFformatarg[]) { - {FF_FORMAT_ARG_TYPE_STRBUF, &buffer, "result"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &buffer2, "sum"}, + FF_FORMAT_ARG(buffer, "result"), + FF_FORMAT_ARG(buffer2, "sum"), })); } } @@ -95,8 +95,8 @@ static void printCPUCacheCompact(const FFCPUCacheResult* result, FFCPUCacheOptio FF_STRBUF_AUTO_DESTROY buffer2 = ffStrbufCreate(); ffParseSize(sum, &buffer2); FF_PRINT_FORMAT_CHECKED(FF_CPUCACHE_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_CPUCACHE_NUM_FORMAT_ARGS, ((FFformatarg[]) { - {FF_FORMAT_ARG_TYPE_STRBUF, &buffer, "result"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &buffer2, "sum"}, + FF_FORMAT_ARG(buffer, "result"), + FF_FORMAT_ARG(buffer2, "sum"), })); } } diff --git a/src/modules/cpuusage/cpuusage.c b/src/modules/cpuusage/cpuusage.c index d09ae9080f..873fd77b94 100644 --- a/src/modules/cpuusage/cpuusage.c +++ b/src/modules/cpuusage/cpuusage.c @@ -86,14 +86,14 @@ void ffPrintCPUUsage(FFCPUUsageOptions* options) FF_STRBUF_AUTO_DESTROY maxBar = ffStrbufCreate(); ffPercentAppendBar(&maxBar, maxValue, options->percent, &options->moduleArgs); FF_PRINT_FORMAT_CHECKED(FF_CPUUSAGE_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_CPUUSAGE_NUM_FORMAT_ARGS, ((FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_STRBUF, &avgNum, "avg"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &maxNum, "max"}, - {FF_FORMAT_ARG_TYPE_UINT, &maxIndex, "max-index"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &minNum, "min"}, - {FF_FORMAT_ARG_TYPE_UINT, &minIndex, "min-index"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &avgBar, "avg-bar"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &maxBar, "max-bar"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &minBar, "min-bar"}, + FF_FORMAT_ARG(avgNum, "avg"), + FF_FORMAT_ARG(maxNum, "max"), + FF_FORMAT_ARG(maxIndex, "max-index"), + FF_FORMAT_ARG(minNum, "min"), + FF_FORMAT_ARG(minIndex, "min-index"), + FF_FORMAT_ARG(avgBar, "avg-bar"), + FF_FORMAT_ARG(maxBar, "max-bar"), + FF_FORMAT_ARG(minBar, "min-bar"), })); } } diff --git a/src/modules/cursor/cursor.c b/src/modules/cursor/cursor.c index 579db4d59b..7026bda478 100644 --- a/src/modules/cursor/cursor.c +++ b/src/modules/cursor/cursor.c @@ -39,8 +39,8 @@ void ffPrintCursor(FFCursorOptions* options) else { FF_PRINT_FORMAT_CHECKED(FF_CURSOR_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_CURSOR_NUM_FORMAT_ARGS, ((FFformatarg[]) { - {FF_FORMAT_ARG_TYPE_STRBUF, &result.theme, "theme"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result.size, "size"}, + FF_FORMAT_ARG(result.theme, "theme"), + FF_FORMAT_ARG(result.size, "size"), })); } } diff --git a/src/modules/datetime/datetime.c b/src/modules/datetime/datetime.c index f7c657842a..67bded503f 100644 --- a/src/modules/datetime/datetime.c +++ b/src/modules/datetime/datetime.c @@ -66,28 +66,28 @@ void ffPrintDateTimeFormat(struct tm* tm, const FFModuleArgs* moduleArgs) strftime(result.timezoneName, sizeof(result.timezoneName), "%Z", tm); FF_PRINT_FORMAT_CHECKED(FF_DATETIME_DISPLAY_NAME, 0, moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_DATETIME_NUM_FORMAT_ARGS, ((FFformatarg[]) { - {FF_FORMAT_ARG_TYPE_UINT16, &result.year, "year"}, // 1 - {FF_FORMAT_ARG_TYPE_UINT8, &result.yearShort, "year-short"}, // 2 - {FF_FORMAT_ARG_TYPE_UINT8, &result.month, "month"}, // 3 - {FF_FORMAT_ARG_TYPE_STRING, result.monthPretty, "month-pretty"}, // 4 - {FF_FORMAT_ARG_TYPE_STRING, result.monthName, "month-name"}, // 5 - {FF_FORMAT_ARG_TYPE_STRING, result.monthNameShort, "month-name-short"}, // 6 - {FF_FORMAT_ARG_TYPE_UINT8, &result.week, "week"}, // 7 - {FF_FORMAT_ARG_TYPE_STRING, result.weekday, "weekday"}, // 8 - {FF_FORMAT_ARG_TYPE_STRING, result.weekdayShort, "weekday-short"}, // 9 - {FF_FORMAT_ARG_TYPE_UINT16, &result.dayInYear, "day-in-year"}, // 10 - {FF_FORMAT_ARG_TYPE_UINT8, &result.dayInMonth, "day-in-month"}, // 11 - {FF_FORMAT_ARG_TYPE_UINT8, &result.dayInWeek, "day-in-week"}, // 12 - {FF_FORMAT_ARG_TYPE_UINT8, &result.hour, "hour"}, // 13 - {FF_FORMAT_ARG_TYPE_STRING, result.hourPretty, "hour-pretty"}, // 14 - {FF_FORMAT_ARG_TYPE_UINT8, &result.hour12, "hour-12"}, // 15 - {FF_FORMAT_ARG_TYPE_STRING, result.hour12Pretty, "hour-12-pretty"}, // 16 - {FF_FORMAT_ARG_TYPE_UINT8, &result.minute, "minute"}, // 17 - {FF_FORMAT_ARG_TYPE_STRING, result.minutePretty, "minute-pretty"}, // 18 - {FF_FORMAT_ARG_TYPE_UINT8, &result.second, "second"}, // 19 - {FF_FORMAT_ARG_TYPE_STRING, result.secondPretty, "second-pretty"}, // 20 - {FF_FORMAT_ARG_TYPE_STRING, result.offsetFromUtc, "offset-from-utc"}, // 21 - {FF_FORMAT_ARG_TYPE_STRING, result.timezoneName, "timezone-name"}, // 22 + FF_FORMAT_ARG(result.year, "year"), // 1 + FF_FORMAT_ARG(result.yearShort, "year-short"), // 2 + FF_FORMAT_ARG(result.month, "month"), // 3 + FF_FORMAT_ARG(result.monthPretty, "month-pretty"), // 4 + FF_FORMAT_ARG(result.monthName, "month-name"), // 5 + FF_FORMAT_ARG(result.monthNameShort, "month-name-short"), // 6 + FF_FORMAT_ARG(result.week, "week"), // 7 + FF_FORMAT_ARG(result.weekday, "weekday"), // 8 + FF_FORMAT_ARG(result.weekdayShort, "weekday-short"), // 9 + FF_FORMAT_ARG(result.dayInYear, "day-in-year"), // 10 + FF_FORMAT_ARG(result.dayInMonth, "day-in-month"), // 11 + FF_FORMAT_ARG(result.dayInWeek, "day-in-week"), // 12 + FF_FORMAT_ARG(result.hour, "hour"), // 13 + FF_FORMAT_ARG(result.hourPretty, "hour-pretty"), // 14 + FF_FORMAT_ARG(result.hour12, "hour-12"), // 15 + FF_FORMAT_ARG(result.hour12Pretty, "hour-12-pretty"), // 16 + FF_FORMAT_ARG(result.minute, "minute"), // 17 + FF_FORMAT_ARG(result.minutePretty, "minute-pretty"), // 18 + FF_FORMAT_ARG(result.second, "second"), // 19 + FF_FORMAT_ARG(result.secondPretty, "second-pretty"), // 20 + FF_FORMAT_ARG(result.offsetFromUtc, "offset-from-utc"), // 21 + FF_FORMAT_ARG(result.timezoneName, "timezone-name"), // 22 })); } diff --git a/src/modules/de/de.c b/src/modules/de/de.c index 9c293d146a..3decd8318a 100644 --- a/src/modules/de/de.c +++ b/src/modules/de/de.c @@ -37,9 +37,9 @@ void ffPrintDE(FFDEOptions* options) else { FF_PRINT_FORMAT_CHECKED(FF_DE_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_DE_NUM_FORMAT_ARGS, ((FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_STRBUF, &result->deProcessName, "process-name"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result->dePrettyName, "pretty-name"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &version, "version"} + FF_FORMAT_ARG(result->deProcessName, "process-name"), + FF_FORMAT_ARG(result->dePrettyName, "pretty-name"), + FF_FORMAT_ARG(version, "version") })); } } diff --git a/src/modules/disk/disk.c b/src/modules/disk/disk.c index b66236d371..69ed5f8b69 100644 --- a/src/modules/disk/disk.c +++ b/src/modules/disk/disk.c @@ -36,10 +36,10 @@ static void printDisk(FFDiskOptions* options, const FFDisk* disk) else { FF_PARSE_FORMAT_STRING_CHECKED(&key, &options->moduleArgs.key, 4, ((FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_STRBUF, &disk->mountpoint, "mountpoint"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &disk->name, "name"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &disk->mountFrom, "mount-from"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &options->moduleArgs.keyIcon, "icon"}, + FF_FORMAT_ARG(disk->mountpoint, "mountpoint"), + FF_FORMAT_ARG(disk->name, "name"), + FF_FORMAT_ARG(disk->mountFrom, "mount-from"), + FF_FORMAT_ARG(options->moduleArgs.keyIcon, "icon"), })); } @@ -121,20 +121,20 @@ static void printDisk(FFDiskOptions* options, const FFDisk* disk) bool isReadOnly = !!(disk->type & FF_DISK_VOLUME_TYPE_READONLY_BIT); FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_DISK_NUM_FORMAT_ARGS, ((FFformatarg[]) { - {FF_FORMAT_ARG_TYPE_STRBUF, &usedPretty, "size-used"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &totalPretty, "size-total"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &bytesPercentageNum, "size-percentage"}, - {FF_FORMAT_ARG_TYPE_UINT, &disk->filesUsed, "files-used"}, - {FF_FORMAT_ARG_TYPE_UINT, &disk->filesTotal, "files-total"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &filesPercentageNum, "files-percentage"}, - {FF_FORMAT_ARG_TYPE_BOOL, &isExternal, "is-external"}, - {FF_FORMAT_ARG_TYPE_BOOL, &isHidden, "is-hidden"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &disk->filesystem, "filesystem"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &disk->name, "name"}, - {FF_FORMAT_ARG_TYPE_BOOL, &isReadOnly, "is-readonly"}, + FF_FORMAT_ARG(usedPretty, "size-used"), + FF_FORMAT_ARG(totalPretty, "size-total"), + FF_FORMAT_ARG(bytesPercentageNum, "size-percentage"), + FF_FORMAT_ARG(disk->filesUsed, "files-used"), + FF_FORMAT_ARG(disk->filesTotal, "files-total"), + FF_FORMAT_ARG(filesPercentageNum, "files-percentage"), + FF_FORMAT_ARG(isExternal, "is-external"), + FF_FORMAT_ARG(isHidden, "is-hidden"), + FF_FORMAT_ARG(disk->filesystem, "filesystem"), + FF_FORMAT_ARG(disk->name, "name"), + FF_FORMAT_ARG(isReadOnly, "is-readonly"), {FF_FORMAT_ARG_TYPE_STRING, ffTimeToShortStr(disk->createTime), "create-time"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &bytesPercentageBar, "size-percentage-bar"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &filesPercentageBar, "files-percentage-bar"}, + FF_FORMAT_ARG(bytesPercentageBar, "size-percentage-bar"), + FF_FORMAT_ARG(filesPercentageBar, "files-percentage-bar"), })); } } diff --git a/src/modules/diskio/diskio.c b/src/modules/diskio/diskio.c index b0ac964054..086f46d9d3 100644 --- a/src/modules/diskio/diskio.c +++ b/src/modules/diskio/diskio.c @@ -23,10 +23,10 @@ static void formatKey(const FFDiskIOOptions* options, FFDiskIOResult* dev, uint3 { ffStrbufClear(key); FF_PARSE_FORMAT_STRING_CHECKED(key, &options->moduleArgs.key, 4, ((FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_UINT, &index, "index"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &dev->name, "name"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &dev->devPath, "dev-path"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &options->moduleArgs.keyIcon, "icon"}, + FF_FORMAT_ARG(index, "index"), + FF_FORMAT_ARG(dev->name, "name"), + FF_FORMAT_ARG(dev->devPath, "dev-path"), + FF_FORMAT_ARG(options->moduleArgs.keyIcon, "icon"), })); } } @@ -76,14 +76,14 @@ void ffPrintDiskIO(FFDiskIOOptions* options) if (!options->detectTotal) ffStrbufAppendS(&buffer, "/s"); FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_DISKIO_NUM_FORMAT_ARGS, ((FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_STRBUF, &buffer, "size-read"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &buffer2, "size-written"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &dev->name, "name"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &dev->devPath, "dev-path"}, - {FF_FORMAT_ARG_TYPE_UINT64, &dev->bytesRead, "bytes-read"}, - {FF_FORMAT_ARG_TYPE_UINT64, &dev->bytesWritten, "bytes-written"}, - {FF_FORMAT_ARG_TYPE_UINT64, &dev->readCount, "read-count"}, - {FF_FORMAT_ARG_TYPE_UINT64, &dev->writeCount, "write-count"}, + FF_FORMAT_ARG(buffer, "size-read"), + FF_FORMAT_ARG(buffer2, "size-written"), + FF_FORMAT_ARG(dev->name, "name"), + FF_FORMAT_ARG(dev->devPath, "dev-path"), + FF_FORMAT_ARG(dev->bytesRead, "bytes-read"), + FF_FORMAT_ARG(dev->bytesWritten, "bytes-written"), + FF_FORMAT_ARG(dev->readCount, "read-count"), + FF_FORMAT_ARG(dev->writeCount, "write-count"), })); } ++index; diff --git a/src/modules/display/display.c b/src/modules/display/display.c index c180d338ab..4e3f67eb3a 100644 --- a/src/modules/display/display.c +++ b/src/modules/display/display.c @@ -92,10 +92,10 @@ void ffPrintDisplay(FFDisplayOptions* options) else { FF_PARSE_FORMAT_STRING_CHECKED(&key, &options->moduleArgs.key, 4, ((FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_UINT, &moduleIndex, "index"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result->name, "name"}, - {FF_FORMAT_ARG_TYPE_STRING, displayType, "type"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &options->moduleArgs.keyIcon, "icon"}, + FF_FORMAT_ARG(moduleIndex, "index"), + FF_FORMAT_ARG(result->name, "name"), + FF_FORMAT_ARG(displayType, "type"), + FF_FORMAT_ARG(options->moduleArgs.keyIcon, "icon"), })); } @@ -152,21 +152,21 @@ void ffPrintDisplay(FFDisplayOptions* options) refreshRate[0] = 0; FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_DISPLAY_NUM_FORMAT_ARGS, ((FFformatarg[]) { - {FF_FORMAT_ARG_TYPE_UINT, &result->width, "width"}, - {FF_FORMAT_ARG_TYPE_UINT, &result->height, "height"}, - {FF_FORMAT_ARG_TYPE_STRING, refreshRate, "refresh-rate"}, - {FF_FORMAT_ARG_TYPE_UINT, &result->scaledWidth, "scaled-width"}, - {FF_FORMAT_ARG_TYPE_UINT, &result->scaledHeight, "scaled-height"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result->name, "name"}, - {FF_FORMAT_ARG_TYPE_STRING, displayType, "type"}, - {FF_FORMAT_ARG_TYPE_UINT, &result->rotation, "rotation"}, - {FF_FORMAT_ARG_TYPE_BOOL, &result->primary, "is-primary"}, - {FF_FORMAT_ARG_TYPE_UINT, &result->physicalWidth, "physical-width"}, - {FF_FORMAT_ARG_TYPE_UINT, &result->physicalHeight, "physical-height"}, - {FF_FORMAT_ARG_TYPE_DOUBLE, &inch, "inch"}, - {FF_FORMAT_ARG_TYPE_DOUBLE, &ppi, "ppi"}, - {FF_FORMAT_ARG_TYPE_UINT8, &result->bitDepth, "bit-depth"}, - {FF_FORMAT_ARG_TYPE_BOOL, &result->hdrEnabled, "hdr-enabled"}, + FF_FORMAT_ARG(result->width, "width"), + FF_FORMAT_ARG(result->height, "height"), + FF_FORMAT_ARG(refreshRate, "refresh-rate"), + FF_FORMAT_ARG(result->scaledWidth, "scaled-width"), + FF_FORMAT_ARG(result->scaledHeight, "scaled-height"), + FF_FORMAT_ARG(result->name, "name"), + FF_FORMAT_ARG(displayType, "type"), + FF_FORMAT_ARG(result->rotation, "rotation"), + FF_FORMAT_ARG(result->primary, "is-primary"), + FF_FORMAT_ARG(result->physicalWidth, "physical-width"), + FF_FORMAT_ARG(result->physicalHeight, "physical-height"), + FF_FORMAT_ARG(inch, "inch"), + FF_FORMAT_ARG(ppi, "ppi"), + FF_FORMAT_ARG(result->bitDepth, "bit-depth"), + FF_FORMAT_ARG(result->hdrEnabled, "hdr-enabled"), })); } } diff --git a/src/modules/dns/dns.c b/src/modules/dns/dns.c index 3eef47be27..63a744885e 100644 --- a/src/modules/dns/dns.c +++ b/src/modules/dns/dns.c @@ -49,7 +49,7 @@ void ffPrintDNS(FFDNSOptions* options) else { FF_PRINT_FORMAT_CHECKED(FF_DNS_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_DNS_NUM_FORMAT_ARGS, ((FFformatarg[]) { - {FF_FORMAT_ARG_TYPE_STRBUF, &buf, "result"}, + FF_FORMAT_ARG(buf, "result"), })); } diff --git a/src/modules/editor/editor.c b/src/modules/editor/editor.c index 490c313a88..b814a55e9d 100644 --- a/src/modules/editor/editor.c +++ b/src/modules/editor/editor.c @@ -42,11 +42,11 @@ void ffPrintEditor(FFEditorOptions* options) else { FF_PRINT_FORMAT_CHECKED(FF_EDITOR_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_EDITOR_NUM_FORMAT_ARGS, ((FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_STRING, result.type, "type"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result.name, "name"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result.exe, "exe-name"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result.path, "path"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result.version, "version"}, + FF_FORMAT_ARG(result.type, "type"), + FF_FORMAT_ARG(result.name, "name"), + FF_FORMAT_ARG(result.exe, "exe-name"), + FF_FORMAT_ARG(result.path, "path"), + FF_FORMAT_ARG(result.version, "version"), })); } diff --git a/src/modules/font/font.c b/src/modules/font/font.c index a0bd9121fe..3fbc9ac940 100644 --- a/src/modules/font/font.c +++ b/src/modules/font/font.c @@ -29,11 +29,11 @@ void ffPrintFont(FFFontOptions* options) else { FF_PRINT_FORMAT_CHECKED(FF_FONT_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_FONT_NUM_FORMAT_ARGS, ((FFformatarg[]) { - {FF_FORMAT_ARG_TYPE_STRBUF, &font.fonts[0], "font1"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &font.fonts[1], "font2"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &font.fonts[2], "font3"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &font.fonts[3], "font4"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &font.display, "combined"}, + FF_FORMAT_ARG(font.fonts[0], "font1"), + FF_FORMAT_ARG(font.fonts[1], "font2"), + FF_FORMAT_ARG(font.fonts[2], "font3"), + FF_FORMAT_ARG(font.fonts[3], "font4"), + FF_FORMAT_ARG(font.display, "combined"), })); } } diff --git a/src/modules/gamepad/gamepad.c b/src/modules/gamepad/gamepad.c index 988fc3a1ec..b1b3457f0e 100644 --- a/src/modules/gamepad/gamepad.c +++ b/src/modules/gamepad/gamepad.c @@ -31,10 +31,10 @@ static void printDevice(FFGamepadOptions* options, const FFGamepadDevice* device ffPercentAppendBar(&percentageBar, device->battery, options->percent, &options->moduleArgs); FF_PRINT_FORMAT_CHECKED(FF_GAMEPAD_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_GAMEPAD_NUM_FORMAT_ARGS, ((FFformatarg[]) { - {FF_FORMAT_ARG_TYPE_STRBUF, &device->name, "name"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &device->serial, "serial"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &percentageNum, "battery-percentage"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &percentageBar, "battery-percentage-bar"}, + FF_FORMAT_ARG(device->name, "name"), + FF_FORMAT_ARG(device->serial, "serial"), + FF_FORMAT_ARG(percentageNum, "battery-percentage"), + FF_FORMAT_ARG(percentageBar, "battery-percentage-bar"), })); } } diff --git a/src/modules/gpu/gpu.c b/src/modules/gpu/gpu.c index b16040e95e..bdc2e890da 100644 --- a/src/modules/gpu/gpu.c +++ b/src/modules/gpu/gpu.c @@ -91,18 +91,18 @@ static void printGPUResult(FFGPUOptions* options, uint8_t index, const FFGPUResu ffParseFrequency(gpu->frequency, &frequency); FF_PRINT_FORMAT_CHECKED(FF_GPU_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_GPU_NUM_FORMAT_ARGS, ((FFformatarg[]) { - {FF_FORMAT_ARG_TYPE_STRBUF, &gpu->vendor, "vendor"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &gpu->name, "name"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &gpu->driver, "driver"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &tempStr, "temperature"}, - {FF_FORMAT_ARG_TYPE_INT, &gpu->coreCount, "core-count"}, - {FF_FORMAT_ARG_TYPE_STRING, type, "type"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &dTotal, "dedicated-total"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &dUsed, "dedicated-used"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &sTotal, "shared-total"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &sUsed, "shared-used"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &gpu->platformApi, "platform-api"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &frequency, "frequency"}, + FF_FORMAT_ARG(gpu->vendor, "vendor"), + FF_FORMAT_ARG(gpu->name, "name"), + FF_FORMAT_ARG(gpu->driver, "driver"), + FF_FORMAT_ARG(tempStr, "temperature"), + FF_FORMAT_ARG(gpu->coreCount, "core-count"), + FF_FORMAT_ARG(type, "type"), + FF_FORMAT_ARG(dTotal, "dedicated-total"), + FF_FORMAT_ARG(dUsed, "dedicated-used"), + FF_FORMAT_ARG(sTotal, "shared-total"), + FF_FORMAT_ARG(sUsed, "shared-used"), + FF_FORMAT_ARG(gpu->platformApi, "platform-api"), + FF_FORMAT_ARG(frequency, "frequency"), })); } } diff --git a/src/modules/host/host.c b/src/modules/host/host.c index 8e2d4b9a78..c63a9896ec 100644 --- a/src/modules/host/host.c +++ b/src/modules/host/host.c @@ -49,13 +49,13 @@ void ffPrintHost(FFHostOptions* options) else { FF_PRINT_FORMAT_CHECKED(FF_HOST_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_HOST_NUM_FORMAT_ARGS, ((FFformatarg[]) { - {FF_FORMAT_ARG_TYPE_STRBUF, &host.family, "family"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &host.name, "name"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &host.version, "version"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &host.sku, "sku"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &host.vendor, "vendor"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &host.serial, "serial"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &host.uuid, "uuid"}, + FF_FORMAT_ARG(host.family, "family"), + FF_FORMAT_ARG(host.name, "name"), + FF_FORMAT_ARG(host.version, "version"), + FF_FORMAT_ARG(host.sku, "sku"), + FF_FORMAT_ARG(host.vendor, "vendor"), + FF_FORMAT_ARG(host.serial, "serial"), + FF_FORMAT_ARG(host.uuid, "uuid"), })); } diff --git a/src/modules/icons/icons.c b/src/modules/icons/icons.c index cf120e61fb..891aeb5720 100644 --- a/src/modules/icons/icons.c +++ b/src/modules/icons/icons.c @@ -36,8 +36,8 @@ void ffPrintIcons(FFIconsOptions* options) else { FF_PRINT_FORMAT_CHECKED(FF_ICONS_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_ICONS_NUM_FORMAT_ARGS, ((FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_STRBUF, &result.icons1, "icons1"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result.icons2, "icons2"}, + FF_FORMAT_ARG(result.icons1, "icons1"), + FF_FORMAT_ARG(result.icons2, "icons2"), })); } diff --git a/src/modules/initsystem/initsystem.c b/src/modules/initsystem/initsystem.c index fbded86b45..7a2824a60e 100644 --- a/src/modules/initsystem/initsystem.c +++ b/src/modules/initsystem/initsystem.c @@ -36,10 +36,10 @@ void ffPrintInitSystem(FFInitSystemOptions* options) else { FF_PRINT_FORMAT_CHECKED(FF_INITSYSTEM_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_INITSYSTEM_NUM_FORMAT_ARGS, ((FFformatarg[]) { - {FF_FORMAT_ARG_TYPE_STRBUF, &result.name, "name"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result.exe, "exe"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result.version, "version"}, - {FF_FORMAT_ARG_TYPE_UINT, &result.pid, "pid"}, + FF_FORMAT_ARG(result.name, "name"), + FF_FORMAT_ARG(result.exe, "exe"), + FF_FORMAT_ARG(result.version, "version"), + FF_FORMAT_ARG(result.pid, "pid"), })); } diff --git a/src/modules/kernel/kernel.c b/src/modules/kernel/kernel.c index 089934d9af..13b96c49c2 100644 --- a/src/modules/kernel/kernel.c +++ b/src/modules/kernel/kernel.c @@ -23,12 +23,12 @@ void ffPrintKernel(FFKernelOptions* options) FF_STRBUF_AUTO_DESTROY str = ffStrbufCreate(); ffParseSize(info->pageSize, &str); FF_PRINT_FORMAT_CHECKED(FF_KERNEL_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_KERNEL_NUM_FORMAT_ARGS, ((FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_STRBUF, &info->name, "sysname"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &info->release, "release"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &info->version, "version"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &info->architecture, "arch"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &info->displayVersion, "display-version"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &str, "page-size"}, + FF_FORMAT_ARG(info->name, "sysname"), + FF_FORMAT_ARG(info->release, "release"), + FF_FORMAT_ARG(info->version, "version"), + FF_FORMAT_ARG(info->architecture, "arch"), + FF_FORMAT_ARG(info->displayVersion, "display-version"), + FF_FORMAT_ARG(str, "page-size"), })); } } diff --git a/src/modules/lm/lm.c b/src/modules/lm/lm.c index 1775561a31..12500821a0 100644 --- a/src/modules/lm/lm.c +++ b/src/modules/lm/lm.c @@ -39,9 +39,9 @@ void ffPrintLM(FFLMOptions* options) else { FF_PRINT_FORMAT_CHECKED(FF_LM_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_LM_NUM_FORMAT_ARGS, ((FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_STRBUF, &result.service, "service"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result.type, "type"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result.version, "version"}, + FF_FORMAT_ARG(result.service, "service"), + FF_FORMAT_ARG(result.type, "type"), + FF_FORMAT_ARG(result.version, "version"), })); } ffStrbufDestroy(&result.service); diff --git a/src/modules/loadavg/loadavg.c b/src/modules/loadavg/loadavg.c index 26d4ffb8d7..7802c3fd25 100644 --- a/src/modules/loadavg/loadavg.c +++ b/src/modules/loadavg/loadavg.c @@ -50,9 +50,9 @@ void ffPrintLoadavg(FFLoadavgOptions* options) { ffStrbufClear(&buffer); FF_PARSE_FORMAT_STRING_CHECKED(&buffer, &options->moduleArgs.key, 3, ((FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_UINT, &index, "index"}, - {FF_FORMAT_ARG_TYPE_UINT, &duration, "duration"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &options->moduleArgs.keyIcon, "icon"}, + FF_FORMAT_ARG(index, "index"), + FF_FORMAT_ARG(duration, "duration"), + FF_FORMAT_ARG(options->moduleArgs.keyIcon, "icon"), })); } @@ -85,9 +85,9 @@ void ffPrintLoadavg(FFLoadavgOptions* options) else { FF_PRINT_FORMAT_CHECKED(FF_LOADAVG_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_LOADAVG_NUM_FORMAT_ARGS, ((FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_DOUBLE, &result[0], "loadavg1"}, - {FF_FORMAT_ARG_TYPE_DOUBLE, &result[1], "loadavg2"}, - {FF_FORMAT_ARG_TYPE_DOUBLE, &result[2], "loadavg3"}, + FF_FORMAT_ARG(result[0], "loadavg1"), + FF_FORMAT_ARG(result[1], "loadavg2"), + FF_FORMAT_ARG(result[2], "loadavg3"), })); } } diff --git a/src/modules/locale/locale.c b/src/modules/locale/locale.c index 36f43de10e..cfd4177617 100644 --- a/src/modules/locale/locale.c +++ b/src/modules/locale/locale.c @@ -25,7 +25,7 @@ void ffPrintLocale(FFLocaleOptions* options) else { FF_PRINT_FORMAT_CHECKED(FF_LOCALE_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_LOCALE_NUM_FORMAT_ARGS, ((FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_STRBUF, &locale, "result"} + FF_FORMAT_ARG(locale, "result") })); } } diff --git a/src/modules/localip/localip.c b/src/modules/localip/localip.c index 2a5db4914b..da9440610d 100644 --- a/src/modules/localip/localip.c +++ b/src/modules/localip/localip.c @@ -26,10 +26,10 @@ static void formatKey(const FFLocalIpOptions* options, FFLocalIpResult* ip, uint { ffStrbufClear(key); FF_PARSE_FORMAT_STRING_CHECKED(key, &options->moduleArgs.key, 4, ((FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_UINT, &index, "index"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &ip->name, "name"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &ip->mac, "mac"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &options->moduleArgs.keyIcon, "icon"}, + FF_FORMAT_ARG(index, "index"), + FF_FORMAT_ARG(ip->name, "name"), + FF_FORMAT_ARG(ip->mac, "mac"), + FF_FORMAT_ARG(options->moduleArgs.keyIcon, "icon"), })); } } @@ -120,13 +120,13 @@ void ffPrintLocalIp(FFLocalIpOptions* options) ffStrbufSetF(&speedStr, "%u Mbps", (unsigned) ip->speed); } FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_LOCALIP_NUM_FORMAT_ARGS, ((FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_STRBUF, &ip->ipv4, "ipv4"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &ip->ipv6, "ipv6"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &ip->mac, "mac"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &ip->name, "ifname"}, - {FF_FORMAT_ARG_TYPE_BOOL, &ip->defaultRoute, "is-default-route"}, - {FF_FORMAT_ARG_TYPE_INT, &ip->mtu, "mtu"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &speedStr, "speed"}, + FF_FORMAT_ARG(ip->ipv4, "ipv4"), + FF_FORMAT_ARG(ip->ipv6, "ipv6"), + FF_FORMAT_ARG(ip->mac, "mac"), + FF_FORMAT_ARG(ip->name, "ifname"), + FF_FORMAT_ARG(ip->defaultRoute, "is-default-route"), + FF_FORMAT_ARG(ip->mtu, "mtu"), + FF_FORMAT_ARG(speedStr, "speed"), })); } ++index; diff --git a/src/modules/media/media.c b/src/modules/media/media.c index 64e6edd2b9..6c7ac2c8e5 100644 --- a/src/modules/media/media.c +++ b/src/modules/media/media.c @@ -96,11 +96,11 @@ void ffPrintMedia(FFMediaOptions* options) else { FF_PRINT_FORMAT_CHECKED(FF_MEDIA_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_MEDIA_NUM_FORMAT_ARGS, ((FFformatarg[]) { - {FF_FORMAT_ARG_TYPE_STRBUF, &songPretty, "combined"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &media->song, "title"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &media->artist, "artist"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &media->album, "album"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &media->status, "status"}, + FF_FORMAT_ARG(songPretty, "combined"), + FF_FORMAT_ARG(media->song, "title"), + FF_FORMAT_ARG(media->artist, "artist"), + FF_FORMAT_ARG(media->album, "album"), + FF_FORMAT_ARG(media->status, "status"), })); } } diff --git a/src/modules/memory/memory.c b/src/modules/memory/memory.c index 2d6bc6d837..1ce5ab8fd9 100644 --- a/src/modules/memory/memory.c +++ b/src/modules/memory/memory.c @@ -61,10 +61,10 @@ void ffPrintMemory(FFMemoryOptions* options) FF_STRBUF_AUTO_DESTROY percentageBar = ffStrbufCreate(); ffPercentAppendBar(&percentageBar, percentage, options->percent, &options->moduleArgs); FF_PRINT_FORMAT_CHECKED(FF_MEMORY_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_MEMORY_NUM_FORMAT_ARGS, ((FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_STRBUF, &usedPretty, "used"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &totalPretty, "total"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &percentageNum, "percentage"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &percentageBar, "percentage-bar"}, + FF_FORMAT_ARG(usedPretty, "used"), + FF_FORMAT_ARG(totalPretty, "total"), + FF_FORMAT_ARG(percentageNum, "percentage"), + FF_FORMAT_ARG(percentageBar, "percentage-bar"), })); } } diff --git a/src/modules/monitor/monitor.c b/src/modules/monitor/monitor.c index 6fdd53eb5c..a2d43cff7d 100644 --- a/src/modules/monitor/monitor.c +++ b/src/modules/monitor/monitor.c @@ -42,9 +42,9 @@ void ffPrintMonitor(FFMonitorOptions* options) { uint32_t moduleIndex = result.length == 1 ? 0 : index + 1; FF_PARSE_FORMAT_STRING_CHECKED(&key, &options->moduleArgs.key, 3, ((FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_UINT, &moduleIndex, "index"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &display->name, "name"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &options->moduleArgs.keyIcon, "icon"}, + FF_FORMAT_ARG(moduleIndex, "index"), + FF_FORMAT_ARG(display->name, "name"), + FF_FORMAT_ARG(options->moduleArgs.keyIcon, "icon"), })); } @@ -72,17 +72,17 @@ void ffPrintMonitor(FFMonitorOptions* options) buf[0] = '\0'; FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_MONITOR_NUM_FORMAT_ARGS, ((FFformatarg[]) { - {FF_FORMAT_ARG_TYPE_STRBUF, &display->name, "name"}, - {FF_FORMAT_ARG_TYPE_UINT, &display->width, "width"}, - {FF_FORMAT_ARG_TYPE_UINT, &display->height, "height"}, - {FF_FORMAT_ARG_TYPE_UINT, &display->physicalWidth, "physical-width"}, - {FF_FORMAT_ARG_TYPE_UINT, &display->physicalHeight, "physical-height"}, - {FF_FORMAT_ARG_TYPE_DOUBLE, &inch, "inch"}, - {FF_FORMAT_ARG_TYPE_DOUBLE, &ppi, "ppi"}, - {FF_FORMAT_ARG_TYPE_UINT16, &display->manufactureYear, "manufacture-year"}, - {FF_FORMAT_ARG_TYPE_UINT16, &display->manufactureWeek, "manufacture-week"}, - {FF_FORMAT_ARG_TYPE_STRING, buf, "serial"}, - {FF_FORMAT_ARG_TYPE_DOUBLE, buf, "refresh-rate"}, + FF_FORMAT_ARG(display->name, "name"), + FF_FORMAT_ARG(display->width, "width"), + FF_FORMAT_ARG(display->height, "height"), + FF_FORMAT_ARG(display->physicalWidth, "physical-width"), + FF_FORMAT_ARG(display->physicalHeight, "physical-height"), + FF_FORMAT_ARG(inch, "inch"), + FF_FORMAT_ARG(ppi, "ppi"), + FF_FORMAT_ARG(display->manufactureYear, "manufacture-year"), + FF_FORMAT_ARG(display->manufactureWeek, "manufacture-week"), + FF_FORMAT_ARG(buf, "serial"), + FF_FORMAT_ARG(display->refreshRate, "refresh-rate"), })); } diff --git a/src/modules/netio/netio.c b/src/modules/netio/netio.c index f6d772746c..e6eebd4dfc 100644 --- a/src/modules/netio/netio.c +++ b/src/modules/netio/netio.c @@ -26,9 +26,9 @@ static void formatKey(const FFNetIOOptions* options, FFNetIOResult* inf, uint32_ { ffStrbufClear(key); FF_PARSE_FORMAT_STRING_CHECKED(key, &options->moduleArgs.key, 3, ((FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_UINT, &index, "index"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &inf->name, "name"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &options->moduleArgs.keyIcon, "icon"}, + FF_FORMAT_ARG(index, "index"), + FF_FORMAT_ARG(inf->name, "name"), + FF_FORMAT_ARG(options->moduleArgs.keyIcon, "icon"), })); } } @@ -81,18 +81,18 @@ void ffPrintNetIO(FFNetIOOptions* options) if (!options->detectTotal) ffStrbufAppendS(&buffer2, "/s"); FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_NETIO_NUM_FORMAT_ARGS, ((FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_STRBUF, &buffer, "rx-size"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &buffer2, "tx-size"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &inf->name, "ifname"}, - {FF_FORMAT_ARG_TYPE_BOOL, &inf->defaultRoute, "is-default-route"}, - {FF_FORMAT_ARG_TYPE_UINT64, &inf->txBytes, "tx-bytes"}, - {FF_FORMAT_ARG_TYPE_UINT64, &inf->rxBytes, "rx-bytes"}, - {FF_FORMAT_ARG_TYPE_UINT64, &inf->txPackets, "tx-packets"}, - {FF_FORMAT_ARG_TYPE_UINT64, &inf->rxPackets, "rx-packets"}, - {FF_FORMAT_ARG_TYPE_UINT64, &inf->rxErrors, "rx-errors"}, - {FF_FORMAT_ARG_TYPE_UINT64, &inf->txErrors, "tx-errors"}, - {FF_FORMAT_ARG_TYPE_UINT64, &inf->rxDrops, "rx-drops"}, - {FF_FORMAT_ARG_TYPE_UINT64, &inf->txDrops, "tx-drops"}, + FF_FORMAT_ARG(buffer, "rx-size"), + FF_FORMAT_ARG(buffer2, "tx-size"), + FF_FORMAT_ARG(inf->name, "ifname"), + FF_FORMAT_ARG(inf->defaultRoute, "is-default-route"), + FF_FORMAT_ARG(inf->txBytes, "tx-bytes"), + FF_FORMAT_ARG(inf->rxBytes, "rx-bytes"), + FF_FORMAT_ARG(inf->txPackets, "tx-packets"), + FF_FORMAT_ARG(inf->rxPackets, "rx-packets"), + FF_FORMAT_ARG(inf->rxErrors, "rx-errors"), + FF_FORMAT_ARG(inf->txErrors, "tx-errors"), + FF_FORMAT_ARG(inf->rxDrops, "rx-drops"), + FF_FORMAT_ARG(inf->txDrops, "tx-drops"), })); } ++index; diff --git a/src/modules/opencl/opencl.c b/src/modules/opencl/opencl.c index cb29a155e0..30f3c716c2 100644 --- a/src/modules/opencl/opencl.c +++ b/src/modules/opencl/opencl.c @@ -25,9 +25,9 @@ void ffPrintOpenCL(FFOpenCLOptions* options) else { FF_PRINT_FORMAT_CHECKED(FF_OPENCL_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_OPENCL_NUM_FORMAT_ARGS, ((FFformatarg[]) { - {FF_FORMAT_ARG_TYPE_STRBUF, &result->version, "version"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result->name, "name"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result->vendor, "vendor"}, + FF_FORMAT_ARG(result->version, "version"), + FF_FORMAT_ARG(result->name, "name"), + FF_FORMAT_ARG(result->vendor, "vendor"), })); } } diff --git a/src/modules/opengl/opengl.c b/src/modules/opengl/opengl.c index aea90dbb64..d00c87e557 100644 --- a/src/modules/opengl/opengl.c +++ b/src/modules/opengl/opengl.c @@ -30,11 +30,11 @@ void ffPrintOpenGL(FFOpenGLOptions* options) else { FF_PRINT_FORMAT_CHECKED(FF_OPENGL_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_OPENGL_NUM_FORMAT_ARGS, ((FFformatarg[]) { - {FF_FORMAT_ARG_TYPE_STRBUF, &result.version, "version"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result.renderer, "renderer"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result.vendor, "vendor"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result.slv, "slv"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result.library, "library"}, + FF_FORMAT_ARG(result.version, "version"), + FF_FORMAT_ARG(result.renderer, "renderer"), + FF_FORMAT_ARG(result.vendor, "vendor"), + FF_FORMAT_ARG(result.slv, "slv"), + FF_FORMAT_ARG(result.library, "library"), })); } diff --git a/src/modules/os/os.c b/src/modules/os/os.c index bb6edb659b..c00676fced 100644 --- a/src/modules/os/os.c +++ b/src/modules/os/os.c @@ -112,18 +112,18 @@ void ffPrintOS(FFOSOptions* options) else { FF_PRINT_FORMAT_CHECKED(FF_OS_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_OS_NUM_FORMAT_ARGS, ((FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_STRBUF, &instance.state.platform.sysinfo.name, "sysname"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &os->name, "name"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &os->prettyName, "pretty-name"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &os->id, "id"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &os->idLike, "id-like"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &os->variant, "variant"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &os->variantID, "variant-id"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &os->version, "version"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &os->versionID, "version-id"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &os->codename, "codename"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &os->buildID, "build-id"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &instance.state.platform.sysinfo.architecture, "arch"} + FF_FORMAT_ARG(instance.state.platform.sysinfo.name, "sysname"), + FF_FORMAT_ARG(os->name, "name"), + FF_FORMAT_ARG(os->prettyName, "pretty-name"), + FF_FORMAT_ARG(os->id, "id"), + FF_FORMAT_ARG(os->idLike, "id-like"), + FF_FORMAT_ARG(os->variant, "variant"), + FF_FORMAT_ARG(os->variantID, "variant-id"), + FF_FORMAT_ARG(os->version, "version"), + FF_FORMAT_ARG(os->versionID, "version-id"), + FF_FORMAT_ARG(os->codename, "codename"), + FF_FORMAT_ARG(os->buildID, "build-id"), + FF_FORMAT_ARG(instance.state.platform.sysinfo.architecture, "arch") })); } } diff --git a/src/modules/packages/packages.c b/src/modules/packages/packages.c index 8593a9f46b..3d056c12d4 100644 --- a/src/modules/packages/packages.c +++ b/src/modules/packages/packages.c @@ -82,43 +82,43 @@ void ffPrintPackages(FFPackagesOptions* options) uint32_t brewAll = counts.brew + counts.brewCask; uint32_t guixAll = counts.guixSystem + counts.guixUser + counts.guixHome; FF_PRINT_FORMAT_CHECKED(FF_PACKAGES_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_PACKAGES_NUM_FORMAT_ARGS, ((FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_UINT, &counts.all, "all"}, - {FF_FORMAT_ARG_TYPE_UINT, &counts.pacman, "pacman"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &counts.pacmanBranch, "pacman-branch"}, - {FF_FORMAT_ARG_TYPE_UINT, &counts.dpkg, "dpkg"}, - {FF_FORMAT_ARG_TYPE_UINT, &counts.rpm, "rpm"}, - {FF_FORMAT_ARG_TYPE_UINT, &counts.emerge, "emerge"}, - {FF_FORMAT_ARG_TYPE_UINT, &counts.eopkg, "eopkg"}, - {FF_FORMAT_ARG_TYPE_UINT, &counts.xbps, "xbps"}, - {FF_FORMAT_ARG_TYPE_UINT, &counts.nixSystem, "nix-system"}, - {FF_FORMAT_ARG_TYPE_UINT, &counts.nixUser, "nix-user"}, - {FF_FORMAT_ARG_TYPE_UINT, &counts.nixDefault, "nix-default"}, - {FF_FORMAT_ARG_TYPE_UINT, &counts.apk, "apk"}, - {FF_FORMAT_ARG_TYPE_UINT, &counts.pkg, "pkg"}, - {FF_FORMAT_ARG_TYPE_UINT, &counts.flatpakSystem, "flatpak-system"}, - {FF_FORMAT_ARG_TYPE_UINT, &counts.flatpakUser, "flatpak-user"}, - {FF_FORMAT_ARG_TYPE_UINT, &counts.snap, "snap"}, - {FF_FORMAT_ARG_TYPE_UINT, &counts.brew, "brew"}, - {FF_FORMAT_ARG_TYPE_UINT, &counts.brewCask, "brew-cask"}, - {FF_FORMAT_ARG_TYPE_UINT, &counts.macports, "macports"}, - {FF_FORMAT_ARG_TYPE_UINT, &counts.scoop, "scoop"}, - {FF_FORMAT_ARG_TYPE_UINT, &counts.choco, "choco"}, - {FF_FORMAT_ARG_TYPE_UINT, &counts.pkgtool, "pkgtool"}, - {FF_FORMAT_ARG_TYPE_UINT, &counts.paludis, "paludis"}, - {FF_FORMAT_ARG_TYPE_UINT, &counts.winget, "winget"}, - {FF_FORMAT_ARG_TYPE_UINT, &counts.opkg, "opkg"}, - {FF_FORMAT_ARG_TYPE_UINT, &counts.am, "am"}, - {FF_FORMAT_ARG_TYPE_UINT, &counts.sorcery, "sorcery"}, - {FF_FORMAT_ARG_TYPE_UINT, &counts.lpkg, "lpkg"}, - {FF_FORMAT_ARG_TYPE_UINT, &counts.lpkgbuild, "lpkgbuild"}, - {FF_FORMAT_ARG_TYPE_UINT, &counts.guixSystem, "guix-system"}, - {FF_FORMAT_ARG_TYPE_UINT, &counts.guixUser, "guix-user"}, - {FF_FORMAT_ARG_TYPE_UINT, &counts.guixHome, "guix-home"}, - {FF_FORMAT_ARG_TYPE_UINT, &counts.linglong, "linglong"}, - {FF_FORMAT_ARG_TYPE_UINT, &nixAll, "nix-all"}, - {FF_FORMAT_ARG_TYPE_UINT, &flatpakAll, "flatpak-all"}, - {FF_FORMAT_ARG_TYPE_UINT, &brewAll, "brew-all"}, - {FF_FORMAT_ARG_TYPE_UINT, &guixAll, "guix-all"}, + FF_FORMAT_ARG(counts.all, "all"), + FF_FORMAT_ARG(counts.pacman, "pacman"), + FF_FORMAT_ARG(counts.pacmanBranch, "pacman-branch"), + FF_FORMAT_ARG(counts.dpkg, "dpkg"), + FF_FORMAT_ARG(counts.rpm, "rpm"), + FF_FORMAT_ARG(counts.emerge, "emerge"), + FF_FORMAT_ARG(counts.eopkg, "eopkg"), + FF_FORMAT_ARG(counts.xbps, "xbps"), + FF_FORMAT_ARG(counts.nixSystem, "nix-system"), + FF_FORMAT_ARG(counts.nixUser, "nix-user"), + FF_FORMAT_ARG(counts.nixDefault, "nix-default"), + FF_FORMAT_ARG(counts.apk, "apk"), + FF_FORMAT_ARG(counts.pkg, "pkg"), + FF_FORMAT_ARG(counts.flatpakSystem, "flatpak-system"), + FF_FORMAT_ARG(counts.flatpakUser, "flatpak-user"), + FF_FORMAT_ARG(counts.snap, "snap"), + FF_FORMAT_ARG(counts.brew, "brew"), + FF_FORMAT_ARG(counts.brewCask, "brew-cask"), + FF_FORMAT_ARG(counts.macports, "macports"), + FF_FORMAT_ARG(counts.scoop, "scoop"), + FF_FORMAT_ARG(counts.choco, "choco"), + FF_FORMAT_ARG(counts.pkgtool, "pkgtool"), + FF_FORMAT_ARG(counts.paludis, "paludis"), + FF_FORMAT_ARG(counts.winget, "winget"), + FF_FORMAT_ARG(counts.opkg, "opkg"), + FF_FORMAT_ARG(counts.am, "am"), + FF_FORMAT_ARG(counts.sorcery, "sorcery"), + FF_FORMAT_ARG(counts.lpkg, "lpkg"), + FF_FORMAT_ARG(counts.lpkgbuild, "lpkgbuild"), + FF_FORMAT_ARG(counts.guixSystem, "guix-system"), + FF_FORMAT_ARG(counts.guixUser, "guix-user"), + FF_FORMAT_ARG(counts.guixHome, "guix-home"), + FF_FORMAT_ARG(counts.linglong, "linglong"), + FF_FORMAT_ARG(nixAll, "nix-all"), + FF_FORMAT_ARG(flatpakAll, "flatpak-all"), + FF_FORMAT_ARG(brewAll, "brew-all"), + FF_FORMAT_ARG(guixAll, "guix-all"), })); } diff --git a/src/modules/physicaldisk/physicaldisk.c b/src/modules/physicaldisk/physicaldisk.c index 10149ae657..f5ce33bc62 100644 --- a/src/modules/physicaldisk/physicaldisk.c +++ b/src/modules/physicaldisk/physicaldisk.c @@ -24,10 +24,10 @@ static void formatKey(const FFPhysicalDiskOptions* options, FFPhysicalDiskResult { ffStrbufClear(key); FF_PARSE_FORMAT_STRING_CHECKED(key, &options->moduleArgs.key, 4, ((FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_UINT, &index, "index"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &dev->name, "name"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &dev->devPath, "dev-path"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &options->moduleArgs.keyIcon, "icon"}, + FF_FORMAT_ARG(index, "index"), + FF_FORMAT_ARG(dev->name, "name"), + FF_FORMAT_ARG(dev->devPath, "dev-path"), + FF_FORMAT_ARG(options->moduleArgs.keyIcon, "icon"), })); } } @@ -109,16 +109,16 @@ void ffPrintPhysicalDisk(FFPhysicalDiskOptions* options) if (dev->type & FF_PHYSICALDISK_TYPE_READWRITE) readOnlyType = "Read-write"; FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_PHYSICALDISK_NUM_FORMAT_ARGS, ((FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_STRBUF, &buffer, "size"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &dev->name, "name"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &dev->interconnect, "interconnect"}, - {FF_FORMAT_ARG_TYPE_STRING, physicalType, "type"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &dev->devPath, "dev-path"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &dev->serial, "serial"}, - {FF_FORMAT_ARG_TYPE_STRING, removableType, "removable-type"}, - {FF_FORMAT_ARG_TYPE_STRING, readOnlyType, "readonly-type"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &dev->revision, "revision"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &tempStr, "temperature"}, + FF_FORMAT_ARG(buffer, "size"), + FF_FORMAT_ARG(dev->name, "name"), + FF_FORMAT_ARG(dev->interconnect, "interconnect"), + FF_FORMAT_ARG(physicalType, "type"), + FF_FORMAT_ARG(dev->devPath, "dev-path"), + FF_FORMAT_ARG(dev->serial, "serial"), + FF_FORMAT_ARG(removableType, "removable-type"), + FF_FORMAT_ARG(readOnlyType, "readonly-type"), + FF_FORMAT_ARG(dev->revision, "revision"), + FF_FORMAT_ARG(tempStr, "temperature"), })); } ++index; diff --git a/src/modules/physicalmemory/physicalmemory.c b/src/modules/physicalmemory/physicalmemory.c index 6949b045d8..747b7e7095 100644 --- a/src/modules/physicalmemory/physicalmemory.c +++ b/src/modules/physicalmemory/physicalmemory.c @@ -55,17 +55,17 @@ void ffPrintPhysicalMemory(FFPhysicalMemoryOptions* options) else { FF_PRINT_FORMAT_CHECKED(FF_PHYSICALMEMORY_DISPLAY_NAME, (uint8_t) i, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_PHYSICALMEMORY_NUM_FORMAT_ARGS, ((FFformatarg[]) { - {FF_FORMAT_ARG_TYPE_UINT64, &device->size, "bytes"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &prettySize, "size"}, - {FF_FORMAT_ARG_TYPE_UINT, &device->maxSpeed, "max-speed"}, - {FF_FORMAT_ARG_TYPE_UINT, &device->runningSpeed, "running-speed"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &device->type, "type"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &device->formFactor, "form-factor"}, - {FF_FORMAT_ARG_TYPE_DOUBLE, &device->locator, "locator"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &device->vendor, "vendor"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &device->serial, "serial"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &device->partNumber, "part-number"}, - {FF_FORMAT_ARG_TYPE_BOOL, &device->ecc, "is-ecc-enabled"}, + FF_FORMAT_ARG(device->size, "bytes"), + FF_FORMAT_ARG(prettySize, "size"), + FF_FORMAT_ARG(device->maxSpeed, "max-speed"), + FF_FORMAT_ARG(device->runningSpeed, "running-speed"), + FF_FORMAT_ARG(device->type, "type"), + FF_FORMAT_ARG(device->formFactor, "form-factor"), + FF_FORMAT_ARG(device->locator, "locator"), + FF_FORMAT_ARG(device->vendor, "vendor"), + FF_FORMAT_ARG(device->serial, "serial"), + FF_FORMAT_ARG(device->partNumber, "part-number"), + FF_FORMAT_ARG(device->ecc, "is-ecc-enabled"), })); } } diff --git a/src/modules/player/player.c b/src/modules/player/player.c index 712d643514..2dd781a80b 100644 --- a/src/modules/player/player.c +++ b/src/modules/player/player.c @@ -74,10 +74,10 @@ void ffPrintPlayer(FFPlayerOptions* options) else { FF_PRINT_FORMAT_CHECKED(FF_PLAYER_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_PLAYER_NUM_FORMAT_ARGS, ((FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_STRBUF, &playerPretty, "player"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &media->player, "name"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &media->playerId, "id"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &media->url, "url"}, + FF_FORMAT_ARG(playerPretty, "player"), + FF_FORMAT_ARG(media->player, "name"), + FF_FORMAT_ARG(media->playerId, "id"), + FF_FORMAT_ARG(media->url, "url"), })); } } diff --git a/src/modules/poweradapter/poweradapter.c b/src/modules/poweradapter/poweradapter.c index cadbfbbb9e..3445f7c35f 100644 --- a/src/modules/poweradapter/poweradapter.c +++ b/src/modules/poweradapter/poweradapter.c @@ -39,12 +39,12 @@ void ffPrintPowerAdapter(FFPowerAdapterOptions* options) else { FF_PRINT_FORMAT_CHECKED(FF_POWERADAPTER_DISPLAY_NAME, i, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_POWERADAPTER_NUM_FORMAT_ARGS, ((FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_INT, &result->watts, "watts"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result->name, "name"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result->manufacturer, "manufacturer"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result->modelName, "model-name"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result->description, "description"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result->serial, "serial"}, + FF_FORMAT_ARG(result->watts, "watts"), + FF_FORMAT_ARG(result->name, "name"), + FF_FORMAT_ARG(result->manufacturer, "manufacturer"), + FF_FORMAT_ARG(result->modelName, "model-name"), + FF_FORMAT_ARG(result->description, "description"), + FF_FORMAT_ARG(result->serial, "serial"), })); } diff --git a/src/modules/processes/processes.c b/src/modules/processes/processes.c index f50cb3ea2b..8c4d4865b4 100644 --- a/src/modules/processes/processes.c +++ b/src/modules/processes/processes.c @@ -26,7 +26,7 @@ void ffPrintProcesses(FFProcessesOptions* options) else { FF_PRINT_FORMAT_CHECKED(FF_PROCESSES_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_PROCESSES_NUM_FORMAT_ARGS, ((FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_UINT, &numProcesses, "result"} + FF_FORMAT_ARG(numProcesses, "result") })); } } diff --git a/src/modules/publicip/publicip.c b/src/modules/publicip/publicip.c index aa94d02a0f..110dea8e0c 100644 --- a/src/modules/publicip/publicip.c +++ b/src/modules/publicip/publicip.c @@ -31,8 +31,8 @@ void ffPrintPublicIp(FFPublicIpOptions* options) else { FF_PRINT_FORMAT_CHECKED(FF_PUBLICIP_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_PUBLICIP_NUM_FORMAT_ARGS, ((FFformatarg[]) { - {FF_FORMAT_ARG_TYPE_STRBUF, &result.ip, "ip"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result.location, "location"}, + FF_FORMAT_ARG(result.ip, "ip"), + FF_FORMAT_ARG(result.location, "location"), })); } diff --git a/src/modules/shell/shell.c b/src/modules/shell/shell.c index 6d7edb1778..8629971565 100644 --- a/src/modules/shell/shell.c +++ b/src/modules/shell/shell.c @@ -32,14 +32,14 @@ void ffPrintShell(FFShellOptions* options) else { FF_PRINT_FORMAT_CHECKED(FF_SHELL_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_SHELL_NUM_FORMAT_ARGS, ((FFformatarg[]) { - {FF_FORMAT_ARG_TYPE_STRBUF, &result->processName, "process-name"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result->exe, "exe"}, - {FF_FORMAT_ARG_TYPE_STRING, result->exeName, "exe-name"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result->version, "version"}, - {FF_FORMAT_ARG_TYPE_UINT, &result->pid, "pid"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result->prettyName, "pretty-name"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result->exePath, "exe-path"}, - {FF_FORMAT_ARG_TYPE_INT, &result->tty, "tty"}, + FF_FORMAT_ARG(result->processName, "process-name"), + FF_FORMAT_ARG(result->exe, "exe"), + FF_FORMAT_ARG(result->exeName, "exe-name"), + FF_FORMAT_ARG(result->version, "version"), + FF_FORMAT_ARG(result->pid, "pid"), + FF_FORMAT_ARG(result->prettyName, "pretty-name"), + FF_FORMAT_ARG(result->exePath, "exe-path"), + FF_FORMAT_ARG(result->tty, "tty"), })); } } diff --git a/src/modules/sound/sound.c b/src/modules/sound/sound.c index 4fd66f942d..3d24b2be6d 100644 --- a/src/modules/sound/sound.c +++ b/src/modules/sound/sound.c @@ -52,11 +52,11 @@ static void printDevice(FFSoundOptions* options, const FFSoundDevice* device, ui ffPercentAppendBar(&percentageBar, device->volume, options->percent, &options->moduleArgs); FF_PRINT_FORMAT_CHECKED(FF_SOUND_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_SOUND_NUM_FORMAT_ARGS, ((FFformatarg[]) { - {FF_FORMAT_ARG_TYPE_BOOL, &device->main, "is-main"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &device->name, "name"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &percentageNum, "volume-percentage"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &device->identifier, "identifier"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &percentageBar, "volume-percentage-bar"}, + FF_FORMAT_ARG(device->main, "is-main"), + FF_FORMAT_ARG(device->name, "name"), + FF_FORMAT_ARG(percentageNum, "volume-percentage"), + FF_FORMAT_ARG(device->identifier, "identifier"), + FF_FORMAT_ARG(percentageBar, "volume-percentage-bar"), })); } } diff --git a/src/modules/swap/swap.c b/src/modules/swap/swap.c index d3e9817794..6666a9c6ee 100644 --- a/src/modules/swap/swap.c +++ b/src/modules/swap/swap.c @@ -70,10 +70,10 @@ void ffPrintSwap(FFSwapOptions* options) FF_STRBUF_AUTO_DESTROY percentageBar = ffStrbufCreate(); ffPercentAppendBar(&percentageBar, percentage, options->percent, &options->moduleArgs); FF_PRINT_FORMAT_CHECKED(FF_SWAP_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_SWAP_NUM_FORMAT_ARGS, ((FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_STRBUF, &usedPretty, "used"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &totalPretty, "total"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &percentageNum, "percentage"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &percentageBar, "percentage-bar"}, + FF_FORMAT_ARG(usedPretty, "used"), + FF_FORMAT_ARG(totalPretty, "total"), + FF_FORMAT_ARG(percentageNum, "percentage"), + FF_FORMAT_ARG(percentageBar, "percentage-bar"), })); } } diff --git a/src/modules/terminal/terminal.c b/src/modules/terminal/terminal.c index 97f15fad44..85fd84af74 100644 --- a/src/modules/terminal/terminal.c +++ b/src/modules/terminal/terminal.c @@ -30,14 +30,14 @@ void ffPrintTerminal(FFTerminalOptions* options) else { FF_PRINT_FORMAT_CHECKED(FF_TERMINAL_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_TERMINAL_NUM_FORMAT_ARGS, ((FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_STRBUF, &result->processName, "process-name"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result->exe, "exe"}, - {FF_FORMAT_ARG_TYPE_STRING, result->exeName, "exe-name"}, - {FF_FORMAT_ARG_TYPE_UINT, &result->pid, "pid"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result->prettyName, "pretty-name"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result->version, "version"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result->exePath, "exe-path"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result->tty, "tty"}, + FF_FORMAT_ARG(result->processName, "process-name"), + FF_FORMAT_ARG(result->exe, "exe"), + FF_FORMAT_ARG(result->exeName, "exe-name"), + FF_FORMAT_ARG(result->pid, "pid"), + FF_FORMAT_ARG(result->prettyName, "pretty-name"), + FF_FORMAT_ARG(result->version, "version"), + FF_FORMAT_ARG(result->exePath, "exe-path"), + FF_FORMAT_ARG(result->tty, "tty"), })); } } diff --git a/src/modules/terminalfont/terminalfont.c b/src/modules/terminalfont/terminalfont.c index 87e772c312..a686babe54 100644 --- a/src/modules/terminalfont/terminalfont.c +++ b/src/modules/terminalfont/terminalfont.c @@ -34,10 +34,10 @@ void ffPrintTerminalFont(FFTerminalFontOptions* options) else { FF_PRINT_FORMAT_CHECKED(FF_TERMINALFONT_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_TERMINALFONT_NUM_FORMAT_ARGS, ((FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_STRBUF, &terminalFont.font.pretty, "combined"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &terminalFont.font.name, "name"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &terminalFont.font.size, "size"}, - {FF_FORMAT_ARG_TYPE_LIST, &terminalFont.font.styles, "styles"}, + FF_FORMAT_ARG(terminalFont.font.pretty, "combined"), + FF_FORMAT_ARG(terminalFont.font.name, "name"), + FF_FORMAT_ARG(terminalFont.font.size, "size"), + FF_FORMAT_ARG(terminalFont.font.styles, "styles"), })); } } diff --git a/src/modules/terminalsize/terminalsize.c b/src/modules/terminalsize/terminalsize.c index db2f2e4799..71272281e1 100644 --- a/src/modules/terminalsize/terminalsize.c +++ b/src/modules/terminalsize/terminalsize.c @@ -30,10 +30,10 @@ void ffPrintTerminalSize(FFTerminalSizeOptions* options) else { FF_PRINT_FORMAT_CHECKED(FF_TERMINALSIZE_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_TERMINALSIZE_NUM_FORMAT_ARGS, ((FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_UINT16, &result.rows, "rows"}, - {FF_FORMAT_ARG_TYPE_UINT16, &result.columns, "columns"}, - {FF_FORMAT_ARG_TYPE_UINT16, &result.width, "width"}, - {FF_FORMAT_ARG_TYPE_UINT16, &result.height, "height"}, + FF_FORMAT_ARG(result.rows, "rows"), + FF_FORMAT_ARG(result.columns, "columns"), + FF_FORMAT_ARG(result.width, "width"), + FF_FORMAT_ARG(result.height, "height"), })); } } diff --git a/src/modules/terminaltheme/terminaltheme.c b/src/modules/terminaltheme/terminaltheme.c index ab0bde18f9..93e7029181 100644 --- a/src/modules/terminaltheme/terminaltheme.c +++ b/src/modules/terminaltheme/terminaltheme.c @@ -30,13 +30,15 @@ void ffPrintTerminalTheme(FFTerminalThemeOptions* options) else { char fg[32], bg[32]; + const char* fgType = result.fg.dark ? "Dark" : "Light"; + const char* bgType = result.bg.dark ? "Dark" : "Light"; snprintf(fg, sizeof(fg), "#%02" PRIX16 "%02" PRIX16 "%02" PRIX16, result.fg.r, result.fg.g, result.fg.b); snprintf(bg, sizeof(bg), "#%02" PRIX16 "%02" PRIX16 "%02" PRIX16, result.bg.r, result.bg.g, result.bg.b); FF_PRINT_FORMAT_CHECKED(FF_TERMINALTHEME_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_TERMINALTHEME_NUM_FORMAT_ARGS, ((FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_STRING, fg, "fg-color"}, - {FF_FORMAT_ARG_TYPE_STRING, result.fg.dark ? "Dark" : "Light", "fg-type"}, - {FF_FORMAT_ARG_TYPE_STRING, bg, "bg-color"}, - {FF_FORMAT_ARG_TYPE_STRING, result.bg.dark ? "Dark" : "Light", "bg-type"}, + FF_FORMAT_ARG(fg, "fg-color"), + FF_FORMAT_ARG(fgType, "fg-type"), + FF_FORMAT_ARG(bg, "bg-color"), + FF_FORMAT_ARG(bgType, "bg-type"), })); } } diff --git a/src/modules/theme/theme.c b/src/modules/theme/theme.c index 8e90df093a..bef3c2594d 100644 --- a/src/modules/theme/theme.c +++ b/src/modules/theme/theme.c @@ -36,8 +36,8 @@ void ffPrintTheme(FFThemeOptions* options) else { FF_PRINT_FORMAT_CHECKED(FF_THEME_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_THEME_NUM_FORMAT_ARGS, ((FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_STRBUF, &result.theme1, "theme1"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result.theme2, "theme2"}, + FF_FORMAT_ARG(result.theme1, "theme1"), + FF_FORMAT_ARG(result.theme2, "theme2"), })); } diff --git a/src/modules/title/title.c b/src/modules/title/title.c index cf7c2fbffb..bd363ce5a9 100644 --- a/src/modules/title/title.c +++ b/src/modules/title/title.c @@ -57,14 +57,14 @@ void ffPrintTitle(FFTitleOptions* options) else { FF_PRINT_FORMAT_CHECKED(FF_TITLE_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_TITLE_NUM_FORMAT_ARGS, ((FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_STRBUF, &instance.state.platform.userName, "user-name"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &hostName, "host-name"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &instance.state.platform.homeDir, "home-dir"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &instance.state.platform.exePath, "exe-path"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &instance.state.platform.userShell, "user-shell"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &userNameColored, "user-name-colored"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &atColored, "at-symbol-colored"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &hostNameColored, "host-name-colored"}, + FF_FORMAT_ARG(instance.state.platform.userName, "user-name"), + FF_FORMAT_ARG(hostName, "host-name"), + FF_FORMAT_ARG(instance.state.platform.homeDir, "home-dir"), + FF_FORMAT_ARG(instance.state.platform.exePath, "exe-path"), + FF_FORMAT_ARG(instance.state.platform.userShell, "user-shell"), + FF_FORMAT_ARG(userNameColored, "user-name-colored"), + FF_FORMAT_ARG(atColored, "at-symbol-colored"), + FF_FORMAT_ARG(hostNameColored, "host-name-colored"), })); } } diff --git a/src/modules/uptime/uptime.c b/src/modules/uptime/uptime.c index a9f91d8bdc..caccc1f86a 100644 --- a/src/modules/uptime/uptime.c +++ b/src/modules/uptime/uptime.c @@ -79,12 +79,12 @@ void ffPrintUptime(FFUptimeOptions* options) else { FF_PRINT_FORMAT_CHECKED(FF_UPTIME_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_UPTIME_NUM_FORMAT_ARGS, ((FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_UINT, &days, "days"}, - {FF_FORMAT_ARG_TYPE_UINT, &hours, "hours"}, - {FF_FORMAT_ARG_TYPE_UINT, &minutes, "minutes"}, - {FF_FORMAT_ARG_TYPE_UINT, &seconds, "seconds"}, - {FF_FORMAT_ARG_TYPE_UINT, &milliseconds, "milliseconds"}, - {FF_FORMAT_ARG_TYPE_STRING, ffTimeToShortStr(result.uptime), "boot-time"}, + FF_FORMAT_ARG(days, "days"), + FF_FORMAT_ARG(hours, "hours"), + FF_FORMAT_ARG(minutes, "minutes"), + FF_FORMAT_ARG(seconds, "seconds"), + FF_FORMAT_ARG(milliseconds, "milliseconds"), + {FF_FORMAT_ARG_TYPE_STRING, ffTimeToShortStr(result.bootTime), "boot-time"}, })); } } diff --git a/src/modules/users/users.c b/src/modules/users/users.c index adbef14e40..3c7db48e0c 100644 --- a/src/modules/users/users.c +++ b/src/modules/users/users.c @@ -69,10 +69,10 @@ void ffPrintUsers(FFUsersOptions* options) FFUserResult* user = (FFUserResult*)ffListGet(&users, i); FF_PRINT_FORMAT_CHECKED(FF_USERS_MODULE_NAME, users.length == 1 ? 0 : (uint8_t) (i + 1), &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_USERS_NUM_FORMAT_ARGS, ((FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_STRBUF, &user->name, "name"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &user->hostName, "host-name"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &user->sessionName, "session-name"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &user->clientIp, "client-ip"}, + FF_FORMAT_ARG(user->name, "name"), + FF_FORMAT_ARG(user->hostName, "host-name"), + FF_FORMAT_ARG(user->sessionName, "session-name"), + FF_FORMAT_ARG(user->clientIp, "client-ip"), {FF_FORMAT_ARG_TYPE_STRING, ffTimeToShortStr(user->loginTime), "login-time"}, })); } diff --git a/src/modules/version/version.c b/src/modules/version/version.c index f3df9f3991..73b5e7ddee 100644 --- a/src/modules/version/version.c +++ b/src/modules/version/version.c @@ -30,17 +30,18 @@ void ffPrintVersion(FFVersionOptions* options) } } + const char* buildType = result->debugMode ? "debug" : "release"; FF_PRINT_FORMAT_CHECKED(FF_VERSION_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_VERSION_NUM_FORMAT_ARGS, ((FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_STRING, result->projectName, "project-name"}, - {FF_FORMAT_ARG_TYPE_STRING, result->version, "version"}, - {FF_FORMAT_ARG_TYPE_STRING, result->versionTweak, "version-tweak"}, - {FF_FORMAT_ARG_TYPE_STRING, result->debugMode ? "debug" : "release", "build-type"}, - {FF_FORMAT_ARG_TYPE_STRING, result->sysName, "sysname"}, - {FF_FORMAT_ARG_TYPE_STRING, result->architecture, "arch"}, - {FF_FORMAT_ARG_TYPE_STRING, result->cmakeBuiltType, "cmake-built-type"}, - {FF_FORMAT_ARG_TYPE_STRING, result->compileTime, "compile-time"}, - {FF_FORMAT_ARG_TYPE_STRING, result->compiler, "compiler"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &buf, "libc-used"}, + FF_FORMAT_ARG(result->projectName, "project-name"), + FF_FORMAT_ARG(result->version, "version"), + FF_FORMAT_ARG(result->versionTweak, "version-tweak"), + FF_FORMAT_ARG(buildType, "build-type"), + FF_FORMAT_ARG(result->sysName, "sysname"), + FF_FORMAT_ARG(result->architecture, "arch"), + FF_FORMAT_ARG(result->cmakeBuiltType, "cmake-built-type"), + FF_FORMAT_ARG(result->compileTime, "compile-time"), + FF_FORMAT_ARG(result->compiler, "compiler"), + FF_FORMAT_ARG(buf, "libc-used"), })); } } diff --git a/src/modules/vulkan/vulkan.c b/src/modules/vulkan/vulkan.c index 76e2bba260..dbafd7ef8d 100644 --- a/src/modules/vulkan/vulkan.c +++ b/src/modules/vulkan/vulkan.c @@ -44,10 +44,10 @@ void ffPrintVulkan(FFVulkanOptions* options) else { FF_PRINT_FORMAT_CHECKED(FF_VULKAN_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_VULKAN_NUM_FORMAT_ARGS, ((FFformatarg[]) { - {FF_FORMAT_ARG_TYPE_STRBUF, &vulkan->driver, "driver"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &vulkan->apiVersion, "api-version"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &vulkan->conformanceVersion, "conformance-version"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &vulkan->instanceVersion, "instance-version"}, + FF_FORMAT_ARG(vulkan->driver, "driver"), + FF_FORMAT_ARG(vulkan->apiVersion, "api-version"), + FF_FORMAT_ARG(vulkan->conformanceVersion, "conformance-version"), + FF_FORMAT_ARG(vulkan->instanceVersion, "instance-version"), })); } } diff --git a/src/modules/wallpaper/wallpaper.c b/src/modules/wallpaper/wallpaper.c index 4461c63c73..901cdd12ed 100644 --- a/src/modules/wallpaper/wallpaper.c +++ b/src/modules/wallpaper/wallpaper.c @@ -36,8 +36,8 @@ void ffPrintWallpaper(FFWallpaperOptions* options) else { FF_PRINT_FORMAT_CHECKED(FF_WALLPAPER_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_WALLPAPER_NUM_FORMAT_ARGS, ((FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_STRING, filename, "file-name"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &fullpath, "full-path"}, + FF_FORMAT_ARG(filename, "file-name"), + FF_FORMAT_ARG(fullpath, "full-path"), })); } } diff --git a/src/modules/weather/weather.c b/src/modules/weather/weather.c index 14bb669a2c..c46ea38997 100644 --- a/src/modules/weather/weather.c +++ b/src/modules/weather/weather.c @@ -26,7 +26,7 @@ void ffPrintWeather(FFWeatherOptions* options) else { FF_PRINT_FORMAT_CHECKED(FF_WEATHER_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_WEATHER_NUM_FORMAT_ARGS, ((FFformatarg[]) { - {FF_FORMAT_ARG_TYPE_STRBUF, &result, "result"}, + FF_FORMAT_ARG(result, "result"), })); } } diff --git a/src/modules/wifi/wifi.c b/src/modules/wifi/wifi.c index fa2ddb05d9..ace8340a18 100644 --- a/src/modules/wifi/wifi.c +++ b/src/modules/wifi/wifi.c @@ -81,17 +81,17 @@ void ffPrintWifi(FFWifiOptions* options) FF_STRBUF_AUTO_DESTROY percentBar = ffStrbufCreate(); ffPercentAppendBar(&percentBar, item->conn.signalQuality, options->percent, &options->moduleArgs); FF_PRINT_FORMAT_CHECKED(FF_WIFI_MODULE_NAME, moduleIndex, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_WIFI_NUM_FORMAT_ARGS, ((FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_STRBUF, &item->inf.description, "inf-desc"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &item->inf.status, "inf-status"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &item->conn.status, "status"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &item->conn.ssid, "ssid"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &item->conn.bssid, "bssid"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &item->conn.protocol, "protocol"}, - {FF_FORMAT_ARG_TYPE_DOUBLE, &percentNum, "signal-quality"}, - {FF_FORMAT_ARG_TYPE_DOUBLE, &item->conn.rxRate, "rx-rate"}, - {FF_FORMAT_ARG_TYPE_DOUBLE, &item->conn.txRate, "tx-rate"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &item->conn.security, "security"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &percentBar, "signal-quality-bar"}, + FF_FORMAT_ARG(item->inf.description, "inf-desc"), + FF_FORMAT_ARG(item->inf.status, "inf-status"), + FF_FORMAT_ARG(item->conn.status, "status"), + FF_FORMAT_ARG(item->conn.ssid, "ssid"), + FF_FORMAT_ARG(item->conn.bssid, "bssid"), + FF_FORMAT_ARG(item->conn.protocol, "protocol"), + FF_FORMAT_ARG(percentNum, "signal-quality"), + FF_FORMAT_ARG(item->conn.rxRate, "rx-rate"), + FF_FORMAT_ARG(item->conn.txRate, "tx-rate"), + FF_FORMAT_ARG(item->conn.security, "security"), + FF_FORMAT_ARG(percentBar, "signal-quality-bar"), })); } diff --git a/src/modules/wm/wm.c b/src/modules/wm/wm.c index 849053367d..97dba1941f 100644 --- a/src/modules/wm/wm.c +++ b/src/modules/wm/wm.c @@ -46,10 +46,10 @@ void ffPrintWM(FFWMOptions* options) else { FF_PRINT_FORMAT_CHECKED(FF_WM_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_WM_NUM_FORMAT_ARGS, ((FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_STRBUF, &result->wmProcessName, "process-name"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result->wmPrettyName, "pretty-name"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result->wmProtocolName, "protocol-name"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &pluginName, "plugin-name"}, + FF_FORMAT_ARG(result->wmProcessName, "process-name"), + FF_FORMAT_ARG(result->wmPrettyName, "pretty-name"), + FF_FORMAT_ARG(result->wmProtocolName, "protocol-name"), + FF_FORMAT_ARG(pluginName, "plugin-name"), })); } } diff --git a/src/modules/wmtheme/wmtheme.c b/src/modules/wmtheme/wmtheme.c index 5234f2b148..6f81c89ad2 100644 --- a/src/modules/wmtheme/wmtheme.c +++ b/src/modules/wmtheme/wmtheme.c @@ -20,7 +20,7 @@ void ffPrintWMTheme(FFWMThemeOptions* options) else { FF_PRINT_FORMAT_CHECKED(FF_WMTHEME_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_WMTHEME_NUM_FORMAT_ARGS, ((FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_STRBUF, &themeOrError, "result"}, + FF_FORMAT_ARG(themeOrError, "result"), })); } } diff --git a/src/modules/zpool/zpool.c b/src/modules/zpool/zpool.c index 6a9b8780f2..66a59f2913 100644 --- a/src/modules/zpool/zpool.c +++ b/src/modules/zpool/zpool.c @@ -20,9 +20,10 @@ static void printZpool(FFZpoolOptions* options, FFZpoolResult* result, uint8_t i else { ffStrbufClear(&buffer); - FF_PARSE_FORMAT_STRING_CHECKED(&buffer, &options->moduleArgs.key, 2, ((FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_UINT8, &index, "index"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result->name, "name"}, + FF_PARSE_FORMAT_STRING_CHECKED(&buffer, &options->moduleArgs.key, 3, ((FFformatarg[]){ + FF_FORMAT_ARG(index, "index"), + FF_FORMAT_ARG(result->name, "name"), + FF_FORMAT_ARG(options->moduleArgs.keyIcon, "icon"), })); } @@ -60,14 +61,14 @@ static void printZpool(FFZpoolOptions* options, FFZpoolResult* result, uint8_t i ffPercentAppendBar(&fragPercentageBar, fragPercentage, options->percent, &options->moduleArgs); FF_PRINT_FORMAT_CHECKED(buffer.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_ZPOOL_NUM_FORMAT_ARGS, ((FFformatarg[]) { - {FF_FORMAT_ARG_TYPE_STRBUF, &result->name, "name"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result->state, "state"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &usedPretty, "size-used"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &totalPretty, "size-total"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &bytesPercentageNum, "size-percentage"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &fragPercentage, "frag-percentage"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &bytesPercentageBar, "size-percentage-bar"}, - {FF_FORMAT_ARG_TYPE_STRBUF, &fragPercentageBar, "frag-percentage-bar"}, + FF_FORMAT_ARG(result->name, "name"), + FF_FORMAT_ARG(result->state, "state"), + FF_FORMAT_ARG(usedPretty, "size-used"), + FF_FORMAT_ARG(totalPretty, "size-total"), + FF_FORMAT_ARG(bytesPercentageNum, "size-percentage"), + FF_FORMAT_ARG(fragPercentage, "frag-percentage"), + FF_FORMAT_ARG(bytesPercentageBar, "size-percentage-bar"), + FF_FORMAT_ARG(fragPercentageBar, "frag-percentage-bar"), })); } } diff --git a/src/options/library.c b/src/options/library.c deleted file mode 100644 index 6ca05b573d..0000000000 --- a/src/options/library.c +++ /dev/null @@ -1,239 +0,0 @@ -#include "fastfetch.h" -#include "common/jsonconfig.h" -#include "options/general.h" -#include "util/stringUtils.h" - -const char* ffOptionsParseLibraryJsonConfig(FFOptionsLibrary* options, yyjson_val* root) -{ - yyjson_val* object = yyjson_obj_get(root, "library"); - if (!object) return NULL; - if (!yyjson_is_obj(object)) return "Property 'library' must be an object"; - - yyjson_val *key_, *val; - size_t idx, max; - yyjson_obj_foreach(object, idx, max, key_, val) - { - const char* key = yyjson_get_str(key_); - - if (ffStrEqualsIgnCase(key, "vulkan")) - ffStrbufSetS(&options->libVulkan, yyjson_get_str(val)); - else if (ffStrEqualsIgnCase(key, "opencl")) - ffStrbufSetS(&options->libOpenCL, yyjson_get_str(val)); - else if (ffStrEqualsIgnCase(key, "sqlite") || ffStrEqualsIgnCase(key, "sqlite3")) - ffStrbufSetS(&options->libSQLite3, yyjson_get_str(val)); - else if (ffStrEqualsIgnCase(key, "imagemagick")) - ffStrbufSetS(&options->libImageMagick, yyjson_get_str(val)); - else if (ffStrEqualsIgnCase(key, "chafa")) - ffStrbufSetS(&options->libChafa, yyjson_get_str(val)); - else if (ffStrEqualsIgnCase(key, "z")) - ffStrbufSetS(&options->libZ, yyjson_get_str(val)); - else if (ffStrEqualsIgnCase(key, "egl")) - ffStrbufSetS(&options->libEGL, yyjson_get_str(val)); - -#ifdef __ANDROID__ - else if (ffStrEqualsIgnCase(key, "freetype")) - ffStrbufSetS(&options->libfreetype, yyjson_get_str(val)); -#endif - -#if defined(__linux__) || defined(__FreeBSD__) || defined(__sun) - else if (ffStrEqualsIgnCase(key, "wayland")) - ffStrbufSetS(&options->libWayland, yyjson_get_str(val)); - else if (ffStrEqualsIgnCase(key, "xcbRandr")) - ffStrbufSetS(&options->libXcbRandr, yyjson_get_str(val)); - else if (ffStrEqualsIgnCase(key, "xcb")) - ffStrbufSetS(&options->libXcb, yyjson_get_str(val)); - else if (ffStrEqualsIgnCase(key, "Xrandr")) - ffStrbufSetS(&options->libXrandr, yyjson_get_str(val)); - else if (ffStrEqualsIgnCase(key, "X11")) - ffStrbufSetS(&options->libX11, yyjson_get_str(val)); - else if (ffStrEqualsIgnCase(key, "gio")) - ffStrbufSetS(&options->libGIO, yyjson_get_str(val)); - else if (ffStrEqualsIgnCase(key, "DConf")) - ffStrbufSetS(&options->libDConf, yyjson_get_str(val)); - else if (ffStrEqualsIgnCase(key, "dbus")) - ffStrbufSetS(&options->libDBus, yyjson_get_str(val)); - else if (ffStrEqualsIgnCase(key, "XFConf")) - ffStrbufSetS(&options->libXFConf, yyjson_get_str(val)); - else if (ffStrEqualsIgnCase(key, "rpm")) - ffStrbufSetS(&options->librpm, yyjson_get_str(val)); - else if (ffStrEqualsIgnCase(key, "glx")) - ffStrbufSetS(&options->libGLX, yyjson_get_str(val)); - else if (ffStrEqualsIgnCase(key, "osmesa")) - ffStrbufSetS(&options->libOSMesa, yyjson_get_str(val)); - else if (ffStrEqualsIgnCase(key, "pulse")) - ffStrbufSetS(&options->libPulse, yyjson_get_str(val)); - else if (ffStrEqualsIgnCase(key, "ddcutil")) - ffStrbufSetS(&options->libDdcutil, yyjson_get_str(val)); - else if (ffStrEqualsIgnCase(key, "drm")) - ffStrbufSetS(&options->libdrm, yyjson_get_str(val)); - else if (ffStrEqualsIgnCase(key, "elf")) - ffStrbufSetS(&options->libelf, yyjson_get_str(val)); -#endif - - else - return "Unknown library property"; - } - - return NULL; -} - -bool ffOptionsParseLibraryCommandLine(FFOptionsLibrary* options, const char* key, const char* value) -{ - if(ffStrStartsWithIgnCase(key, "--lib-")) - { - const char* subkey = key + strlen("--lib-"); - if(ffStrEqualsIgnCase(subkey, "vulkan")) - ffOptionParseString(key, value, &options->libVulkan); - else if(ffStrEqualsIgnCase(subkey, "opencl")) - ffOptionParseString(key, value, &options->libOpenCL); - else if(ffStrEqualsIgnCase(subkey, "sqlite") || ffStrEqualsIgnCase(subkey, "sqlite3")) - ffOptionParseString(key, value, &options->libSQLite3); - else if(ffStrEqualsIgnCase(subkey, "imagemagick")) - ffOptionParseString(key, value, &options->libImageMagick); - else if(ffStrEqualsIgnCase(subkey, "chafa")) - ffOptionParseString(key, value, &options->libChafa); - else if(ffStrEqualsIgnCase(subkey, "z")) - ffOptionParseString(key, value, &options->libZ); - else if(ffStrEqualsIgnCase(subkey, "egl")) - ffOptionParseString(key, value, &options->libEGL); - -#ifdef __ANDROID__ - else if(ffStrEqualsIgnCase(subkey, "freetype")) - ffOptionParseString(key, value, &options->libfreetype); -#endif - -#if defined(__linux__) || defined(__FreeBSD__) || defined(__sun) - else if(ffStrEqualsIgnCase(subkey, "wayland")) - ffOptionParseString(key, value, &options->libWayland); - else if(ffStrEqualsIgnCase(subkey, "xcbRandr")) - ffOptionParseString(key, value, &options->libXcbRandr); - else if(ffStrEqualsIgnCase(subkey, "xcb")) - ffOptionParseString(key, value, &options->libXcb); - else if(ffStrEqualsIgnCase(subkey, "Xrandr")) - ffOptionParseString(key, value, &options->libXrandr); - else if(ffStrEqualsIgnCase(subkey, "X11")) - ffOptionParseString(key, value, &options->libX11); - else if(ffStrEqualsIgnCase(subkey, "gio")) - ffOptionParseString(key, value, &options->libGIO); - else if(ffStrEqualsIgnCase(subkey, "DConf")) - ffOptionParseString(key, value, &options->libDConf); - else if(ffStrEqualsIgnCase(subkey, "dbus")) - ffOptionParseString(key, value, &options->libDBus); - else if(ffStrEqualsIgnCase(subkey, "XFConf")) - ffOptionParseString(key, value, &options->libXFConf); - else if(ffStrEqualsIgnCase(subkey, "rpm")) - ffOptionParseString(key, value, &options->librpm); - else if(ffStrEqualsIgnCase(subkey, "glx")) - ffOptionParseString(key, value, &options->libGLX); - else if(ffStrEqualsIgnCase(subkey, "osmesa")) - ffOptionParseString(key, value, &options->libOSMesa); - else if(ffStrEqualsIgnCase(subkey, "pulse")) - ffOptionParseString(key, value, &options->libPulse); - else if(ffStrEqualsIgnCase(subkey, "ddcutil")) - ffOptionParseString(key, value, &options->libDdcutil); - else if(ffStrEqualsIgnCase(subkey, "drm")) - ffOptionParseString(key, value, &options->libdrm); - else if(ffStrEqualsIgnCase(subkey, "elf")) - ffOptionParseString(key, value, &options->libelf); -#endif - - else - return false; - } - else - return false; - - return true; -} - -void ffOptionsInitLibrary(FFOptionsLibrary* options) -{ - static_assert(sizeof(*options) % sizeof(FFstrbuf) == 0, "FFOptionsLibrary is not aligned"); - for (FFstrbuf* pBuf = (void*) options; pBuf < (FFstrbuf*) (options + 1); pBuf++) - ffStrbufInit(pBuf); -} - -void ffOptionsDestroyLibrary(FFOptionsLibrary* options) -{ - for (FFstrbuf* pBuf = (void*) options; pBuf < (FFstrbuf*) (options + 1); pBuf++) - ffStrbufDestroy(pBuf); -} - -void ffOptionsGenerateLibraryJsonConfig(FFOptionsLibrary* options, yyjson_mut_doc* doc) -{ - __attribute__((__cleanup__(ffOptionsDestroyLibrary))) FFOptionsLibrary defaultOptions; - ffOptionsInitLibrary(&defaultOptions); - - yyjson_mut_val* obj = yyjson_mut_obj(doc); - - if (!ffStrbufEqual(&options->libVulkan, &defaultOptions.libVulkan)) - yyjson_mut_obj_add_strbuf(doc, obj, "vulkan", &options->libVulkan); - - if (!ffStrbufEqual(&options->libOpenCL, &defaultOptions.libOpenCL)) - yyjson_mut_obj_add_strbuf(doc, obj, "OpenCL", &options->libOpenCL); - - if (!ffStrbufEqual(&options->libSQLite3, &defaultOptions.libSQLite3)) - yyjson_mut_obj_add_strbuf(doc, obj, "sqlite", &options->libSQLite3); - - if (!ffStrbufEqual(&options->libImageMagick, &defaultOptions.libImageMagick)) - yyjson_mut_obj_add_strbuf(doc, obj, "ImageMagick", &options->libImageMagick); - - if (!ffStrbufEqual(&options->libChafa, &defaultOptions.libChafa)) - yyjson_mut_obj_add_strbuf(doc, obj, "chafa", &options->libChafa); - - if (!ffStrbufEqual(&options->libZ, &defaultOptions.libZ)) - yyjson_mut_obj_add_strbuf(doc, obj, "z", &options->libZ); - - if (!ffStrbufEqual(&options->libEGL, &defaultOptions.libEGL)) - yyjson_mut_obj_add_strbuf(doc, obj, "egl", &options->libEGL); - -#if defined(__linux__) || defined(__FreeBSD__) || defined(__sun) - if (!ffStrbufEqual(&options->libWayland, &defaultOptions.libWayland)) - yyjson_mut_obj_add_strbuf(doc, obj, "wayland", &options->libWayland); - - if (!ffStrbufEqual(&options->libXcbRandr, &defaultOptions.libXcbRandr)) - yyjson_mut_obj_add_strbuf(doc, obj, "xcbRandr", &options->libXcbRandr); - - if (!ffStrbufEqual(&options->libXcb, &defaultOptions.libXcb)) - yyjson_mut_obj_add_strbuf(doc, obj, "xcb", &options->libXcb); - - if (!ffStrbufEqual(&options->libXrandr, &defaultOptions.libXrandr)) - yyjson_mut_obj_add_strbuf(doc, obj, "Xrandr", &options->libXrandr); - - if (!ffStrbufEqual(&options->libX11, &defaultOptions.libX11)) - yyjson_mut_obj_add_strbuf(doc, obj, "X11", &options->libX11); - - if (!ffStrbufEqual(&options->libGIO, &defaultOptions.libGIO)) - yyjson_mut_obj_add_strbuf(doc, obj, "gio", &options->libGIO); - - if (!ffStrbufEqual(&options->libDConf, &defaultOptions.libDConf)) - yyjson_mut_obj_add_strbuf(doc, obj, "DConf", &options->libDConf); - - if (!ffStrbufEqual(&options->libDBus, &defaultOptions.libDBus)) - yyjson_mut_obj_add_strbuf(doc, obj, "dbus", &options->libDBus); - - if (!ffStrbufEqual(&options->libXFConf, &defaultOptions.libXFConf)) - yyjson_mut_obj_add_strbuf(doc, obj, "XFConf", &options->libXFConf); - - if (!ffStrbufEqual(&options->librpm, &defaultOptions.librpm)) - yyjson_mut_obj_add_strbuf(doc, obj, "rpm", &options->librpm); - - if (!ffStrbufEqual(&options->libGLX, &defaultOptions.libGLX)) - yyjson_mut_obj_add_strbuf(doc, obj, "glx", &options->libGLX); - - if (!ffStrbufEqual(&options->libOSMesa, &defaultOptions.libOSMesa)) - yyjson_mut_obj_add_strbuf(doc, obj, "OSMesa", &options->libOSMesa); - - if (!ffStrbufEqual(&options->libPulse, &defaultOptions.libPulse)) - yyjson_mut_obj_add_strbuf(doc, obj, "pulse", &options->libPulse); - - if (!ffStrbufEqual(&options->libDdcutil, &defaultOptions.libDdcutil)) - yyjson_mut_obj_add_strbuf(doc, obj, "ddcutil", &options->libDdcutil); - - if (!ffStrbufEqual(&options->libdrm, &defaultOptions.libdrm)) - yyjson_mut_obj_add_strbuf(doc, obj, "drm", &options->libdrm); -#endif - - if (yyjson_mut_obj_size(obj) > 0) - yyjson_mut_obj_add_val(doc, doc->root, "library", obj); -} diff --git a/src/options/library.h b/src/options/library.h deleted file mode 100644 index db96af2a57..0000000000 --- a/src/options/library.h +++ /dev/null @@ -1,43 +0,0 @@ -#pragma once - -#include "util/FFstrbuf.h" - -typedef struct FFOptionsLibrary -{ - FFstrbuf libVulkan; - FFstrbuf libOpenCL; - FFstrbuf libSQLite3; - FFstrbuf libImageMagick; - FFstrbuf libChafa; - FFstrbuf libZ; - FFstrbuf libEGL; - -#ifdef __ANDROID__ - FFstrbuf libfreetype; -#endif - -#if defined(__linux__) || defined(__FreeBSD__) || defined(__sun) - FFstrbuf libWayland; - FFstrbuf libXcbRandr; - FFstrbuf libXcb; - FFstrbuf libXrandr; - FFstrbuf libX11; - FFstrbuf libGIO; - FFstrbuf libDConf; - FFstrbuf libDBus; - FFstrbuf libXFConf; - FFstrbuf librpm; - FFstrbuf libGLX; - FFstrbuf libOSMesa; - FFstrbuf libPulse; - FFstrbuf libDdcutil; - FFstrbuf libdrm; - FFstrbuf libelf; -#endif -} FFOptionsLibrary; - -const char* ffOptionsParseLibraryJsonConfig(FFOptionsLibrary* options, yyjson_val* root); -bool ffOptionsParseLibraryCommandLine(FFOptionsLibrary* options, const char* key, const char* value); -void ffOptionsInitLibrary(FFOptionsLibrary* options); -void ffOptionsDestroyLibrary(FFOptionsLibrary* options); -void ffOptionsGenerateLibraryJsonConfig(FFOptionsLibrary* options, yyjson_mut_doc* doc); diff --git a/src/util/binary_linux.c b/src/util/binary_linux.c index b3be2b8050..e5c7f5c982 100644 --- a/src/util/binary_linux.c +++ b/src/util/binary_linux.c @@ -1,12 +1,12 @@ #include "binary.h" -#if defined(FF_HAVE_ELF) || defined(__sun) +#if defined(FF_HAVE_ELF) || defined(__sun) || defined(__FreeBSD__) #include "common/io/io.h" #include "common/library.h" #include "util/stringUtils.h" -#include +#include // #1254 #include struct FFElfData { @@ -28,7 +28,7 @@ const char* ffBinaryExtractStrings(const char* elfFile, bool (*cb)(const char* s if (!elfData.inited) { elfData.inited = true; - FF_LIBRARY_LOAD(libelf, &instance.config.library.libelf, "dlopen libelf" FF_LIBRARY_EXTENSION " failed", "libelf" FF_LIBRARY_EXTENSION, 1); + FF_LIBRARY_LOAD(libelf, "dlopen libelf" FF_LIBRARY_EXTENSION " failed", "libelf" FF_LIBRARY_EXTENSION, 1); FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libelf, elfData, elf_version) if (elfData.ffelf_version(EV_CURRENT) == EV_NONE) return "elf_version() failed"; diff --git a/tests/format.c b/tests/format.c index 173a5a298c..6b7d0a727a 100644 --- a/tests/format.c +++ b/tests/format.c @@ -69,10 +69,48 @@ int main(void) VERIFY("output({1n>20})", "12345 67890", "output({1n>20})"); VERIFY("output({120})", "12345 67890", "output({120})"); VERIFY("output({1:11})", "", "output()"); + VERIFY("output({2:2})", "", "output({2:2})"); + } + + { + VERIFY("output({1~0})", "12345 67890", "output(12345 67890)"); + VERIFY("output({1~1})", "12345 67890", "output(2345 67890)"); + VERIFY("output({1~10})", "12345 67890", "output(0)"); + VERIFY("output({1~20})", "12345 67890", "output()"); + VERIFY("output({1~-5})", "12345 67890", "output(67890)"); + VERIFY("output({1~-50})", "12345 67890", "output()"); + VERIFY("output({1~0,1})", "12345 67890", "output(1)"); + VERIFY("output({1~0,6})", "12345 67890", "output(12345 )"); + VERIFY("output({1~0,10})", "12345 67890", "output(12345 6789)"); + VERIFY("output({1~5,10})", "12345 67890", "output( 6789)"); + VERIFY("output({1~5,100})", "12345 67890", "output( 67890)"); + VERIFY("output({1~10,10})", "12345 67890", "output()"); + VERIFY("output({1~10,5})", "12345 67890", "output()"); + VERIFY("output({1~3,-3})", "12345 67890", "output(45 67)"); + VERIFY("output({1~-5,-3})", "12345 67890", "output(67)"); + VERIFY("output({1~-0,10})", "12345 67890", "output(12345 6789)"); + VERIFY("output({1~-3,-5})", "12345 67890", "output()"); + VERIFY("output({1~})", "12345 67890", "output(12345 67890)"); // Same as {1~0} + VERIFY("output({1~-0})", "12345 67890", "output(12345 67890)"); // Same as {1~0} + VERIFY("output({1~,-1})", "12345 67890", "output(12345 6789)"); // Same as {1~0,-1} + VERIFY("output({1~,})", "12345 67890", "output()"); // Same as {1~0,0} + } + + { + VERIFY("output({1n~0})", "12345 67890", "output({1n~0})"); + VERIFY("output({1~<0})", "12345 67890", "output({1~<0})"); + VERIFY("output({1~-})", "12345 67890", "output({1~-})"); + VERIFY("output({1~-,1})", "12345 67890", "output({1~-,1})"); + VERIFY("output({1~0,,1})", "12345 67890", "output({1~0,,1})"); + VERIFY("output({1~0,1,})", "12345 67890", "output({1~0,1,})"); + VERIFY("output({1~,0,1})", "12345 67890", "output({1~,0,1})"); + VERIFY("output({2,0})", "12345 67890", "output({2,0})"); } { VERIFY("output({1:20}{1<20}{1>20})", "12345 67890", "output(12345 6789012345 67890 12345 67890)"); + VERIFY("output({?1}OK{?}{/1}NOT OK{/})", "12345 67890", "output(OK)"); + VERIFY("output({?1}OK{?}{/1}NOT OK{/})", "", "output(NOT OK)"); } //Success