Compare commits

...

32 Commits

Author SHA1 Message Date
Carter Li d5b91a8983 Merge pull request #758 from fastfetch-cli/dev
Release: v2.8.9
2024-03-15 09:50:54 +08:00
李通洲 72fee13112 Release: v2.8.9 2024-03-15 09:21:13 +08:00
李通洲 20ae897f39 fastfetch: remove unused #includes 2024-03-15 08:37:58 +08:00
李通洲 6f756d103f Doc: update changelog 2024-03-14 20:43:17 +08:00
李通洲 c9dd858ce3 CPU (Linux): bing cpuMHz back
It's used in WSL
2024-03-14 20:40:40 +08:00
李通洲 2e201eaaf7 CPU: bring min frequency back & code optimizations 2024-03-14 19:24:03 +08:00
李通洲 7c54dcba69 CPU (Linux): fix detection when .../base_frequency doesn't exist 2024-03-14 10:32:34 +08:00
李通洲 a107395707 Logo (Chafa): fix blurry result when specifying both width and height
Who knows why it was coded like that

Fix #757
2024-03-14 10:18:17 +08:00
李通洲 8a9fe22855 Logo: fix proxmox
Fix #756
2024-03-13 23:58:40 +08:00
李通洲 7e04e23528 CPU: rename min frequency to base frequency 2024-03-13 23:42:59 +08:00
李通洲 8d779f68f3 CPU: detect base frequency 2024-03-13 23:41:11 +08:00
李通洲 98ba08c1a0 CI (macOS): fix build 2024-03-13 10:37:45 +08:00
李通洲 a1499b82f8 Doc: update changelog 2024-03-13 08:44:09 +08:00
李通洲 c6c866d78a Host (Apple): add MacBook Air 2024 2024-03-12 18:27:02 +08:00
李通洲 7a6999bd20 Fastfetch: print final new line in --format json 2024-03-09 12:07:07 +08:00
李通洲 1084cf3523 Terminal (Linux): actually ignore SessionLeader 2024-03-09 11:52:31 +08:00
Carter Li ed5f2a3968 Chore: update screenshots 2024-03-08 15:58:47 +08:00
Carter Li 17e1d4b72d Package: update debian stuff 2024-03-08 10:03:31 +08:00
Carter Li 912f6c4f3c Merge pull request #752 from fastfetch-cli/dev
Release: v2.8.8
2024-03-08 09:54:06 +08:00
李通洲 77d71b5fef Doc: update changelog 2024-03-08 09:36:35 +08:00
Carter Li 6938a73a8a Users (Linux): fix detection of client ip 2024-03-08 09:17:40 +08:00
李通洲 cee9df189d Release: v2.8.8 2024-03-08 08:40:40 +08:00
李通洲 2a125e226b Terminal (Linux): ignore SessionLeader
I don't know why it's there, but let's ignore it for now
2024-03-07 22:38:03 +08:00
李通洲 4a7e60ef57 CPU (Linux): don't crash if /sys/devices/system/cpu/cpufreq/ doesn't exist
Ref: #750
2024-03-07 21:31:23 +08:00
李通洲 0a6140346e DisplayServer (Linux): fix old libdrm version compatibility
Ref: #748
2024-03-07 19:20:56 +08:00
Carter Li 01862ebc04 Display (Linux): fix width being detected as height when using libdrm 2024-03-07 14:39:13 +08:00
李通洲 3185299214 Doc: update changelog 2024-03-07 14:00:57 +08:00
李通洲 5b6ebe4f11 Doc: update README 2024-03-07 13:56:40 +08:00
李通洲 6274ef591b Vulkan: try fixing old vulkan-header library compatibility
Ref: #748
2024-03-07 13:34:31 +08:00
李通洲 7acdaebee4 Printing: merge ffPrintError and ffPrintErrorString 2024-03-07 11:10:18 +08:00
李通洲 6dcfb6b88f Fastfetch: fully resolve the format arg num issue
Ref: #749
2024-03-07 10:47:28 +08:00
李通洲 064972aecd Disk: fix segfault with --help disk-format
Fix #749
2024-03-07 09:04:22 +08:00
86 changed files with 628 additions and 538 deletions
+1 -2
View File
@@ -245,8 +245,7 @@ jobs:
- name: install required packages - name: install required packages
run: | run: |
brew update HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1 brew install --overwrite vulkan-loader vulkan-headers molten-vk imagemagick chafa
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1 brew install vulkan-loader vulkan-headers molten-vk imagemagick chafa
- name: Initialize CodeQL - name: Initialize CodeQL
uses: github/codeql-action/init@v3 uses: github/codeql-action/init@v3
+25
View File
@@ -1,3 +1,28 @@
# 2.8.9
Bugfixes:
* Don't detect `SessionLeader` as terminal, actually (Terminal, Linux)
* Fix blurry chafa result when specifying both width and height (#757, Logo)
Features:
* Support new MacBook Air (Host, macOS)
* Distinguish min frequency and base frequency (CPU)
Logo:
* Fix proxmox
# 2.8.8
Bugfixes:
* Fix old fish version compatibility (#744)
* Fix truncated texts in `--help format` (#745)
* Fix old vulkan-header and libdrm library compatibility (#748, Linux)
* Fix possible segfaults in `--help *-format` (#749)
* Fix invalid resolution detection when using libdrm (Linux, Display)
* Fix segfault when `/sys/devices/system/cpu/cpufreq/` doesn't exist (#750, CPU, Linux)
* Don't detect `SessionLeader` as terminal (Terminal, Linux)
* Fix detection of client IP (Users, Linux)
# 2.8.7 # 2.8.7
Bugfixes: Bugfixes:
+1 -1
View File
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.12.0) # target_link_libraries with OBJECT libs & project homepage url cmake_minimum_required(VERSION 3.12.0) # target_link_libraries with OBJECT libs & project homepage url
project(fastfetch project(fastfetch
VERSION 2.8.7 VERSION 2.8.9
LANGUAGES C LANGUAGES C
DESCRIPTION "Fast neofetch-like system information tool" DESCRIPTION "Fast neofetch-like system information tool"
HOMEPAGE_URL "https://github.com/fastfetch-cli/fastfetch" HOMEPAGE_URL "https://github.com/fastfetch-cli/fastfetch"
+4 -2
View File
@@ -27,8 +27,10 @@ There are [screenshots on different platforms](https://github.com/fastfetch-cli/
### Linux ### Linux
* Ubuntu: `ppa:zhangsongcui3371/fastfetch` Some distros packaged a outdated fastfetch version. Older version is not supported, please always ensure that the latest version is used.
* Debian / Ubuntu: Download `fastfetch-<version>-Linux.deb` from [Github release page](https://github.com/fastfetch-cli/fastfetch/releases/latest) and `dpkg -i fastfetch-<version>-Linux.deb`
* Ubuntu: [`ppa:zhangsongcui3371/fastfetch`](https://launchpad.net/~zhangsongcui3371/+archive/ubuntu/fastfetch) (for Ubuntu 22.04 or above)
* Debian / Ubuntu: Download `fastfetch-<version>-Linux.deb` from [Github release page](https://github.com/fastfetch-cli/fastfetch/releases/latest) and `dpkg -i fastfetch-<version>-Linux.deb` (for Ubuntu 22.04 or above and Debian 12 or above).
* Arch Linux: `sudo pacman -S fastfetch`. You can also find fastfetch [on the AUR](https://aur.archlinux.org/packages/fastfetch-git). * Arch Linux: `sudo pacman -S fastfetch`. You can also find fastfetch [on the AUR](https://aur.archlinux.org/packages/fastfetch-git).
* Fedora: `sudo dnf install fastfetch` * Fedora: `sudo dnf install fastfetch`
* Gentoo: `sudo emerge --ask app-misc/fastfetch` * Gentoo: `sudo emerge --ask app-misc/fastfetch`
+6
View File
@@ -1,3 +1,9 @@
fastfetch (2.8.8) jammy; urgency=medium
* Update to 2.8.8
-- Carter Li <zhangsongcui@live.cn> Fri, 08 Mar 2024 09:59:41 +0800
fastfetch (2.8.6) jammy; urgency=medium fastfetch (2.8.6) jammy; urgency=medium
* Update to 2.8.6 * Update to 2.8.6
+1 -1
View File
@@ -1 +1 @@
fastfetch_2.8.6_source.buildinfo universe/utils optional fastfetch_2.8.8_source.buildinfo universe/utils optional
Binary file not shown.

Before

Width:  |  Height:  |  Size: 68 KiB

After

Width:  |  Height:  |  Size: 341 KiB

+1 -1
View File
@@ -118,7 +118,7 @@ static void parseStructureCommand(
} }
} }
ffPrintErrorString(line, 0, NULL, FF_PRINT_TYPE_NO_CUSTOM_KEY, "<no implementation provided>"); ffPrintError(line, 0, NULL, FF_PRINT_TYPE_NO_CUSTOM_KEY, "<no implementation provided>");
} }
void ffPrintCommandOption(FFdata* data, yyjson_mut_doc* jsonDoc) void ffPrintCommandOption(FFdata* data, yyjson_mut_doc* jsonDoc)
+4
View File
@@ -24,3 +24,7 @@ typedef struct FFformatarg
void ffFormatAppendFormatArg(FFstrbuf* buffer, const FFformatarg* formatarg); void ffFormatAppendFormatArg(FFstrbuf* buffer, const FFformatarg* formatarg);
void ffParseFormatString(FFstrbuf* buffer, const FFstrbuf* formatstr, uint32_t numArgs, const FFformatarg* arguments); void ffParseFormatString(FFstrbuf* buffer, const FFstrbuf* formatstr, uint32_t numArgs, const FFformatarg* arguments);
#define FF_PARSE_FORMAT_STRING_CHECKED(buffer, formatstr, numArgs, arguments) do {\
static_assert(sizeof(arguments) / sizeof(*(arguments)) == (numArgs), "Invalid number of format arguments");\
ffParseFormatString((buffer), (formatstr), (numArgs), (arguments));\
} while (0)
+1 -1
View File
@@ -235,6 +235,6 @@ void ffPrintJsonConfig(bool prepare, yyjson_mut_doc* jsonDoc)
yyjson_mut_doc_set_root(jsonDoc, obj); yyjson_mut_doc_set_root(jsonDoc, obj);
} }
else else
ffPrintErrorString("JsonConfig", 0, NULL, FF_PRINT_TYPE_NO_CUSTOM_KEY, "%s", error); ffPrintError("JsonConfig", 0, NULL, FF_PRINT_TYPE_NO_CUSTOM_KEY, "%s", error);
} }
} }
+4 -12
View File
@@ -37,9 +37,9 @@ void ffPrintLogoAndKey(const char* moduleName, uint8_t moduleIndex, const FFModu
else else
{ {
FF_STRBUF_AUTO_DESTROY key = ffStrbufCreate(); FF_STRBUF_AUTO_DESTROY key = ffStrbufCreate();
ffParseFormatString(&key, &moduleArgs->key, 1, (FFformatarg[]){ FF_PARSE_FORMAT_STRING_CHECKED(&key, &moduleArgs->key, 1, ((FFformatarg[]){
{FF_FORMAT_ARG_TYPE_UINT8, &moduleIndex} {FF_FORMAT_ARG_TYPE_UINT8, &moduleIndex}
}); }));
ffStrbufWriteTo(&key, stdout); ffStrbufWriteTo(&key, stdout);
} }
@@ -60,7 +60,7 @@ void ffPrintLogoAndKey(const char* moduleName, uint8_t moduleIndex, const FFModu
} }
} }
void ffPrintFormatString(const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, FFPrintType printType, uint32_t numArgs, const FFformatarg* arguments) void ffPrintFormat(const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, FFPrintType printType, uint32_t numArgs, const FFformatarg* arguments)
{ {
FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate(); FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate();
if (moduleArgs) if (moduleArgs)
@@ -93,7 +93,7 @@ static void printError(const char* moduleName, uint8_t moduleIndex, const FFModu
putchar('\n'); putchar('\n');
} }
void ffPrintErrorString(const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, FFPrintType printType, const char* message, ...) void ffPrintError(const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, FFPrintType printType, const char* message, ...)
{ {
va_list arguments; va_list arguments;
va_start(arguments, message); va_start(arguments, message);
@@ -101,14 +101,6 @@ void ffPrintErrorString(const char* moduleName, uint8_t moduleIndex, const FFMod
va_end(arguments); va_end(arguments);
} }
void ffPrintError(const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, const char* message, ...)
{
va_list arguments;
va_start(arguments, message);
printError(moduleName, moduleIndex, moduleArgs, FF_PRINT_TYPE_DEFAULT, message, arguments);
va_end(arguments);
}
void ffPrintColor(const FFstrbuf* colorValue) void ffPrintColor(const FFstrbuf* colorValue)
{ {
//If the color is not set, this would reset in \033[m, which resets everything. //If the color is not set, this would reset in \033[m, which resets everything.
+10 -7
View File
@@ -12,14 +12,17 @@ typedef enum FFPrintType {
} FFPrintType; } FFPrintType;
void ffPrintLogoAndKey(const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, FFPrintType printType); void ffPrintLogoAndKey(const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, FFPrintType printType);
void ffPrintFormatString(const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, FFPrintType printType, uint32_t numArgs, const FFformatarg* arguments); void ffPrintFormat(const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, FFPrintType printType, uint32_t numArgs, const FFformatarg* arguments);
static inline void ffPrintFormat(const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, uint32_t numArgs, const FFformatarg* arguments) #define FF_PRINT_FORMAT_CHECKED(moduleName, moduleIndex, moduleArgs, printType, numArgs, arguments) do {\
{ static_assert(sizeof(arguments) / sizeof(*(arguments)) == (numArgs), "Invalid number of format arguments");\
ffPrintFormatString(moduleName, moduleIndex, moduleArgs, FF_PRINT_TYPE_DEFAULT, numArgs, arguments); ffPrintFormat((moduleName), (moduleIndex), (moduleArgs), (printType), (numArgs), (arguments));\
} } while (0)
FF_C_PRINTF(5, 6) void ffPrintErrorString(const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, FFPrintType printType, const char* message, ...); FF_C_PRINTF(5, 6) void ffPrintError(const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, FFPrintType printType, const char* message, ...);
FF_C_PRINTF(4, 5) void ffPrintError(const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, const char* message, ...);
void ffPrintColor(const FFstrbuf* colorValue); void ffPrintColor(const FFstrbuf* colorValue);
void ffPrintCharTimes(char c, uint32_t times); void ffPrintCharTimes(char c, uint32_t times);
void ffPrintModuleFormatHelp(const char* name, const char* def, uint32_t numArgs, const char* args[]); void ffPrintModuleFormatHelp(const char* name, const char* def, uint32_t numArgs, const char* args[]);
#define FF_PRINT_MODULE_FORMAT_HELP_CHECKED(moduleName, def, numArgs, args) do {\
static_assert(sizeof(args) / sizeof(*(args)) == (numArgs), "Invalid number of format arguments");\
ffPrintModuleFormatHelp((moduleName), (def), (numArgs), (args));\
} while (0)
+3 -1
View File
@@ -13,10 +13,12 @@ typedef struct FFCPUResult
uint16_t coresLogical; uint16_t coresLogical;
uint16_t coresOnline; uint16_t coresOnline;
double frequencyMin; // GHz double frequencyBase; // GHz
double frequencyMax; // GHz double frequencyMax; // GHz
double frequencyMin; // GHz
double temperature; double temperature;
} FFCPUResult; } FFCPUResult;
const char* ffCPUDetectByCpuid(FFCPUResult* cpu);
const char* ffDetectCPU(const FFCPUOptions* options, FFCPUResult* cpu); const char* ffDetectCPU(const FFCPUOptions* options, FFCPUResult* cpu);
+1 -2
View File
@@ -60,14 +60,13 @@ static const char* detectFrequency(FFCPUResult* cpu)
ffCfDictGetData(properties, CFSTR("voltage-states5-sram"), pCoreLength - 8, 4, (uint8_t*) &aMax, NULL); ffCfDictGetData(properties, CFSTR("voltage-states5-sram"), pCoreLength - 8, 4, (uint8_t*) &aMax, NULL);
cpu->frequencyMax = aMax / (1000.0 * 1000 * 1000); cpu->frequencyMax = aMax / (1000.0 * 1000 * 1000);
} }
else
cpu->frequencyMax = 0.0;
return NULL; return NULL;
} }
#else #else
static const char* detectFrequency(FFCPUResult* cpu) static const char* detectFrequency(FFCPUResult* cpu)
{ {
cpu->frequencyBase = ffSysctlGetInt64("hw.cpufrequency", 0) / 1000.0 / 1000.0 / 1000.0;
cpu->frequencyMin = ffSysctlGetInt64("hw.cpufrequency_min", 0) / 1000.0 / 1000.0 / 1000.0; cpu->frequencyMin = ffSysctlGetInt64("hw.cpufrequency_min", 0) / 1000.0 / 1000.0 / 1000.0;
cpu->frequencyMax = ffSysctlGetInt64("hw.cpufrequency_max", 0); cpu->frequencyMax = ffSysctlGetInt64("hw.cpufrequency_max", 0);
if(cpu->frequencyMax > 0.0) if(cpu->frequencyMax > 0.0)
+1 -2
View File
@@ -11,8 +11,7 @@ const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu)
cpu->coresLogical = cpu->coresPhysical; cpu->coresLogical = cpu->coresPhysical;
cpu->coresOnline = cpu->coresPhysical; cpu->coresOnline = cpu->coresPhysical;
cpu->frequencyMin = ffSysctlGetInt("hw.clockrate", 0) / 1000.0; cpu->frequencyBase = ffSysctlGetInt("hw.clockrate", 0) / 1000.0;
cpu->frequencyMax = cpu->frequencyMin;
cpu->temperature = FF_CPU_TEMP_UNSET; cpu->temperature = FF_CPU_TEMP_UNSET;
if (options->temp) if (options->temp)
+33 -21
View File
@@ -94,11 +94,14 @@ static double getFrequency(FFstrbuf* basePath, const char* cpuinfoFileName, cons
if (ok) if (ok)
return ffStrbufToDouble(buffer) / 1e6; return ffStrbufToDouble(buffer) / 1e6;
ffStrbufAppendS(basePath, scalingFileName); if (scalingFileName)
ok = ffReadFileBuffer(basePath->chars, buffer); {
ffStrbufSubstrBefore(basePath, baseLen); ffStrbufAppendS(basePath, scalingFileName);
if (ok) ok = ffReadFileBuffer(basePath->chars, buffer);
return ffStrbufToDouble(buffer) / 1e6; ffStrbufSubstrBefore(basePath, baseLen);
if (ok)
return ffStrbufToDouble(buffer) / 1e6;
}
return 0.0/0.0; return 0.0/0.0;
} }
@@ -107,9 +110,10 @@ static bool detectFrequency(FFCPUResult* cpu)
{ {
FF_STRBUF_AUTO_DESTROY path = ffStrbufCreateS("/sys/devices/system/cpu/cpufreq/"); FF_STRBUF_AUTO_DESTROY path = ffStrbufCreateS("/sys/devices/system/cpu/cpufreq/");
FF_AUTO_CLOSE_DIR DIR* dir = opendir(path.chars); FF_AUTO_CLOSE_DIR DIR* dir = opendir(path.chars);
if (!dir) return false;
FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate(); FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate();
uint32_t baseLen = path.length; uint32_t baseLen = path.length;
bool flag = false;
struct dirent* entry; struct dirent* entry;
while((entry = readdir(dir)) != NULL) while((entry = readdir(dir)) != NULL)
@@ -117,26 +121,34 @@ static bool detectFrequency(FFCPUResult* cpu)
if (ffStrStartsWith(entry->d_name, "policy") && isdigit(entry->d_name[strlen("policy")])) if (ffStrStartsWith(entry->d_name, "policy") && isdigit(entry->d_name[strlen("policy")]))
{ {
ffStrbufAppendS(&path, entry->d_name); ffStrbufAppendS(&path, entry->d_name);
double fmin = getFrequency(&path, "/cpuinfo_min_freq", "/scaling_min_freq", &buffer); double fbase = getFrequency(&path, "/base_frequency", NULL, &buffer);
if (fmin != fmin) continue; if (fbase == fbase)
double fmax = getFrequency(&path, "/cpuinfo_max_freq", "/scaling_max_freq", &buffer);
if (fmax != fmax) continue;
if (flag)
{ {
cpu->frequencyMin = cpu->frequencyMin < fmin ? cpu->frequencyMin : fmin; if (cpu->frequencyBase == cpu->frequencyBase)
cpu->frequencyMax = cpu->frequencyMax > fmax ? cpu->frequencyMax : fmax; cpu->frequencyBase = cpu->frequencyBase > fbase ? cpu->frequencyBase : fbase;
else
cpu->frequencyBase = fbase;
} }
else double fmax = getFrequency(&path, "/cpuinfo_max_freq", "/scaling_max_freq", &buffer);
if (fmax == fmax)
{ {
cpu->frequencyMin = fmin; if (cpu->frequencyMax == cpu->frequencyMax)
cpu->frequencyMax = fmax; cpu->frequencyMax = cpu->frequencyMax > fmax ? cpu->frequencyMax : fmax;
flag = true; else
cpu->frequencyMax = fmax;
}
double fmin = getFrequency(&path, "/cpuinfo_min_freq", "/scaling_min_freq", &buffer);
if (fmin == fmin)
{
if (cpu->frequencyMin == cpu->frequencyMin)
cpu->frequencyMin = cpu->frequencyMin < fmin ? cpu->frequencyMin : fmin;
else
cpu->frequencyMin = fmin;
} }
ffStrbufSubstrBefore(&path, baseLen); ffStrbufSubstrBefore(&path, baseLen);
} }
} }
return flag; return true;
} }
static double detectCPUTemp(void) static double detectCPUTemp(void)
@@ -232,8 +244,8 @@ const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu)
cpu->coresOnline = (uint16_t) get_nprocs(); cpu->coresOnline = (uint16_t) get_nprocs();
cpu->coresPhysical = (uint16_t) ffStrbufToUInt(&physicalCoresBuffer, cpu->coresLogical); cpu->coresPhysical = (uint16_t) ffStrbufToUInt(&physicalCoresBuffer, cpu->coresLogical);
if (!detectFrequency(cpu)) if (!detectFrequency(cpu) || cpu->frequencyBase != cpu->frequencyBase)
cpu->frequencyMin = cpu->frequencyMax = ffStrbufToDouble(&cpuMHz) / 1000; cpu->frequencyBase = ffStrbufToDouble(&cpuMHz) / 1000;
if(cpuUarch.length > 0) if(cpuUarch.length > 0)
{ {
+46 -33
View File
@@ -64,50 +64,53 @@ static const char* detectMaxSpeedBySmbios(FFCPUResult* cpu)
return "No active CPU is found in SMBIOS data"; return "No active CPU is found in SMBIOS data";
} }
double speed;
if (data->MaxSpeed > 0 && data->MaxSpeed < 30000) // VMware reports weird values if (data->MaxSpeed > 0 && data->MaxSpeed < 30000) // VMware reports weird values
speed = data->MaxSpeed / 1000.0; {
else double speed = data->MaxSpeed / 1000.0;
speed = data->CurrentSpeed / 1000.0; if (cpu->frequencyBase < speed)
cpu->frequencyMax = speed;
}
if (cpu->frequencyMax < speed)
cpu->frequencyMax = speed;
return NULL; return NULL;
} }
static const char* detectByOS(FFCPUResult* cpu) static const char* detectNCores(FFCPUResult* cpu)
{ {
DWORD length = 0;
GetLogicalProcessorInformationEx(RelationAll, NULL, &length);
if (length == 0)
return "GetLogicalProcessorInformationEx(RelationAll, NULL, &length) failed";
SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX* FF_AUTO_FREE
pProcessorInfo = (SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX*)malloc(length);
if (!pProcessorInfo || !GetLogicalProcessorInformationEx(RelationAll, pProcessorInfo, &length))
return "GetLogicalProcessorInformationEx(RelationAll, pProcessorInfo, &length) failed";
for(
SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX* ptr = pProcessorInfo;
(uint8_t*)ptr < ((uint8_t*)pProcessorInfo) + length;
ptr = (SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX*)(((uint8_t*)ptr) + ptr->Size)
)
{ {
DWORD length = 0; if(ptr->Relationship == RelationProcessorCore)
GetLogicalProcessorInformationEx(RelationAll, NULL, &length); ++cpu->coresPhysical;
if (length == 0) else if(ptr->Relationship == RelationGroup)
return "GetLogicalProcessorInformationEx(RelationAll, NULL, &length) failed";
SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX* FF_AUTO_FREE
pProcessorInfo = (SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX*)malloc(length);
if (pProcessorInfo && GetLogicalProcessorInformationEx(RelationAll, pProcessorInfo, &length))
{ {
for( for (uint32_t index = 0; index < ptr->Group.ActiveGroupCount; ++index)
SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX* ptr = pProcessorInfo;
(uint8_t*)ptr < ((uint8_t*)pProcessorInfo) + length;
ptr = (SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX*)(((uint8_t*)ptr) + ptr->Size)
)
{ {
if(ptr->Relationship == RelationProcessorCore) cpu->coresOnline += ptr->Group.GroupInfo[index].ActiveProcessorCount;
++cpu->coresPhysical; cpu->coresLogical += ptr->Group.GroupInfo[index].MaximumProcessorCount;
else if(ptr->Relationship == RelationGroup)
{
cpu->coresOnline += ptr->Group.GroupInfo->ActiveProcessorCount;
cpu->coresLogical += ptr->Group.GroupInfo->MaximumProcessorCount;
}
} }
} }
else
return "GetLogicalProcessorInformationEx(RelationAll, pProcessorInfo, &length) failed";
} }
return NULL;
}
static const char* detectByRegistry(FFCPUResult* cpu)
{
FF_HKEY_AUTO_DESTROY hKey = NULL; FF_HKEY_AUTO_DESTROY hKey = NULL;
if(!ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, L"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0", &hKey, NULL)) if(!ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, L"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0", &hKey, NULL))
return "ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, L\"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0\", &hKey, NULL) failed"; return "ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, L\"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0\", &hKey, NULL) failed";
@@ -115,24 +118,34 @@ static const char* detectByOS(FFCPUResult* cpu)
{ {
uint32_t mhz; uint32_t mhz;
if(ffRegReadUint(hKey, L"~MHz", &mhz, NULL)) if(ffRegReadUint(hKey, L"~MHz", &mhz, NULL))
cpu->frequencyMin = cpu->frequencyMax = mhz / 1000.0; cpu->frequencyBase = mhz / 1000.0;
} }
ffRegReadStrbuf(hKey, L"ProcessorNameString", &cpu->name, NULL); ffRegReadStrbuf(hKey, L"ProcessorNameString", &cpu->name, NULL);
ffRegReadStrbuf(hKey, L"VendorIdentifier", &cpu->vendor, NULL); ffRegReadStrbuf(hKey, L"VendorIdentifier", &cpu->vendor, NULL);
if (cpu->coresLogical == 0)
{
DWORD cores;
if (RegQueryInfoKeyW(HKEY_LOCAL_MACHINE, L"HARDWARE\\DESCRIPTION\\System\\CentralProcessor", NULL, NULL, &cores, NULL, NULL, NULL, NULL, NULL, NULL, NULL) == ERROR_SUCCESS)
cpu->coresOnline = cpu->coresPhysical = cpu->coresLogical = (uint16_t) cores;
}
return NULL; return NULL;
} }
const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu) const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu)
{ {
const char* error = detectByOS(cpu); detectNCores(cpu);
const char* error = detectByRegistry(cpu);
if (error) if (error)
return error; return error;
detectMaxSpeedBySmbios(cpu);
if(options->temp) if(options->temp)
ffDetectSmbiosTemp(&cpu->temperature, NULL); ffDetectSmbiosTemp(&cpu->temperature, NULL);
detectMaxSpeedBySmbios(cpu);
return NULL; return NULL;
} }
+3 -3
View File
@@ -143,7 +143,7 @@ static inline const char* drmType2Name(uint32_t connector_type)
return "DPI"; return "DPI";
case DRM_MODE_CONNECTOR_WRITEBACK: case DRM_MODE_CONNECTOR_WRITEBACK:
return "Writeback"; return "Writeback";
case DRM_MODE_CONNECTOR_SPI: case 19 /*DRM_MODE_CONNECTOR_SPI*/:
return "SPI"; return "SPI";
case 20 /*DRM_MODE_CONNECTOR_USB*/: case 20 /*DRM_MODE_CONNECTOR_USB*/:
return "USB"; return "USB";
@@ -250,8 +250,8 @@ static const char* drmConnectLibdrm(FFDisplayServerResult* result)
drmModeCrtc* crtc = ffdrmModeGetCrtc(fd, encoder->crtc_id); drmModeCrtc* crtc = ffdrmModeGetCrtc(fd, encoder->crtc_id);
if (crtc) if (crtc)
{ {
width = crtc->mode.vdisplay; width = crtc->mode.hdisplay;
height = crtc->mode.hdisplay; height = crtc->mode.vdisplay;
refreshRate = crtc->mode.vrefresh; refreshRate = crtc->mode.vrefresh;
if (refreshRate == 0) if (refreshRate == 0)
{ {
+2
View File
@@ -111,6 +111,8 @@ static const char* getProductNameWithHwModel(const FFstrbuf* hwModel)
else if(ffStrbufStartsWithS(hwModel, "Mac")) else if(ffStrbufStartsWithS(hwModel, "Mac"))
{ {
const char* version = hwModel->chars + strlen("Mac"); const char* version = hwModel->chars + strlen("Mac");
if(ffStrEquals(version, "15,13")) return "MacBook Air (15-inch, M3, 2024)";
if(ffStrEquals(version, "15,2")) return "MacBook Air (13-inch, M3, 2024)";
if(ffStrEquals(version, "15,3")) return "MacBook Pro (14-inch, Nov 2023, Two Thunderbolt / USB 4 ports)"; if(ffStrEquals(version, "15,3")) return "MacBook Pro (14-inch, Nov 2023, Two Thunderbolt / USB 4 ports)";
if(ffStrEquals(version, "15,4")) return "iMac (24-inch, 2023, Two Thunderbolt / USB 4 ports)"; if(ffStrEquals(version, "15,4")) return "iMac (24-inch, 2023, Two Thunderbolt / USB 4 ports)";
if(ffStrEquals(version, "15,5")) return "iMac (24-inch, 2023, Two Thunderbolt / USB 4 ports, Two USB 3 ports)"; if(ffStrEquals(version, "15,5")) return "iMac (24-inch, 2023, Two Thunderbolt / USB 4 ports, Two USB 3 ports)";
@@ -341,6 +341,7 @@ static void getTerminalFromEnv(FFTerminalResult* result)
!ffStrbufEqualS(&result->processName, "systemd") && !ffStrbufEqualS(&result->processName, "systemd") &&
!ffStrbufEqualS(&result->processName, "init") && !ffStrbufEqualS(&result->processName, "init") &&
!ffStrbufEqualS(&result->processName, "(init)") && !ffStrbufEqualS(&result->processName, "(init)") &&
!ffStrbufEqualS(&result->processName, "SessionLeader") && // #750
#endif #endif
!ffStrbufEqualS(&result->processName, "0") !ffStrbufEqualS(&result->processName, "0")
+8 -4
View File
@@ -10,6 +10,10 @@
#define setutxent setutent #define setutxent setutent
#define getutxent getutent #define getutxent getutent
#endif #endif
#ifdef __linux__
#include <netinet/in.h>
#include <arpa/inet.h>
#endif
const char* ffDetectUsers(FFlist* users) const char* ffDetectUsers(FFlist* users)
{ {
@@ -33,11 +37,11 @@ next:
ffStrbufInitS(&user->hostName, n->ut_host); ffStrbufInitS(&user->hostName, n->ut_host);
ffStrbufInitS(&user->sessionName, n->ut_line); ffStrbufInitS(&user->sessionName, n->ut_line);
#ifdef __linux__ #ifdef __linux__
if(n->ut_addr_v6[0] || n->ut_addr_v6[1] || n->ut_addr_v6[2] || n->ut_addr_v6[3]) // https://www.linuxquestions.org/questions/programming-9/get-the-ip-addr-out-from-an-int32_t-value-287687/#post1458622
ffStrbufInitF(&user->clientIp, "%u.%u.%u.%u", n->ut_addr_v6[0], n->ut_addr_v6[1], n->ut_addr_v6[2], n->ut_addr_v6[3]); ffStrbufInitS(&user->clientIp, inet_ntoa((struct in_addr) { .s_addr = (in_addr_t) n->ut_addr_v6[0] }));
else #else
#endif
ffStrbufInit(&user->clientIp); ffStrbufInit(&user->clientIp);
#endif
user->loginTime = (uint64_t) n->ut_tv.tv_sec * 1000 + (uint64_t) n->ut_tv.tv_usec / 1000; user->loginTime = (uint64_t) n->ut_tv.tv_sec * 1000 + (uint64_t) n->ut_tv.tv_usec / 1000;
} }
+3 -3
View File
@@ -18,7 +18,7 @@ static inline void applyVulkanVersion(uint32_t vulkanVersion, FFVersion* ffVersi
ffVersion->patch = VK_VERSION_PATCH(vulkanVersion); ffVersion->patch = VK_VERSION_PATCH(vulkanVersion);
} }
static void applyDriverName(VkPhysicalDeviceDriverProperties* properties, FFstrbuf* result) static void applyDriverName(VkPhysicalDeviceDriverPropertiesKHR* properties, FFstrbuf* result)
{ {
if(!ffStrSet(properties->driverName)) if(!ffStrSet(properties->driverName))
return; return;
@@ -127,8 +127,8 @@ static const char* detectVulkan(FFVulkanResult* result)
//On VK 1.1 and up, we use vkGetPhysicalDeviceProperties2, so we can put VkPhysicalDeviceDriverProperties in the pNext chain. //On VK 1.1 and up, we use vkGetPhysicalDeviceProperties2, so we can put VkPhysicalDeviceDriverProperties in the pNext chain.
//This is required to get the driver name and conformance version. //This is required to get the driver name and conformance version.
VkPhysicalDeviceDriverProperties driverProperties = { VkPhysicalDeviceDriverPropertiesKHR driverProperties = {
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRIVER_PROPERTIES, .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRIVER_PROPERTIES_KHR,
}; };
VkPhysicalDeviceProperties2 physicalDeviceProperties = { VkPhysicalDeviceProperties2 physicalDeviceProperties = {
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2, .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2,
+3 -5
View File
@@ -1,20 +1,15 @@
#include "fastfetch.h" #include "fastfetch.h"
#include "common/commandoption.h" #include "common/commandoption.h"
#include "common/printing.h"
#include "common/parsing.h"
#include "common/io/io.h" #include "common/io/io.h"
#include "common/time.h"
#include "common/jsonconfig.h" #include "common/jsonconfig.h"
#include "detection/version/version.h" #include "detection/version/version.h"
#include "util/stringUtils.h" #include "util/stringUtils.h"
#include "util/mallocHelper.h" #include "util/mallocHelper.h"
#include "logo/logo.h"
#include "fastfetch_datatext.h" #include "fastfetch_datatext.h"
#include <stdlib.h> #include <stdlib.h>
#include <ctype.h> #include <ctype.h>
#include <string.h> #include <string.h>
#include <inttypes.h>
#ifdef WIN32 #ifdef WIN32
#include "util/windows/getline.h" #include "util/windows/getline.h"
@@ -824,7 +819,10 @@ static void run(FFdata* data)
ffPrintCommandOption(data, instance.state.resultDoc); ffPrintCommandOption(data, instance.state.resultDoc);
if (instance.state.resultDoc) if (instance.state.resultDoc)
{
yyjson_mut_write_fp(stdout, instance.state.resultDoc, YYJSON_WRITE_INF_AND_NAN_AS_NULL | YYJSON_WRITE_PRETTY_TWO_SPACES, NULL, NULL); yyjson_mut_write_fp(stdout, instance.state.resultDoc, YYJSON_WRITE_INF_AND_NAN_AS_NULL | YYJSON_WRITE_PRETTY_TWO_SPACES, NULL, NULL);
putchar('\n');
}
else else
ffFinish(); ffFinish();
} }
+11 -11
View File
@@ -3299,6 +3299,17 @@ static const FFlogo P[] = {
FF_COLOR_FG_WHITE, FF_COLOR_FG_WHITE,
}, },
}, },
// Proxmox
{
.names = {"proxmox"},
.lines = FASTFETCH_DATATEXT_LOGO_PROXMOX,
.colors = {
FF_COLOR_FG_WHITE,
FF_COLOR_FG_256 "202"
},
.colorKeys = FF_COLOR_FG_WHITE,
.colorTitle = FF_COLOR_FG_256 "202",
},
// PuffOS // PuffOS
{ {
.names = {"PuffOS"}, .names = {"PuffOS"},
@@ -3558,17 +3569,6 @@ static const FFlogo R[] = {
.colorKeys = FF_COLOR_FG_BLUE, .colorKeys = FF_COLOR_FG_BLUE,
.colorTitle = FF_COLOR_FG_BLUE, .colorTitle = FF_COLOR_FG_BLUE,
}, },
// Proxmox
{
.names = {"proxmox"},
.lines = FASTFETCH_DATATEXT_LOGO_PROXMOX,
.colors = {
FF_COLOR_FG_WHITE,
FF_COLOR_FG_256 "202"
},
.colorKeys = FF_COLOR_FG_WHITE,
.colorTitle = FF_COLOR_FG_256 "202",
},
// LAST // LAST
{}, {},
}; };
+2 -4
View File
@@ -768,10 +768,8 @@ static bool printImageIfExistsSlowPath(FFLogoType type, bool printError)
requestData.characterPixelWidth = 1; requestData.characterPixelWidth = 1;
requestData.characterPixelHeight = 1; requestData.characterPixelHeight = 1;
if( if(!getCharacterPixelDimensions(&requestData))
(type != FF_LOGO_TYPE_IMAGE_CHAFA || instance.config.logo.width == 0 || instance.config.logo.height == 0) && {
!getCharacterPixelDimensions(&requestData)
) {
if(printError) if(printError)
fputs("Logo: getCharacterPixelDimensions() failed", stderr); fputs("Logo: getCharacterPixelDimensions() failed", stderr);
return false; return false;
+8 -8
View File
@@ -7,7 +7,7 @@
#include "modules/battery/battery.h" #include "modules/battery/battery.h"
#include "util/stringUtils.h" #include "util/stringUtils.h"
#define FF_BATTERY_NUM_FORMAT_ARGS 8 #define FF_BATTERY_NUM_FORMAT_ARGS 9
static void printBattery(FFBatteryOptions* options, FFBatteryResult* result, uint8_t index) static void printBattery(FFBatteryOptions* options, FFBatteryResult* result, uint8_t index)
{ {
@@ -61,7 +61,7 @@ static void printBattery(FFBatteryOptions* options, FFBatteryResult* result, uin
ffPercentAppendNum(&capacityStr, result->capacity, options->percent, false); ffPercentAppendNum(&capacityStr, result->capacity, options->percent, false);
FF_STRBUF_AUTO_DESTROY tempStr = ffStrbufCreate(); FF_STRBUF_AUTO_DESTROY tempStr = ffStrbufCreate();
ffTempsAppendNum(result->temperature, &tempStr, options->tempConfig); ffTempsAppendNum(result->temperature, &tempStr, options->tempConfig);
ffPrintFormat(FF_BATTERY_MODULE_NAME, index, &options->moduleArgs, FF_BATTERY_NUM_FORMAT_ARGS, (FFformatarg[]){ FF_PRINT_FORMAT_CHECKED(FF_BATTERY_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_BATTERY_NUM_FORMAT_ARGS, ((FFformatarg[]) {
{FF_FORMAT_ARG_TYPE_STRBUF, &result->manufacturer}, {FF_FORMAT_ARG_TYPE_STRBUF, &result->manufacturer},
{FF_FORMAT_ARG_TYPE_STRBUF, &result->modelName}, {FF_FORMAT_ARG_TYPE_STRBUF, &result->modelName},
{FF_FORMAT_ARG_TYPE_STRBUF, &result->technology}, {FF_FORMAT_ARG_TYPE_STRBUF, &result->technology},
@@ -71,7 +71,7 @@ static void printBattery(FFBatteryOptions* options, FFBatteryResult* result, uin
{FF_FORMAT_ARG_TYPE_UINT, &result->cycleCount}, {FF_FORMAT_ARG_TYPE_UINT, &result->cycleCount},
{FF_FORMAT_ARG_TYPE_STRBUF, &result->serial}, {FF_FORMAT_ARG_TYPE_STRBUF, &result->serial},
{FF_FORMAT_ARG_TYPE_STRBUF, &result->manufactureDate}, {FF_FORMAT_ARG_TYPE_STRBUF, &result->manufactureDate},
}); }));
} }
} }
@@ -83,7 +83,7 @@ void ffPrintBattery(FFBatteryOptions* options)
if (error) if (error)
{ {
ffPrintError(FF_BATTERY_MODULE_NAME, 0, &options->moduleArgs, "%s", error); ffPrintError(FF_BATTERY_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "%s", error);
} }
else else
{ {
@@ -100,7 +100,7 @@ void ffPrintBattery(FFBatteryOptions* options)
ffStrbufDestroy(&result->manufactureDate); ffStrbufDestroy(&result->manufactureDate);
} }
if(results.length == 0) if(results.length == 0)
ffPrintError(FF_BATTERY_MODULE_NAME, 0, &options->moduleArgs, "No batteries found"); ffPrintError(FF_BATTERY_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "No batteries found");
} }
} }
@@ -155,7 +155,7 @@ void ffParseBatteryJsonObject(FFBatteryOptions* options, yyjson_val* module)
if (ffPercentParseJsonObject(key, val, &options->percent)) if (ffPercentParseJsonObject(key, val, &options->percent))
continue; continue;
ffPrintError(FF_BATTERY_MODULE_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key); ffPrintError(FF_BATTERY_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Unknown JSON key %s", key);
} }
} }
@@ -216,7 +216,7 @@ void ffGenerateBatteryJsonResult(FFBatteryOptions* options, yyjson_mut_doc* doc,
void ffPrintBatteryHelpFormat(void) void ffPrintBatteryHelpFormat(void)
{ {
ffPrintModuleFormatHelp(FF_BATTERY_MODULE_NAME, "{4}, {5}", FF_BATTERY_NUM_FORMAT_ARGS, (const char* []) { FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_BATTERY_MODULE_NAME, "{4}, {5}", FF_BATTERY_NUM_FORMAT_ARGS, ((const char* []) {
"Battery manufactor", "Battery manufactor",
"Battery model", "Battery model",
"Battery technology", "Battery technology",
@@ -226,7 +226,7 @@ void ffPrintBatteryHelpFormat(void)
"Battery cycle count", "Battery cycle count",
"Battery serial number", "Battery serial number",
"Battery manufactor date", "Battery manufactor date",
}); }));
} }
void ffInitBatteryOptions(FFBatteryOptions* options) void ffInitBatteryOptions(FFBatteryOptions* options)
+9 -9
View File
@@ -21,13 +21,13 @@ void ffPrintBios(FFBiosOptions* options)
if(error) if(error)
{ {
ffPrintError(FF_BIOS_MODULE_NAME, 0, &options->moduleArgs, "%s", error); ffPrintError(FF_BIOS_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "%s", error);
goto exit; goto exit;
} }
if(bios.version.length == 0) if(bios.version.length == 0)
{ {
ffPrintError(FF_BIOS_MODULE_NAME, 0, &options->moduleArgs, "bios_version is not set."); ffPrintError(FF_BIOS_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "bios_version is not set.");
goto exit; goto exit;
} }
@@ -43,9 +43,9 @@ void ffPrintBios(FFBiosOptions* options)
else else
{ {
ffStrbufClear(&key); ffStrbufClear(&key);
ffParseFormatString(&key, &options->moduleArgs.key, 3, (FFformatarg[]){ FF_PARSE_FORMAT_STRING_CHECKED(&key, &options->moduleArgs.key, 1, ((FFformatarg[]){
{FF_FORMAT_ARG_TYPE_STRBUF, &bios.type}, {FF_FORMAT_ARG_TYPE_STRBUF, &bios.type},
}); }));
} }
if(options->moduleArgs.outputFormat.length == 0) if(options->moduleArgs.outputFormat.length == 0)
@@ -59,13 +59,13 @@ void ffPrintBios(FFBiosOptions* options)
} }
else else
{ {
ffPrintFormat(key.chars, 0, &options->moduleArgs, FF_BIOS_NUM_FORMAT_ARGS, (FFformatarg[]) { FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_BIOS_NUM_FORMAT_ARGS, ((FFformatarg[]) {
{FF_FORMAT_ARG_TYPE_STRBUF, &bios.date}, {FF_FORMAT_ARG_TYPE_STRBUF, &bios.date},
{FF_FORMAT_ARG_TYPE_STRBUF, &bios.release}, {FF_FORMAT_ARG_TYPE_STRBUF, &bios.release},
{FF_FORMAT_ARG_TYPE_STRBUF, &bios.vendor}, {FF_FORMAT_ARG_TYPE_STRBUF, &bios.vendor},
{FF_FORMAT_ARG_TYPE_STRBUF, &bios.version}, {FF_FORMAT_ARG_TYPE_STRBUF, &bios.version},
{FF_FORMAT_ARG_TYPE_STRBUF, &bios.type}, {FF_FORMAT_ARG_TYPE_STRBUF, &bios.type},
}); }));
} }
exit: exit:
@@ -99,7 +99,7 @@ void ffParseBiosJsonObject(FFBiosOptions* options, yyjson_val* module)
if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs)) if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs))
continue; continue;
ffPrintError(FF_BIOS_MODULE_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key); ffPrintError(FF_BIOS_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Unknown JSON key %s", key);
} }
} }
@@ -151,13 +151,13 @@ exit:
void ffPrintBiosHelpFormat(void) void ffPrintBiosHelpFormat(void)
{ {
ffPrintModuleFormatHelp(FF_BIOS_MODULE_NAME, "{4} ({2})", FF_BIOS_NUM_FORMAT_ARGS, (const char* []) { FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_BIOS_MODULE_NAME, "{4} ({2})", FF_BIOS_NUM_FORMAT_ARGS, ((const char* []) {
"bios date", "bios date",
"bios release", "bios release",
"bios vendor", "bios vendor",
"bios version", "bios version",
"firmware type", "firmware type",
}); }));
} }
void ffInitBiosOptions(FFBiosOptions* options) void ffInitBiosOptions(FFBiosOptions* options)
+7 -7
View File
@@ -32,12 +32,12 @@ static void printDevice(FFBluetoothOptions* options, const FFBluetoothResult* de
FF_STRBUF_AUTO_DESTROY percentageStr = ffStrbufCreate(); FF_STRBUF_AUTO_DESTROY percentageStr = ffStrbufCreate();
ffPercentAppendNum(&percentageStr, device->battery, options->percent, false); ffPercentAppendNum(&percentageStr, device->battery, options->percent, false);
ffPrintFormat(FF_BLUETOOTH_MODULE_NAME, index, &options->moduleArgs, FF_BLUETOOTH_NUM_FORMAT_ARGS, (FFformatarg[]) { 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}, {FF_FORMAT_ARG_TYPE_STRBUF, &device->name},
{FF_FORMAT_ARG_TYPE_STRBUF, &device->address}, {FF_FORMAT_ARG_TYPE_STRBUF, &device->address},
{FF_FORMAT_ARG_TYPE_STRBUF, &device->type}, {FF_FORMAT_ARG_TYPE_STRBUF, &device->type},
{FF_FORMAT_ARG_TYPE_STRBUF, &percentageStr} {FF_FORMAT_ARG_TYPE_STRBUF, &percentageStr}
}); }));
} }
} }
@@ -48,7 +48,7 @@ void ffPrintBluetooth(FFBluetoothOptions* options)
if(error) if(error)
{ {
ffPrintError(FF_BLUETOOTH_MODULE_NAME, 0, &options->moduleArgs, "%s", error); ffPrintError(FF_BLUETOOTH_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "%s", error);
} }
else else
{ {
@@ -64,7 +64,7 @@ void ffPrintBluetooth(FFBluetoothOptions* options)
if(filtered.length == 0) if(filtered.length == 0)
{ {
ffPrintError(FF_BLUETOOTH_MODULE_NAME, 0, &options->moduleArgs, "No bluetooth devices found"); ffPrintError(FF_BLUETOOTH_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "No bluetooth devices found");
} }
for(uint32_t i = 0; i < filtered.length; i++) for(uint32_t i = 0; i < filtered.length; i++)
@@ -123,7 +123,7 @@ void ffParseBluetoothJsonObject(FFBluetoothOptions* options, yyjson_val* module)
if (ffPercentParseJsonObject(key, val, &options->percent)) if (ffPercentParseJsonObject(key, val, &options->percent))
continue; continue;
ffPrintError(FF_BLUETOOTH_MODULE_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key); ffPrintError(FF_BLUETOOTH_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Unknown JSON key %s", key);
} }
} }
@@ -175,12 +175,12 @@ void ffGenerateBluetoothJsonResult(FF_MAYBE_UNUSED FFBluetoothOptions* options,
void ffPrintBluetoothHelpFormat(void) void ffPrintBluetoothHelpFormat(void)
{ {
ffPrintModuleFormatHelp(FF_BLUETOOTH_MODULE_NAME, "{1} ({4})", FF_BLUETOOTH_NUM_FORMAT_ARGS, (const char* []) { FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_BLUETOOTH_MODULE_NAME, "{1} ({4})", FF_BLUETOOTH_NUM_FORMAT_ARGS, ((const char* []) {
"Name", "Name",
"Address", "Address",
"Type", "Type",
"Battery percentage" "Battery percentage"
}); }));
} }
void ffInitBluetoothOptions(FFBluetoothOptions* options) void ffInitBluetoothOptions(FFBluetoothOptions* options)
+8 -8
View File
@@ -4,7 +4,7 @@
#include "modules/board/board.h" #include "modules/board/board.h"
#include "util/stringUtils.h" #include "util/stringUtils.h"
#define FF_BOARD_NUM_FORMAT_ARGS 3 #define FF_BOARD_NUM_FORMAT_ARGS 4
void ffPrintBoard(FFBoardOptions* options) void ffPrintBoard(FFBoardOptions* options)
{ {
@@ -17,13 +17,13 @@ void ffPrintBoard(FFBoardOptions* options)
const char* error = ffDetectBoard(&result); const char* error = ffDetectBoard(&result);
if(error) if(error)
{ {
ffPrintError(FF_BOARD_MODULE_NAME, 0, &options->moduleArgs, "%s", error); ffPrintError(FF_BOARD_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "%s", error);
goto exit; goto exit;
} }
if(result.name.length == 0) if(result.name.length == 0)
{ {
ffPrintError(FF_BOARD_MODULE_NAME, 0, &options->moduleArgs, "board_name is not set."); ffPrintError(FF_BOARD_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "board_name is not set.");
goto exit; goto exit;
} }
@@ -37,12 +37,12 @@ void ffPrintBoard(FFBoardOptions* options)
} }
else else
{ {
ffPrintFormat(FF_BOARD_MODULE_NAME, 0, &options->moduleArgs, FF_BOARD_NUM_FORMAT_ARGS, (FFformatarg[]) { 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}, {FF_FORMAT_ARG_TYPE_STRBUF, &result.name},
{FF_FORMAT_ARG_TYPE_STRBUF, &result.vendor}, {FF_FORMAT_ARG_TYPE_STRBUF, &result.vendor},
{FF_FORMAT_ARG_TYPE_STRBUF, &result.version}, {FF_FORMAT_ARG_TYPE_STRBUF, &result.version},
{FF_FORMAT_ARG_TYPE_STRBUF, &result.serial}, {FF_FORMAT_ARG_TYPE_STRBUF, &result.serial},
}); }));
} }
exit: exit:
@@ -75,7 +75,7 @@ void ffParseBoardJsonObject(FFBoardOptions* options, yyjson_val* module)
if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs)) if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs))
continue; continue;
ffPrintError(FF_BOARD_MODULE_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key); ffPrintError(FF_BOARD_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Unknown JSON key %s", key);
} }
} }
@@ -124,12 +124,12 @@ exit:
void ffPrintBoardHelpFormat(void) void ffPrintBoardHelpFormat(void)
{ {
ffPrintModuleFormatHelp(FF_BOARD_MODULE_NAME, "{1} ({3})", FF_BOARD_NUM_FORMAT_ARGS, (const char* []) { FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_BOARD_MODULE_NAME, "{1} ({3})", FF_BOARD_NUM_FORMAT_ARGS, ((const char* []) {
"board name", "board name",
"board vendor", "board vendor",
"board version", "board version",
"board serial number", "board serial number",
}); }));
} }
void ffInitBoardOptions(FFBoardOptions* options) void ffInitBoardOptions(FFBoardOptions* options)
+9 -9
View File
@@ -15,13 +15,13 @@ void ffPrintBrightness(FFBrightnessOptions* options)
if(error) if(error)
{ {
ffPrintError(FF_BRIGHTNESS_MODULE_NAME, 0, &options->moduleArgs, "%s", error); ffPrintError(FF_BRIGHTNESS_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "%s", error);
return; return;
} }
if(result.length == 0) if(result.length == 0)
{ {
ffPrintError(FF_BRIGHTNESS_MODULE_NAME, 0, &options->moduleArgs, "No result is detected."); ffPrintError(FF_BRIGHTNESS_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "No result is detected.");
return; return;
} }
@@ -37,10 +37,10 @@ void ffPrintBrightness(FFBrightnessOptions* options)
else else
{ {
uint32_t moduleIndex = result.length == 1 ? 0 : index + 1; uint32_t moduleIndex = result.length == 1 ? 0 : index + 1;
ffParseFormatString(&key, &options->moduleArgs.key, 2, (FFformatarg[]){ FF_PARSE_FORMAT_STRING_CHECKED(&key, &options->moduleArgs.key, 2, ((FFformatarg[]){
{FF_FORMAT_ARG_TYPE_UINT, &moduleIndex}, {FF_FORMAT_ARG_TYPE_UINT, &moduleIndex},
{FF_FORMAT_ARG_TYPE_STRBUF, &item->name} {FF_FORMAT_ARG_TYPE_STRBUF, &item->name}
}); }));
} }
const double percent = (item->current - item->min) / (item->max - item->min) * 100; const double percent = (item->current - item->min) / (item->max - item->min) * 100;
@@ -69,13 +69,13 @@ void ffPrintBrightness(FFBrightnessOptions* options)
{ {
FF_STRBUF_AUTO_DESTROY valueStr = ffStrbufCreate(); FF_STRBUF_AUTO_DESTROY valueStr = ffStrbufCreate();
ffPercentAppendNum(&valueStr, percent, options->percent, false); ffPercentAppendNum(&valueStr, percent, options->percent, false);
ffPrintFormatString(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_BRIGHTNESS_NUM_FORMAT_ARGS, (FFformatarg[]) { 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, &valueStr}, {FF_FORMAT_ARG_TYPE_STRBUF, &valueStr},
{FF_FORMAT_ARG_TYPE_STRBUF, &item->name}, {FF_FORMAT_ARG_TYPE_STRBUF, &item->name},
{FF_FORMAT_ARG_TYPE_DOUBLE, &item->max}, {FF_FORMAT_ARG_TYPE_DOUBLE, &item->max},
{FF_FORMAT_ARG_TYPE_DOUBLE, &item->min}, {FF_FORMAT_ARG_TYPE_DOUBLE, &item->min},
{FF_FORMAT_ARG_TYPE_DOUBLE, &item->current}, {FF_FORMAT_ARG_TYPE_DOUBLE, &item->current},
}); }));
} }
ffStrbufClear(&key); ffStrbufClear(&key);
@@ -125,7 +125,7 @@ void ffParseBrightnessJsonObject(FFBrightnessOptions* options, yyjson_val* modul
if (ffPercentParseJsonObject(key, val, &options->percent)) if (ffPercentParseJsonObject(key, val, &options->percent))
continue; continue;
ffPrintError(FF_BRIGHTNESS_MODULE_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key); ffPrintError(FF_BRIGHTNESS_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Unknown JSON key %s", key);
} }
} }
@@ -180,13 +180,13 @@ void ffGenerateBrightnessJsonResult(FF_MAYBE_UNUSED FFBrightnessOptions* options
void ffPrintBrightnessHelpFormat(void) void ffPrintBrightnessHelpFormat(void)
{ {
ffPrintModuleFormatHelp(FF_BRIGHTNESS_MODULE_NAME, "{1}", FF_BRIGHTNESS_NUM_FORMAT_ARGS, (const char* []) { FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_BRIGHTNESS_MODULE_NAME, "{1}", FF_BRIGHTNESS_NUM_FORMAT_ARGS, ((const char* []) {
"Screen brightness (percentage)", "Screen brightness (percentage)",
"Screen name", "Screen name",
"Maximum brightness value", "Maximum brightness value",
"Minimum brightness value", "Minimum brightness value",
"Current brightness value", "Current brightness value",
}); }));
} }
void ffInitBrightnessOptions(FFBrightnessOptions* options) void ffInitBrightnessOptions(FFBrightnessOptions* options)
+8 -8
View File
@@ -5,7 +5,7 @@
#include "modules/camera/camera.h" #include "modules/camera/camera.h"
#include "util/stringUtils.h" #include "util/stringUtils.h"
#define FF_CAMERA_NUM_FORMAT_ARGS 5 #define FF_CAMERA_NUM_FORMAT_ARGS 6
static void printDevice(FFCameraOptions* options, const FFCameraResult* device, uint8_t index) static void printDevice(FFCameraOptions* options, const FFCameraResult* device, uint8_t index)
{ {
@@ -27,14 +27,14 @@ static void printDevice(FFCameraOptions* options, const FFCameraResult* device,
} }
else else
{ {
ffPrintFormat(FF_CAMERA_MODULE_NAME, index, &options->moduleArgs, FF_CAMERA_NUM_FORMAT_ARGS, (FFformatarg[]) { 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}, {FF_FORMAT_ARG_TYPE_STRBUF, &device->name},
{FF_FORMAT_ARG_TYPE_STRBUF, &device->vendor}, {FF_FORMAT_ARG_TYPE_STRBUF, &device->vendor},
{FF_FORMAT_ARG_TYPE_STRBUF, &device->colorspace}, {FF_FORMAT_ARG_TYPE_STRBUF, &device->colorspace},
{FF_FORMAT_ARG_TYPE_STRBUF, &device->id}, {FF_FORMAT_ARG_TYPE_STRBUF, &device->id},
{FF_FORMAT_ARG_TYPE_UINT, &device->width}, {FF_FORMAT_ARG_TYPE_UINT, &device->width},
{FF_FORMAT_ARG_TYPE_UINT, &device->height}, {FF_FORMAT_ARG_TYPE_UINT, &device->height},
}); })));
} }
} }
@@ -45,13 +45,13 @@ void ffPrintCamera(FFCameraOptions* options)
if (error) if (error)
{ {
ffPrintError(FF_CAMERA_MODULE_NAME, 0, &options->moduleArgs, "%s", error); ffPrintError(FF_CAMERA_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "%s", error);
return; return;
} }
if (result.length == 0) if (result.length == 0)
{ {
ffPrintError(FF_CAMERA_MODULE_NAME, 0, &options->moduleArgs, "No camera found"); ffPrintError(FF_CAMERA_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "No camera found");
return; return;
} }
@@ -92,7 +92,7 @@ void ffParseCameraJsonObject(FFCameraOptions* options, yyjson_val* module)
if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs)) if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs))
continue; continue;
ffPrintError(FF_CAMERA_MODULE_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key); ffPrintError(FF_CAMERA_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Unknown JSON key %s", key);
} }
} }
@@ -138,14 +138,14 @@ void ffGenerateCameraJsonResult(FF_MAYBE_UNUSED FFCameraOptions* options, yyjson
void ffPrintCameraHelpFormat(void) void ffPrintCameraHelpFormat(void)
{ {
ffPrintModuleFormatHelp(FF_CAMERA_MODULE_NAME, "{1} ({4}px x {5}px)", FF_CAMERA_NUM_FORMAT_ARGS, (const char* []) { FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_CAMERA_MODULE_NAME, "{1} ({4}px x {5}px)", FF_CAMERA_NUM_FORMAT_ARGS, ((const char* []) {
"Device name", "Device name",
"Vendor", "Vendor",
"Color space", "Color space",
"Identifier", "Identifier",
"Width (in px)", "Width (in px)",
"Height (in px)", "Height (in px)",
}); }));
} }
void ffInitCameraOptions(FFCameraOptions* options) void ffInitCameraOptions(FFCameraOptions* options)
+8 -8
View File
@@ -4,7 +4,7 @@
#include "modules/chassis/chassis.h" #include "modules/chassis/chassis.h"
#include "util/stringUtils.h" #include "util/stringUtils.h"
#define FF_CHASSIS_NUM_FORMAT_ARGS 3 #define FF_CHASSIS_NUM_FORMAT_ARGS 4
void ffPrintChassis(FFChassisOptions* options) void ffPrintChassis(FFChassisOptions* options)
{ {
@@ -18,13 +18,13 @@ void ffPrintChassis(FFChassisOptions* options)
if(error) if(error)
{ {
ffPrintError(FF_CHASSIS_MODULE_NAME, 0, &options->moduleArgs, "%s", error); ffPrintError(FF_CHASSIS_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "%s", error);
goto exit; goto exit;
} }
if(result.type.length == 0) if(result.type.length == 0)
{ {
ffPrintError(FF_CHASSIS_MODULE_NAME, 0, &options->moduleArgs, "chassis_type is not set by O.E.M."); ffPrintError(FF_CHASSIS_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "chassis_type is not set by O.E.M.");
goto exit; goto exit;
} }
@@ -38,12 +38,12 @@ void ffPrintChassis(FFChassisOptions* options)
} }
else else
{ {
ffPrintFormat(FF_CHASSIS_MODULE_NAME, 0, &options->moduleArgs, FF_CHASSIS_NUM_FORMAT_ARGS, (FFformatarg[]) { 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}, {FF_FORMAT_ARG_TYPE_STRBUF, &result.type},
{FF_FORMAT_ARG_TYPE_STRBUF, &result.vendor}, {FF_FORMAT_ARG_TYPE_STRBUF, &result.vendor},
{FF_FORMAT_ARG_TYPE_STRBUF, &result.version}, {FF_FORMAT_ARG_TYPE_STRBUF, &result.version},
{FF_FORMAT_ARG_TYPE_STRBUF, &result.serial}, {FF_FORMAT_ARG_TYPE_STRBUF, &result.serial},
}); }));
} }
exit: exit:
@@ -76,7 +76,7 @@ void ffParseChassisJsonObject(FFChassisOptions* options, yyjson_val* module)
if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs)) if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs))
continue; continue;
ffPrintError(FF_CHASSIS_MODULE_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key); ffPrintError(FF_CHASSIS_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Unknown JSON key %s", key);
} }
} }
@@ -125,12 +125,12 @@ exit:
void ffPrintChassisHelpFormat(void) void ffPrintChassisHelpFormat(void)
{ {
ffPrintModuleFormatHelp(FF_CHASSIS_MODULE_NAME, "{1}", FF_CHASSIS_NUM_FORMAT_ARGS, (const char* []) { FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_CHASSIS_MODULE_NAME, "{1}", FF_CHASSIS_NUM_FORMAT_ARGS, ((const char* []) {
"chassis type", "chassis type",
"chassis vendor", "chassis vendor",
"chassis version", "chassis version",
"chassis serial number", "chassis serial number",
}); }));
} }
void ffInitChassisOptions(FFChassisOptions* options) void ffInitChassisOptions(FFChassisOptions* options)
+7 -7
View File
@@ -88,7 +88,7 @@ void ffPrintColors(FFColorsOptions* options)
if (!flag) if (!flag)
{ {
ffPrintError(FF_COLORS_MODULE_NAME, 0, &options->moduleArgs, "%s", "Nothing to print"); ffPrintError(FF_COLORS_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "%s", "Nothing to print");
} }
} }
@@ -166,7 +166,7 @@ void ffParseColorsJsonObject(FFColorsOptions* options, yyjson_val* module)
{}, {},
}); });
if (error) if (error)
ffPrintErrorString(FF_COLORS_MODULE_NAME, 0, NULL, FF_PRINT_TYPE_NO_CUSTOM_KEY, "Invalid %s value: %s", key, error); ffPrintError(FF_COLORS_MODULE_NAME, 0, NULL, FF_PRINT_TYPE_NO_CUSTOM_KEY, "Invalid %s value: %s", key, error);
else else
options->symbol = (FFColorsSymbol) value; options->symbol = (FFColorsSymbol) value;
continue; continue;
@@ -181,7 +181,7 @@ void ffParseColorsJsonObject(FFColorsOptions* options, yyjson_val* module)
if (ffStrEqualsIgnCase(key, "block")) if (ffStrEqualsIgnCase(key, "block"))
{ {
if (!yyjson_is_obj(val)) if (!yyjson_is_obj(val))
ffPrintErrorString(FF_COLORS_MODULE_NAME, 0, NULL, FF_PRINT_TYPE_NO_CUSTOM_KEY, "Invalid %s value: must be an object", key); ffPrintError(FF_COLORS_MODULE_NAME, 0, NULL, FF_PRINT_TYPE_NO_CUSTOM_KEY, "Invalid %s value: must be an object", key);
else else
{ {
yyjson_val* width = yyjson_obj_get(val, "width"); yyjson_val* width = yyjson_obj_get(val, "width");
@@ -192,15 +192,15 @@ void ffParseColorsJsonObject(FFColorsOptions* options, yyjson_val* module)
if (range) if (range)
{ {
if (!yyjson_is_arr(range) || yyjson_arr_size(range) != 2) if (!yyjson_is_arr(range) || yyjson_arr_size(range) != 2)
ffPrintErrorString(FF_COLORS_MODULE_NAME, 0, NULL, FF_PRINT_TYPE_NO_CUSTOM_KEY, "Invalid %s.range value: must be an array of 2 elements", key); ffPrintError(FF_COLORS_MODULE_NAME, 0, NULL, FF_PRINT_TYPE_NO_CUSTOM_KEY, "Invalid %s.range value: must be an array of 2 elements", key);
else else
{ {
uint8_t start = (uint8_t) yyjson_get_uint(yyjson_arr_get(range, 0)); uint8_t start = (uint8_t) yyjson_get_uint(yyjson_arr_get(range, 0));
uint8_t end = (uint8_t) yyjson_get_uint(yyjson_arr_get(range, 1)); uint8_t end = (uint8_t) yyjson_get_uint(yyjson_arr_get(range, 1));
if (start > end) if (start > end)
ffPrintErrorString(FF_COLORS_MODULE_NAME, 0, NULL, FF_PRINT_TYPE_NO_CUSTOM_KEY, "Invalid %s.range value: range[0] > range[1]", key); ffPrintError(FF_COLORS_MODULE_NAME, 0, NULL, FF_PRINT_TYPE_NO_CUSTOM_KEY, "Invalid %s.range value: range[0] > range[1]", key);
else if (end > 15) else if (end > 15)
ffPrintErrorString(FF_COLORS_MODULE_NAME, 0, NULL, FF_PRINT_TYPE_NO_CUSTOM_KEY, "Invalid %s.range value: range[1] > 15", key); ffPrintError(FF_COLORS_MODULE_NAME, 0, NULL, FF_PRINT_TYPE_NO_CUSTOM_KEY, "Invalid %s.range value: range[1] > 15", key);
else else
{ {
options->block.range[0] = start; options->block.range[0] = start;
@@ -212,7 +212,7 @@ void ffParseColorsJsonObject(FFColorsOptions* options, yyjson_val* module)
continue; continue;
} }
ffPrintErrorString(FF_COLORS_MODULE_NAME, 0, NULL, FF_PRINT_TYPE_NO_CUSTOM_KEY, "Unknown JSON key %s", key); ffPrintError(FF_COLORS_MODULE_NAME, 0, NULL, FF_PRINT_TYPE_NO_CUSTOM_KEY, "Unknown JSON key %s", key);
} }
} }
+7 -7
View File
@@ -22,13 +22,13 @@ void ffPrintCommand(FFCommandOptions* options)
if(error) if(error)
{ {
ffPrintError(FF_COMMAND_MODULE_NAME, 0, &options->moduleArgs, "%s", error); ffPrintError(FF_COMMAND_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "%s", error);
return; return;
} }
if(!result.length) if(!result.length)
{ {
ffPrintError(FF_COMMAND_MODULE_NAME, 0, &options->moduleArgs, "No result printed"); ffPrintError(FF_COMMAND_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "No result printed");
return; return;
} }
@@ -39,9 +39,9 @@ void ffPrintCommand(FFCommandOptions* options)
} }
else else
{ {
ffPrintFormat(FF_COMMAND_MODULE_NAME, 0, &options->moduleArgs, FF_COMMAND_NUM_FORMAT_ARGS, (FFformatarg[]){ 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} {FF_FORMAT_ARG_TYPE_STRBUF, &result}
}); }));
} }
} }
@@ -92,7 +92,7 @@ void ffParseCommandJsonObject(FFCommandOptions* options, yyjson_val* module)
continue; continue;
} }
ffPrintError(FF_COMMAND_MODULE_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key); ffPrintError(FF_COMMAND_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Unknown JSON key %s", key);
} }
} }
@@ -141,9 +141,9 @@ void ffGenerateCommandJsonResult(FF_MAYBE_UNUSED FFCommandOptions* options, yyjs
void ffPrintCommandHelpFormat(void) void ffPrintCommandHelpFormat(void)
{ {
ffPrintModuleFormatHelp(FF_COMMAND_MODULE_NAME, "{1}", FF_COMMAND_NUM_FORMAT_ARGS, (const char* []) { FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_COMMAND_MODULE_NAME, "{1}", FF_COMMAND_NUM_FORMAT_ARGS, ((const char* []) {
"Command result" "Command result"
}); }));
} }
void ffInitCommandOptions(FFCommandOptions* options) void ffInitCommandOptions(FFCommandOptions* options)
+18 -14
View File
@@ -13,7 +13,7 @@ void ffPrintCPU(FFCPUOptions* options)
FFCPUResult cpu; FFCPUResult cpu;
cpu.temperature = FF_CPU_TEMP_UNSET; cpu.temperature = FF_CPU_TEMP_UNSET;
cpu.coresPhysical = cpu.coresLogical = cpu.coresOnline = 0; cpu.coresPhysical = cpu.coresLogical = cpu.coresOnline = 0;
cpu.frequencyMax = cpu.frequencyMin = 0; cpu.frequencyMin = cpu.frequencyMax = cpu.frequencyBase = 0.0/0.0;
ffStrbufInit(&cpu.name); ffStrbufInit(&cpu.name);
ffStrbufInit(&cpu.vendor); ffStrbufInit(&cpu.vendor);
@@ -21,11 +21,11 @@ void ffPrintCPU(FFCPUOptions* options)
if(error) if(error)
{ {
ffPrintError(FF_CPU_MODULE_NAME, 0, &options->moduleArgs, "%s", error); ffPrintError(FF_CPU_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "%s", error);
} }
else if(cpu.vendor.length == 0 && cpu.name.length == 0 && cpu.coresOnline <= 1) else if(cpu.vendor.length == 0 && cpu.name.length == 0 && cpu.coresOnline <= 1)
{ {
ffPrintError(FF_CPU_MODULE_NAME, 0, &options->moduleArgs, "No CPU detected"); ffPrintError(FF_CPU_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "No CPU detected");
} }
else else
{ {
@@ -48,8 +48,11 @@ void ffPrintCPU(FFCPUOptions* options)
if(cpu.coresOnline > 1) if(cpu.coresOnline > 1)
ffStrbufAppendF(&str, " (%u)", cpu.coresOnline); ffStrbufAppendF(&str, " (%u)", cpu.coresOnline);
if(cpu.frequencyMax > 0.0) double freq = cpu.frequencyMax;
ffStrbufAppendF(&str, " @ %.*f GHz", options->freqNdigits, cpu.frequencyMax); if(freq != freq)
freq = cpu.frequencyBase;
if(freq == freq)
ffStrbufAppendF(&str, " @ %.*f GHz", options->freqNdigits, freq);
if(cpu.temperature == cpu.temperature) //FF_CPU_TEMP_UNSET if(cpu.temperature == cpu.temperature) //FF_CPU_TEMP_UNSET
{ {
@@ -63,16 +66,16 @@ void ffPrintCPU(FFCPUOptions* options)
{ {
FF_STRBUF_AUTO_DESTROY tempStr = ffStrbufCreate(); FF_STRBUF_AUTO_DESTROY tempStr = ffStrbufCreate();
ffTempsAppendNum(cpu.temperature, &tempStr, options->tempConfig); ffTempsAppendNum(cpu.temperature, &tempStr, options->tempConfig);
ffPrintFormat(FF_CPU_MODULE_NAME, 0, &options->moduleArgs, FF_CPU_NUM_FORMAT_ARGS, (FFformatarg[]){ 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}, {FF_FORMAT_ARG_TYPE_STRBUF, &cpu.name},
{FF_FORMAT_ARG_TYPE_STRBUF, &cpu.vendor}, {FF_FORMAT_ARG_TYPE_STRBUF, &cpu.vendor},
{FF_FORMAT_ARG_TYPE_UINT16, &cpu.coresPhysical}, {FF_FORMAT_ARG_TYPE_UINT16, &cpu.coresPhysical},
{FF_FORMAT_ARG_TYPE_UINT16, &cpu.coresLogical}, {FF_FORMAT_ARG_TYPE_UINT16, &cpu.coresLogical},
{FF_FORMAT_ARG_TYPE_UINT16, &cpu.coresOnline}, {FF_FORMAT_ARG_TYPE_UINT16, &cpu.coresOnline},
{FF_FORMAT_ARG_TYPE_DOUBLE, &cpu.frequencyMin}, {FF_FORMAT_ARG_TYPE_DOUBLE, &cpu.frequencyBase},
{FF_FORMAT_ARG_TYPE_DOUBLE, &cpu.frequencyMax}, {FF_FORMAT_ARG_TYPE_DOUBLE, &cpu.frequencyMax},
{FF_FORMAT_ARG_TYPE_STRBUF, &tempStr} {FF_FORMAT_ARG_TYPE_STRBUF, &tempStr}
}); }));
} }
} }
@@ -121,7 +124,7 @@ void ffParseCPUJsonObject(FFCPUOptions* options, yyjson_val* module)
continue; continue;
} }
ffPrintError(FF_CPU_MODULE_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key); ffPrintError(FF_CPU_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Unknown JSON key %s", key);
} }
} }
@@ -143,7 +146,7 @@ void ffGenerateCPUJsonResult(FFCPUOptions* options, yyjson_mut_doc* doc, yyjson_
FFCPUResult cpu; FFCPUResult cpu;
cpu.temperature = FF_CPU_TEMP_UNSET; cpu.temperature = FF_CPU_TEMP_UNSET;
cpu.coresPhysical = cpu.coresLogical = cpu.coresOnline = 0; cpu.coresPhysical = cpu.coresLogical = cpu.coresOnline = 0;
cpu.frequencyMax = cpu.frequencyMin = 0; cpu.frequencyMin = cpu.frequencyMax = cpu.frequencyBase = 0.0/0.0;
ffStrbufInit(&cpu.name); ffStrbufInit(&cpu.name);
ffStrbufInit(&cpu.vendor); ffStrbufInit(&cpu.vendor);
@@ -169,8 +172,9 @@ void ffGenerateCPUJsonResult(FFCPUOptions* options, yyjson_mut_doc* doc, yyjson_
yyjson_mut_obj_add_uint(doc, cores, "online", cpu.coresOnline); yyjson_mut_obj_add_uint(doc, cores, "online", cpu.coresOnline);
yyjson_mut_val* frequency = yyjson_mut_obj_add_obj(doc, obj, "frequency"); yyjson_mut_val* frequency = yyjson_mut_obj_add_obj(doc, obj, "frequency");
yyjson_mut_obj_add_real(doc, frequency, "min", cpu.frequencyMin); yyjson_mut_obj_add_real(doc, frequency, "base", cpu.frequencyBase);
yyjson_mut_obj_add_real(doc, frequency, "max", cpu.frequencyMax); yyjson_mut_obj_add_real(doc, frequency, "max", cpu.frequencyMax);
yyjson_mut_obj_add_real(doc, frequency, "min", cpu.frequencyMin);
yyjson_mut_obj_add_real(doc, obj, "temperature", cpu.temperature); yyjson_mut_obj_add_real(doc, obj, "temperature", cpu.temperature);
} }
@@ -181,16 +185,16 @@ void ffGenerateCPUJsonResult(FFCPUOptions* options, yyjson_mut_doc* doc, yyjson_
void ffPrintCPUHelpFormat(void) void ffPrintCPUHelpFormat(void)
{ {
ffPrintModuleFormatHelp(FF_CPU_MODULE_NAME, "{1} ({5}) @ {7} GHz", FF_CPU_NUM_FORMAT_ARGS, (const char* []) { FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_CPU_MODULE_NAME, "{1} ({5}) @ {7} GHz", FF_CPU_NUM_FORMAT_ARGS, ((const char* []) {
"Name", "Name",
"Vendor", "Vendor",
"Physical core count", "Physical core count",
"Logical core count", "Logical core count",
"Online core count", "Online core count",
"Min frequency", "Base frequency",
"Max frequency", "Max frequency",
"Temperature (formatted)" "Temperature (formatted)"
}); }));
} }
void ffInitCPUOptions(FFCPUOptions* options) void ffInitCPUOptions(FFCPUOptions* options)
+6 -6
View File
@@ -15,7 +15,7 @@ void ffPrintCPUUsage(FFCPUUsageOptions* options)
if(error) if(error)
{ {
ffPrintError(FF_CPUUSAGE_DISPLAY_NAME, 0, &options->moduleArgs, "%s", error); ffPrintError(FF_CPUUSAGE_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "%s", error);
return; return;
} }
@@ -79,13 +79,13 @@ void ffPrintCPUUsage(FFCPUUsageOptions* options)
ffPercentAppendNum(&minStr, minValue, options->percent, false); ffPercentAppendNum(&minStr, minValue, options->percent, false);
FF_STRBUF_AUTO_DESTROY maxStr = ffStrbufCreate(); FF_STRBUF_AUTO_DESTROY maxStr = ffStrbufCreate();
ffPercentAppendNum(&maxStr, maxValue, options->percent, false); ffPercentAppendNum(&maxStr, maxValue, options->percent, false);
ffPrintFormat(FF_CPUUSAGE_DISPLAY_NAME, 0, &options->moduleArgs, FF_CPUUSAGE_NUM_FORMAT_ARGS, (FFformatarg[]){ 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, &avgStr}, {FF_FORMAT_ARG_TYPE_STRBUF, &avgStr},
{FF_FORMAT_ARG_TYPE_STRBUF, &maxStr}, {FF_FORMAT_ARG_TYPE_STRBUF, &maxStr},
{FF_FORMAT_ARG_TYPE_UINT, &maxIndex}, {FF_FORMAT_ARG_TYPE_UINT, &maxIndex},
{FF_FORMAT_ARG_TYPE_STRBUF, &minStr}, {FF_FORMAT_ARG_TYPE_STRBUF, &minStr},
{FF_FORMAT_ARG_TYPE_UINT, &minIndex}, {FF_FORMAT_ARG_TYPE_UINT, &minIndex},
}); }));
} }
} }
@@ -130,7 +130,7 @@ void ffParseCPUUsageJsonObject(FFCPUUsageOptions* options, yyjson_val* module)
if (ffPercentParseJsonObject(key, val, &options->percent)) if (ffPercentParseJsonObject(key, val, &options->percent))
continue; continue;
ffPrintError(FF_CPUUSAGE_MODULE_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key); ffPrintError(FF_CPUUSAGE_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Unknown JSON key %s", key);
} }
} }
@@ -166,13 +166,13 @@ void ffGenerateCPUUsageJsonResult(FF_MAYBE_UNUSED FFCPUUsageOptions* options, yy
void ffPrintCPUUsageHelpFormat(void) void ffPrintCPUUsageHelpFormat(void)
{ {
ffPrintModuleFormatHelp(FF_CPUUSAGE_MODULE_NAME, "{1}", FF_CPUUSAGE_NUM_FORMAT_ARGS, (const char* []) { FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_CPUUSAGE_MODULE_NAME, "{1}", FF_CPUUSAGE_NUM_FORMAT_ARGS, ((const char* []) {
"CPU usage (percentage, average)", "CPU usage (percentage, average)",
"CPU usage (percentage, maximum)", "CPU usage (percentage, maximum)",
"CPU core index of maximum usage", "CPU core index of maximum usage",
"CPU usage (percentage, minimum)", "CPU usage (percentage, minimum)",
"CPU core index of minimum usage", "CPU core index of minimum usage",
}); }));
} }
void ffInitCPUUsageOptions(FFCPUUsageOptions* options) void ffInitCPUUsageOptions(FFCPUUsageOptions* options)
+6 -6
View File
@@ -16,7 +16,7 @@ void ffPrintCursor(FFCursorOptions* options)
ffDetectCursor(&result); ffDetectCursor(&result);
if(result.error.length) if(result.error.length)
ffPrintError(FF_CURSOR_MODULE_NAME, 0, &options->moduleArgs, "%s", result.error.chars); ffPrintError(FF_CURSOR_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "%s", result.error.chars);
else else
{ {
ffStrbufRemoveIgnCaseEndS(&result.theme, "cursors"); ffStrbufRemoveIgnCaseEndS(&result.theme, "cursors");
@@ -38,10 +38,10 @@ void ffPrintCursor(FFCursorOptions* options)
} }
else else
{ {
ffPrintFormat(FF_CURSOR_MODULE_NAME, 0, &options->moduleArgs, FF_CURSOR_NUM_FORMAT_ARGS, (FFformatarg[]){ 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}, {FF_FORMAT_ARG_TYPE_STRBUF, &result.theme},
{FF_FORMAT_ARG_TYPE_STRBUF, &result.size} {FF_FORMAT_ARG_TYPE_STRBUF, &result.size}
}); }));
} }
} }
@@ -73,7 +73,7 @@ void ffParseCursorJsonObject(FFCursorOptions* options, yyjson_val* module)
if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs)) if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs))
continue; continue;
ffPrintError(FF_CURSOR_MODULE_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key); ffPrintError(FF_CURSOR_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Unknown JSON key %s", key);
} }
} }
@@ -112,10 +112,10 @@ void ffGenerateCursorJsonResult(FF_MAYBE_UNUSED FFCursorOptions* options, yyjson
void ffPrintCursorHelpFormat(void) void ffPrintCursorHelpFormat(void)
{ {
ffPrintModuleFormatHelp(FF_CURSOR_MODULE_NAME, "{1} ({2}px)", FF_CURSOR_NUM_FORMAT_ARGS, (const char* []) { FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_CURSOR_MODULE_NAME, "{1} ({2}px)", FF_CURSOR_NUM_FORMAT_ARGS, ((const char* []) {
"Cursor theme", "Cursor theme",
"Cursor size" "Cursor size"
}); }));
} }
void ffInitCursorOptions(FFCursorOptions* options) void ffInitCursorOptions(FFCursorOptions* options)
+2 -2
View File
@@ -8,7 +8,7 @@ void ffPrintCustom(FFCustomOptions* options)
{ {
if (options->moduleArgs.outputFormat.length == 0) if (options->moduleArgs.outputFormat.length == 0)
{ {
ffPrintError(FF_CUSTOM_MODULE_NAME, 0, &options->moduleArgs, "output format must be set for custom module"); ffPrintError(FF_CUSTOM_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "output format must be set for custom module");
return; return;
} }
@@ -48,7 +48,7 @@ void ffParseCustomJsonObject(FFCustomOptions* options, yyjson_val* module)
if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs)) if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs))
continue; continue;
ffPrintError(FF_CUSTOM_MODULE_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key); ffPrintError(FF_CUSTOM_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Unknown JSON key %s", key);
} }
} }
+6 -6
View File
@@ -65,7 +65,7 @@ void ffPrintDateTimeFormat(struct tm* tm, const FFModuleArgs* moduleArgs)
strftime(result.offsetFromUtc, sizeof(result.offsetFromUtc), "%z", tm); strftime(result.offsetFromUtc, sizeof(result.offsetFromUtc), "%z", tm);
strftime(result.timezoneName, sizeof(result.timezoneName), "%Z", tm); strftime(result.timezoneName, sizeof(result.timezoneName), "%Z", tm);
ffPrintFormat(FF_DATETIME_DISPLAY_NAME, 0, moduleArgs, FF_DATETIME_NUM_FORMAT_ARGS, (FFformatarg[]) { 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}, // 1 {FF_FORMAT_ARG_TYPE_UINT16, &result.year}, // 1
{FF_FORMAT_ARG_TYPE_UINT8, &result.yearShort}, // 2 {FF_FORMAT_ARG_TYPE_UINT8, &result.yearShort}, // 2
{FF_FORMAT_ARG_TYPE_UINT8, &result.month}, // 3 {FF_FORMAT_ARG_TYPE_UINT8, &result.month}, // 3
@@ -88,7 +88,7 @@ void ffPrintDateTimeFormat(struct tm* tm, const FFModuleArgs* moduleArgs)
{FF_FORMAT_ARG_TYPE_STRING, result.secondPretty}, // 20 {FF_FORMAT_ARG_TYPE_STRING, result.secondPretty}, // 20
{FF_FORMAT_ARG_TYPE_STRING, result.offsetFromUtc}, // 21 {FF_FORMAT_ARG_TYPE_STRING, result.offsetFromUtc}, // 21
{FF_FORMAT_ARG_TYPE_STRING, result.timezoneName}, // 22 {FF_FORMAT_ARG_TYPE_STRING, result.timezoneName}, // 22
}); }));
} }
void ffPrintDateTime(FFDateTimeOptions* options) void ffPrintDateTime(FFDateTimeOptions* options)
@@ -106,7 +106,7 @@ void ffPrintDateTime(FFDateTimeOptions* options)
char buffer[32]; char buffer[32];
if (strftime(buffer, sizeof(buffer), "%F %T", tm) == 0) //yyyy-MM-dd HH:mm:ss if (strftime(buffer, sizeof(buffer), "%F %T", tm) == 0) //yyyy-MM-dd HH:mm:ss
{ {
ffPrintError(FF_DATETIME_DISPLAY_NAME, 0, &options->moduleArgs, "strftime() failed"); ffPrintError(FF_DATETIME_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "strftime() failed");
return; return;
} }
@@ -138,7 +138,7 @@ void ffParseDateTimeJsonObject(FFDateTimeOptions* options, yyjson_val* module)
if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs)) if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs))
continue; continue;
ffPrintError(FF_DATETIME_DISPLAY_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key); ffPrintError(FF_DATETIME_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Unknown JSON key %s", key);
} }
} }
@@ -157,7 +157,7 @@ void ffGenerateDateTimeJsonResult(FF_MAYBE_UNUSED FFDateTimeOptions* options, yy
void ffPrintDateTimeHelpFormat(void) void ffPrintDateTimeHelpFormat(void)
{ {
ffPrintModuleFormatHelp(FF_DATETIME_MODULE_NAME, "{1}-{4}-{11} {14}:{18}:{20}", FF_DATETIME_NUM_FORMAT_ARGS, (const char* []) { FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_DATETIME_MODULE_NAME, "{1}-{4}-{11} {14}:{18}:{20}", FF_DATETIME_NUM_FORMAT_ARGS, ((const char* []) {
"year", "year",
"last two digits of year", "last two digits of year",
"month", "month",
@@ -180,7 +180,7 @@ void ffPrintDateTimeHelpFormat(void)
"second with leading zero", "second with leading zero",
"offset from UTC in the ISO 8601 format", "offset from UTC in the ISO 8601 format",
"locale-dependent timezone name or abbreviation", "locale-dependent timezone name or abbreviation",
}); }));
} }
void ffInitDateTimeOptions(FFDateTimeOptions* options) void ffInitDateTimeOptions(FFDateTimeOptions* options)
+6 -6
View File
@@ -13,7 +13,7 @@ void ffPrintDE(FFDEOptions* options)
if(result->dePrettyName.length == 0) if(result->dePrettyName.length == 0)
{ {
ffPrintError(FF_DE_MODULE_NAME, 0, &options->moduleArgs, "No DE found"); ffPrintError(FF_DE_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "No DE found");
return; return;
} }
@@ -36,11 +36,11 @@ void ffPrintDE(FFDEOptions* options)
} }
else else
{ {
ffPrintFormat(FF_DE_MODULE_NAME, 0, &options->moduleArgs, FF_DE_NUM_FORMAT_ARGS, (FFformatarg[]){ 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}, {FF_FORMAT_ARG_TYPE_STRBUF, &result->deProcessName},
{FF_FORMAT_ARG_TYPE_STRBUF, &result->dePrettyName}, {FF_FORMAT_ARG_TYPE_STRBUF, &result->dePrettyName},
{FF_FORMAT_ARG_TYPE_STRBUF, &version} {FF_FORMAT_ARG_TYPE_STRBUF, &version}
}); }));
} }
} }
@@ -79,7 +79,7 @@ void ffParseDEJsonObject(FFDEOptions* options, yyjson_val* module)
continue; continue;
} }
ffPrintError(FF_DE_MODULE_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key); ffPrintError(FF_DE_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Unknown JSON key %s", key);
} }
} }
@@ -115,11 +115,11 @@ void ffGenerateDEJsonResult(FF_MAYBE_UNUSED FFDEOptions* options, yyjson_mut_doc
void ffPrintDEHelpFormat(void) void ffPrintDEHelpFormat(void)
{ {
ffPrintModuleFormatHelp(FF_DE_MODULE_NAME, "{2} {3}", FF_DE_NUM_FORMAT_ARGS, (const char* []) { FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_DE_MODULE_NAME, "{2} {3}", FF_DE_NUM_FORMAT_ARGS, ((const char* []) {
"DE process name", "DE process name",
"DE pretty name", "DE pretty name",
"DE version" "DE version"
}); }));
} }
void ffInitDEOptions(FFDEOptions* options) void ffInitDEOptions(FFDEOptions* options)
+12 -10
View File
@@ -34,11 +34,11 @@ static void printDisk(FFDiskOptions* options, const FFDisk* disk)
} }
else else
{ {
ffParseFormatString(&key, &options->moduleArgs.key, 3, (FFformatarg[]){ FF_PARSE_FORMAT_STRING_CHECKED(&key, &options->moduleArgs.key, 3, ((FFformatarg[]){
{FF_FORMAT_ARG_TYPE_STRBUF, &disk->mountpoint}, {FF_FORMAT_ARG_TYPE_STRBUF, &disk->mountpoint},
{FF_FORMAT_ARG_TYPE_STRBUF, &disk->name}, {FF_FORMAT_ARG_TYPE_STRBUF, &disk->name},
{FF_FORMAT_ARG_TYPE_STRBUF, &disk->mountFrom}, {FF_FORMAT_ARG_TYPE_STRBUF, &disk->mountFrom},
}); }));
} }
FF_STRBUF_AUTO_DESTROY usedPretty = ffStrbufCreate(); FF_STRBUF_AUTO_DESTROY usedPretty = ffStrbufCreate();
@@ -112,7 +112,7 @@ static void printDisk(FFDiskOptions* options, const FFDisk* disk)
bool isExternal = !!(disk->type & FF_DISK_VOLUME_TYPE_EXTERNAL_BIT); bool isExternal = !!(disk->type & FF_DISK_VOLUME_TYPE_EXTERNAL_BIT);
bool isHidden = !!(disk->type & FF_DISK_VOLUME_TYPE_HIDDEN_BIT); bool isHidden = !!(disk->type & FF_DISK_VOLUME_TYPE_HIDDEN_BIT);
bool isReadOnly = !!(disk->type & FF_DISK_VOLUME_TYPE_READONLY_BIT); bool isReadOnly = !!(disk->type & FF_DISK_VOLUME_TYPE_READONLY_BIT);
ffPrintFormatString(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_DISK_NUM_FORMAT_ARGS, (FFformatarg[]){ 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}, {FF_FORMAT_ARG_TYPE_STRBUF, &usedPretty},
{FF_FORMAT_ARG_TYPE_STRBUF, &totalPretty}, {FF_FORMAT_ARG_TYPE_STRBUF, &totalPretty},
{FF_FORMAT_ARG_TYPE_STRBUF, &bytesPercentageStr}, {FF_FORMAT_ARG_TYPE_STRBUF, &bytesPercentageStr},
@@ -124,7 +124,7 @@ static void printDisk(FFDiskOptions* options, const FFDisk* disk)
{FF_FORMAT_ARG_TYPE_STRBUF, &disk->filesystem}, {FF_FORMAT_ARG_TYPE_STRBUF, &disk->filesystem},
{FF_FORMAT_ARG_TYPE_STRBUF, &disk->name}, {FF_FORMAT_ARG_TYPE_STRBUF, &disk->name},
{FF_FORMAT_ARG_TYPE_BOOL, &isReadOnly}, {FF_FORMAT_ARG_TYPE_BOOL, &isReadOnly},
}); }));
} }
} }
@@ -139,7 +139,7 @@ static void printMountpoint(FFDiskOptions* options, const FFlist* disks, const c
} }
} }
ffPrintError(FF_DISK_MODULE_NAME, 0, &options->moduleArgs, "No disk found for mountpoint: %s", mountpoint); ffPrintError(FF_DISK_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "No disk found for mountpoint: %s", mountpoint);
} }
static void printMountpoints(FFDiskOptions* options, const FFlist* disks) static void printMountpoints(FFDiskOptions* options, const FFlist* disks)
@@ -183,7 +183,7 @@ void ffPrintDisk(FFDiskOptions* options)
if(error) if(error)
{ {
ffPrintError(FF_DISK_MODULE_NAME, 0, &options->moduleArgs, "%s", error); ffPrintError(FF_DISK_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "%s", error);
} }
else else
{ {
@@ -360,7 +360,7 @@ void ffParseDiskJsonObject(FFDiskOptions* options, yyjson_val* module)
if (ffPercentParseJsonObject(key, val, &options->percent)) if (ffPercentParseJsonObject(key, val, &options->percent))
continue; continue;
ffPrintError(FF_DISK_MODULE_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key); ffPrintError(FF_DISK_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Unknown JSON key %s", key);
} }
} }
@@ -453,7 +453,7 @@ void ffGenerateDiskJsonResult(FFDiskOptions* options, yyjson_mut_doc* doc, yyjso
void ffPrintDiskHelpFormat(void) void ffPrintDiskHelpFormat(void)
{ {
ffPrintModuleFormatHelp(FF_DISK_MODULE_NAME, "{1} / {2} ({3}) - {9}", FF_DISK_NUM_FORMAT_ARGS, (const char* []) { FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_DISK_MODULE_NAME, "{1} / {2} ({3}) - {9}", FF_DISK_NUM_FORMAT_ARGS, ((const char* []) {
"Size used", "Size used",
"Size total", "Size total",
"Size percentage", "Size percentage",
@@ -462,8 +462,10 @@ void ffPrintDiskHelpFormat(void)
"Files percentage", "Files percentage",
"True if external volume", "True if external volume",
"True if hidden volume", "True if hidden volume",
"Filesystem" "Filesystem",
}); "Label / name",
"True if read-only",
}));
} }
void ffInitDiskOptions(FFDiskOptions* options) void ffInitDiskOptions(FFDiskOptions* options)
+8 -8
View File
@@ -22,11 +22,11 @@ static void formatKey(const FFDiskIOOptions* options, FFDiskIOResult* dev, uint3
else else
{ {
ffStrbufClear(key); ffStrbufClear(key);
ffParseFormatString(key, &options->moduleArgs.key, 2, (FFformatarg[]){ FF_PARSE_FORMAT_STRING_CHECKED(key, &options->moduleArgs.key, 3, ((FFformatarg[]){
{FF_FORMAT_ARG_TYPE_UINT, &index}, {FF_FORMAT_ARG_TYPE_UINT, &index},
{FF_FORMAT_ARG_TYPE_STRBUF, &dev->name}, {FF_FORMAT_ARG_TYPE_STRBUF, &dev->name},
{FF_FORMAT_ARG_TYPE_STRBUF, &dev->devPath}, {FF_FORMAT_ARG_TYPE_STRBUF, &dev->devPath},
}); }));
} }
} }
@@ -37,7 +37,7 @@ void ffPrintDiskIO(FFDiskIOOptions* options)
if(error) if(error)
{ {
ffPrintError(FF_DISKIO_DISPLAY_NAME, 0, &options->moduleArgs, "%s", error); ffPrintError(FF_DISKIO_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "%s", error);
return; return;
} }
@@ -74,7 +74,7 @@ void ffPrintDiskIO(FFDiskIOOptions* options)
ffParseSize(dev->bytesWritten, &buffer2); ffParseSize(dev->bytesWritten, &buffer2);
if (!options->detectTotal) ffStrbufAppendS(&buffer, "/s"); if (!options->detectTotal) ffStrbufAppendS(&buffer, "/s");
ffPrintFormatString(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_DISKIO_NUM_FORMAT_ARGS, (FFformatarg[]){ 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}, {FF_FORMAT_ARG_TYPE_STRBUF, &buffer},
{FF_FORMAT_ARG_TYPE_STRBUF, &buffer2}, {FF_FORMAT_ARG_TYPE_STRBUF, &buffer2},
{FF_FORMAT_ARG_TYPE_STRBUF, &dev->name}, {FF_FORMAT_ARG_TYPE_STRBUF, &dev->name},
@@ -83,7 +83,7 @@ void ffPrintDiskIO(FFDiskIOOptions* options)
{FF_FORMAT_ARG_TYPE_UINT64, &dev->bytesWritten}, {FF_FORMAT_ARG_TYPE_UINT64, &dev->bytesWritten},
{FF_FORMAT_ARG_TYPE_UINT64, &dev->readCount}, {FF_FORMAT_ARG_TYPE_UINT64, &dev->readCount},
{FF_FORMAT_ARG_TYPE_UINT64, &dev->writeCount}, {FF_FORMAT_ARG_TYPE_UINT64, &dev->writeCount},
}); }));
} }
++index; ++index;
} }
@@ -142,7 +142,7 @@ void ffParseDiskIOJsonObject(FFDiskIOOptions* options, yyjson_val* module)
continue; continue;
} }
ffPrintError(FF_DISKIO_MODULE_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key); ffPrintError(FF_DISKIO_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Unknown JSON key %s", key);
} }
} }
@@ -192,7 +192,7 @@ void ffGenerateDiskIOJsonResult(FFDiskIOOptions* options, yyjson_mut_doc* doc, y
void ffPrintDiskIOHelpFormat(void) void ffPrintDiskIOHelpFormat(void)
{ {
ffPrintModuleFormatHelp(FF_DISKIO_MODULE_NAME, "{1} (R) - {2} (W)", FF_DISKIO_NUM_FORMAT_ARGS, (const char* []) { FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_DISKIO_MODULE_NAME, "{1} (R) - {2} (W)", FF_DISKIO_NUM_FORMAT_ARGS, ((const char* []) {
"Size of data read [per second] (formatted)", "Size of data read [per second] (formatted)",
"Size of data written [per second] (formatted)", "Size of data written [per second] (formatted)",
"Device name", "Device name",
@@ -201,7 +201,7 @@ void ffPrintDiskIOHelpFormat(void)
"Size of data written [per second] (in bytes)", "Size of data written [per second] (in bytes)",
"Number of reads", "Number of reads",
"Number of writes", "Number of writes",
}); }));
} }
void ffInitDiskIOOptions(FFDiskIOOptions* options) void ffInitDiskIOOptions(FFDiskIOOptions* options)
+12 -11
View File
@@ -4,7 +4,7 @@
#include "modules/display/display.h" #include "modules/display/display.h"
#include "util/stringUtils.h" #include "util/stringUtils.h"
#define FF_DISPLAY_NUM_FORMAT_ARGS 8 #define FF_DISPLAY_NUM_FORMAT_ARGS 9
static int sortByNameAsc(FFDisplayResult* a, FFDisplayResult* b) static int sortByNameAsc(FFDisplayResult* a, FFDisplayResult* b)
{ {
@@ -22,7 +22,7 @@ void ffPrintDisplay(FFDisplayOptions* options)
if(dsResult->displays.length == 0) if(dsResult->displays.length == 0)
{ {
ffPrintError(FF_DISPLAY_MODULE_NAME, 0, &options->moduleArgs, "Couldn't detect display"); ffPrintError(FF_DISPLAY_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Couldn't detect display");
return; return;
} }
@@ -89,11 +89,11 @@ void ffPrintDisplay(FFDisplayOptions* options)
} }
else else
{ {
ffParseFormatString(&key, &options->moduleArgs.key, 3, (FFformatarg[]){ FF_PARSE_FORMAT_STRING_CHECKED(&key, &options->moduleArgs.key, 3, ((FFformatarg[]){
{FF_FORMAT_ARG_TYPE_UINT, &moduleIndex}, {FF_FORMAT_ARG_TYPE_UINT, &moduleIndex},
{FF_FORMAT_ARG_TYPE_STRBUF, &result->name}, {FF_FORMAT_ARG_TYPE_STRBUF, &result->name},
{FF_FORMAT_ARG_TYPE_STRING, displayType}, {FF_FORMAT_ARG_TYPE_STRING, displayType},
}); }));
} }
if(options->moduleArgs.outputFormat.length == 0) if(options->moduleArgs.outputFormat.length == 0)
@@ -125,7 +125,7 @@ void ffPrintDisplay(FFDisplayOptions* options)
} }
else else
{ {
ffPrintFormatString(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_DISPLAY_NUM_FORMAT_ARGS, (FFformatarg[]) { 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}, {FF_FORMAT_ARG_TYPE_UINT, &result->width},
{FF_FORMAT_ARG_TYPE_UINT, &result->height}, {FF_FORMAT_ARG_TYPE_UINT, &result->height},
{FF_FORMAT_ARG_TYPE_DOUBLE, &result->refreshRate}, {FF_FORMAT_ARG_TYPE_DOUBLE, &result->refreshRate},
@@ -135,7 +135,7 @@ void ffPrintDisplay(FFDisplayOptions* options)
{FF_FORMAT_ARG_TYPE_STRING, displayType}, {FF_FORMAT_ARG_TYPE_STRING, displayType},
{FF_FORMAT_ARG_TYPE_UINT, &result->rotation}, {FF_FORMAT_ARG_TYPE_UINT, &result->rotation},
{FF_FORMAT_ARG_TYPE_BOOL, &result->primary}, {FF_FORMAT_ARG_TYPE_BOOL, &result->primary},
}); }));
} }
} }
} }
@@ -205,7 +205,7 @@ void ffParseDisplayJsonObject(FFDisplayOptions* options, yyjson_val* module)
{}, {},
}); });
if (error) if (error)
ffPrintError(FF_DISPLAY_MODULE_NAME, 0, &options->moduleArgs, "Invalid %s value: %s", key, error); ffPrintError(FF_DISPLAY_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Invalid %s value: %s", key, error);
else else
options->compactType = (FFDisplayCompactType) value; options->compactType = (FFDisplayCompactType) value;
continue; continue;
@@ -227,13 +227,13 @@ void ffParseDisplayJsonObject(FFDisplayOptions* options, yyjson_val* module)
{}, {},
}); });
if (error) if (error)
ffPrintError(FF_DISPLAY_MODULE_NAME, 0, &options->moduleArgs, "Invalid %s value: %s", key, error); ffPrintError(FF_DISPLAY_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Invalid %s value: %s", key, error);
else else
options->order = (FFDisplayOrder) value; options->order = (FFDisplayOrder) value;
continue; continue;
} }
ffPrintError(FF_DISPLAY_MODULE_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key); ffPrintError(FF_DISPLAY_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Unknown JSON key %s", key);
} }
} }
@@ -309,7 +309,7 @@ void ffGenerateDisplayJsonResult(FF_MAYBE_UNUSED FFDisplayOptions* options, yyjs
void ffPrintDisplayHelpFormat(void) void ffPrintDisplayHelpFormat(void)
{ {
ffPrintModuleFormatHelp(FF_DISPLAY_MODULE_NAME, "{1}x{2} @ {3}Hz (as {4}x{5}) [{7}]", FF_DISPLAY_NUM_FORMAT_ARGS, (const char* []) { FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_DISPLAY_MODULE_NAME, "{1}x{2} @ {3}Hz (as {4}x{5}) [{7}]", FF_DISPLAY_NUM_FORMAT_ARGS, ((const char* []) {
"Screen width (in pixels)", "Screen width (in pixels)",
"Screen height (in pixels)", "Screen height (in pixels)",
"Screen refresh rate (in Hz)", "Screen refresh rate (in Hz)",
@@ -318,7 +318,8 @@ void ffPrintDisplayHelpFormat(void)
"Screen name", "Screen name",
"Screen type (builtin, external or unknown)", "Screen type (builtin, external or unknown)",
"Screen rotation (in degrees)", "Screen rotation (in degrees)",
}); "True if being the primary screen",
}));
} }
void ffInitDisplayOptions(FFDisplayOptions* options) void ffInitDisplayOptions(FFDisplayOptions* options)
+6 -6
View File
@@ -17,7 +17,7 @@ void ffPrintFont(FFFontOptions* options)
if(error) if(error)
{ {
ffPrintError(FF_FONT_MODULE_NAME, 0, &options->moduleArgs, "%s", error); ffPrintError(FF_FONT_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "%s", error);
} }
else else
{ {
@@ -28,13 +28,13 @@ void ffPrintFont(FFFontOptions* options)
} }
else else
{ {
ffPrintFormat(FF_FONT_MODULE_NAME, 0, &options->moduleArgs, FF_FONT_NUM_FORMAT_ARGS, (FFformatarg[]) { 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]}, {FF_FORMAT_ARG_TYPE_STRBUF, &font.fonts[0]},
{FF_FORMAT_ARG_TYPE_STRBUF, &font.fonts[1]}, {FF_FORMAT_ARG_TYPE_STRBUF, &font.fonts[1]},
{FF_FORMAT_ARG_TYPE_STRBUF, &font.fonts[2]}, {FF_FORMAT_ARG_TYPE_STRBUF, &font.fonts[2]},
{FF_FORMAT_ARG_TYPE_STRBUF, &font.fonts[3]}, {FF_FORMAT_ARG_TYPE_STRBUF, &font.fonts[3]},
{FF_FORMAT_ARG_TYPE_STRBUF, &font.display}, {FF_FORMAT_ARG_TYPE_STRBUF, &font.display},
}); }));
} }
} }
@@ -66,7 +66,7 @@ void ffParseFontJsonObject(FFFontOptions* options, yyjson_val* module)
if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs)) if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs))
continue; continue;
ffPrintError(FF_FONT_MODULE_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key); ffPrintError(FF_FONT_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Unknown JSON key %s", key);
} }
} }
@@ -106,13 +106,13 @@ void ffGenerateFontJsonResult(FF_MAYBE_UNUSED FFFontOptions* options, yyjson_mut
void ffPrintFontHelpFormat(void) void ffPrintFontHelpFormat(void)
{ {
ffPrintModuleFormatHelp(FF_FONT_MODULE_NAME, "{5}", FF_FONT_NUM_FORMAT_ARGS, (const char* []) { FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_FONT_MODULE_NAME, "{5}", FF_FONT_NUM_FORMAT_ARGS, ((const char* []) {
"Font 1", "Font 1",
"Font 2", "Font 2",
"Font 3", "Font 3",
"Font 4", "Font 4",
"Combined fonts" "Combined fonts"
}); }));
} }
void ffInitFontOptions(FFFontOptions* options) void ffInitFontOptions(FFFontOptions* options)
+8 -8
View File
@@ -5,7 +5,7 @@
#include "modules/gamepad/gamepad.h" #include "modules/gamepad/gamepad.h"
#include "util/stringUtils.h" #include "util/stringUtils.h"
#define FF_GAMEPAD_NUM_FORMAT_ARGS 2 #define FF_GAMEPAD_NUM_FORMAT_ARGS 3
static void printDevice(FFGamepadOptions* options, const FFGamepadDevice* device, uint8_t index) static void printDevice(FFGamepadOptions* options, const FFGamepadDevice* device, uint8_t index)
{ {
@@ -28,11 +28,11 @@ static void printDevice(FFGamepadOptions* options, const FFGamepadDevice* device
FF_STRBUF_AUTO_DESTROY percentageStr = ffStrbufCreate(); FF_STRBUF_AUTO_DESTROY percentageStr = ffStrbufCreate();
ffPercentAppendNum(&percentageStr, device->battery, options->percent, false); ffPercentAppendNum(&percentageStr, device->battery, options->percent, false);
ffPrintFormat(FF_GAMEPAD_MODULE_NAME, index, &options->moduleArgs, FF_GAMEPAD_NUM_FORMAT_ARGS, (FFformatarg[]) { 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}, {FF_FORMAT_ARG_TYPE_STRBUF, &device->name},
{FF_FORMAT_ARG_TYPE_STRBUF, &device->serial}, {FF_FORMAT_ARG_TYPE_STRBUF, &device->serial},
{FF_FORMAT_ARG_TYPE_STRBUF, &percentageStr}, {FF_FORMAT_ARG_TYPE_STRBUF, &percentageStr},
}); }));
} }
} }
@@ -44,13 +44,13 @@ void ffPrintGamepad(FFGamepadOptions* options)
if(error) if(error)
{ {
ffPrintError(FF_GAMEPAD_MODULE_NAME, 0, &options->moduleArgs, "%s", error); ffPrintError(FF_GAMEPAD_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "%s", error);
return; return;
} }
if(!result.length) if(!result.length)
{ {
ffPrintError(FF_GAMEPAD_MODULE_NAME, 0, &options->moduleArgs, "No devices detected"); ffPrintError(FF_GAMEPAD_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "No devices detected");
return; return;
} }
@@ -92,7 +92,7 @@ void ffParseGamepadJsonObject(FFGamepadOptions* options, yyjson_val* module)
if (ffPercentParseJsonObject(key, val, &options->percent)) if (ffPercentParseJsonObject(key, val, &options->percent))
continue; continue;
ffPrintError(FF_GAMEPAD_MODULE_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key); ffPrintError(FF_GAMEPAD_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Unknown JSON key %s", key);
} }
} }
@@ -141,11 +141,11 @@ void ffGenerateGamepadJsonResult(FF_MAYBE_UNUSED FFGamepadOptions* options, yyjs
void ffPrintGamepadHelpFormat(void) void ffPrintGamepadHelpFormat(void)
{ {
ffPrintModuleFormatHelp(FF_GAMEPAD_MODULE_NAME, "{1} ({3})", FF_GAMEPAD_NUM_FORMAT_ARGS, (const char* []) { FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_GAMEPAD_MODULE_NAME, "{1} ({3})", FF_GAMEPAD_NUM_FORMAT_ARGS, ((const char* []) {
"Name", "Name",
"Serial number", "Serial number",
"Battery percentage", "Battery percentage",
}); }));
} }
void ffInitGamepadOptions(FFGamepadOptions* options) void ffInitGamepadOptions(FFGamepadOptions* options)
+8 -8
View File
@@ -75,7 +75,7 @@ static void printGPUResult(FFGPUOptions* options, uint8_t index, const FFGPUResu
{ {
FF_STRBUF_AUTO_DESTROY tempStr = ffStrbufCreate(); FF_STRBUF_AUTO_DESTROY tempStr = ffStrbufCreate();
ffTempsAppendNum(gpu->temperature, &tempStr, options->tempConfig); ffTempsAppendNum(gpu->temperature, &tempStr, options->tempConfig);
ffPrintFormat(FF_GPU_MODULE_NAME, index, &options->moduleArgs, FF_GPU_NUM_FORMAT_ARGS, (FFformatarg[]){ 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}, {FF_FORMAT_ARG_TYPE_STRBUF, &gpu->vendor},
{FF_FORMAT_ARG_TYPE_STRBUF, &gpu->name}, {FF_FORMAT_ARG_TYPE_STRBUF, &gpu->name},
{FF_FORMAT_ARG_TYPE_STRBUF, &gpu->driver}, {FF_FORMAT_ARG_TYPE_STRBUF, &gpu->driver},
@@ -88,7 +88,7 @@ static void printGPUResult(FFGPUOptions* options, uint8_t index, const FFGPUResu
{FF_FORMAT_ARG_TYPE_UINT64, &gpu->shared.used}, {FF_FORMAT_ARG_TYPE_UINT64, &gpu->shared.used},
{FF_FORMAT_ARG_TYPE_STRBUF, &gpu->platformApi}, {FF_FORMAT_ARG_TYPE_STRBUF, &gpu->platformApi},
{FF_FORMAT_ARG_TYPE_DOUBLE, &gpu->frequency}, {FF_FORMAT_ARG_TYPE_DOUBLE, &gpu->frequency},
}); }));
} }
} }
@@ -98,7 +98,7 @@ void ffPrintGPU(FFGPUOptions* options)
const char* error = ffDetectGPU(options, &gpus); const char* error = ffDetectGPU(options, &gpus);
if (error) if (error)
{ {
ffPrintError(FF_GPU_MODULE_NAME, 0, &options->moduleArgs, "%s", error); ffPrintError(FF_GPU_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "%s", error);
return; return;
} }
@@ -120,7 +120,7 @@ void ffPrintGPU(FFGPUOptions* options)
printGPUResult(options, selectedGPUs.length == 1 ? 0 : (uint8_t) (i + 1), * (const FFGPUResult**) ffListGet(&selectedGPUs, i)); printGPUResult(options, selectedGPUs.length == 1 ? 0 : (uint8_t) (i + 1), * (const FFGPUResult**) ffListGet(&selectedGPUs, i));
if(selectedGPUs.length == 0) if(selectedGPUs.length == 0)
ffPrintError(FF_GPU_MODULE_NAME, 0, &options->moduleArgs, "No GPUs found"); ffPrintError(FF_GPU_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "No GPUs found");
FF_LIST_FOR_EACH(FFGPUResult, gpu, gpus) FF_LIST_FOR_EACH(FFGPUResult, gpu, gpus)
{ {
@@ -206,7 +206,7 @@ void ffParseGPUJsonObject(FFGPUOptions* options, yyjson_val* module)
{}, {},
}); });
if (error) if (error)
ffPrintError(FF_GPU_MODULE_NAME, 0, &options->moduleArgs, "Invalid %s value: %s", key, error); ffPrintError(FF_GPU_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Invalid %s value: %s", key, error);
else else
options->hideType = (FFGPUType) value; options->hideType = (FFGPUType) value;
continue; continue;
@@ -215,7 +215,7 @@ void ffParseGPUJsonObject(FFGPUOptions* options, yyjson_val* module)
if (ffPercentParseJsonObject(key, val, &options->percent)) if (ffPercentParseJsonObject(key, val, &options->percent))
continue; continue;
ffPrintError(FF_GPU_MODULE_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key); ffPrintError(FF_GPU_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Unknown JSON key %s", key);
} }
} }
@@ -332,7 +332,7 @@ void ffGenerateGPUJsonResult(FFGPUOptions* options, yyjson_mut_doc* doc, yyjson_
void ffPrintGPUHelpFormat(void) void ffPrintGPUHelpFormat(void)
{ {
ffPrintModuleFormatHelp(FF_GPU_MODULE_NAME, "{1} {2}", FF_GPU_NUM_FORMAT_ARGS, (const char* []) { FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_GPU_MODULE_NAME, "{1} {2}", FF_GPU_NUM_FORMAT_ARGS, ((const char* []) {
"GPU vendor", "GPU vendor",
"GPU name", "GPU name",
"GPU driver", "GPU driver",
@@ -345,7 +345,7 @@ void ffPrintGPUHelpFormat(void)
"GPU used shared memory", "GPU used shared memory",
"The platform API that GPU supports", "The platform API that GPU supports",
"Current frequency in GHz", "Current frequency in GHz",
}); }));
} }
void ffInitGPUOptions(FFGPUOptions* options) void ffInitGPUOptions(FFGPUOptions* options)
+7 -7
View File
@@ -20,13 +20,13 @@ void ffPrintHost(FFHostOptions* options)
const char* error = ffDetectHost(&host); const char* error = ffDetectHost(&host);
if(error) if(error)
{ {
ffPrintError(FF_HOST_MODULE_NAME, 0, &options->moduleArgs, "%s", error); ffPrintError(FF_HOST_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "%s", error);
goto exit; goto exit;
} }
if(host.family.length == 0 && host.name.length == 0) if(host.family.length == 0 && host.name.length == 0)
{ {
ffPrintError(FF_HOST_MODULE_NAME, 0, &options->moduleArgs, "neither product_family nor product_name is set by O.E.M."); ffPrintError(FF_HOST_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "neither product_family nor product_name is set by O.E.M.");
goto exit; goto exit;
} }
@@ -48,7 +48,7 @@ void ffPrintHost(FFHostOptions* options)
} }
else else
{ {
ffPrintFormat(FF_HOST_MODULE_NAME, 0, &options->moduleArgs, FF_HOST_NUM_FORMAT_ARGS, (FFformatarg[]) { 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}, {FF_FORMAT_ARG_TYPE_STRBUF, &host.family},
{FF_FORMAT_ARG_TYPE_STRBUF, &host.name}, {FF_FORMAT_ARG_TYPE_STRBUF, &host.name},
{FF_FORMAT_ARG_TYPE_STRBUF, &host.version}, {FF_FORMAT_ARG_TYPE_STRBUF, &host.version},
@@ -56,7 +56,7 @@ void ffPrintHost(FFHostOptions* options)
{FF_FORMAT_ARG_TYPE_STRBUF, &host.vendor}, {FF_FORMAT_ARG_TYPE_STRBUF, &host.vendor},
{FF_FORMAT_ARG_TYPE_STRBUF, &host.serial}, {FF_FORMAT_ARG_TYPE_STRBUF, &host.serial},
{FF_FORMAT_ARG_TYPE_STRBUF, &host.uuid}, {FF_FORMAT_ARG_TYPE_STRBUF, &host.uuid},
}); }));
} }
exit: exit:
@@ -92,7 +92,7 @@ void ffParseHostJsonObject(FFHostOptions* options, yyjson_val* module)
if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs)) if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs))
continue; continue;
ffPrintError(FF_HOST_MODULE_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key); ffPrintError(FF_HOST_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Unknown JSON key %s", key);
} }
} }
@@ -149,7 +149,7 @@ exit:
void ffPrintHostHelpFormat(void) void ffPrintHostHelpFormat(void)
{ {
ffPrintModuleFormatHelp(FF_HOST_MODULE_NAME, "{2} {3}", FF_HOST_NUM_FORMAT_ARGS, (const char* []) { FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_HOST_MODULE_NAME, "{2} {3}", FF_HOST_NUM_FORMAT_ARGS, ((const char* []) {
"product family", "product family",
"product name", "product name",
"product version", "product version",
@@ -157,7 +157,7 @@ void ffPrintHostHelpFormat(void)
"product vendor", "product vendor",
"product serial number", "product serial number",
"product uuid", "product uuid",
}); }));
} }
void ffInitHostOptions(FFHostOptions* options) void ffInitHostOptions(FFHostOptions* options)
+6 -6
View File
@@ -13,7 +13,7 @@ void ffPrintIcons(FFIconsOptions* options)
if(error) if(error)
{ {
ffPrintError(FF_ICONS_MODULE_NAME, 0, &options->moduleArgs, "%s", error); ffPrintError(FF_ICONS_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "%s", error);
return; return;
} }
@@ -24,9 +24,9 @@ void ffPrintIcons(FFIconsOptions* options)
} }
else else
{ {
ffPrintFormat(FF_ICONS_MODULE_NAME, 0, &options->moduleArgs, FF_ICONS_NUM_FORMAT_ARGS, (FFformatarg[]){ 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, &icons} {FF_FORMAT_ARG_TYPE_STRBUF, &icons}
}); }));
} }
} }
@@ -53,7 +53,7 @@ void ffParseIconsJsonObject(FFIconsOptions* options, yyjson_val* module)
if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs)) if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs))
continue; continue;
ffPrintError(FF_ICONS_MODULE_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key); ffPrintError(FF_ICONS_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Unknown JSON key %s", key);
} }
} }
@@ -81,9 +81,9 @@ void ffGenerateIconsJsonResult(FF_MAYBE_UNUSED FFIconsOptions* options, yyjson_m
void ffPrintIconsHelpFormat(void) void ffPrintIconsHelpFormat(void)
{ {
ffPrintModuleFormatHelp(FF_ICONS_MODULE_NAME, "{1}", FF_ICONS_NUM_FORMAT_ARGS, (const char* []) { FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_ICONS_MODULE_NAME, "{1}", FF_ICONS_NUM_FORMAT_ARGS, ((const char* []) {
"Combined icons" "Combined icons"
}); }));
} }
void ffInitIconsOptions(FFIconsOptions* options) void ffInitIconsOptions(FFIconsOptions* options)
+11 -9
View File
@@ -3,7 +3,7 @@
#include "modules/kernel/kernel.h" #include "modules/kernel/kernel.h"
#include "util/stringUtils.h" #include "util/stringUtils.h"
#define FF_KERNEL_NUM_FORMAT_ARGS 4 #define FF_KERNEL_NUM_FORMAT_ARGS 5
void ffPrintKernel(FFKernelOptions* options) void ffPrintKernel(FFKernelOptions* options)
{ {
@@ -20,13 +20,13 @@ void ffPrintKernel(FFKernelOptions* options)
} }
else else
{ {
ffPrintFormat(FF_KERNEL_MODULE_NAME, 0, &options->moduleArgs, FF_KERNEL_NUM_FORMAT_ARGS, (FFformatarg[]){ 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, &platform->systemName}, {FF_FORMAT_ARG_TYPE_STRBUF, &platform->systemName},
{FF_FORMAT_ARG_TYPE_STRBUF, &platform->systemRelease}, {FF_FORMAT_ARG_TYPE_STRBUF, &platform->systemRelease},
{FF_FORMAT_ARG_TYPE_STRBUF, &platform->systemVersion}, {FF_FORMAT_ARG_TYPE_STRBUF, &platform->systemVersion},
{FF_FORMAT_ARG_TYPE_STRBUF, &platform->systemArchitecture}, {FF_FORMAT_ARG_TYPE_STRBUF, &platform->systemArchitecture},
{FF_FORMAT_ARG_TYPE_STRBUF, &platform->systemDisplayVersion} {FF_FORMAT_ARG_TYPE_STRBUF, &platform->systemDisplayVersion}
}); }));
} }
} }
@@ -53,7 +53,7 @@ void ffParseKernelJsonObject(FFKernelOptions* options, yyjson_val* module)
if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs)) if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs))
continue; continue;
ffPrintError(FF_KERNEL_MODULE_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key); ffPrintError(FF_KERNEL_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Unknown JSON key %s", key);
} }
} }
@@ -77,11 +77,13 @@ void ffGenerateKernelJsonResult(FF_MAYBE_UNUSED FFKernelOptions* options, yyjson
void ffPrintKernelHelpFormat(void) void ffPrintKernelHelpFormat(void)
{ {
ffPrintModuleFormatHelp(FF_KERNEL_MODULE_NAME, "{2}", FF_KERNEL_NUM_FORMAT_ARGS, (const char* []) { FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_KERNEL_MODULE_NAME, "{2}", FF_KERNEL_NUM_FORMAT_ARGS, ((const char* []) {
"Kernel sysname", "Sysname",
"Kernel release", "Release",
"Kernel version" "Version",
}); "Architecture",
"Display version",
}));
} }
void ffInitKernelOptions(FFKernelOptions* options) void ffInitKernelOptions(FFKernelOptions* options)
+7 -7
View File
@@ -16,13 +16,13 @@ void ffPrintLM(FFLMOptions* options)
if(error) if(error)
{ {
ffPrintError(FF_LM_MODULE_NAME, 0, &options->moduleArgs, "%s", error); ffPrintError(FF_LM_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "%s", error);
return; return;
} }
if(result.service.length == 0) if(result.service.length == 0)
{ {
ffPrintError(FF_LM_MODULE_NAME, 0, &options->moduleArgs, "No LM service found"); ffPrintError(FF_LM_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "No LM service found");
return; return;
} }
@@ -38,11 +38,11 @@ void ffPrintLM(FFLMOptions* options)
} }
else else
{ {
ffPrintFormat(FF_LM_MODULE_NAME, 0, &options->moduleArgs, FF_LM_NUM_FORMAT_ARGS, (FFformatarg[]){ 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}, {FF_FORMAT_ARG_TYPE_STRBUF, &result.service},
{FF_FORMAT_ARG_TYPE_STRBUF, &result.type}, {FF_FORMAT_ARG_TYPE_STRBUF, &result.type},
{FF_FORMAT_ARG_TYPE_STRBUF, &result.version}, {FF_FORMAT_ARG_TYPE_STRBUF, &result.version},
}); }));
} }
ffStrbufDestroy(&result.service); ffStrbufDestroy(&result.service);
ffStrbufDestroy(&result.type); ffStrbufDestroy(&result.type);
@@ -72,7 +72,7 @@ void ffParseLMJsonObject(FFLMOptions* options, yyjson_val* module)
if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs)) if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs))
continue; continue;
ffPrintError(FF_LM_MODULE_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key); ffPrintError(FF_LM_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Unknown JSON key %s", key);
} }
} }
@@ -117,11 +117,11 @@ exit:
void ffPrintLMHelpFormat(void) void ffPrintLMHelpFormat(void)
{ {
ffPrintModuleFormatHelp(FF_LM_MODULE_NAME, "{1} {3} ({2})", FF_LM_NUM_FORMAT_ARGS, (const char* []) { FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_LM_MODULE_NAME, "{1} {3} ({2})", FF_LM_NUM_FORMAT_ARGS, ((const char* []) {
"LM service", "LM service",
"LM type", "LM type",
"LM version" "LM version"
}); }));
} }
void ffInitLMOptions(FFLMOptions* options) void ffInitLMOptions(FFLMOptions* options)
+6 -6
View File
@@ -13,7 +13,7 @@ void ffPrintLocale(FFLocaleOptions* options)
ffDetectLocale(&locale); ffDetectLocale(&locale);
if(locale.length == 0) if(locale.length == 0)
{ {
ffPrintError(FF_LOCALE_MODULE_NAME, 0, &options->moduleArgs, "No locale found"); ffPrintError(FF_LOCALE_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "No locale found");
return; return;
} }
@@ -24,9 +24,9 @@ void ffPrintLocale(FFLocaleOptions* options)
} }
else else
{ {
ffPrintFormat(FF_LOCALE_MODULE_NAME, 0, &options->moduleArgs, FF_LOCALE_NUM_FORMAT_ARGS, (FFformatarg[]){ 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} {FF_FORMAT_ARG_TYPE_STRBUF, &locale}
}); }));
} }
} }
@@ -53,7 +53,7 @@ void ffParseLocaleJsonObject(FFLocaleOptions* options, yyjson_val* module)
if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs)) if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs))
continue; continue;
ffPrintError(FF_LOCALE_MODULE_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key); ffPrintError(FF_LOCALE_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Unknown JSON key %s", key);
} }
} }
@@ -81,9 +81,9 @@ void ffGenerateLocaleJsonResult(FF_MAYBE_UNUSED FFLocaleOptions* options, yyjson
void ffPrintLocaleHelpFormat(void) void ffPrintLocaleHelpFormat(void)
{ {
ffPrintModuleFormatHelp(FF_LOCALE_MODULE_NAME, "{1}", FF_LOCALE_NUM_FORMAT_ARGS, (const char* []) { FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_LOCALE_MODULE_NAME, "{1}", FF_LOCALE_NUM_FORMAT_ARGS, ((const char* []) {
"Locale code" "Locale code"
}); }));
} }
void ffInitLocaleOptions(FFLocaleOptions* options) void ffInitLocaleOptions(FFLocaleOptions* options)
+9 -9
View File
@@ -25,11 +25,11 @@ static void formatKey(const FFLocalIpOptions* options, FFLocalIpResult* ip, uint
else else
{ {
ffStrbufClear(key); ffStrbufClear(key);
ffParseFormatString(key, &options->moduleArgs.key, 3, (FFformatarg[]){ FF_PARSE_FORMAT_STRING_CHECKED(key, &options->moduleArgs.key, 3, ((FFformatarg[]){
{FF_FORMAT_ARG_TYPE_UINT, &index}, {FF_FORMAT_ARG_TYPE_UINT, &index},
{FF_FORMAT_ARG_TYPE_STRBUF, &ip->name}, {FF_FORMAT_ARG_TYPE_STRBUF, &ip->name},
{FF_FORMAT_ARG_TYPE_STRBUF, &ip->mac}, {FF_FORMAT_ARG_TYPE_STRBUF, &ip->mac},
}); }));
} }
} }
@@ -66,13 +66,13 @@ void ffPrintLocalIp(FFLocalIpOptions* options)
if(error) if(error)
{ {
ffPrintError(FF_LOCALIP_DISPLAY_NAME, 0, &options->moduleArgs, "%s", error); ffPrintError(FF_LOCALIP_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "%s", error);
return; return;
} }
if(results.length == 0) if(results.length == 0)
{ {
ffPrintError(FF_LOCALIP_DISPLAY_NAME, 0, &options->moduleArgs, "Failed to detect any IPs"); ffPrintError(FF_LOCALIP_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Failed to detect any IPs");
return; return;
} }
@@ -110,13 +110,13 @@ void ffPrintLocalIp(FFLocalIpOptions* options)
} }
else else
{ {
ffPrintFormatString(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_LOCALIP_NUM_FORMAT_ARGS, (FFformatarg[]){ 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}, {FF_FORMAT_ARG_TYPE_STRBUF, &ip->ipv4},
{FF_FORMAT_ARG_TYPE_STRBUF, &ip->ipv6}, {FF_FORMAT_ARG_TYPE_STRBUF, &ip->ipv6},
{FF_FORMAT_ARG_TYPE_STRBUF, &ip->mac}, {FF_FORMAT_ARG_TYPE_STRBUF, &ip->mac},
{FF_FORMAT_ARG_TYPE_STRBUF, &ip->name}, {FF_FORMAT_ARG_TYPE_STRBUF, &ip->name},
{FF_FORMAT_ARG_TYPE_BOOL, &ip->defaultRoute}, {FF_FORMAT_ARG_TYPE_BOOL, &ip->defaultRoute},
}); }));
} }
++index; ++index;
} }
@@ -268,7 +268,7 @@ void ffParseLocalIpJsonObject(FFLocalIpOptions* options, yyjson_val* module)
continue; continue;
} }
ffPrintError(FF_LOCALIP_MODULE_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key); ffPrintError(FF_LOCALIP_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Unknown JSON key %s", key);
} }
} }
@@ -345,13 +345,13 @@ exit:
void ffPrintLocalIpHelpFormat(void) void ffPrintLocalIpHelpFormat(void)
{ {
ffPrintModuleFormatHelp(FF_LOCALIP_MODULE_NAME, "{1}", FF_LOCALIP_NUM_FORMAT_ARGS, (const char* []) { FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_LOCALIP_MODULE_NAME, "{1}", FF_LOCALIP_NUM_FORMAT_ARGS, ((const char* []) {
"Local IPv4 address", "Local IPv4 address",
"Local IPv6 address", "Local IPv6 address",
"Physical (MAC) address", "Physical (MAC) address",
"Interface name", "Interface name",
"Is default route" "Is default route"
}); }));
} }
void ffInitLocalIpOptions(FFLocalIpOptions* options) void ffInitLocalIpOptions(FFLocalIpOptions* options)
+6 -6
View File
@@ -49,7 +49,7 @@ void ffPrintMedia(FFMediaOptions* options)
if(media->error.length > 0) if(media->error.length > 0)
{ {
ffPrintError(FF_MEDIA_MODULE_NAME, 0, &options->moduleArgs, "%s", media->error.chars); ffPrintError(FF_MEDIA_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "%s", media->error.chars);
return; return;
} }
@@ -95,13 +95,13 @@ void ffPrintMedia(FFMediaOptions* options)
} }
else else
{ {
ffPrintFormat(FF_MEDIA_MODULE_NAME, 0, &options->moduleArgs, FF_MEDIA_NUM_FORMAT_ARGS, (FFformatarg[]){ 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}, {FF_FORMAT_ARG_TYPE_STRBUF, &songPretty},
{FF_FORMAT_ARG_TYPE_STRBUF, &media->song}, {FF_FORMAT_ARG_TYPE_STRBUF, &media->song},
{FF_FORMAT_ARG_TYPE_STRBUF, &media->artist}, {FF_FORMAT_ARG_TYPE_STRBUF, &media->artist},
{FF_FORMAT_ARG_TYPE_STRBUF, &media->album}, {FF_FORMAT_ARG_TYPE_STRBUF, &media->album},
{FF_FORMAT_ARG_TYPE_STRBUF, &media->status} {FF_FORMAT_ARG_TYPE_STRBUF, &media->status}
}); }));
} }
} }
@@ -128,7 +128,7 @@ void ffParseMediaJsonObject(FFMediaOptions* options, yyjson_val* module)
if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs)) if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs))
continue; continue;
ffPrintError(FF_MEDIA_MODULE_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key); ffPrintError(FF_MEDIA_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Unknown JSON key %s", key);
} }
} }
@@ -159,13 +159,13 @@ void ffGenerateMediaJsonResult(FF_MAYBE_UNUSED FFMediaOptions* options, yyjson_m
void ffPrintMediaHelpFormat(void) void ffPrintMediaHelpFormat(void)
{ {
ffPrintModuleFormatHelp(FF_MEDIA_MODULE_NAME, "{3} - {1} ({5})", FF_MEDIA_NUM_FORMAT_ARGS, (const char* []) { FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_MEDIA_MODULE_NAME, "{3} - {1} ({5})", FF_MEDIA_NUM_FORMAT_ARGS, ((const char* []) {
"Pretty media name", "Pretty media name",
"Media name", "Media name",
"Artist name", "Artist name",
"Album name", "Album name",
"Status", "Status",
}); }));
} }
void ffInitMediaOptions(FFMediaOptions* options) void ffInitMediaOptions(FFMediaOptions* options)
+7 -7
View File
@@ -15,7 +15,7 @@ void ffPrintMemory(FFMemoryOptions* options)
if(error) if(error)
{ {
ffPrintError(FF_MEMORY_MODULE_NAME, 0, &options->moduleArgs, "%s", error); ffPrintError(FF_MEMORY_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "%s", error);
return; return;
} }
@@ -58,11 +58,11 @@ void ffPrintMemory(FFMemoryOptions* options)
{ {
FF_STRBUF_AUTO_DESTROY percentageStr = ffStrbufCreate(); FF_STRBUF_AUTO_DESTROY percentageStr = ffStrbufCreate();
ffPercentAppendNum(&percentageStr, percentage, options->percent, false); ffPercentAppendNum(&percentageStr, percentage, options->percent, false);
ffPrintFormat(FF_MEMORY_MODULE_NAME, 0, &options->moduleArgs, FF_MEMORY_NUM_FORMAT_ARGS, (FFformatarg[]){ 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}, {FF_FORMAT_ARG_TYPE_STRBUF, &usedPretty},
{FF_FORMAT_ARG_TYPE_STRBUF, &totalPretty}, {FF_FORMAT_ARG_TYPE_STRBUF, &totalPretty},
{FF_FORMAT_ARG_TYPE_STRBUF, &percentageStr}, {FF_FORMAT_ARG_TYPE_STRBUF, &percentageStr},
}); }));
} }
} }
@@ -95,7 +95,7 @@ void ffParseMemoryJsonObject(FFMemoryOptions* options, yyjson_val* module)
if (ffPercentParseJsonObject(key, val, &options->percent)) if (ffPercentParseJsonObject(key, val, &options->percent))
continue; continue;
ffPrintError(FF_MEMORY_MODULE_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key); ffPrintError(FF_MEMORY_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Unknown JSON key %s", key);
} }
} }
@@ -127,11 +127,11 @@ void ffGenerateMemoryJsonResult(FF_MAYBE_UNUSED FFMemoryOptions* options, yyjson
void ffPrintMemoryHelpFormat(void) void ffPrintMemoryHelpFormat(void)
{ {
ffPrintModuleFormatHelp(FF_MEMORY_MODULE_NAME, "{1} / {2} ({3})", FF_MEMORY_NUM_FORMAT_ARGS, (const char* []) { FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_MEMORY_MODULE_NAME, "{1} / {2} ({3})", FF_MEMORY_NUM_FORMAT_ARGS, ((const char* []) {
"Used size", "Used size",
"Total size", "Total size",
"Percentage used" "Percentage used",
}); }));
} }
void ffInitMemoryOptions(FFMemoryOptions* options) void ffInitMemoryOptions(FFMemoryOptions* options)
+16 -15
View File
@@ -6,7 +6,7 @@
#include <math.h> #include <math.h>
#define FF_MONITOR_NUM_FORMAT_ARGS 7 #define FF_MONITOR_NUM_FORMAT_ARGS 10
void ffPrintMonitor(FFMonitorOptions* options) void ffPrintMonitor(FFMonitorOptions* options)
{ {
@@ -16,13 +16,13 @@ void ffPrintMonitor(FFMonitorOptions* options)
if(error) if(error)
{ {
ffPrintError(FF_MONITOR_MODULE_NAME, 0, &options->moduleArgs, "%s", error); ffPrintError(FF_MONITOR_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "%s", error);
return; return;
} }
if(!result.length) if(!result.length)
{ {
ffPrintError(FF_MONITOR_MODULE_NAME, 0, &options->moduleArgs, "No physical display detected"); ffPrintError(FF_MONITOR_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "No physical display detected");
return; return;
} }
@@ -41,10 +41,10 @@ void ffPrintMonitor(FFMonitorOptions* options)
else else
{ {
uint32_t moduleIndex = result.length == 1 ? 0 : index + 1; uint32_t moduleIndex = result.length == 1 ? 0 : index + 1;
ffParseFormatString(&key, &options->moduleArgs.key, 2, (FFformatarg[]){ FF_PARSE_FORMAT_STRING_CHECKED(&key, &options->moduleArgs.key, 2, ((FFformatarg[]){
{FF_FORMAT_ARG_TYPE_UINT, &moduleIndex}, {FF_FORMAT_ARG_TYPE_UINT, &moduleIndex},
{FF_FORMAT_ARG_TYPE_STRBUF, &display->name}, {FF_FORMAT_ARG_TYPE_STRBUF, &display->name},
}); }));
} }
if(options->moduleArgs.outputFormat.length == 0) if(options->moduleArgs.outputFormat.length == 0)
@@ -68,7 +68,7 @@ void ffPrintMonitor(FFMonitorOptions* options)
else else
buf[0] = '\0'; buf[0] = '\0';
ffPrintFormatString(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_MONITOR_NUM_FORMAT_ARGS, (FFformatarg[]) { 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}, {FF_FORMAT_ARG_TYPE_STRBUF, &display->name},
{FF_FORMAT_ARG_TYPE_UINT, &display->width}, {FF_FORMAT_ARG_TYPE_UINT, &display->width},
{FF_FORMAT_ARG_TYPE_UINT, &display->height}, {FF_FORMAT_ARG_TYPE_UINT, &display->height},
@@ -79,7 +79,7 @@ void ffPrintMonitor(FFMonitorOptions* options)
{FF_FORMAT_ARG_TYPE_UINT16, &display->manufactureYear}, {FF_FORMAT_ARG_TYPE_UINT16, &display->manufactureYear},
{FF_FORMAT_ARG_TYPE_UINT16, &display->manufactureWeek}, {FF_FORMAT_ARG_TYPE_UINT16, &display->manufactureWeek},
{FF_FORMAT_ARG_TYPE_STRING, buf}, {FF_FORMAT_ARG_TYPE_STRING, buf},
}); }));
} }
ffStrbufDestroy(&display->name); ffStrbufDestroy(&display->name);
@@ -110,7 +110,7 @@ void ffParseMonitorJsonObject(FFMonitorOptions* options, yyjson_val* module)
if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs)) if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs))
continue; continue;
ffPrintError(FF_MONITOR_MODULE_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key); ffPrintError(FF_MONITOR_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Unknown JSON key %s", key);
} }
} }
@@ -179,17 +179,18 @@ void ffGenerateMonitorJsonResult(FF_MAYBE_UNUSED FFMonitorOptions* options, yyjs
void ffPrintMonitorHelpFormat(void) void ffPrintMonitorHelpFormat(void)
{ {
ffPrintModuleFormatHelp(FF_MONITOR_MODULE_NAME, "{2}x{3} px - {4}x{5} mm ({6} inches, {7} ppi)", FF_MONITOR_NUM_FORMAT_ARGS, (const char* []) { FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_MONITOR_MODULE_NAME, "{2}x{3} px - {4}x{5} mm ({6} inches, {7} ppi)", FF_MONITOR_NUM_FORMAT_ARGS, ((const char* []) {
"Display name", "Display name",
"Display native resolution width in pixels", "Native resolution width in pixels",
"Display native resolution height in pixels", "Native resolution height in pixels",
"Display physical width in millimeters", "Physical width in millimeters",
"Display physical height in millimeters", "Physical height in millimeters",
"Display physical diagonal length in inches", "Physical diagonal length in inches",
"Pixels per inch (PPI)",
"Year of manufacturing", "Year of manufacturing",
"Nth week of manufacturing in the year", "Nth week of manufacturing in the year",
"Serial number", "Serial number",
}); }));
} }
void ffInitMonitorOptions(FFMonitorOptions* options) void ffInitMonitorOptions(FFMonitorOptions* options)
+8 -8
View File
@@ -25,10 +25,10 @@ static void formatKey(const FFNetIOOptions* options, FFNetIOResult* inf, uint32_
else else
{ {
ffStrbufClear(key); ffStrbufClear(key);
ffParseFormatString(key, &options->moduleArgs.key, 2, (FFformatarg[]){ FF_PARSE_FORMAT_STRING_CHECKED(key, &options->moduleArgs.key, 2, ((FFformatarg[]){
{FF_FORMAT_ARG_TYPE_UINT, &index}, {FF_FORMAT_ARG_TYPE_UINT, &index},
{FF_FORMAT_ARG_TYPE_STRBUF, &inf->name}, {FF_FORMAT_ARG_TYPE_STRBUF, &inf->name},
}); }));
} }
} }
@@ -39,7 +39,7 @@ void ffPrintNetIO(FFNetIOOptions* options)
if(error) if(error)
{ {
ffPrintError(FF_NETIO_DISPLAY_NAME, 0, &options->moduleArgs, "%s", error); ffPrintError(FF_NETIO_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "%s", error);
return; return;
} }
@@ -79,7 +79,7 @@ void ffPrintNetIO(FFNetIOOptions* options)
ffParseSize(inf->txBytes, &buffer2); ffParseSize(inf->txBytes, &buffer2);
if (!options->detectTotal) ffStrbufAppendS(&buffer2, "/s"); if (!options->detectTotal) ffStrbufAppendS(&buffer2, "/s");
ffPrintFormatString(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_NETIO_NUM_FORMAT_ARGS, (FFformatarg[]){ 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}, {FF_FORMAT_ARG_TYPE_STRBUF, &buffer},
{FF_FORMAT_ARG_TYPE_STRBUF, &buffer2}, {FF_FORMAT_ARG_TYPE_STRBUF, &buffer2},
{FF_FORMAT_ARG_TYPE_STRBUF, &inf->name}, {FF_FORMAT_ARG_TYPE_STRBUF, &inf->name},
@@ -92,7 +92,7 @@ void ffPrintNetIO(FFNetIOOptions* options)
{FF_FORMAT_ARG_TYPE_UINT64, &inf->txErrors}, {FF_FORMAT_ARG_TYPE_UINT64, &inf->txErrors},
{FF_FORMAT_ARG_TYPE_UINT64, &inf->rxDrops}, {FF_FORMAT_ARG_TYPE_UINT64, &inf->rxDrops},
{FF_FORMAT_ARG_TYPE_UINT64, &inf->txDrops}, {FF_FORMAT_ARG_TYPE_UINT64, &inf->txDrops},
}); }));
} }
++index; ++index;
} }
@@ -162,7 +162,7 @@ void ffParseNetIOJsonObject(FFNetIOOptions* options, yyjson_val* module)
continue; continue;
} }
ffPrintError(FF_NETIO_MODULE_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key); ffPrintError(FF_NETIO_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Unknown JSON key %s", key);
} }
} }
@@ -218,7 +218,7 @@ void ffGenerateNetIOJsonResult(FFNetIOOptions* options, yyjson_mut_doc* doc, yyj
void ffPrintNetIOHelpFormat(void) void ffPrintNetIOHelpFormat(void)
{ {
ffPrintModuleFormatHelp(FF_NETIO_MODULE_NAME, "{1} (IN) - {2} (OUT)", FF_NETIO_NUM_FORMAT_ARGS, (const char* []) { FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_NETIO_MODULE_NAME, "{1} (IN) - {2} (OUT)", FF_NETIO_NUM_FORMAT_ARGS, ((const char* []) {
"Size of data received [per second] (formatted)", "Size of data received [per second] (formatted)",
"Size of data sent [per second] (formatted)", "Size of data sent [per second] (formatted)",
"Interface name", "Interface name",
@@ -231,7 +231,7 @@ void ffPrintNetIOHelpFormat(void)
"Number of errors sent [per second]", "Number of errors sent [per second]",
"Number of packets dropped when receiving [per second]", "Number of packets dropped when receiving [per second]",
"Number of packets dropped when sending [per second]", "Number of packets dropped when sending [per second]",
}); }));
} }
void ffInitNetIOOptions(FFNetIOOptions* options) void ffInitNetIOOptions(FFNetIOOptions* options)
+6 -6
View File
@@ -16,7 +16,7 @@ void ffPrintOpenCL(FFOpenCLOptions* options)
const char* error = ffDetectOpenCL(&opencl); const char* error = ffDetectOpenCL(&opencl);
if(error != NULL) if(error != NULL)
ffPrintError(FF_OPENCL_MODULE_NAME, 0, &options->moduleArgs, "%s", error); ffPrintError(FF_OPENCL_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "%s", error);
else else
{ {
if(options->moduleArgs.outputFormat.length == 0) if(options->moduleArgs.outputFormat.length == 0)
@@ -26,11 +26,11 @@ void ffPrintOpenCL(FFOpenCLOptions* options)
} }
else else
{ {
ffPrintFormat(FF_OPENCL_MODULE_NAME, 0, &options->moduleArgs, FF_OPENCL_NUM_FORMAT_ARGS, (FFformatarg[]) { 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, &opencl.version}, {FF_FORMAT_ARG_TYPE_STRBUF, &opencl.version},
{FF_FORMAT_ARG_TYPE_STRBUF, &opencl.device}, {FF_FORMAT_ARG_TYPE_STRBUF, &opencl.device},
{FF_FORMAT_ARG_TYPE_STRBUF, &opencl.vendor}, {FF_FORMAT_ARG_TYPE_STRBUF, &opencl.vendor},
}); }));
} }
} }
@@ -62,7 +62,7 @@ void ffParseOpenCLJsonObject(FFOpenCLOptions* options, yyjson_val* module)
if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs)) if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs))
continue; continue;
ffPrintError(FF_OPENCL_MODULE_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key); ffPrintError(FF_OPENCL_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Unknown JSON key %s", key);
} }
} }
@@ -102,11 +102,11 @@ void ffGenerateOpenCLJsonResult(FF_MAYBE_UNUSED FFOpenCLOptions* options, yyjson
void ffPrintOpenCLHelpFormat(void) void ffPrintOpenCLHelpFormat(void)
{ {
ffPrintModuleFormatHelp(FF_OPENCL_MODULE_NAME, "{1}", FF_OPENCL_NUM_FORMAT_ARGS, (const char* []) { FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_OPENCL_MODULE_NAME, "{1}", FF_OPENCL_NUM_FORMAT_ARGS, ((const char* []) {
"version", "version",
"device", "device",
"vendor" "vendor"
}); }));
} }
void ffInitOpenCLOptions(FFOpenCLOptions* options) void ffInitOpenCLOptions(FFOpenCLOptions* options)
+8 -8
View File
@@ -17,7 +17,7 @@ void ffPrintOpenGL(FFOpenGLOptions* options)
const char* error = ffDetectOpenGL(options, &result); const char* error = ffDetectOpenGL(options, &result);
if(error) if(error)
{ {
ffPrintError(FF_OPENGL_MODULE_NAME, 0, &options->moduleArgs, "%s", error); ffPrintError(FF_OPENGL_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "%s", error);
return; return;
} }
@@ -28,12 +28,12 @@ void ffPrintOpenGL(FFOpenGLOptions* options)
} }
else else
{ {
ffPrintFormat(FF_OPENGL_MODULE_NAME, 0, &options->moduleArgs, FF_OPENGL_NUM_FORMAT_ARGS, (FFformatarg[]) { 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}, {FF_FORMAT_ARG_TYPE_STRBUF, &result.version},
{FF_FORMAT_ARG_TYPE_STRBUF, &result.renderer}, {FF_FORMAT_ARG_TYPE_STRBUF, &result.renderer},
{FF_FORMAT_ARG_TYPE_STRBUF, &result.vendor}, {FF_FORMAT_ARG_TYPE_STRBUF, &result.vendor},
{FF_FORMAT_ARG_TYPE_STRBUF, &result.slv} {FF_FORMAT_ARG_TYPE_STRBUF, &result.slv},
}); }));
} }
ffStrbufDestroy(&result.version); ffStrbufDestroy(&result.version);
@@ -90,14 +90,14 @@ void ffParseOpenGLJsonObject(FFOpenGLOptions* options, yyjson_val* module)
{}, {},
}); });
if (error) if (error)
ffPrintError(FF_OPENGL_MODULE_NAME, 0, &options->moduleArgs, "Invalid %s value: %s", key, error); ffPrintError(FF_OPENGL_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Invalid %s value: %s", key, error);
else else
options->library = (FFOpenGLLibrary) value; options->library = (FFOpenGLLibrary) value;
continue; continue;
} }
#endif #endif
ffPrintError(FF_OPENGL_MODULE_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key); ffPrintError(FF_OPENGL_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Unknown JSON key %s", key);
} }
} }
@@ -160,12 +160,12 @@ void ffGenerateOpenGLJsonResult(FF_MAYBE_UNUSED FFOpenGLOptions* options, yyjson
void ffPrintOpenGLHelpFormat(void) void ffPrintOpenGLHelpFormat(void)
{ {
ffPrintModuleFormatHelp(FF_OPENGL_MODULE_NAME, "{1}", FF_OPENGL_NUM_FORMAT_ARGS, (const char* []) { FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_OPENGL_MODULE_NAME, "{1}", FF_OPENGL_NUM_FORMAT_ARGS, ((const char* []) {
"version", "version",
"renderer", "renderer",
"vendor", "vendor",
"shading language version" "shading language version"
}); }));
} }
void ffInitOpenGLOptions(FFOpenGLOptions* options) void ffInitOpenGLOptions(FFOpenGLOptions* options)
+6 -6
View File
@@ -101,7 +101,7 @@ void ffPrintOS(FFOSOptions* options)
if(os->name.length == 0 && os->prettyName.length == 0 && os->id.length == 0) if(os->name.length == 0 && os->prettyName.length == 0 && os->id.length == 0)
{ {
ffPrintError(FF_OS_MODULE_NAME, 0, &options->moduleArgs, "Could not detect OS"); ffPrintError(FF_OS_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Could not detect OS");
return; return;
} }
@@ -119,7 +119,7 @@ void ffPrintOS(FFOSOptions* options)
} }
else else
{ {
ffPrintFormat(FF_OS_MODULE_NAME, 0, &options->moduleArgs, FF_OS_NUM_FORMAT_ARGS, (FFformatarg[]){ 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.systemName}, {FF_FORMAT_ARG_TYPE_STRBUF, &instance.state.platform.systemName},
{FF_FORMAT_ARG_TYPE_STRBUF, &os->name}, {FF_FORMAT_ARG_TYPE_STRBUF, &os->name},
{FF_FORMAT_ARG_TYPE_STRBUF, &os->prettyName}, {FF_FORMAT_ARG_TYPE_STRBUF, &os->prettyName},
@@ -132,7 +132,7 @@ void ffPrintOS(FFOSOptions* options)
{FF_FORMAT_ARG_TYPE_STRBUF, &os->codename}, {FF_FORMAT_ARG_TYPE_STRBUF, &os->codename},
{FF_FORMAT_ARG_TYPE_STRBUF, &os->buildID}, {FF_FORMAT_ARG_TYPE_STRBUF, &os->buildID},
{FF_FORMAT_ARG_TYPE_STRBUF, &instance.state.platform.systemArchitecture} {FF_FORMAT_ARG_TYPE_STRBUF, &instance.state.platform.systemArchitecture}
}); }));
} }
} }
@@ -159,7 +159,7 @@ void ffParseOSJsonObject(FFOSOptions* options, yyjson_val* module)
if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs)) if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs))
continue; continue;
ffPrintError(FF_OS_MODULE_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key); ffPrintError(FF_OS_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Unknown JSON key %s", key);
} }
} }
@@ -196,7 +196,7 @@ void ffGenerateOSJsonResult(FF_MAYBE_UNUSED FFOSOptions* options, yyjson_mut_doc
void ffPrintOSHelpFormat(void) void ffPrintOSHelpFormat(void)
{ {
ffPrintModuleFormatHelp(FF_OS_MODULE_NAME, "{3} {10} {12}", FF_OS_NUM_FORMAT_ARGS, (const char* []) { FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_OS_MODULE_NAME, "{3} {10} {12}", FF_OS_NUM_FORMAT_ARGS, ((const char* []) {
"Name of the kernel (Linux, WIN32_NT, Darwin, FreeBSD)", "Name of the kernel (Linux, WIN32_NT, Darwin, FreeBSD)",
"Name of the OS", "Name of the OS",
"Pretty name of the OS", "Pretty name of the OS",
@@ -209,7 +209,7 @@ void ffPrintOSHelpFormat(void)
"Version codename of the OS", "Version codename of the OS",
"Build ID of the OS", "Build ID of the OS",
"Architecture of the OS" "Architecture of the OS"
}); }));
} }
void ffInitOSOptions(FFOSOptions* options) void ffInitOSOptions(FFOSOptions* options)
+7 -7
View File
@@ -15,7 +15,7 @@ void ffPrintPackages(FFPackagesOptions* options)
if(error) if(error)
{ {
ffPrintError(FF_PACKAGES_MODULE_NAME, 0, &options->moduleArgs, "%s", error); ffPrintError(FF_PACKAGES_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "%s", error);
return; return;
} }
@@ -69,7 +69,7 @@ void ffPrintPackages(FFPackagesOptions* options)
} }
else else
{ {
ffPrintFormat(FF_PACKAGES_MODULE_NAME, 0, &options->moduleArgs, FF_PACKAGES_NUM_FORMAT_ARGS, (FFformatarg[]){ 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}, {FF_FORMAT_ARG_TYPE_UINT, &counts.all},
{FF_FORMAT_ARG_TYPE_UINT, &counts.pacman}, {FF_FORMAT_ARG_TYPE_UINT, &counts.pacman},
{FF_FORMAT_ARG_TYPE_STRBUF, &counts.pacmanBranch}, {FF_FORMAT_ARG_TYPE_STRBUF, &counts.pacmanBranch},
@@ -95,7 +95,7 @@ void ffPrintPackages(FFPackagesOptions* options)
{FF_FORMAT_ARG_TYPE_UINT, &counts.paludis}, {FF_FORMAT_ARG_TYPE_UINT, &counts.paludis},
{FF_FORMAT_ARG_TYPE_UINT, &counts.winget}, {FF_FORMAT_ARG_TYPE_UINT, &counts.winget},
{FF_FORMAT_ARG_TYPE_UINT, &counts.opkg}, {FF_FORMAT_ARG_TYPE_UINT, &counts.opkg},
}); }));
} }
ffStrbufDestroy(&counts.pacmanBranch); ffStrbufDestroy(&counts.pacmanBranch);
@@ -175,7 +175,7 @@ void ffParsePackagesJsonObject(FFPackagesOptions* options, yyjson_val* module)
{ {
if (!yyjson_is_null(val) && !yyjson_is_arr(val)) if (!yyjson_is_null(val) && !yyjson_is_arr(val))
{ {
ffPrintError(FF_PACKAGES_MODULE_NAME, 0, &options->moduleArgs, "Invalid JSON value for %s", key); ffPrintError(FF_PACKAGES_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Invalid JSON value for %s", key);
continue; continue;
} }
@@ -215,7 +215,7 @@ void ffParsePackagesJsonObject(FFPackagesOptions* options, yyjson_val* module)
} }
} }
ffPrintError(FF_PACKAGES_MODULE_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key); ffPrintError(FF_PACKAGES_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Unknown JSON key %s", key);
} }
} }
@@ -300,7 +300,7 @@ void ffGeneratePackagesJsonResult(FF_MAYBE_UNUSED FFPackagesOptions* options, yy
void ffPrintPackagesHelpFormat(void) void ffPrintPackagesHelpFormat(void)
{ {
ffPrintModuleFormatHelp(FF_PACKAGES_MODULE_NAME, "{2} (pacman){?3}[{3}]{?}, {4} (dpkg), {5} (rpm), {6} (emerge), {7} (eopkg), {8} (xbps), {9} (nix-system), {10} (nix-user), {11} (nix-default), {12} (apk), {13} (pkg), {14} (flatpak-system), {15} (flatpack-user), {16} (snap), {17} (brew), {18} (brew-cask), {19} (MacPorts), {20} (scoop), {21} (choco), {22} (pkgtool), {23} (paludis), {24} (winget), {25} (opkg)", FF_PACKAGES_NUM_FORMAT_ARGS, (const char* []) { FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_PACKAGES_MODULE_NAME, "{2} (pacman){?3}[{3}]{?}, {4} (dpkg), {5} (rpm), {6} (emerge), {7} (eopkg), {8} (xbps), {9} (nix-system), {10} (nix-user), {11} (nix-default), {12} (apk), {13} (pkg), {14} (flatpak-system), {15} (flatpack-user), {16} (snap), {17} (brew), {18} (brew-cask), {19} (MacPorts), {20} (scoop), {21} (choco), {22} (pkgtool), {23} (paludis), {24} (winget), {25} (opkg)", FF_PACKAGES_NUM_FORMAT_ARGS, ((const char* []) {
"Number of all packages", "Number of all packages",
"Number of pacman packages", "Number of pacman packages",
"Pacman branch on manjaro", "Pacman branch on manjaro",
@@ -326,7 +326,7 @@ void ffPrintPackagesHelpFormat(void)
"Number of paludis packages", "Number of paludis packages",
"Number of winget packages", "Number of winget packages",
"Number of opkg packages" "Number of opkg packages"
}); }));
} }
void ffInitPackagesOptions(FFPackagesOptions* options) void ffInitPackagesOptions(FFPackagesOptions* options)
+9 -9
View File
@@ -7,7 +7,7 @@
#include "util/stringUtils.h" #include "util/stringUtils.h"
#define FF_PHYSICALDISK_DISPLAY_NAME "Physical Disk" #define FF_PHYSICALDISK_DISPLAY_NAME "Physical Disk"
#define FF_PHYSICALDISK_NUM_FORMAT_ARGS 9 #define FF_PHYSICALDISK_NUM_FORMAT_ARGS 10
static int sortDevices(const FFPhysicalDiskResult* left, const FFPhysicalDiskResult* right) static int sortDevices(const FFPhysicalDiskResult* left, const FFPhysicalDiskResult* right)
{ {
@@ -23,11 +23,11 @@ static void formatKey(const FFPhysicalDiskOptions* options, FFPhysicalDiskResult
else else
{ {
ffStrbufClear(key); ffStrbufClear(key);
ffParseFormatString(key, &options->moduleArgs.key, 2, (FFformatarg[]){ FF_PARSE_FORMAT_STRING_CHECKED(key, &options->moduleArgs.key, 3, ((FFformatarg[]){
{FF_FORMAT_ARG_TYPE_UINT, &index}, {FF_FORMAT_ARG_TYPE_UINT, &index},
{FF_FORMAT_ARG_TYPE_STRBUF, &dev->name}, {FF_FORMAT_ARG_TYPE_STRBUF, &dev->name},
{FF_FORMAT_ARG_TYPE_STRBUF, &dev->devPath}, {FF_FORMAT_ARG_TYPE_STRBUF, &dev->devPath},
}); }));
} }
} }
@@ -38,7 +38,7 @@ void ffPrintPhysicalDisk(FFPhysicalDiskOptions* options)
if(error) if(error)
{ {
ffPrintError(FF_PHYSICALDISK_DISPLAY_NAME, 0, &options->moduleArgs, "%s", error); ffPrintError(FF_PHYSICALDISK_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "%s", error);
return; return;
} }
@@ -108,7 +108,7 @@ void ffPrintPhysicalDisk(FFPhysicalDiskOptions* options)
if (dev->type & FF_PHYSICALDISK_TYPE_READWRITE) if (dev->type & FF_PHYSICALDISK_TYPE_READWRITE)
readOnlyType = "Read-write"; readOnlyType = "Read-write";
ffParseSize(dev->size, &buffer); ffParseSize(dev->size, &buffer);
ffPrintFormatString(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_PHYSICALDISK_NUM_FORMAT_ARGS, (FFformatarg[]){ 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}, {FF_FORMAT_ARG_TYPE_STRBUF, &buffer},
{FF_FORMAT_ARG_TYPE_STRBUF, &dev->name}, {FF_FORMAT_ARG_TYPE_STRBUF, &dev->name},
{FF_FORMAT_ARG_TYPE_STRBUF, &dev->interconnect}, {FF_FORMAT_ARG_TYPE_STRBUF, &dev->interconnect},
@@ -119,7 +119,7 @@ void ffPrintPhysicalDisk(FFPhysicalDiskOptions* options)
{FF_FORMAT_ARG_TYPE_STRING, readOnlyType}, {FF_FORMAT_ARG_TYPE_STRING, readOnlyType},
{FF_FORMAT_ARG_TYPE_STRBUF, &dev->revision}, {FF_FORMAT_ARG_TYPE_STRBUF, &dev->revision},
{FF_FORMAT_ARG_TYPE_DOUBLE, &tempStr}, {FF_FORMAT_ARG_TYPE_DOUBLE, &tempStr},
}); }));
} }
++index; ++index;
} }
@@ -175,7 +175,7 @@ void ffParsePhysicalDiskJsonObject(FFPhysicalDiskOptions* options, yyjson_val* m
if (ffTempsParseJsonObject(key, val, &options->temp, &options->tempConfig)) if (ffTempsParseJsonObject(key, val, &options->temp, &options->tempConfig))
continue; continue;
ffPrintError(FF_PHYSICALDISK_MODULE_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key); ffPrintError(FF_PHYSICALDISK_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Unknown JSON key %s", key);
} }
} }
@@ -252,7 +252,7 @@ void ffGeneratePhysicalDiskJsonResult(FFPhysicalDiskOptions* options, yyjson_mut
void ffPrintPhysicalDiskHelpFormat(void) void ffPrintPhysicalDiskHelpFormat(void)
{ {
ffPrintModuleFormatHelp(FF_PHYSICALDISK_MODULE_NAME, "{1}", FF_PHYSICALDISK_NUM_FORMAT_ARGS, (const char* []) { FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_PHYSICALDISK_MODULE_NAME, "{1}", FF_PHYSICALDISK_NUM_FORMAT_ARGS, ((const char* []) {
"Device size (formatted)", "Device size (formatted)",
"Device name", "Device name",
"Device interconnect type", "Device interconnect type",
@@ -263,7 +263,7 @@ void ffPrintPhysicalDiskHelpFormat(void)
"Device kind (Read-only or Read-write)", "Device kind (Read-only or Read-write)",
"Product revision", "Product revision",
"Device temperature (formatted)", "Device temperature (formatted)",
}); }));
} }
void ffInitPhysicalDiskOptions(FFPhysicalDiskOptions* options) void ffInitPhysicalDiskOptions(FFPhysicalDiskOptions* options)
+6 -6
View File
@@ -15,7 +15,7 @@ void ffPrintPlayer(FFPlayerOptions* options)
if(media->error.length > 0) if(media->error.length > 0)
{ {
ffPrintError(FF_PLAYER_DISPLAY_NAME, 0, &options->moduleArgs, "%s", media->error.chars); ffPrintError(FF_PLAYER_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "%s", media->error.chars);
return; return;
} }
@@ -64,12 +64,12 @@ void ffPrintPlayer(FFPlayerOptions* options)
} }
else else
{ {
ffPrintFormat(FF_PLAYER_DISPLAY_NAME, 0, &options->moduleArgs, FF_PLAYER_NUM_FORMAT_ARGS, (FFformatarg[]){ 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}, {FF_FORMAT_ARG_TYPE_STRBUF, &playerPretty},
{FF_FORMAT_ARG_TYPE_STRBUF, &media->player}, {FF_FORMAT_ARG_TYPE_STRBUF, &media->player},
{FF_FORMAT_ARG_TYPE_STRBUF, &media->playerId}, {FF_FORMAT_ARG_TYPE_STRBUF, &media->playerId},
{FF_FORMAT_ARG_TYPE_STRBUF, &media->url} {FF_FORMAT_ARG_TYPE_STRBUF, &media->url}
}); }));
} }
} }
@@ -96,7 +96,7 @@ void ffParsePlayerJsonObject(FFPlayerOptions* options, yyjson_val* module)
if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs)) if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs))
continue; continue;
ffPrintError(FF_PLAYER_MODULE_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key); ffPrintError(FF_PLAYER_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Unknown JSON key %s", key);
} }
} }
@@ -126,12 +126,12 @@ void ffGeneratePlayerJsonResult(FF_MAYBE_UNUSED FFMediaOptions* options, yyjson_
void ffPrintPlayerHelpFormat(void) void ffPrintPlayerHelpFormat(void)
{ {
ffPrintModuleFormatHelp(FF_PLAYER_MODULE_NAME, "{1}", FF_PLAYER_NUM_FORMAT_ARGS, (const char* []) { FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_PLAYER_MODULE_NAME, "{1}", FF_PLAYER_NUM_FORMAT_ARGS, ((const char* []) {
"Pretty player name", "Pretty player name",
"Player name", "Player name",
"Player Identifier", "Player Identifier",
"URL name" "URL name"
}); }));
} }
void ffInitPlayerOptions(FFPlayerOptions* options) void ffInitPlayerOptions(FFPlayerOptions* options)
+9 -9
View File
@@ -15,11 +15,11 @@ void ffPrintPowerAdapter(FFPowerAdapterOptions* options)
if (error) if (error)
{ {
ffPrintError(FF_POWERADAPTER_DISPLAY_NAME, 0, &options->moduleArgs, "%s", error); ffPrintError(FF_POWERADAPTER_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "%s", error);
} }
else if(results.length == 0) else if(results.length == 0)
{ {
ffPrintError(FF_POWERADAPTER_DISPLAY_NAME, 0, &options->moduleArgs, "No power adapters found"); ffPrintError(FF_POWERADAPTER_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "No power adapters found");
} }
else else
{ {
@@ -38,14 +38,14 @@ void ffPrintPowerAdapter(FFPowerAdapterOptions* options)
} }
else else
{ {
ffPrintFormat(FF_POWERADAPTER_DISPLAY_NAME, i, &options->moduleArgs, FF_POWERADAPTER_NUM_FORMAT_ARGS, (FFformatarg[]){ 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}, {FF_FORMAT_ARG_TYPE_INT, &result->watts},
{FF_FORMAT_ARG_TYPE_STRBUF, &result->name}, {FF_FORMAT_ARG_TYPE_STRBUF, &result->name},
{FF_FORMAT_ARG_TYPE_STRBUF, &result->manufacturer}, {FF_FORMAT_ARG_TYPE_STRBUF, &result->manufacturer},
{FF_FORMAT_ARG_TYPE_STRBUF, &result->modelName}, {FF_FORMAT_ARG_TYPE_STRBUF, &result->modelName},
{FF_FORMAT_ARG_TYPE_STRBUF, &result->description}, {FF_FORMAT_ARG_TYPE_STRBUF, &result->description},
{FF_FORMAT_ARG_TYPE_STRBUF, &result->serial}, {FF_FORMAT_ARG_TYPE_STRBUF, &result->serial},
}); }));
} }
ffStrbufDestroy(&result->manufacturer); ffStrbufDestroy(&result->manufacturer);
@@ -88,7 +88,7 @@ void ffParsePowerAdapterJsonObject(FFPowerAdapterOptions* options, yyjson_val* m
if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs)) if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs))
continue; continue;
ffPrintError(FF_POWERADAPTER_MODULE_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key); ffPrintError(FF_POWERADAPTER_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Unknown JSON key %s", key);
} }
} }
@@ -124,14 +124,14 @@ void ffGeneratePowerAdapterJsonResult(FF_MAYBE_UNUSED FFPowerAdapterOptions* opt
void ffPrintPowerAdapterHelpFormat(void) void ffPrintPowerAdapterHelpFormat(void)
{ {
ffPrintModuleFormatHelp(FF_POWERADAPTER_MODULE_NAME, "{1}W", FF_POWERADAPTER_NUM_FORMAT_ARGS, (const char* []) { FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_POWERADAPTER_MODULE_NAME, "{1}W", FF_POWERADAPTER_NUM_FORMAT_ARGS, ((const char* []) {
"PowerAdapter watts", "PowerAdapter watts",
"PowerAdapter name", "PowerAdapter name",
"PowerAdapter manufacturer", "PowerAdapter manufacturer",
"PowerAdapter model", "PowerAdapter model",
"PowerAdapter description" "PowerAdapter description",
"PowerAdapter serial number" "PowerAdapter serial number",
}); }));
} }
void ffInitPowerAdapterOptions(FFPowerAdapterOptions* options) void ffInitPowerAdapterOptions(FFPowerAdapterOptions* options)
+5 -5
View File
@@ -13,7 +13,7 @@ void ffPrintProcesses(FFProcessesOptions* options)
if(error) if(error)
{ {
ffPrintError(FF_PROCESSES_MODULE_NAME, 0, &options->moduleArgs, "%s", error); ffPrintError(FF_PROCESSES_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "%s", error);
return; return;
} }
@@ -25,9 +25,9 @@ void ffPrintProcesses(FFProcessesOptions* options)
} }
else else
{ {
ffPrintFormat(FF_PROCESSES_MODULE_NAME, 0, &options->moduleArgs, FF_PROCESSES_NUM_FORMAT_ARGS, (FFformatarg[]){ 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} {FF_FORMAT_ARG_TYPE_UINT, &numProcesses}
}); }));
} }
} }
@@ -54,7 +54,7 @@ void ffParseProcessesJsonObject(FFProcessesOptions* options, yyjson_val* module)
if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs)) if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs))
continue; continue;
ffPrintError(FF_PROCESSES_MODULE_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key); ffPrintError(FF_PROCESSES_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Unknown JSON key %s", key);
} }
} }
@@ -82,7 +82,7 @@ void ffGenerateProcessesJsonResult(FF_MAYBE_UNUSED FFProcessesOptions* options,
void ffPrintProcessesHelpFormat(void) void ffPrintProcessesHelpFormat(void)
{ {
ffPrintModuleFormatHelp(FF_PROCESSES_MODULE_NAME, "{1}", FF_PROCESSES_NUM_FORMAT_ARGS, (const char* []) { FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_PROCESSES_MODULE_NAME, "{1}", FF_PROCESSES_NUM_FORMAT_ARGS, (const char* []) {
"Count" "Count"
}); });
} }
+7 -7
View File
@@ -5,7 +5,7 @@
#include "util/stringUtils.h" #include "util/stringUtils.h"
#define FF_PUBLICIP_DISPLAY_NAME "Public IP" #define FF_PUBLICIP_DISPLAY_NAME "Public IP"
#define FF_PUBLICIP_NUM_FORMAT_ARGS 1 #define FF_PUBLICIP_NUM_FORMAT_ARGS 2
void ffPrintPublicIp(FFPublicIpOptions* options) void ffPrintPublicIp(FFPublicIpOptions* options)
{ {
@@ -16,7 +16,7 @@ void ffPrintPublicIp(FFPublicIpOptions* options)
if (error) if (error)
{ {
ffPrintError(FF_PUBLICIP_DISPLAY_NAME, 0, &options->moduleArgs, "%s", error); ffPrintError(FF_PUBLICIP_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "%s", error);
return; return;
} }
@@ -30,10 +30,10 @@ void ffPrintPublicIp(FFPublicIpOptions* options)
} }
else else
{ {
ffPrintFormat(FF_PUBLICIP_DISPLAY_NAME, 0, &options->moduleArgs, FF_PUBLICIP_NUM_FORMAT_ARGS, (FFformatarg[]) { 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}, {FF_FORMAT_ARG_TYPE_STRBUF, &result.ip},
{FF_FORMAT_ARG_TYPE_STRBUF, &result.location}, {FF_FORMAT_ARG_TYPE_STRBUF, &result.location},
}); }));
} }
ffStrbufDestroy(&result.ip); ffStrbufDestroy(&result.ip);
@@ -87,7 +87,7 @@ void ffParsePublicIpJsonObject(FFPublicIpOptions* options, yyjson_val* module)
continue; continue;
} }
ffPrintError(FF_PUBLICIP_MODULE_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key); ffPrintError(FF_PUBLICIP_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Unknown JSON key %s", key);
} }
} }
@@ -125,10 +125,10 @@ void ffGeneratePublicIpJsonResult(FFPublicIpOptions* options, yyjson_mut_doc* do
void ffPrintPublicIpHelpFormat(void) void ffPrintPublicIpHelpFormat(void)
{ {
ffPrintModuleFormatHelp(FF_PUBLICIP_MODULE_NAME, "{1} ({2})", FF_PUBLICIP_NUM_FORMAT_ARGS, (const char* []) { FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_PUBLICIP_MODULE_NAME, "{1} ({2})", FF_PUBLICIP_NUM_FORMAT_ARGS, ((const char* []) {
"Public IP address", "Public IP address",
"Location" "Location"
}); }));
} }
void ffInitPublicIpOptions(FFPublicIpOptions* options) void ffInitPublicIpOptions(FFPublicIpOptions* options)
+1 -1
View File
@@ -105,7 +105,7 @@ void ffParseSeparatorJsonObject(FFSeparatorOptions* options, yyjson_val* module)
continue; continue;
} }
ffPrintErrorString(FF_SEPARATOR_MODULE_NAME, 0, NULL, FF_PRINT_TYPE_NO_CUSTOM_KEY, "Unknown JSON key %s", key); ffPrintError(FF_SEPARATOR_MODULE_NAME, 0, NULL, FF_PRINT_TYPE_NO_CUSTOM_KEY, "Unknown JSON key %s", key);
} }
} }
+8 -7
View File
@@ -4,7 +4,7 @@
#include "modules/shell/shell.h" #include "modules/shell/shell.h"
#include "util/stringUtils.h" #include "util/stringUtils.h"
#define FF_SHELL_NUM_FORMAT_ARGS 6 #define FF_SHELL_NUM_FORMAT_ARGS 8
void ffPrintShell(FFShellOptions* options) void ffPrintShell(FFShellOptions* options)
{ {
@@ -12,7 +12,7 @@ void ffPrintShell(FFShellOptions* options)
if(result->processName.length == 0) if(result->processName.length == 0)
{ {
ffPrintError(FF_SHELL_MODULE_NAME, 0, &options->moduleArgs, "Couldn't detect shell"); ffPrintError(FF_SHELL_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Couldn't detect shell");
return; return;
} }
@@ -31,7 +31,7 @@ void ffPrintShell(FFShellOptions* options)
} }
else else
{ {
ffPrintFormat(FF_SHELL_MODULE_NAME, 0, &options->moduleArgs, FF_SHELL_NUM_FORMAT_ARGS, (FFformatarg[]) { 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}, {FF_FORMAT_ARG_TYPE_STRBUF, &result->processName},
{FF_FORMAT_ARG_TYPE_STRBUF, &result->exe}, {FF_FORMAT_ARG_TYPE_STRBUF, &result->exe},
{FF_FORMAT_ARG_TYPE_STRING, result->exeName}, {FF_FORMAT_ARG_TYPE_STRING, result->exeName},
@@ -40,7 +40,7 @@ void ffPrintShell(FFShellOptions* options)
{FF_FORMAT_ARG_TYPE_STRBUF, &result->prettyName}, {FF_FORMAT_ARG_TYPE_STRBUF, &result->prettyName},
{FF_FORMAT_ARG_TYPE_STRBUF, &result->exePath}, {FF_FORMAT_ARG_TYPE_STRBUF, &result->exePath},
{FF_FORMAT_ARG_TYPE_INT, &result->tty}, {FF_FORMAT_ARG_TYPE_INT, &result->tty},
}); }));
} }
} }
@@ -67,7 +67,7 @@ void ffParseShellJsonObject(FFShellOptions* options, yyjson_val* module)
if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs)) if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs))
continue; continue;
ffPrintError(FF_SHELL_MODULE_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key); ffPrintError(FF_SHELL_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Unknown JSON key %s", key);
} }
} }
@@ -106,7 +106,7 @@ void ffGenerateShellJsonResult(FF_MAYBE_UNUSED FFShellOptions* options, yyjson_m
void ffPrintShellHelpFormat(void) void ffPrintShellHelpFormat(void)
{ {
ffPrintModuleFormatHelp(FF_SHELL_MODULE_NAME, "{3} {4}", FF_SHELL_NUM_FORMAT_ARGS, (const char* []) { FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_SHELL_MODULE_NAME, "{3} {4}", FF_SHELL_NUM_FORMAT_ARGS, ((const char* []) {
"Shell process name", "Shell process name",
"The first argument of the command line when running the shell", "The first argument of the command line when running the shell",
"Shell base name of arg0", "Shell base name of arg0",
@@ -114,7 +114,8 @@ void ffPrintShellHelpFormat(void)
"Shell pid", "Shell pid",
"Shell pretty name", "Shell pretty name",
"Shell full exe path", "Shell full exe path",
}); "Shell tty used",
}));
} }
void ffInitShellOptions(FFShellOptions* options) void ffInitShellOptions(FFShellOptions* options)
+8 -8
View File
@@ -49,12 +49,12 @@ static void printDevice(FFSoundOptions* options, const FFSoundDevice* device, ui
FF_STRBUF_AUTO_DESTROY percentageStr = ffStrbufCreate(); FF_STRBUF_AUTO_DESTROY percentageStr = ffStrbufCreate();
ffPercentAppendNum(&percentageStr, device->volume, options->percent, false); ffPercentAppendNum(&percentageStr, device->volume, options->percent, false);
ffPrintFormat(FF_SOUND_MODULE_NAME, index, &options->moduleArgs, FF_SOUND_NUM_FORMAT_ARGS, (FFformatarg[]) { 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}, {FF_FORMAT_ARG_TYPE_BOOL, &device->main},
{FF_FORMAT_ARG_TYPE_STRBUF, &device->name}, {FF_FORMAT_ARG_TYPE_STRBUF, &device->name},
{FF_FORMAT_ARG_TYPE_STRBUF, &percentageStr}, {FF_FORMAT_ARG_TYPE_STRBUF, &percentageStr},
{FF_FORMAT_ARG_TYPE_STRBUF, &device->identifier} {FF_FORMAT_ARG_TYPE_STRBUF, &device->identifier}
}); }));
} }
} }
@@ -66,7 +66,7 @@ void ffPrintSound(FFSoundOptions* options)
if(error) if(error)
{ {
ffPrintError(FF_SOUND_MODULE_NAME, 0, &options->moduleArgs, "%s", error); ffPrintError(FF_SOUND_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "%s", error);
return; return;
} }
@@ -86,7 +86,7 @@ void ffPrintSound(FFSoundOptions* options)
if(filtered.length == 0) if(filtered.length == 0)
{ {
ffPrintError(FF_SOUND_MODULE_NAME, 0, &options->moduleArgs, "No active sound devices found"); ffPrintError(FF_SOUND_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "No active sound devices found");
return; return;
} }
@@ -150,7 +150,7 @@ void ffParseSoundJsonObject(FFSoundOptions* options, yyjson_val* module)
{}, {},
}); });
if (error) if (error)
ffPrintError(FF_SOUND_MODULE_NAME, 0, &options->moduleArgs, "Invalid %s value: %s", key, error); ffPrintError(FF_SOUND_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Invalid %s value: %s", key, error);
else else
options->soundType = (FFSoundType) value; options->soundType = (FFSoundType) value;
continue; continue;
@@ -159,7 +159,7 @@ void ffParseSoundJsonObject(FFSoundOptions* options, yyjson_val* module)
if (ffPercentParseJsonObject(key, val, &options->percent)) if (ffPercentParseJsonObject(key, val, &options->percent))
continue; continue;
ffPrintError(FF_SOUND_MODULE_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key); ffPrintError(FF_SOUND_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Unknown JSON key %s", key);
} }
} }
@@ -231,12 +231,12 @@ void ffGenerateSoundJsonResult(FF_MAYBE_UNUSED FFSoundOptions* options, yyjson_m
void ffPrintSoundHelpFormat(void) void ffPrintSoundHelpFormat(void)
{ {
ffPrintModuleFormatHelp(FF_SOUND_MODULE_NAME, "{2} ({3}%)", FF_SOUND_NUM_FORMAT_ARGS, (const char* []) { FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_SOUND_MODULE_NAME, "{2} ({3}%)", FF_SOUND_NUM_FORMAT_ARGS, ((const char* []) {
"Is main sound device", "Is main sound device",
"Device name", "Device name",
"Volume", "Volume",
"Identifier" "Identifier"
}); }));
} }
void ffInitSoundOptions(FFSoundOptions* options) void ffInitSoundOptions(FFSoundOptions* options)
+6 -6
View File
@@ -15,7 +15,7 @@ void ffPrintSwap(FFSwapOptions* options)
if(error) if(error)
{ {
ffPrintError(FF_SWAP_MODULE_NAME, 0, &options->moduleArgs, "%s", error); ffPrintError(FF_SWAP_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "%s", error);
return; return;
} }
@@ -67,11 +67,11 @@ void ffPrintSwap(FFSwapOptions* options)
{ {
FF_STRBUF_AUTO_DESTROY percentageStr = ffStrbufCreate(); FF_STRBUF_AUTO_DESTROY percentageStr = ffStrbufCreate();
ffPercentAppendNum(&percentageStr, percentage, options->percent, false); ffPercentAppendNum(&percentageStr, percentage, options->percent, false);
ffPrintFormat(FF_SWAP_MODULE_NAME, 0, &options->moduleArgs, FF_SWAP_NUM_FORMAT_ARGS, (FFformatarg[]){ 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}, {FF_FORMAT_ARG_TYPE_STRBUF, &usedPretty},
{FF_FORMAT_ARG_TYPE_STRBUF, &totalPretty}, {FF_FORMAT_ARG_TYPE_STRBUF, &totalPretty},
{FF_FORMAT_ARG_TYPE_STRBUF, &percentageStr}, {FF_FORMAT_ARG_TYPE_STRBUF, &percentageStr},
}); }));
} }
} }
@@ -104,7 +104,7 @@ void ffParseSwapJsonObject(FFSwapOptions* options, yyjson_val* module)
if (ffPercentParseJsonObject(key, val, &options->percent)) if (ffPercentParseJsonObject(key, val, &options->percent))
continue; continue;
ffPrintError(FF_SWAP_MODULE_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key); ffPrintError(FF_SWAP_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Unknown JSON key %s", key);
} }
} }
@@ -136,11 +136,11 @@ void ffGenerateSwapJsonResult(FF_MAYBE_UNUSED FFSwapOptions* options, yyjson_mut
void ffPrintSwapHelpFormat(void) void ffPrintSwapHelpFormat(void)
{ {
ffPrintModuleFormatHelp(FF_SWAP_MODULE_NAME, "{1} / {2} ({3})", FF_SWAP_NUM_FORMAT_ARGS, (const char* []) { FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_SWAP_MODULE_NAME, "{1} / {2} ({3})", FF_SWAP_NUM_FORMAT_ARGS, ((const char* []) {
"Used size", "Used size",
"Total size", "Total size",
"Percentage used" "Percentage used"
}); }));
} }
void ffInitSwapOptions(FFSwapOptions* options) void ffInitSwapOptions(FFSwapOptions* options)
+6 -6
View File
@@ -14,7 +14,7 @@ void ffPrintTerminal(FFTerminalOptions* options)
if(result->processName.length == 0) if(result->processName.length == 0)
{ {
ffPrintError(FF_TERMINAL_MODULE_NAME, 0, &options->moduleArgs, "Couldn't detect terminal"); ffPrintError(FF_TERMINAL_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Couldn't detect terminal");
return; return;
} }
@@ -29,7 +29,7 @@ void ffPrintTerminal(FFTerminalOptions* options)
} }
else else
{ {
ffPrintFormat(FF_TERMINAL_MODULE_NAME, 0, &options->moduleArgs, FF_TERMINAL_NUM_FORMAT_ARGS, (FFformatarg[]){ 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}, {FF_FORMAT_ARG_TYPE_STRBUF, &result->processName},
{FF_FORMAT_ARG_TYPE_STRBUF, &result->exe}, {FF_FORMAT_ARG_TYPE_STRBUF, &result->exe},
{FF_FORMAT_ARG_TYPE_STRING, result->exeName}, {FF_FORMAT_ARG_TYPE_STRING, result->exeName},
@@ -38,7 +38,7 @@ void ffPrintTerminal(FFTerminalOptions* options)
{FF_FORMAT_ARG_TYPE_STRBUF, &result->version}, {FF_FORMAT_ARG_TYPE_STRBUF, &result->version},
{FF_FORMAT_ARG_TYPE_STRBUF, &result->exePath}, {FF_FORMAT_ARG_TYPE_STRBUF, &result->exePath},
{FF_FORMAT_ARG_TYPE_STRBUF, &result->tty}, {FF_FORMAT_ARG_TYPE_STRBUF, &result->tty},
}); }));
} }
} }
@@ -65,7 +65,7 @@ void ffParseTerminalJsonObject(FFTerminalOptions* options, yyjson_val* module)
if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs)) if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs))
continue; continue;
ffPrintError(FF_TERMINAL_MODULE_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key); ffPrintError(FF_TERMINAL_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Unknown JSON key %s", key);
} }
} }
@@ -101,7 +101,7 @@ void ffGenerateTerminalJsonResult(FF_MAYBE_UNUSED FFTerminalOptions* options, yy
void ffPrintTerminalHelpFormat(void) void ffPrintTerminalHelpFormat(void)
{ {
ffPrintModuleFormatHelp(FF_TERMINAL_MODULE_NAME, "{5} {6}", FF_TERMINAL_NUM_FORMAT_ARGS, (const char* []) { FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_TERMINAL_MODULE_NAME, "{5} {6}", FF_TERMINAL_NUM_FORMAT_ARGS, ((const char* []) {
"Terminal process name", "Terminal process name",
"The first argument of the command line when running the terminal", "The first argument of the command line when running the terminal",
"Terminal base name of arg0", "Terminal base name of arg0",
@@ -110,7 +110,7 @@ void ffPrintTerminalHelpFormat(void)
"Terminal version", "Terminal version",
"Terminal full exe path", "Terminal full exe path",
"Terminal tty / pts used", "Terminal tty / pts used",
}); }));
} }
void ffInitTerminalOptions(FFTerminalOptions* options) void ffInitTerminalOptions(FFTerminalOptions* options)
+6 -6
View File
@@ -16,7 +16,7 @@ void ffPrintTerminalFont(FFTerminalFontOptions* options)
if(!ffDetectTerminalFont(&terminalFont)) if(!ffDetectTerminalFont(&terminalFont))
{ {
ffPrintError(FF_TERMINALFONT_DISPLAY_NAME, 0, &options->moduleArgs, "%s", terminalFont.error.chars); ffPrintError(FF_TERMINALFONT_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "%s", terminalFont.error.chars);
} }
else else
{ {
@@ -33,12 +33,12 @@ void ffPrintTerminalFont(FFTerminalFontOptions* options)
} }
else else
{ {
ffPrintFormat(FF_TERMINALFONT_DISPLAY_NAME, 0, &options->moduleArgs, FF_TERMINALFONT_NUM_FORMAT_ARGS, (FFformatarg[]){ 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}, {FF_FORMAT_ARG_TYPE_STRBUF, &terminalFont.font.pretty},
{FF_FORMAT_ARG_TYPE_STRBUF, &terminalFont.font.name}, {FF_FORMAT_ARG_TYPE_STRBUF, &terminalFont.font.name},
{FF_FORMAT_ARG_TYPE_STRBUF, &terminalFont.font.size}, {FF_FORMAT_ARG_TYPE_STRBUF, &terminalFont.font.size},
{FF_FORMAT_ARG_TYPE_LIST, &terminalFont.font.styles} {FF_FORMAT_ARG_TYPE_LIST, &terminalFont.font.styles}
}); }));
} }
} }
@@ -70,7 +70,7 @@ void ffParseTerminalFontJsonObject(FFTerminalFontOptions* options, yyjson_val* m
if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs)) if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs))
continue; continue;
ffPrintError(FF_TERMINALFONT_MODULE_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key); ffPrintError(FF_TERMINALFONT_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Unknown JSON key %s", key);
} }
} }
@@ -123,12 +123,12 @@ void ffGenerateTerminalFontJsonResult(FF_MAYBE_UNUSED FFTerminalOptions* options
void ffPrintTerminalFontHelpFormat(void) void ffPrintTerminalFontHelpFormat(void)
{ {
ffPrintModuleFormatHelp(FF_TERMINALFONT_MODULE_NAME, "{1}", FF_TERMINALFONT_NUM_FORMAT_ARGS, (const char* []) { FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_TERMINALFONT_MODULE_NAME, "{1}", FF_TERMINALFONT_NUM_FORMAT_ARGS, ((const char* []) {
"Terminal font combined", "Terminal font combined",
"Terminal font name", "Terminal font name",
"Terminal font size", "Terminal font size",
"Terminal font styles" "Terminal font styles"
}); }));
} }
void ffInitTerminalFontOptions(FFTerminalFontOptions* options) void ffInitTerminalFontOptions(FFTerminalFontOptions* options)
+6 -6
View File
@@ -13,7 +13,7 @@ void ffPrintTerminalSize(FFTerminalSizeOptions* options)
if(!ffDetectTerminalSize(&result)) if(!ffDetectTerminalSize(&result))
{ {
ffPrintError(FF_TERMINALSIZE_DISPLAY_NAME, 0, &options->moduleArgs, "Failed to detect terminal size"); ffPrintError(FF_TERMINALSIZE_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Failed to detect terminal size");
} }
else else
{ {
@@ -29,12 +29,12 @@ void ffPrintTerminalSize(FFTerminalSizeOptions* options)
} }
else else
{ {
ffPrintFormat(FF_TERMINALSIZE_DISPLAY_NAME, 0, &options->moduleArgs, FF_TERMINALSIZE_NUM_FORMAT_ARGS, (FFformatarg[]){ 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}, {FF_FORMAT_ARG_TYPE_UINT16, &result.rows},
{FF_FORMAT_ARG_TYPE_UINT16, &result.columns}, {FF_FORMAT_ARG_TYPE_UINT16, &result.columns},
{FF_FORMAT_ARG_TYPE_UINT16, &result.width}, {FF_FORMAT_ARG_TYPE_UINT16, &result.width},
{FF_FORMAT_ARG_TYPE_UINT16, &result.height} {FF_FORMAT_ARG_TYPE_UINT16, &result.height}
}); }));
} }
} }
} }
@@ -62,7 +62,7 @@ void ffParseTerminalSizeJsonObject(FFTerminalSizeOptions* options, yyjson_val* m
if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs)) if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs))
continue; continue;
ffPrintError(FF_TERMINALSIZE_MODULE_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key); ffPrintError(FF_TERMINALSIZE_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Unknown JSON key %s", key);
} }
} }
@@ -93,12 +93,12 @@ void ffGenerateTerminalSizeJsonResult(FF_MAYBE_UNUSED FFTerminalOptions* options
void ffPrintTerminalSizeHelpFormat(void) void ffPrintTerminalSizeHelpFormat(void)
{ {
ffPrintModuleFormatHelp(FF_TERMINALSIZE_MODULE_NAME, "{1} columns x {2} rows ({3}px x {4}px)", FF_TERMINALSIZE_NUM_FORMAT_ARGS, (const char* []) { FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_TERMINALSIZE_MODULE_NAME, "{1} columns x {2} rows ({3}px x {4}px)", FF_TERMINALSIZE_NUM_FORMAT_ARGS, ((const char* []) {
"Terminal rows", "Terminal rows",
"Terminal columns", "Terminal columns",
"Terminal width (in pixels)", "Terminal width (in pixels)",
"Terminal height (in pixels)" "Terminal height (in pixels)"
}); }));
} }
void ffInitTerminalSizeOptions(FFTerminalSizeOptions* options) void ffInitTerminalSizeOptions(FFTerminalSizeOptions* options)
+6 -6
View File
@@ -15,7 +15,7 @@ void ffPrintTerminalTheme(FFTerminalThemeOptions* options)
if(!ffDetectTerminalTheme(&result)) if(!ffDetectTerminalTheme(&result))
{ {
ffPrintError(FF_TERMINALTHEME_DISPLAY_NAME, 0, &options->moduleArgs, "Failed to detect terminal theme"); ffPrintError(FF_TERMINALTHEME_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Failed to detect terminal theme");
} }
else else
{ {
@@ -32,12 +32,12 @@ void ffPrintTerminalTheme(FFTerminalThemeOptions* options)
char fg[32], bg[32]; char fg[32], bg[32];
snprintf(fg, sizeof(fg), "#%02" PRIX16 "%02" PRIX16 "%02" PRIX16, result.fg.r, result.fg.g, result.fg.b); 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); snprintf(bg, sizeof(bg), "#%02" PRIX16 "%02" PRIX16 "%02" PRIX16, result.bg.r, result.bg.g, result.bg.b);
ffPrintFormat(FF_TERMINALTHEME_DISPLAY_NAME, 0, &options->moduleArgs, FF_TERMINALTHEME_NUM_FORMAT_ARGS, (FFformatarg[]){ 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}, {FF_FORMAT_ARG_TYPE_STRING, fg},
{FF_FORMAT_ARG_TYPE_STRING, result.fg.dark ? "Dark" : "Light"}, {FF_FORMAT_ARG_TYPE_STRING, result.fg.dark ? "Dark" : "Light"},
{FF_FORMAT_ARG_TYPE_STRING, bg}, {FF_FORMAT_ARG_TYPE_STRING, bg},
{FF_FORMAT_ARG_TYPE_STRING, result.bg.dark ? "Dark" : "Light"}, {FF_FORMAT_ARG_TYPE_STRING, result.bg.dark ? "Dark" : "Light"},
}); }));
} }
} }
} }
@@ -65,7 +65,7 @@ void ffParseTerminalThemeJsonObject(FFTerminalThemeOptions* options, yyjson_val*
if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs)) if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs))
continue; continue;
ffPrintError(FF_TERMINALTHEME_DISPLAY_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key); ffPrintError(FF_TERMINALTHEME_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Unknown JSON key %s", key);
} }
} }
@@ -104,12 +104,12 @@ void ffGenerateTerminalThemeJsonResult(FF_MAYBE_UNUSED FFTerminalOptions* option
void ffPrintTerminalThemeHelpFormat(void) void ffPrintTerminalThemeHelpFormat(void)
{ {
ffPrintModuleFormatHelp(FF_TERMINALTHEME_MODULE_NAME, "{1} (FG) {3} (BG) [{4}]", FF_TERMINALTHEME_NUM_FORMAT_ARGS, (const char* []) { FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_TERMINALTHEME_MODULE_NAME, "{1} (FG) {3} (BG) [{4}]", FF_TERMINALTHEME_NUM_FORMAT_ARGS, ((const char* []) {
"Terminal foreground color", "Terminal foreground color",
"Terminal foreground type (Dark / Light)", "Terminal foreground type (Dark / Light)",
"Terminal background color", "Terminal background color",
"Terminal background type (Dark / Light)", "Terminal background type (Dark / Light)",
}); }));
} }
void ffInitTerminalThemeOptions(FFTerminalThemeOptions* options) void ffInitTerminalThemeOptions(FFTerminalThemeOptions* options)
+6 -6
View File
@@ -13,7 +13,7 @@ void ffPrintTheme(FFThemeOptions* options)
if(error) if(error)
{ {
ffPrintError(FF_THEME_MODULE_NAME, 0, &options->moduleArgs, "%s", error); ffPrintError(FF_THEME_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "%s", error);
return; return;
} }
@@ -24,9 +24,9 @@ void ffPrintTheme(FFThemeOptions* options)
} }
else else
{ {
ffPrintFormat(FF_THEME_MODULE_NAME, 0, &options->moduleArgs, FF_THEME_NUM_FORMAT_ARGS, (FFformatarg[]){ 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, &theme} {FF_FORMAT_ARG_TYPE_STRBUF, &theme}
}); }));
} }
} }
@@ -53,7 +53,7 @@ void ffParseThemeJsonObject(FFThemeOptions* options, yyjson_val* module)
if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs)) if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs))
continue; continue;
ffPrintError(FF_THEME_MODULE_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key); ffPrintError(FF_THEME_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Unknown JSON key %s", key);
} }
} }
@@ -81,9 +81,9 @@ void ffGenerateThemeJsonResult(FF_MAYBE_UNUSED FFThemeOptions* options, yyjson_m
void ffPrintThemeHelpFormat(void) void ffPrintThemeHelpFormat(void)
{ {
ffPrintModuleFormatHelp(FF_THEME_MODULE_NAME, "{1}", FF_THEME_NUM_FORMAT_ARGS, (const char* []) { FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_THEME_MODULE_NAME, "{1}", FF_THEME_NUM_FORMAT_ARGS, ((const char* []) {
"Combined themes" "Combined themes"
}); }));
} }
void ffInitThemeOptions(FFThemeOptions* options) void ffInitThemeOptions(FFThemeOptions* options)
+5 -5
View File
@@ -56,7 +56,7 @@ void ffPrintTitle(FFTitleOptions* options)
} }
else else
{ {
ffPrintFormat(FF_TITLE_MODULE_NAME, 0, &options->moduleArgs, FF_TITLE_NUM_FORMAT_ARGS, (FFformatarg[]){ 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}, {FF_FORMAT_ARG_TYPE_STRBUF, &instance.state.platform.userName},
{FF_FORMAT_ARG_TYPE_STRBUF, &hostName}, {FF_FORMAT_ARG_TYPE_STRBUF, &hostName},
{FF_FORMAT_ARG_TYPE_STRBUF, &instance.state.platform.homeDir}, {FF_FORMAT_ARG_TYPE_STRBUF, &instance.state.platform.homeDir},
@@ -65,7 +65,7 @@ void ffPrintTitle(FFTitleOptions* options)
{FF_FORMAT_ARG_TYPE_STRBUF, &userNameColored}, {FF_FORMAT_ARG_TYPE_STRBUF, &userNameColored},
{FF_FORMAT_ARG_TYPE_STRBUF, &atColored}, {FF_FORMAT_ARG_TYPE_STRBUF, &atColored},
{FF_FORMAT_ARG_TYPE_STRBUF, &hostNameColored}, {FF_FORMAT_ARG_TYPE_STRBUF, &hostNameColored},
}); }));
} }
} }
@@ -139,7 +139,7 @@ void ffParseTitleJsonObject(FFTitleOptions* options, yyjson_val* module)
continue; continue;
} }
ffPrintErrorString(FF_TITLE_MODULE_NAME, 0, NULL, FF_PRINT_TYPE_NO_CUSTOM_KEY, "Unknown JSON key %s", key); ffPrintError(FF_TITLE_MODULE_NAME, 0, NULL, FF_PRINT_TYPE_NO_CUSTOM_KEY, "Unknown JSON key %s", key);
} }
} }
@@ -181,7 +181,7 @@ void ffGenerateTitleJsonResult(FF_MAYBE_UNUSED FFTitleOptions* options, yyjson_m
void ffPrintTitleHelpFormat(void) void ffPrintTitleHelpFormat(void)
{ {
ffPrintModuleFormatHelp(FF_TITLE_MODULE_NAME, "{6}{7}{8}", FF_TITLE_NUM_FORMAT_ARGS, (const char* []) { FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_TITLE_MODULE_NAME, "{6}{7}{8}", FF_TITLE_NUM_FORMAT_ARGS, ((const char* []) {
"User name", "User name",
"Host name", "Host name",
"Home directory", "Home directory",
@@ -190,7 +190,7 @@ void ffPrintTitleHelpFormat(void)
"User name (colored)", "User name (colored)",
"@ symbol (colored)", "@ symbol (colored)",
"Host name (colored)" "Host name (colored)"
}); }));
} }
void ffInitTitleOptions(FFTitleOptions* options) void ffInitTitleOptions(FFTitleOptions* options)
+10 -7
View File
@@ -14,7 +14,7 @@ void ffPrintUptime(FFUptimeOptions* options)
if(error) if(error)
{ {
ffPrintError(FF_UPTIME_MODULE_NAME, 0, &options->moduleArgs, "%s", error); ffPrintError(FF_UPTIME_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "%s", error);
return; return;
} }
@@ -77,7 +77,7 @@ void ffPrintUptime(FFUptimeOptions* options)
} }
else else
{ {
ffPrintFormat(FF_UPTIME_MODULE_NAME, 0, &options->moduleArgs, FF_UPTIME_NUM_FORMAT_ARGS, (FFformatarg[]){ 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}, {FF_FORMAT_ARG_TYPE_UINT, &days},
{FF_FORMAT_ARG_TYPE_UINT, &hours}, {FF_FORMAT_ARG_TYPE_UINT, &hours},
{FF_FORMAT_ARG_TYPE_UINT, &minutes}, {FF_FORMAT_ARG_TYPE_UINT, &minutes},
@@ -85,7 +85,7 @@ void ffPrintUptime(FFUptimeOptions* options)
{FF_FORMAT_ARG_TYPE_UINT, &milliseconds}, {FF_FORMAT_ARG_TYPE_UINT, &milliseconds},
{FF_FORMAT_ARG_TYPE_UINT64, &result.uptime}, {FF_FORMAT_ARG_TYPE_UINT64, &result.uptime},
{FF_FORMAT_ARG_TYPE_UINT64, &result.bootTime}, {FF_FORMAT_ARG_TYPE_UINT64, &result.bootTime},
}); }));
} }
} }
@@ -112,7 +112,7 @@ void ffParseUptimeJsonObject(FFUptimeOptions* options, yyjson_val* module)
if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs)) if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs))
continue; continue;
ffPrintError(FF_UPTIME_MODULE_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key); ffPrintError(FF_UPTIME_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Unknown JSON key %s", key);
} }
} }
@@ -142,12 +142,15 @@ void ffGenerateUptimeJsonResult(FF_MAYBE_UNUSED FFUptimeOptions* options, yyjson
void ffPrintUptimeHelpFormat(void) void ffPrintUptimeHelpFormat(void)
{ {
ffPrintModuleFormatHelp(FF_UPTIME_MODULE_NAME, "{1} days {2} hours {3} mins", FF_UPTIME_NUM_FORMAT_ARGS, (const char* []) { FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_UPTIME_MODULE_NAME, "{1} days {2} hours {3} mins", FF_UPTIME_NUM_FORMAT_ARGS, ((const char* []) {
"Days", "Days",
"Hours", "Hours",
"Minutes", "Minutes",
"Seconds" "Seconds",
}); "Milliseconds",
"Uptime in unix timestamp (ms)",
"Boot time in unix timestamp (ms)",
}));
} }
void ffInitUptimeOptions(FFUptimeOptions* options) void ffInitUptimeOptions(FFUptimeOptions* options)
+8 -8
View File
@@ -8,7 +8,7 @@
#pragma GCC diagnostic ignored "-Wformat" // warning: unknown conversion type character 'F' in format #pragma GCC diagnostic ignored "-Wformat" // warning: unknown conversion type character 'F' in format
#define FF_USERS_NUM_FORMAT_ARGS 1 #define FF_USERS_NUM_FORMAT_ARGS 5
void ffPrintUsers(FFUsersOptions* options) void ffPrintUsers(FFUsersOptions* options)
{ {
@@ -18,13 +18,13 @@ void ffPrintUsers(FFUsersOptions* options)
if(error) if(error)
{ {
ffPrintError(FF_USERS_MODULE_NAME, 0, &options->moduleArgs, "%s", error); ffPrintError(FF_USERS_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "%s", error);
return; return;
} }
if(users.length == 0) if(users.length == 0)
{ {
ffPrintError(FF_USERS_MODULE_NAME, 0, &options->moduleArgs, "%s", "Unable to detect any users"); ffPrintError(FF_USERS_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "%s", "Unable to detect any users");
return; return;
} }
@@ -74,13 +74,13 @@ void ffPrintUsers(FFUsersOptions* options)
{ {
FFUserResult* user = (FFUserResult*)ffListGet(&users, i); FFUserResult* user = (FFUserResult*)ffListGet(&users, i);
ffPrintFormat(FF_USERS_MODULE_NAME, users.length == 1 ? 0 : (uint8_t) (i + 1), &options->moduleArgs, FF_USERS_NUM_FORMAT_ARGS, (FFformatarg[]){ 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}, {FF_FORMAT_ARG_TYPE_STRBUF, &user->name},
{FF_FORMAT_ARG_TYPE_STRBUF, &user->hostName}, {FF_FORMAT_ARG_TYPE_STRBUF, &user->hostName},
{FF_FORMAT_ARG_TYPE_STRBUF, &user->sessionName}, {FF_FORMAT_ARG_TYPE_STRBUF, &user->sessionName},
{FF_FORMAT_ARG_TYPE_STRBUF, &user->clientIp}, {FF_FORMAT_ARG_TYPE_STRBUF, &user->clientIp},
{FF_FORMAT_ARG_TYPE_UINT64, &user->loginTime}, {FF_FORMAT_ARG_TYPE_UINT64, &user->loginTime},
}); }));
} }
} }
@@ -128,7 +128,7 @@ void ffParseUsersJsonObject(FFUsersOptions* options, yyjson_val* module)
continue; continue;
} }
ffPrintError(FF_USERS_MODULE_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key); ffPrintError(FF_USERS_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Unknown JSON key %s", key);
} }
} }
@@ -178,13 +178,13 @@ exit:
void ffPrintUsersHelpFormat(void) void ffPrintUsersHelpFormat(void)
{ {
ffPrintModuleFormatHelp(FF_USERS_MODULE_NAME, "{1}@{2} - login time {5}", FF_USERS_NUM_FORMAT_ARGS, (const char* []) { FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_USERS_MODULE_NAME, "{1}@{2} - login time {5}", FF_USERS_NUM_FORMAT_ARGS, ((const char* []) {
"User name", "User name",
"Host name", "Host name",
"Session name", "Session name",
"Client IP", "Client IP",
"Login Time" "Login Time"
}); }));
} }
void ffInitUsersOptions(FFUsersOptions* options) void ffInitUsersOptions(FFUsersOptions* options)
+5 -5
View File
@@ -31,7 +31,7 @@ void ffPrintVersion(FFVersionOptions* options)
} }
} }
ffPrintFormat(FF_VERSION_MODULE_NAME, 0, &options->moduleArgs, FF_VERSION_NUM_FORMAT_ARGS, (FFformatarg[]){ 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}, {FF_FORMAT_ARG_TYPE_STRING, result.projectName},
{FF_FORMAT_ARG_TYPE_STRING, result.version}, {FF_FORMAT_ARG_TYPE_STRING, result.version},
{FF_FORMAT_ARG_TYPE_STRING, result.versionTweak}, {FF_FORMAT_ARG_TYPE_STRING, result.versionTweak},
@@ -41,7 +41,7 @@ void ffPrintVersion(FFVersionOptions* options)
{FF_FORMAT_ARG_TYPE_STRING, result.compileTime}, {FF_FORMAT_ARG_TYPE_STRING, result.compileTime},
{FF_FORMAT_ARG_TYPE_STRING, result.compiler}, {FF_FORMAT_ARG_TYPE_STRING, result.compiler},
{FF_FORMAT_ARG_TYPE_STRBUF, &buf}, {FF_FORMAT_ARG_TYPE_STRBUF, &buf},
}); }));
} }
} }
@@ -68,7 +68,7 @@ void ffParseVersionJsonObject(FFVersionOptions* options, yyjson_val* module)
if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs)) if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs))
continue; continue;
ffPrintError(FF_VERSION_MODULE_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key); ffPrintError(FF_VERSION_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Unknown JSON key %s", key);
} }
} }
@@ -114,7 +114,7 @@ void ffGenerateVersionJsonResult(FF_MAYBE_UNUSED FFVersionOptions* options, yyjs
void ffPrintVersionHelpFormat(void) void ffPrintVersionHelpFormat(void)
{ {
ffPrintModuleFormatHelp(FF_VERSION_MODULE_NAME, "{1} {2}{3} ({5})", FF_VERSION_NUM_FORMAT_ARGS, (const char* []) { FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_VERSION_MODULE_NAME, "{1} {2}{3} ({5})", FF_VERSION_NUM_FORMAT_ARGS, ((const char* []) {
"Project name", "Project name",
"Version", "Version",
"Version tweak", "Version tweak",
@@ -124,7 +124,7 @@ void ffPrintVersionHelpFormat(void)
"Date time when compiling", "Date time when compiling",
"Compiler used", "Compiler used",
"Libc used" "Libc used"
}); }));
} }
void ffInitVersionOptions(FFVersionOptions* options) void ffInitVersionOptions(FFVersionOptions* options)
+9 -8
View File
@@ -5,7 +5,7 @@
#include "modules/vulkan/vulkan.h" #include "modules/vulkan/vulkan.h"
#include "util/stringUtils.h" #include "util/stringUtils.h"
#define FF_VULKAN_NUM_FORMAT_ARGS 3 #define FF_VULKAN_NUM_FORMAT_ARGS 4
void ffPrintVulkan(FFVulkanOptions* options) void ffPrintVulkan(FFVulkanOptions* options)
{ {
@@ -13,7 +13,7 @@ void ffPrintVulkan(FFVulkanOptions* options)
if(vulkan->error) if(vulkan->error)
{ {
ffPrintError(FF_VULKAN_MODULE_NAME, 0, &options->moduleArgs, "%s", vulkan->error); ffPrintError(FF_VULKAN_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "%s", vulkan->error);
return; return;
} }
@@ -43,11 +43,12 @@ void ffPrintVulkan(FFVulkanOptions* options)
} }
else else
{ {
ffPrintFormat(FF_VULKAN_MODULE_NAME, 0, &options->moduleArgs, FF_VULKAN_NUM_FORMAT_ARGS, (FFformatarg[]) { 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}, {FF_FORMAT_ARG_TYPE_STRBUF, &vulkan->driver},
{FF_FORMAT_ARG_TYPE_STRBUF, &vulkan->apiVersion}, {FF_FORMAT_ARG_TYPE_STRBUF, &vulkan->apiVersion},
{FF_FORMAT_ARG_TYPE_STRBUF, &vulkan->conformanceVersion} {FF_FORMAT_ARG_TYPE_STRBUF, &vulkan->conformanceVersion},
}); {FF_FORMAT_ARG_TYPE_STRBUF, &vulkan->instanceVersion},
}));
} }
} }
@@ -74,7 +75,7 @@ void ffParseVulkanJsonObject(FFVulkanOptions* options, yyjson_val* module)
if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs)) if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs))
continue; continue;
ffPrintError(FF_VULKAN_MODULE_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key); ffPrintError(FF_VULKAN_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Unknown JSON key %s", key);
} }
} }
@@ -144,12 +145,12 @@ void ffGenerateVulkanJsonResult(FF_MAYBE_UNUSED FFVulkanOptions* options, yyjson
void ffPrintVulkanHelpFormat(void) void ffPrintVulkanHelpFormat(void)
{ {
ffPrintModuleFormatHelp(FF_VULKAN_MODULE_NAME, "{2} - {1}", FF_VULKAN_NUM_FORMAT_ARGS, (const char* []) { FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_VULKAN_MODULE_NAME, "{2} - {1}", FF_VULKAN_NUM_FORMAT_ARGS, ((const char* []) {
"Driver name", "Driver name",
"API version", "API version",
"Conformance version", "Conformance version",
"Instance version", "Instance version",
}); }));
} }
void ffInitVulkanOptions(FFVulkanOptions* options) void ffInitVulkanOptions(FFVulkanOptions* options)
+8 -7
View File
@@ -24,7 +24,7 @@ void ffPrintWallpaper(FFWallpaperOptions* options)
if(error) if(error)
{ {
ffPrintError(FF_WALLPAPER_MODULE_NAME, 0, &options->moduleArgs, "%s", error); ffPrintError(FF_WALLPAPER_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "%s", error);
return; return;
} }
@@ -35,10 +35,10 @@ void ffPrintWallpaper(FFWallpaperOptions* options)
} }
else else
{ {
ffPrintFormat(FF_WALLPAPER_MODULE_NAME, 0, &options->moduleArgs, FF_WALLPAPER_NUM_FORMAT_ARGS, (FFformatarg[]){ 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}, {FF_FORMAT_ARG_TYPE_STRING, filename},
{FF_FORMAT_ARG_TYPE_STRBUF, &fullpath}, {FF_FORMAT_ARG_TYPE_STRBUF, &fullpath},
}); }));
} }
} }
@@ -65,7 +65,7 @@ void ffParseWallpaperJsonObject(FFWallpaperOptions* options, yyjson_val* module)
if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs)) if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs))
continue; continue;
ffPrintError(FF_WALLPAPER_MODULE_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key); ffPrintError(FF_WALLPAPER_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Unknown JSON key %s", key);
} }
} }
@@ -91,9 +91,10 @@ void ffGenerateWallpaperJsonResult(FF_MAYBE_UNUSED FFWallpaperOptions* options,
void ffPrintWallpaperHelpFormat(void) void ffPrintWallpaperHelpFormat(void)
{ {
ffPrintModuleFormatHelp(FF_WALLPAPER_MODULE_NAME, "{1}", FF_WALLPAPER_NUM_FORMAT_ARGS, (const char* []) { FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_WALLPAPER_MODULE_NAME, "{1}", FF_WALLPAPER_NUM_FORMAT_ARGS, ((const char* []) {
"Wallpaper image file" "File name",
}); "Full path",
}));
} }
void ffInitWallpaperOptions(FFWallpaperOptions* options) void ffInitWallpaperOptions(FFWallpaperOptions* options)
+6 -6
View File
@@ -13,7 +13,7 @@ void ffPrintWeather(FFWeatherOptions* options)
if(error) if(error)
{ {
ffPrintError(FF_WEATHER_MODULE_NAME, 0, &options->moduleArgs, "%s", error); ffPrintError(FF_WEATHER_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "%s", error);
return; return;
} }
@@ -25,9 +25,9 @@ void ffPrintWeather(FFWeatherOptions* options)
} }
else else
{ {
ffPrintFormat(FF_WEATHER_MODULE_NAME, 0, &options->moduleArgs, FF_WEATHER_NUM_FORMAT_ARGS, (FFformatarg[]) { 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} {FF_FORMAT_ARG_TYPE_STRBUF, &result}
}); }));
} }
} }
@@ -90,7 +90,7 @@ void ffParseWeatherJsonObject(FFWeatherOptions* options, yyjson_val* module)
continue; continue;
} }
ffPrintError(FF_WEATHER_MODULE_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key); ffPrintError(FF_WEATHER_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Unknown JSON key %s", key);
} }
} }
@@ -127,9 +127,9 @@ void ffGenerateWeatherJsonResult(FFWeatherOptions* options, yyjson_mut_doc* doc,
void ffPrintWeatherHelpFormat(void) void ffPrintWeatherHelpFormat(void)
{ {
ffPrintModuleFormatHelp(FF_WEATHER_MODULE_NAME, "{1}", FF_WEATHER_NUM_FORMAT_ARGS, (const char* []) { FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_WEATHER_MODULE_NAME, "{1}", FF_WEATHER_NUM_FORMAT_ARGS, ((const char* []) {
"Weather result" "Weather result"
}); }));
} }
void ffInitWeatherOptions(FFWeatherOptions* options) void ffInitWeatherOptions(FFWeatherOptions* options)
+7 -7
View File
@@ -13,12 +13,12 @@ void ffPrintWifi(FFWifiOptions* options)
const char* error = ffDetectWifi(&result); const char* error = ffDetectWifi(&result);
if(error) if(error)
{ {
ffPrintError(FF_WIFI_MODULE_NAME, 0, &options->moduleArgs, "%s", error); ffPrintError(FF_WIFI_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "%s", error);
return; return;
} }
if(!result.length) if(!result.length)
{ {
ffPrintError(FF_WIFI_MODULE_NAME, 0, &options->moduleArgs, "No Wifi interfaces found"); ffPrintError(FF_WIFI_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "No Wifi interfaces found");
return; return;
} }
@@ -46,7 +46,7 @@ void ffPrintWifi(FFWifiOptions* options)
} }
else else
{ {
ffPrintFormat(FF_WIFI_MODULE_NAME, moduleIndex, &options->moduleArgs, FF_WIFI_NUM_FORMAT_ARGS, (FFformatarg[]){ 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}, {FF_FORMAT_ARG_TYPE_STRBUF, &item->inf.description},
{FF_FORMAT_ARG_TYPE_STRBUF, &item->inf.status}, {FF_FORMAT_ARG_TYPE_STRBUF, &item->inf.status},
{FF_FORMAT_ARG_TYPE_STRBUF, &item->conn.status}, {FF_FORMAT_ARG_TYPE_STRBUF, &item->conn.status},
@@ -57,7 +57,7 @@ void ffPrintWifi(FFWifiOptions* options)
{FF_FORMAT_ARG_TYPE_DOUBLE, &item->conn.rxRate}, {FF_FORMAT_ARG_TYPE_DOUBLE, &item->conn.rxRate},
{FF_FORMAT_ARG_TYPE_DOUBLE, &item->conn.txRate}, {FF_FORMAT_ARG_TYPE_DOUBLE, &item->conn.txRate},
{FF_FORMAT_ARG_TYPE_STRBUF, &item->conn.security}, {FF_FORMAT_ARG_TYPE_STRBUF, &item->conn.security},
}); }));
} }
ffStrbufDestroy(&item->inf.description); ffStrbufDestroy(&item->inf.description);
@@ -93,7 +93,7 @@ void ffParseWifiJsonObject(FFWifiOptions* options, yyjson_val* module)
if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs)) if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs))
continue; continue;
ffPrintError(FF_WIFI_MODULE_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key); ffPrintError(FF_WIFI_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Unknown JSON key %s", key);
} }
} }
@@ -154,7 +154,7 @@ void ffGenerateWifiJsonResult(FF_MAYBE_UNUSED FFWifiOptions* options, yyjson_mut
void ffPrintWifiHelpFormat(void) void ffPrintWifiHelpFormat(void)
{ {
ffPrintModuleFormatHelp(FF_WIFI_MODULE_NAME, "{4} - {10}", FF_WIFI_NUM_FORMAT_ARGS, (const char* []) { FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_WIFI_MODULE_NAME, "{4} - {10}", FF_WIFI_NUM_FORMAT_ARGS, ((const char* []) {
"Interface description", "Interface description",
"Interface status", "Interface status",
"Connection status", "Connection status",
@@ -165,7 +165,7 @@ void ffPrintWifiHelpFormat(void)
"Connection RX rate", "Connection RX rate",
"Connection TX rate", "Connection TX rate",
"Connection Security algorithm" "Connection Security algorithm"
}); }));
} }
void ffInitWifiOptions(FFWifiOptions* options) void ffInitWifiOptions(FFWifiOptions* options)
+6 -6
View File
@@ -13,7 +13,7 @@ void ffPrintWM(FFWMOptions* options)
if(result->wmPrettyName.length == 0) if(result->wmPrettyName.length == 0)
{ {
ffPrintError(FF_WM_MODULE_NAME, 0, &options->moduleArgs, "No WM found"); ffPrintError(FF_WM_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "No WM found");
return; return;
} }
@@ -45,12 +45,12 @@ void ffPrintWM(FFWMOptions* options)
} }
else else
{ {
ffPrintFormat(FF_WM_MODULE_NAME, 0, &options->moduleArgs, FF_WM_NUM_FORMAT_ARGS, (FFformatarg[]){ 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}, {FF_FORMAT_ARG_TYPE_STRBUF, &result->wmProcessName},
{FF_FORMAT_ARG_TYPE_STRBUF, &result->wmPrettyName}, {FF_FORMAT_ARG_TYPE_STRBUF, &result->wmPrettyName},
{FF_FORMAT_ARG_TYPE_STRBUF, &result->wmProtocolName}, {FF_FORMAT_ARG_TYPE_STRBUF, &result->wmProtocolName},
{FF_FORMAT_ARG_TYPE_STRBUF, &pluginName}, {FF_FORMAT_ARG_TYPE_STRBUF, &pluginName},
}); }));
} }
} }
@@ -89,7 +89,7 @@ void ffParseWMJsonObject(FFWMOptions* options, yyjson_val* module)
continue; continue;
} }
ffPrintError(FF_WM_MODULE_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key); ffPrintError(FF_WM_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Unknown JSON key %s", key);
} }
} }
@@ -127,12 +127,12 @@ void ffGenerateWMJsonResult(FF_MAYBE_UNUSED FFWMOptions* options, yyjson_mut_doc
void ffPrintWMHelpFormat(void) void ffPrintWMHelpFormat(void)
{ {
ffPrintModuleFormatHelp(FF_WM_MODULE_NAME, "{2} ({3})", FF_WM_NUM_FORMAT_ARGS, (const char* []) { FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_WM_MODULE_NAME, "{2} ({3})", FF_WM_NUM_FORMAT_ARGS, ((const char* []) {
"WM process name", "WM process name",
"WM pretty name", "WM pretty name",
"WM protocol name", "WM protocol name",
"WM plugin name" "WM plugin name"
}); }));
} }
void ffInitWMOptions(FFWMOptions* options) void ffInitWMOptions(FFWMOptions* options)
+6 -6
View File
@@ -19,14 +19,14 @@ void ffPrintWMTheme(FFWMThemeOptions* options)
} }
else else
{ {
ffPrintFormat(FF_WMTHEME_DISPLAY_NAME, 0, &options->moduleArgs, FF_WMTHEME_NUM_FORMAT_ARGS, (FFformatarg[]){ 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} {FF_FORMAT_ARG_TYPE_STRBUF, &themeOrError}
}); }));
} }
} }
else else
{ {
ffPrintError(FF_WMTHEME_DISPLAY_NAME, 0, &options->moduleArgs, "%*s", themeOrError.length, themeOrError.chars); ffPrintError(FF_WMTHEME_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "%*s", themeOrError.length, themeOrError.chars);
} }
} }
@@ -53,7 +53,7 @@ void ffParseWMThemeJsonObject(FFWMThemeOptions* options, yyjson_val* module)
if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs)) if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs))
continue; continue;
ffPrintError(FF_WMTHEME_DISPLAY_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key); ffPrintError(FF_WMTHEME_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Unknown JSON key %s", key);
} }
} }
@@ -79,9 +79,9 @@ void ffGenerateWMThemeJsonResult(FF_MAYBE_UNUSED FFWMThemeOptions* options, yyjs
void ffPrintWMthemeHelpFormat(void) void ffPrintWMthemeHelpFormat(void)
{ {
ffPrintModuleFormatHelp(FF_WMTHEME_MODULE_NAME, "{1}", FF_WMTHEME_NUM_FORMAT_ARGS, (const char* []) { FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_WMTHEME_MODULE_NAME, "{1}", FF_WMTHEME_NUM_FORMAT_ARGS, ((const char* []) {
"WM theme" "WM theme"
}); }));
} }
void ffInitWMThemeOptions(FFWMThemeOptions* options) void ffInitWMThemeOptions(FFWMThemeOptions* options)
+14
View File
@@ -154,3 +154,17 @@ bool ffRegGetSubKey(HKEY hKey, uint32_t index, FFstrbuf* result, FFstrbuf* error
ffStrbufSetWS(result, resultW); ffStrbufSetWS(result, resultW);
return true; return true;
} }
bool ffRegGetNSubKeys(HKEY hKey, uint32_t* result, FFstrbuf* error)
{
DWORD buffer;
if(RegQueryInfoKeyW(hKey, NULL, NULL, NULL, &buffer, NULL, NULL, NULL, NULL, NULL, NULL, NULL) != ERROR_SUCCESS)
{
if (error)
ffStrbufAppendS(error, "RegQueryInfoKeyW(hKey) failed");
return false;
}
*result = buffer;
return true;
}
+1
View File
@@ -21,5 +21,6 @@ bool ffRegReadData(HKEY hKey, const wchar_t* valueNameW, uint8_t** result, uint3
bool ffRegReadUint(HKEY hKey, const wchar_t* valueNameW, uint32_t* result, FFstrbuf* error); bool ffRegReadUint(HKEY hKey, const wchar_t* valueNameW, uint32_t* result, FFstrbuf* error);
bool ffRegReadUint64(HKEY hKey, const wchar_t* valueNameW, uint64_t* result, FFstrbuf* error); bool ffRegReadUint64(HKEY hKey, const wchar_t* valueNameW, uint64_t* result, FFstrbuf* error);
bool ffRegGetSubKey(HKEY hKey, uint32_t index, FFstrbuf* result, FFstrbuf* error); bool ffRegGetSubKey(HKEY hKey, uint32_t index, FFstrbuf* result, FFstrbuf* error);
bool ffRegGetNSubKeys(HKEY hKey, uint32_t* result, FFstrbuf* error);
#endif #endif