diff --git a/src/common/format.h b/src/common/format.h index 969de6c36..d05921d10 100644 --- a/src/common/format.h +++ b/src/common/format.h @@ -24,3 +24,7 @@ typedef struct FFformatarg void ffFormatAppendFormatArg(FFstrbuf* buffer, const FFformatarg* formatarg); 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) diff --git a/src/common/printing.c b/src/common/printing.c index 90830568c..c5248a4a5 100644 --- a/src/common/printing.c +++ b/src/common/printing.c @@ -37,9 +37,9 @@ void ffPrintLogoAndKey(const char* moduleName, uint8_t moduleIndex, const FFModu else { 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} - }); + })); 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(); if (moduleArgs) diff --git a/src/common/printing.h b/src/common/printing.h index 5b8d1b6ad..4076e57f0 100644 --- a/src/common/printing.h +++ b/src/common/printing.h @@ -12,14 +12,18 @@ typedef enum FFPrintType { } FFPrintType; 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); -static inline void ffPrintFormat(const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, uint32_t numArgs, const FFformatarg* arguments) -{ - ffPrintFormatString(moduleName, moduleIndex, moduleArgs, FF_PRINT_TYPE_DEFAULT, numArgs, arguments); -} +void ffPrintFormat(const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, FFPrintType printType, 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");\ + 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(4, 5) void ffPrintError(const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, const char* message, ...); void ffPrintColor(const FFstrbuf* colorValue); void ffPrintCharTimes(char c, uint32_t times); 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) diff --git a/src/modules/battery/battery.c b/src/modules/battery/battery.c index 39f43b1d2..210eb64fd 100644 --- a/src/modules/battery/battery.c +++ b/src/modules/battery/battery.c @@ -7,7 +7,7 @@ #include "modules/battery/battery.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) { @@ -61,7 +61,7 @@ static void printBattery(FFBatteryOptions* options, FFBatteryResult* result, uin ffPercentAppendNum(&capacityStr, result->capacity, options->percent, false); FF_STRBUF_AUTO_DESTROY tempStr = ffStrbufCreate(); 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->modelName}, {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_STRBUF, &result->serial}, {FF_FORMAT_ARG_TYPE_STRBUF, &result->manufactureDate}, - }); + })); } } @@ -216,7 +216,7 @@ void ffGenerateBatteryJsonResult(FFBatteryOptions* options, yyjson_mut_doc* doc, 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 model", "Battery technology", @@ -226,7 +226,7 @@ void ffPrintBatteryHelpFormat(void) "Battery cycle count", "Battery serial number", "Battery manufactor date", - }); + })); } void ffInitBatteryOptions(FFBatteryOptions* options) diff --git a/src/modules/bios/bios.c b/src/modules/bios/bios.c index eb901f726..9ef589143 100644 --- a/src/modules/bios/bios.c +++ b/src/modules/bios/bios.c @@ -43,9 +43,9 @@ void ffPrintBios(FFBiosOptions* options) else { 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}, - }); + })); } if(options->moduleArgs.outputFormat.length == 0) @@ -59,13 +59,13 @@ void ffPrintBios(FFBiosOptions* options) } 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.release}, {FF_FORMAT_ARG_TYPE_STRBUF, &bios.vendor}, {FF_FORMAT_ARG_TYPE_STRBUF, &bios.version}, {FF_FORMAT_ARG_TYPE_STRBUF, &bios.type}, - }); + })); } exit: @@ -151,13 +151,13 @@ exit: 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 release", "bios vendor", "bios version", "firmware type", - }); + })); } void ffInitBiosOptions(FFBiosOptions* options) diff --git a/src/modules/bluetooth/bluetooth.c b/src/modules/bluetooth/bluetooth.c index 02c14975c..dccf02c96 100644 --- a/src/modules/bluetooth/bluetooth.c +++ b/src/modules/bluetooth/bluetooth.c @@ -32,12 +32,12 @@ static void printDevice(FFBluetoothOptions* options, const FFBluetoothResult* de FF_STRBUF_AUTO_DESTROY percentageStr = ffStrbufCreate(); 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->address}, {FF_FORMAT_ARG_TYPE_STRBUF, &device->type}, {FF_FORMAT_ARG_TYPE_STRBUF, &percentageStr} - }); + })); } } @@ -175,12 +175,12 @@ void ffGenerateBluetoothJsonResult(FF_MAYBE_UNUSED FFBluetoothOptions* options, 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", "Address", "Type", "Battery percentage" - }); + })); } void ffInitBluetoothOptions(FFBluetoothOptions* options) diff --git a/src/modules/board/board.c b/src/modules/board/board.c index 81a663609..130c5be4c 100644 --- a/src/modules/board/board.c +++ b/src/modules/board/board.c @@ -4,7 +4,7 @@ #include "modules/board/board.h" #include "util/stringUtils.h" -#define FF_BOARD_NUM_FORMAT_ARGS 3 +#define FF_BOARD_NUM_FORMAT_ARGS 4 void ffPrintBoard(FFBoardOptions* options) { @@ -37,12 +37,12 @@ void ffPrintBoard(FFBoardOptions* options) } 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.vendor}, {FF_FORMAT_ARG_TYPE_STRBUF, &result.version}, {FF_FORMAT_ARG_TYPE_STRBUF, &result.serial}, - }); + })); } exit: @@ -124,12 +124,12 @@ exit: 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 vendor", "board version", "board serial number", - }); + })); } void ffInitBoardOptions(FFBoardOptions* options) diff --git a/src/modules/brightness/brightness.c b/src/modules/brightness/brightness.c index 454a580d6..8888b0535 100644 --- a/src/modules/brightness/brightness.c +++ b/src/modules/brightness/brightness.c @@ -37,10 +37,10 @@ void ffPrintBrightness(FFBrightnessOptions* options) else { 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_STRBUF, &item->name} - }); + })); } 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(); 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, &item->name}, {FF_FORMAT_ARG_TYPE_DOUBLE, &item->max}, {FF_FORMAT_ARG_TYPE_DOUBLE, &item->min}, {FF_FORMAT_ARG_TYPE_DOUBLE, &item->current}, - }); + })); } ffStrbufClear(&key); @@ -180,13 +180,13 @@ void ffGenerateBrightnessJsonResult(FF_MAYBE_UNUSED FFBrightnessOptions* options 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 name", "Maximum brightness value", "Minimum brightness value", "Current brightness value", - }); + })); } void ffInitBrightnessOptions(FFBrightnessOptions* options) diff --git a/src/modules/camera/camera.c b/src/modules/camera/camera.c index 47f369295..41187cc73 100644 --- a/src/modules/camera/camera.c +++ b/src/modules/camera/camera.c @@ -5,7 +5,7 @@ #include "modules/camera/camera.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) { @@ -27,14 +27,14 @@ static void printDevice(FFCameraOptions* options, const FFCameraResult* device, } 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->vendor}, {FF_FORMAT_ARG_TYPE_STRBUF, &device->colorspace}, {FF_FORMAT_ARG_TYPE_STRBUF, &device->id}, {FF_FORMAT_ARG_TYPE_UINT, &device->width}, {FF_FORMAT_ARG_TYPE_UINT, &device->height}, - }); + }))); } } @@ -138,14 +138,14 @@ void ffGenerateCameraJsonResult(FF_MAYBE_UNUSED FFCameraOptions* options, yyjson 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", "Vendor", "Color space", "Identifier", "Width (in px)", "Height (in px)", - }); + })); } void ffInitCameraOptions(FFCameraOptions* options) diff --git a/src/modules/chassis/chassis.c b/src/modules/chassis/chassis.c index 4966053a1..aef014a2b 100644 --- a/src/modules/chassis/chassis.c +++ b/src/modules/chassis/chassis.c @@ -4,7 +4,7 @@ #include "modules/chassis/chassis.h" #include "util/stringUtils.h" -#define FF_CHASSIS_NUM_FORMAT_ARGS 3 +#define FF_CHASSIS_NUM_FORMAT_ARGS 4 void ffPrintChassis(FFChassisOptions* options) { @@ -38,12 +38,12 @@ void ffPrintChassis(FFChassisOptions* options) } 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.vendor}, {FF_FORMAT_ARG_TYPE_STRBUF, &result.version}, {FF_FORMAT_ARG_TYPE_STRBUF, &result.serial}, - }); + })); } exit: @@ -125,12 +125,12 @@ exit: 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 vendor", "chassis version", "chassis serial number", - }); + })); } void ffInitChassisOptions(FFChassisOptions* options) diff --git a/src/modules/command/command.c b/src/modules/command/command.c index 9970455ad..f311322d8 100644 --- a/src/modules/command/command.c +++ b/src/modules/command/command.c @@ -39,9 +39,9 @@ void ffPrintCommand(FFCommandOptions* options) } 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} - }); + })); } } @@ -141,9 +141,9 @@ void ffGenerateCommandJsonResult(FF_MAYBE_UNUSED FFCommandOptions* options, yyjs 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" - }); + })); } void ffInitCommandOptions(FFCommandOptions* options) diff --git a/src/modules/cpu/cpu.c b/src/modules/cpu/cpu.c index c7ee463e8..32f26e56f 100644 --- a/src/modules/cpu/cpu.c +++ b/src/modules/cpu/cpu.c @@ -63,7 +63,7 @@ void ffPrintCPU(FFCPUOptions* options) { FF_STRBUF_AUTO_DESTROY tempStr = ffStrbufCreate(); 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.vendor}, {FF_FORMAT_ARG_TYPE_UINT16, &cpu.coresPhysical}, @@ -72,7 +72,7 @@ void ffPrintCPU(FFCPUOptions* options) {FF_FORMAT_ARG_TYPE_DOUBLE, &cpu.frequencyMin}, {FF_FORMAT_ARG_TYPE_DOUBLE, &cpu.frequencyMax}, {FF_FORMAT_ARG_TYPE_STRBUF, &tempStr} - }); + })); } } @@ -181,7 +181,7 @@ void ffGenerateCPUJsonResult(FFCPUOptions* options, yyjson_mut_doc* doc, yyjson_ 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", "Vendor", "Physical core count", @@ -190,7 +190,7 @@ void ffPrintCPUHelpFormat(void) "Min frequency", "Max frequency", "Temperature (formatted)" - }); + })); } void ffInitCPUOptions(FFCPUOptions* options) diff --git a/src/modules/cpuusage/cpuusage.c b/src/modules/cpuusage/cpuusage.c index be852f076..f7fa6f222 100644 --- a/src/modules/cpuusage/cpuusage.c +++ b/src/modules/cpuusage/cpuusage.c @@ -79,13 +79,13 @@ void ffPrintCPUUsage(FFCPUUsageOptions* options) ffPercentAppendNum(&minStr, minValue, options->percent, false); FF_STRBUF_AUTO_DESTROY maxStr = ffStrbufCreate(); 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, &maxStr}, {FF_FORMAT_ARG_TYPE_UINT, &maxIndex}, {FF_FORMAT_ARG_TYPE_STRBUF, &minStr}, {FF_FORMAT_ARG_TYPE_UINT, &minIndex}, - }); + })); } } @@ -166,13 +166,13 @@ void ffGenerateCPUUsageJsonResult(FF_MAYBE_UNUSED FFCPUUsageOptions* options, yy 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, maximum)", "CPU core index of maximum usage", "CPU usage (percentage, minimum)", "CPU core index of minimum usage", - }); + })); } void ffInitCPUUsageOptions(FFCPUUsageOptions* options) diff --git a/src/modules/cursor/cursor.c b/src/modules/cursor/cursor.c index f3d151765..70b191402 100644 --- a/src/modules/cursor/cursor.c +++ b/src/modules/cursor/cursor.c @@ -38,10 +38,10 @@ void ffPrintCursor(FFCursorOptions* options) } 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.size} - }); + })); } } @@ -112,10 +112,10 @@ void ffGenerateCursorJsonResult(FF_MAYBE_UNUSED FFCursorOptions* options, yyjson 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 size" - }); + })); } void ffInitCursorOptions(FFCursorOptions* options) diff --git a/src/modules/datetime/datetime.c b/src/modules/datetime/datetime.c index 25a685538..7ecee6213 100644 --- a/src/modules/datetime/datetime.c +++ b/src/modules/datetime/datetime.c @@ -65,7 +65,7 @@ void ffPrintDateTimeFormat(struct tm* tm, const FFModuleArgs* moduleArgs) strftime(result.offsetFromUtc, sizeof(result.offsetFromUtc), "%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_UINT8, &result.yearShort}, // 2 {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.offsetFromUtc}, // 21 {FF_FORMAT_ARG_TYPE_STRING, result.timezoneName}, // 22 - }); + })); } void ffPrintDateTime(FFDateTimeOptions* options) @@ -157,7 +157,7 @@ void ffGenerateDateTimeJsonResult(FF_MAYBE_UNUSED FFDateTimeOptions* options, yy 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", "last two digits of year", "month", @@ -180,7 +180,7 @@ void ffPrintDateTimeHelpFormat(void) "second with leading zero", "offset from UTC in the ISO 8601 format", "locale-dependent timezone name or abbreviation", - }); + })); } void ffInitDateTimeOptions(FFDateTimeOptions* options) diff --git a/src/modules/de/de.c b/src/modules/de/de.c index e71b3334b..8cb5bb0a5 100644 --- a/src/modules/de/de.c +++ b/src/modules/de/de.c @@ -36,11 +36,11 @@ void ffPrintDE(FFDEOptions* options) } 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->dePrettyName}, {FF_FORMAT_ARG_TYPE_STRBUF, &version} - }); + })); } } @@ -115,11 +115,11 @@ void ffGenerateDEJsonResult(FF_MAYBE_UNUSED FFDEOptions* options, yyjson_mut_doc 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 pretty name", "DE version" - }); + })); } void ffInitDEOptions(FFDEOptions* options) diff --git a/src/modules/disk/disk.c b/src/modules/disk/disk.c index f749c5c80..f315e32fc 100644 --- a/src/modules/disk/disk.c +++ b/src/modules/disk/disk.c @@ -34,11 +34,11 @@ static void printDisk(FFDiskOptions* options, const FFDisk* disk) } 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->name}, {FF_FORMAT_ARG_TYPE_STRBUF, &disk->mountFrom}, - }); + })); } 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 isHidden = !!(disk->type & FF_DISK_VOLUME_TYPE_HIDDEN_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, &totalPretty}, {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->name}, {FF_FORMAT_ARG_TYPE_BOOL, &isReadOnly}, - }); + })); } } @@ -453,7 +453,7 @@ void ffGenerateDiskJsonResult(FFDiskOptions* options, yyjson_mut_doc* doc, yyjso 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 total", "Size percentage", @@ -465,7 +465,7 @@ void ffPrintDiskHelpFormat(void) "Filesystem", "Label / name", "True if read-only", - }); + })); } void ffInitDiskOptions(FFDiskOptions* options) diff --git a/src/modules/diskio/diskio.c b/src/modules/diskio/diskio.c index 4afa051ce..22ff1cfe7 100644 --- a/src/modules/diskio/diskio.c +++ b/src/modules/diskio/diskio.c @@ -22,11 +22,11 @@ static void formatKey(const FFDiskIOOptions* options, FFDiskIOResult* dev, uint3 else { 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_STRBUF, &dev->name}, {FF_FORMAT_ARG_TYPE_STRBUF, &dev->devPath}, - }); + })); } } @@ -74,7 +74,7 @@ void ffPrintDiskIO(FFDiskIOOptions* options) ffParseSize(dev->bytesWritten, &buffer2); 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, &buffer2}, {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->readCount}, {FF_FORMAT_ARG_TYPE_UINT64, &dev->writeCount}, - }); + })); } ++index; } @@ -192,7 +192,7 @@ void ffGenerateDiskIOJsonResult(FFDiskIOOptions* options, yyjson_mut_doc* doc, y 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 written [per second] (formatted)", "Device name", @@ -201,7 +201,7 @@ void ffPrintDiskIOHelpFormat(void) "Size of data written [per second] (in bytes)", "Number of reads", "Number of writes", - }); + })); } void ffInitDiskIOOptions(FFDiskIOOptions* options) diff --git a/src/modules/display/display.c b/src/modules/display/display.c index 35540eea8..0f73507bc 100644 --- a/src/modules/display/display.c +++ b/src/modules/display/display.c @@ -4,7 +4,7 @@ #include "modules/display/display.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) { @@ -89,11 +89,11 @@ void ffPrintDisplay(FFDisplayOptions* options) } 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_STRBUF, &result->name}, {FF_FORMAT_ARG_TYPE_STRING, displayType}, - }); + })); } if(options->moduleArgs.outputFormat.length == 0) @@ -125,7 +125,7 @@ void ffPrintDisplay(FFDisplayOptions* options) } 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->height}, {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_UINT, &result->rotation}, {FF_FORMAT_ARG_TYPE_BOOL, &result->primary}, - }); + })); } } } @@ -309,7 +309,7 @@ void ffGenerateDisplayJsonResult(FF_MAYBE_UNUSED FFDisplayOptions* options, yyjs 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 height (in pixels)", "Screen refresh rate (in Hz)", @@ -318,7 +318,8 @@ void ffPrintDisplayHelpFormat(void) "Screen name", "Screen type (builtin, external or unknown)", "Screen rotation (in degrees)", - }); + "True if being the primary screen", + })); } void ffInitDisplayOptions(FFDisplayOptions* options) diff --git a/src/modules/font/font.c b/src/modules/font/font.c index 3b1f1029a..bbfbd6279 100644 --- a/src/modules/font/font.c +++ b/src/modules/font/font.c @@ -28,13 +28,13 @@ void ffPrintFont(FFFontOptions* options) } 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[1]}, {FF_FORMAT_ARG_TYPE_STRBUF, &font.fonts[2]}, {FF_FORMAT_ARG_TYPE_STRBUF, &font.fonts[3]}, {FF_FORMAT_ARG_TYPE_STRBUF, &font.display}, - }); + })); } } @@ -106,13 +106,13 @@ void ffGenerateFontJsonResult(FF_MAYBE_UNUSED FFFontOptions* options, yyjson_mut 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 2", "Font 3", "Font 4", "Combined fonts" - }); + })); } void ffInitFontOptions(FFFontOptions* options) diff --git a/src/modules/gamepad/gamepad.c b/src/modules/gamepad/gamepad.c index e50fb22d7..d24f88aa6 100644 --- a/src/modules/gamepad/gamepad.c +++ b/src/modules/gamepad/gamepad.c @@ -5,7 +5,7 @@ #include "modules/gamepad/gamepad.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) { @@ -28,11 +28,11 @@ static void printDevice(FFGamepadOptions* options, const FFGamepadDevice* device FF_STRBUF_AUTO_DESTROY percentageStr = ffStrbufCreate(); 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->serial}, {FF_FORMAT_ARG_TYPE_STRBUF, &percentageStr}, - }); + })); } } @@ -141,11 +141,11 @@ void ffGenerateGamepadJsonResult(FF_MAYBE_UNUSED FFGamepadOptions* options, yyjs 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", "Serial number", "Battery percentage", - }); + })); } void ffInitGamepadOptions(FFGamepadOptions* options) diff --git a/src/modules/gpu/gpu.c b/src/modules/gpu/gpu.c index 7c3d5b55f..0aa40d6e0 100644 --- a/src/modules/gpu/gpu.c +++ b/src/modules/gpu/gpu.c @@ -75,7 +75,7 @@ static void printGPUResult(FFGPUOptions* options, uint8_t index, const FFGPUResu { FF_STRBUF_AUTO_DESTROY tempStr = ffStrbufCreate(); 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->name}, {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_STRBUF, &gpu->platformApi}, {FF_FORMAT_ARG_TYPE_DOUBLE, &gpu->frequency}, - }); + })); } } @@ -332,7 +332,7 @@ void ffGenerateGPUJsonResult(FFGPUOptions* options, yyjson_mut_doc* doc, yyjson_ 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 name", "GPU driver", @@ -345,7 +345,7 @@ void ffPrintGPUHelpFormat(void) "GPU used shared memory", "The platform API that GPU supports", "Current frequency in GHz", - }); + })); } void ffInitGPUOptions(FFGPUOptions* options) diff --git a/src/modules/host/host.c b/src/modules/host/host.c index 08f11c8e7..df3115774 100644 --- a/src/modules/host/host.c +++ b/src/modules/host/host.c @@ -48,7 +48,7 @@ void ffPrintHost(FFHostOptions* options) } 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.name}, {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.serial}, {FF_FORMAT_ARG_TYPE_STRBUF, &host.uuid}, - }); + })); } exit: @@ -149,7 +149,7 @@ exit: 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 name", "product version", @@ -157,7 +157,7 @@ void ffPrintHostHelpFormat(void) "product vendor", "product serial number", "product uuid", - }); + })); } void ffInitHostOptions(FFHostOptions* options) diff --git a/src/modules/icons/icons.c b/src/modules/icons/icons.c index 8da7ebc28..f37c2e99f 100644 --- a/src/modules/icons/icons.c +++ b/src/modules/icons/icons.c @@ -24,9 +24,9 @@ void ffPrintIcons(FFIconsOptions* options) } 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} - }); + })); } } @@ -81,9 +81,9 @@ void ffGenerateIconsJsonResult(FF_MAYBE_UNUSED FFIconsOptions* options, yyjson_m 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" - }); + })); } void ffInitIconsOptions(FFIconsOptions* options) diff --git a/src/modules/kernel/kernel.c b/src/modules/kernel/kernel.c index c25d75fe4..1ccbe3808 100644 --- a/src/modules/kernel/kernel.c +++ b/src/modules/kernel/kernel.c @@ -3,7 +3,7 @@ #include "modules/kernel/kernel.h" #include "util/stringUtils.h" -#define FF_KERNEL_NUM_FORMAT_ARGS 4 +#define FF_KERNEL_NUM_FORMAT_ARGS 5 void ffPrintKernel(FFKernelOptions* options) { @@ -20,13 +20,13 @@ void ffPrintKernel(FFKernelOptions* options) } 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->systemRelease}, {FF_FORMAT_ARG_TYPE_STRBUF, &platform->systemVersion}, {FF_FORMAT_ARG_TYPE_STRBUF, &platform->systemArchitecture}, {FF_FORMAT_ARG_TYPE_STRBUF, &platform->systemDisplayVersion} - }); + })); } } @@ -77,11 +77,13 @@ void ffGenerateKernelJsonResult(FF_MAYBE_UNUSED FFKernelOptions* options, yyjson void ffPrintKernelHelpFormat(void) { - ffPrintModuleFormatHelp(FF_KERNEL_MODULE_NAME, "{2}", FF_KERNEL_NUM_FORMAT_ARGS, (const char* []) { - "Kernel sysname", - "Kernel release", - "Kernel version" - }); + FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_KERNEL_MODULE_NAME, "{2}", FF_KERNEL_NUM_FORMAT_ARGS, ((const char* []) { + "Sysname", + "Release", + "Version", + "Architecture", + "Display version", + })); } void ffInitKernelOptions(FFKernelOptions* options) diff --git a/src/modules/lm/lm.c b/src/modules/lm/lm.c index f3652a465..e896165a8 100644 --- a/src/modules/lm/lm.c +++ b/src/modules/lm/lm.c @@ -38,11 +38,11 @@ void ffPrintLM(FFLMOptions* options) } 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.type}, {FF_FORMAT_ARG_TYPE_STRBUF, &result.version}, - }); + })); } ffStrbufDestroy(&result.service); ffStrbufDestroy(&result.type); @@ -117,11 +117,11 @@ exit: 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 type", "LM version" - }); + })); } void ffInitLMOptions(FFLMOptions* options) diff --git a/src/modules/locale/locale.c b/src/modules/locale/locale.c index 4baeb3d26..513a043da 100644 --- a/src/modules/locale/locale.c +++ b/src/modules/locale/locale.c @@ -24,9 +24,9 @@ void ffPrintLocale(FFLocaleOptions* options) } 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} - }); + })); } } @@ -81,9 +81,9 @@ void ffGenerateLocaleJsonResult(FF_MAYBE_UNUSED FFLocaleOptions* options, yyjson 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" - }); + })); } void ffInitLocaleOptions(FFLocaleOptions* options) diff --git a/src/modules/localip/localip.c b/src/modules/localip/localip.c index 2b0e25dc4..997549f1c 100644 --- a/src/modules/localip/localip.c +++ b/src/modules/localip/localip.c @@ -25,11 +25,11 @@ static void formatKey(const FFLocalIpOptions* options, FFLocalIpResult* ip, uint else { 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_STRBUF, &ip->name}, {FF_FORMAT_ARG_TYPE_STRBUF, &ip->mac}, - }); + })); } } @@ -110,13 +110,13 @@ void ffPrintLocalIp(FFLocalIpOptions* options) } 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->ipv6}, {FF_FORMAT_ARG_TYPE_STRBUF, &ip->mac}, {FF_FORMAT_ARG_TYPE_STRBUF, &ip->name}, {FF_FORMAT_ARG_TYPE_BOOL, &ip->defaultRoute}, - }); + })); } ++index; } @@ -345,13 +345,13 @@ exit: 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 IPv6 address", "Physical (MAC) address", "Interface name", "Is default route" - }); + })); } void ffInitLocalIpOptions(FFLocalIpOptions* options) diff --git a/src/modules/media/media.c b/src/modules/media/media.c index d816d44f2..6dd55957a 100644 --- a/src/modules/media/media.c +++ b/src/modules/media/media.c @@ -95,13 +95,13 @@ void ffPrintMedia(FFMediaOptions* options) } 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, &media->song}, {FF_FORMAT_ARG_TYPE_STRBUF, &media->artist}, {FF_FORMAT_ARG_TYPE_STRBUF, &media->album}, {FF_FORMAT_ARG_TYPE_STRBUF, &media->status} - }); + })); } } @@ -159,13 +159,13 @@ void ffGenerateMediaJsonResult(FF_MAYBE_UNUSED FFMediaOptions* options, yyjson_m 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", "Media name", "Artist name", "Album name", "Status", - }); + })); } void ffInitMediaOptions(FFMediaOptions* options) diff --git a/src/modules/memory/memory.c b/src/modules/memory/memory.c index e7bd5c105..29493fd87 100644 --- a/src/modules/memory/memory.c +++ b/src/modules/memory/memory.c @@ -58,11 +58,11 @@ void ffPrintMemory(FFMemoryOptions* options) { FF_STRBUF_AUTO_DESTROY percentageStr = ffStrbufCreate(); 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, &totalPretty}, {FF_FORMAT_ARG_TYPE_STRBUF, &percentageStr}, - }); + })); } } @@ -127,11 +127,11 @@ void ffGenerateMemoryJsonResult(FF_MAYBE_UNUSED FFMemoryOptions* options, yyjson 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", "Total size", - "Percentage used" - }); + "Percentage used", + })); } void ffInitMemoryOptions(FFMemoryOptions* options) diff --git a/src/modules/monitor/monitor.c b/src/modules/monitor/monitor.c index 776d4fd18..90abf8476 100644 --- a/src/modules/monitor/monitor.c +++ b/src/modules/monitor/monitor.c @@ -6,7 +6,7 @@ #include -#define FF_MONITOR_NUM_FORMAT_ARGS 7 +#define FF_MONITOR_NUM_FORMAT_ARGS 10 void ffPrintMonitor(FFMonitorOptions* options) { @@ -41,10 +41,10 @@ void ffPrintMonitor(FFMonitorOptions* options) else { 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_STRBUF, &display->name}, - }); + })); } if(options->moduleArgs.outputFormat.length == 0) @@ -68,7 +68,7 @@ void ffPrintMonitor(FFMonitorOptions* options) else 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_UINT, &display->width}, {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->manufactureWeek}, {FF_FORMAT_ARG_TYPE_STRING, buf}, - }); + })); } ffStrbufDestroy(&display->name); @@ -179,17 +179,18 @@ void ffGenerateMonitorJsonResult(FF_MAYBE_UNUSED FFMonitorOptions* options, yyjs 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 native resolution width in pixels", - "Display native resolution height in pixels", - "Display physical width in millimeters", - "Display physical height in millimeters", - "Display physical diagonal length in inches", + "Native resolution width in pixels", + "Native resolution height in pixels", + "Physical width in millimeters", + "Physical height in millimeters", + "Physical diagonal length in inches", + "Pixels per inch (PPI)", "Year of manufacturing", "Nth week of manufacturing in the year", "Serial number", - }); + })); } void ffInitMonitorOptions(FFMonitorOptions* options) diff --git a/src/modules/netio/netio.c b/src/modules/netio/netio.c index ffee3e23d..64b53c431 100644 --- a/src/modules/netio/netio.c +++ b/src/modules/netio/netio.c @@ -25,10 +25,10 @@ static void formatKey(const FFNetIOOptions* options, FFNetIOResult* inf, uint32_ else { 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_STRBUF, &inf->name}, - }); + })); } } @@ -79,7 +79,7 @@ void ffPrintNetIO(FFNetIOOptions* options) ffParseSize(inf->txBytes, &buffer2); 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, &buffer2}, {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->rxDrops}, {FF_FORMAT_ARG_TYPE_UINT64, &inf->txDrops}, - }); + })); } ++index; } @@ -218,7 +218,7 @@ void ffGenerateNetIOJsonResult(FFNetIOOptions* options, yyjson_mut_doc* doc, yyj 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 sent [per second] (formatted)", "Interface name", @@ -231,7 +231,7 @@ void ffPrintNetIOHelpFormat(void) "Number of errors sent [per second]", "Number of packets dropped when receiving [per second]", "Number of packets dropped when sending [per second]", - }); + })); } void ffInitNetIOOptions(FFNetIOOptions* options) diff --git a/src/modules/opencl/opencl.c b/src/modules/opencl/opencl.c index f5c563129..610f132eb 100644 --- a/src/modules/opencl/opencl.c +++ b/src/modules/opencl/opencl.c @@ -26,11 +26,11 @@ void ffPrintOpenCL(FFOpenCLOptions* options) } 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.device}, {FF_FORMAT_ARG_TYPE_STRBUF, &opencl.vendor}, - }); + })); } } @@ -102,11 +102,11 @@ void ffGenerateOpenCLJsonResult(FF_MAYBE_UNUSED FFOpenCLOptions* options, yyjson 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", "device", "vendor" - }); + })); } void ffInitOpenCLOptions(FFOpenCLOptions* options) diff --git a/src/modules/opengl/opengl.c b/src/modules/opengl/opengl.c index 2925a42e4..d74789523 100644 --- a/src/modules/opengl/opengl.c +++ b/src/modules/opengl/opengl.c @@ -28,12 +28,12 @@ void ffPrintOpenGL(FFOpenGLOptions* options) } 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.renderer}, {FF_FORMAT_ARG_TYPE_STRBUF, &result.vendor}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result.slv} - }); + {FF_FORMAT_ARG_TYPE_STRBUF, &result.slv}, + })); } ffStrbufDestroy(&result.version); @@ -160,12 +160,12 @@ void ffGenerateOpenGLJsonResult(FF_MAYBE_UNUSED FFOpenGLOptions* options, yyjson 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", "renderer", "vendor", "shading language version" - }); + })); } void ffInitOpenGLOptions(FFOpenGLOptions* options) diff --git a/src/modules/os/os.c b/src/modules/os/os.c index c7dad4b38..a48527b5f 100644 --- a/src/modules/os/os.c +++ b/src/modules/os/os.c @@ -119,7 +119,7 @@ void ffPrintOS(FFOSOptions* options) } 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, &os->name}, {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->buildID}, {FF_FORMAT_ARG_TYPE_STRBUF, &instance.state.platform.systemArchitecture} - }); + })); } } @@ -196,7 +196,7 @@ void ffGenerateOSJsonResult(FF_MAYBE_UNUSED FFOSOptions* options, yyjson_mut_doc 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 OS", "Pretty name of the OS", @@ -209,7 +209,7 @@ void ffPrintOSHelpFormat(void) "Version codename of the OS", "Build ID of the OS", "Architecture of the OS" - }); + })); } void ffInitOSOptions(FFOSOptions* options) diff --git a/src/modules/packages/packages.c b/src/modules/packages/packages.c index 2b17c0804..7f10f44e2 100644 --- a/src/modules/packages/packages.c +++ b/src/modules/packages/packages.c @@ -69,7 +69,7 @@ void ffPrintPackages(FFPackagesOptions* options) } 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.pacman}, {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.winget}, {FF_FORMAT_ARG_TYPE_UINT, &counts.opkg}, - }); + })); } ffStrbufDestroy(&counts.pacmanBranch); @@ -300,7 +300,7 @@ void ffGeneratePackagesJsonResult(FF_MAYBE_UNUSED FFPackagesOptions* options, yy 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 pacman packages", "Pacman branch on manjaro", @@ -326,7 +326,7 @@ void ffPrintPackagesHelpFormat(void) "Number of paludis packages", "Number of winget packages", "Number of opkg packages" - }); + })); } void ffInitPackagesOptions(FFPackagesOptions* options) diff --git a/src/modules/physicaldisk/physicaldisk.c b/src/modules/physicaldisk/physicaldisk.c index 96d0c2c12..5d953b160 100644 --- a/src/modules/physicaldisk/physicaldisk.c +++ b/src/modules/physicaldisk/physicaldisk.c @@ -7,7 +7,7 @@ #include "util/stringUtils.h" #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) { @@ -23,11 +23,11 @@ static void formatKey(const FFPhysicalDiskOptions* options, FFPhysicalDiskResult else { 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_STRBUF, &dev->name}, {FF_FORMAT_ARG_TYPE_STRBUF, &dev->devPath}, - }); + })); } } @@ -108,7 +108,7 @@ void ffPrintPhysicalDisk(FFPhysicalDiskOptions* options) if (dev->type & FF_PHYSICALDISK_TYPE_READWRITE) readOnlyType = "Read-write"; 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, &dev->name}, {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_STRBUF, &dev->revision}, {FF_FORMAT_ARG_TYPE_DOUBLE, &tempStr}, - }); + })); } ++index; } @@ -252,7 +252,7 @@ void ffGeneratePhysicalDiskJsonResult(FFPhysicalDiskOptions* options, yyjson_mut 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 name", "Device interconnect type", @@ -263,7 +263,7 @@ void ffPrintPhysicalDiskHelpFormat(void) "Device kind (Read-only or Read-write)", "Product revision", "Device temperature (formatted)", - }); + })); } void ffInitPhysicalDiskOptions(FFPhysicalDiskOptions* options) diff --git a/src/modules/player/player.c b/src/modules/player/player.c index 8eae59705..8332a6d98 100644 --- a/src/modules/player/player.c +++ b/src/modules/player/player.c @@ -64,12 +64,12 @@ void ffPrintPlayer(FFPlayerOptions* options) } 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, &media->player}, {FF_FORMAT_ARG_TYPE_STRBUF, &media->playerId}, {FF_FORMAT_ARG_TYPE_STRBUF, &media->url} - }); + })); } } @@ -126,12 +126,12 @@ void ffGeneratePlayerJsonResult(FF_MAYBE_UNUSED FFMediaOptions* options, yyjson_ 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", "Player name", "Player Identifier", "URL name" - }); + })); } void ffInitPlayerOptions(FFPlayerOptions* options) diff --git a/src/modules/poweradapter/poweradapter.c b/src/modules/poweradapter/poweradapter.c index 5bc8a0556..8eee157f7 100644 --- a/src/modules/poweradapter/poweradapter.c +++ b/src/modules/poweradapter/poweradapter.c @@ -38,14 +38,14 @@ void ffPrintPowerAdapter(FFPowerAdapterOptions* options) } 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_STRBUF, &result->name}, {FF_FORMAT_ARG_TYPE_STRBUF, &result->manufacturer}, {FF_FORMAT_ARG_TYPE_STRBUF, &result->modelName}, {FF_FORMAT_ARG_TYPE_STRBUF, &result->description}, {FF_FORMAT_ARG_TYPE_STRBUF, &result->serial}, - }); + })); } ffStrbufDestroy(&result->manufacturer); @@ -124,14 +124,14 @@ void ffGeneratePowerAdapterJsonResult(FF_MAYBE_UNUSED FFPowerAdapterOptions* opt 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 name", "PowerAdapter manufacturer", "PowerAdapter model", - "PowerAdapter description" - "PowerAdapter serial number" - }); + "PowerAdapter description", + "PowerAdapter serial number", + })); } void ffInitPowerAdapterOptions(FFPowerAdapterOptions* options) diff --git a/src/modules/processes/processes.c b/src/modules/processes/processes.c index d255c0863..5335bfd03 100644 --- a/src/modules/processes/processes.c +++ b/src/modules/processes/processes.c @@ -25,9 +25,9 @@ void ffPrintProcesses(FFProcessesOptions* options) } 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} - }); + })); } } @@ -82,7 +82,7 @@ void ffGenerateProcessesJsonResult(FF_MAYBE_UNUSED FFProcessesOptions* options, 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" }); } diff --git a/src/modules/publicip/publicip.c b/src/modules/publicip/publicip.c index da7c4fc9a..46d4d7f0e 100644 --- a/src/modules/publicip/publicip.c +++ b/src/modules/publicip/publicip.c @@ -5,7 +5,7 @@ #include "util/stringUtils.h" #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) { @@ -30,10 +30,10 @@ void ffPrintPublicIp(FFPublicIpOptions* options) } 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.location}, - }); + })); } ffStrbufDestroy(&result.ip); @@ -125,10 +125,10 @@ void ffGeneratePublicIpJsonResult(FFPublicIpOptions* options, yyjson_mut_doc* do 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", "Location" - }); + })); } void ffInitPublicIpOptions(FFPublicIpOptions* options) diff --git a/src/modules/shell/shell.c b/src/modules/shell/shell.c index c3e4fcc1a..92275497e 100644 --- a/src/modules/shell/shell.c +++ b/src/modules/shell/shell.c @@ -4,7 +4,7 @@ #include "modules/shell/shell.h" #include "util/stringUtils.h" -#define FF_SHELL_NUM_FORMAT_ARGS 6 +#define FF_SHELL_NUM_FORMAT_ARGS 8 void ffPrintShell(FFShellOptions* options) { @@ -31,7 +31,7 @@ void ffPrintShell(FFShellOptions* options) } 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->exe}, {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->exePath}, {FF_FORMAT_ARG_TYPE_INT, &result->tty}, - }); + })); } } @@ -106,7 +106,7 @@ void ffGenerateShellJsonResult(FF_MAYBE_UNUSED FFShellOptions* options, yyjson_m 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", "The first argument of the command line when running the shell", "Shell base name of arg0", @@ -114,7 +114,8 @@ void ffPrintShellHelpFormat(void) "Shell pid", "Shell pretty name", "Shell full exe path", - }); + "Shell tty used", + })); } void ffInitShellOptions(FFShellOptions* options) diff --git a/src/modules/sound/sound.c b/src/modules/sound/sound.c index 31a9d32ea..ebecca1a5 100644 --- a/src/modules/sound/sound.c +++ b/src/modules/sound/sound.c @@ -49,12 +49,12 @@ static void printDevice(FFSoundOptions* options, const FFSoundDevice* device, ui FF_STRBUF_AUTO_DESTROY percentageStr = ffStrbufCreate(); 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_STRBUF, &device->name}, {FF_FORMAT_ARG_TYPE_STRBUF, &percentageStr}, {FF_FORMAT_ARG_TYPE_STRBUF, &device->identifier} - }); + })); } } @@ -231,12 +231,12 @@ void ffGenerateSoundJsonResult(FF_MAYBE_UNUSED FFSoundOptions* options, yyjson_m 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", "Device name", "Volume", "Identifier" - }); + })); } void ffInitSoundOptions(FFSoundOptions* options) diff --git a/src/modules/swap/swap.c b/src/modules/swap/swap.c index cb4cad7f2..12fd78627 100644 --- a/src/modules/swap/swap.c +++ b/src/modules/swap/swap.c @@ -67,11 +67,11 @@ void ffPrintSwap(FFSwapOptions* options) { FF_STRBUF_AUTO_DESTROY percentageStr = ffStrbufCreate(); 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, &totalPretty}, {FF_FORMAT_ARG_TYPE_STRBUF, &percentageStr}, - }); + })); } } @@ -136,11 +136,11 @@ void ffGenerateSwapJsonResult(FF_MAYBE_UNUSED FFSwapOptions* options, yyjson_mut 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", "Total size", "Percentage used" - }); + })); } void ffInitSwapOptions(FFSwapOptions* options) diff --git a/src/modules/terminal/terminal.c b/src/modules/terminal/terminal.c index d73d0c1d3..e12fafae5 100644 --- a/src/modules/terminal/terminal.c +++ b/src/modules/terminal/terminal.c @@ -29,7 +29,7 @@ void ffPrintTerminal(FFTerminalOptions* options) } 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->exe}, {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->exePath}, {FF_FORMAT_ARG_TYPE_STRBUF, &result->tty}, - }); + })); } } @@ -101,7 +101,7 @@ void ffGenerateTerminalJsonResult(FF_MAYBE_UNUSED FFTerminalOptions* options, yy 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", "The first argument of the command line when running the terminal", "Terminal base name of arg0", @@ -110,7 +110,7 @@ void ffPrintTerminalHelpFormat(void) "Terminal version", "Terminal full exe path", "Terminal tty / pts used", - }); + })); } void ffInitTerminalOptions(FFTerminalOptions* options) diff --git a/src/modules/terminalfont/terminalfont.c b/src/modules/terminalfont/terminalfont.c index 191df08f4..3e7396895 100644 --- a/src/modules/terminalfont/terminalfont.c +++ b/src/modules/terminalfont/terminalfont.c @@ -33,12 +33,12 @@ void ffPrintTerminalFont(FFTerminalFontOptions* options) } 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.name}, {FF_FORMAT_ARG_TYPE_STRBUF, &terminalFont.font.size}, {FF_FORMAT_ARG_TYPE_LIST, &terminalFont.font.styles} - }); + })); } } @@ -123,12 +123,12 @@ void ffGenerateTerminalFontJsonResult(FF_MAYBE_UNUSED FFTerminalOptions* options 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 name", "Terminal font size", "Terminal font styles" - }); + })); } void ffInitTerminalFontOptions(FFTerminalFontOptions* options) diff --git a/src/modules/terminalsize/terminalsize.c b/src/modules/terminalsize/terminalsize.c index bc2bfa9ca..aafe76e3a 100644 --- a/src/modules/terminalsize/terminalsize.c +++ b/src/modules/terminalsize/terminalsize.c @@ -29,12 +29,12 @@ void ffPrintTerminalSize(FFTerminalSizeOptions* options) } 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.columns}, {FF_FORMAT_ARG_TYPE_UINT16, &result.width}, {FF_FORMAT_ARG_TYPE_UINT16, &result.height} - }); + })); } } } @@ -93,12 +93,12 @@ void ffGenerateTerminalSizeJsonResult(FF_MAYBE_UNUSED FFTerminalOptions* options 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 columns", "Terminal width (in pixels)", "Terminal height (in pixels)" - }); + })); } void ffInitTerminalSizeOptions(FFTerminalSizeOptions* options) diff --git a/src/modules/terminaltheme/terminaltheme.c b/src/modules/terminaltheme/terminaltheme.c index 43e76c65c..1ece77626 100644 --- a/src/modules/terminaltheme/terminaltheme.c +++ b/src/modules/terminaltheme/terminaltheme.c @@ -32,12 +32,12 @@ void ffPrintTerminalTheme(FFTerminalThemeOptions* options) 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(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, result.fg.dark ? "Dark" : "Light"}, {FF_FORMAT_ARG_TYPE_STRING, bg}, {FF_FORMAT_ARG_TYPE_STRING, result.bg.dark ? "Dark" : "Light"}, - }); + })); } } } @@ -104,12 +104,12 @@ void ffGenerateTerminalThemeJsonResult(FF_MAYBE_UNUSED FFTerminalOptions* option 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 type (Dark / Light)", "Terminal background color", "Terminal background type (Dark / Light)", - }); + })); } void ffInitTerminalThemeOptions(FFTerminalThemeOptions* options) diff --git a/src/modules/theme/theme.c b/src/modules/theme/theme.c index 1380283bf..c64b99654 100644 --- a/src/modules/theme/theme.c +++ b/src/modules/theme/theme.c @@ -24,9 +24,9 @@ void ffPrintTheme(FFThemeOptions* options) } 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} - }); + })); } } @@ -81,9 +81,9 @@ void ffGenerateThemeJsonResult(FF_MAYBE_UNUSED FFThemeOptions* options, yyjson_m 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" - }); + })); } void ffInitThemeOptions(FFThemeOptions* options) diff --git a/src/modules/title/title.c b/src/modules/title/title.c index 073bed344..22b5ee01d 100644 --- a/src/modules/title/title.c +++ b/src/modules/title/title.c @@ -56,7 +56,7 @@ void ffPrintTitle(FFTitleOptions* options) } 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, &hostName}, {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, &atColored}, {FF_FORMAT_ARG_TYPE_STRBUF, &hostNameColored}, - }); + })); } } @@ -181,7 +181,7 @@ void ffGenerateTitleJsonResult(FF_MAYBE_UNUSED FFTitleOptions* options, yyjson_m 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", "Host name", "Home directory", @@ -190,7 +190,7 @@ void ffPrintTitleHelpFormat(void) "User name (colored)", "@ symbol (colored)", "Host name (colored)" - }); + })); } void ffInitTitleOptions(FFTitleOptions* options) diff --git a/src/modules/uptime/uptime.c b/src/modules/uptime/uptime.c index 02d9a9ae5..7ae2fabf5 100644 --- a/src/modules/uptime/uptime.c +++ b/src/modules/uptime/uptime.c @@ -77,7 +77,7 @@ void ffPrintUptime(FFUptimeOptions* options) } 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, &hours}, {FF_FORMAT_ARG_TYPE_UINT, &minutes}, @@ -85,7 +85,7 @@ void ffPrintUptime(FFUptimeOptions* options) {FF_FORMAT_ARG_TYPE_UINT, &milliseconds}, {FF_FORMAT_ARG_TYPE_UINT64, &result.uptime}, {FF_FORMAT_ARG_TYPE_UINT64, &result.bootTime}, - }); + })); } } @@ -142,12 +142,15 @@ void ffGenerateUptimeJsonResult(FF_MAYBE_UNUSED FFUptimeOptions* options, yyjson 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", "Hours", "Minutes", - "Seconds" - }); + "Seconds", + "Milliseconds", + "Uptime in unix timestamp (ms)", + "Boot time in unix timestamp (ms)", + })); } void ffInitUptimeOptions(FFUptimeOptions* options) diff --git a/src/modules/users/users.c b/src/modules/users/users.c index 0f7a2b189..304d644df 100644 --- a/src/modules/users/users.c +++ b/src/modules/users/users.c @@ -8,7 +8,7 @@ #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) { @@ -74,13 +74,13 @@ void ffPrintUsers(FFUsersOptions* options) { 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->hostName}, {FF_FORMAT_ARG_TYPE_STRBUF, &user->sessionName}, {FF_FORMAT_ARG_TYPE_STRBUF, &user->clientIp}, {FF_FORMAT_ARG_TYPE_UINT64, &user->loginTime}, - }); + })); } } @@ -178,13 +178,13 @@ exit: 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", "Host name", "Session name", "Client IP", "Login Time" - }); + })); } void ffInitUsersOptions(FFUsersOptions* options) diff --git a/src/modules/version/version.c b/src/modules/version/version.c index 6d27d94cf..da0582d91 100644 --- a/src/modules/version/version.c +++ b/src/modules/version/version.c @@ -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.version}, {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.compiler}, {FF_FORMAT_ARG_TYPE_STRBUF, &buf}, - }); + })); } } @@ -114,7 +114,7 @@ void ffGenerateVersionJsonResult(FF_MAYBE_UNUSED FFVersionOptions* options, yyjs 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", "Version", "Version tweak", @@ -124,7 +124,7 @@ void ffPrintVersionHelpFormat(void) "Date time when compiling", "Compiler used", "Libc used" - }); + })); } void ffInitVersionOptions(FFVersionOptions* options) diff --git a/src/modules/vulkan/vulkan.c b/src/modules/vulkan/vulkan.c index 24b5497da..48d96c844 100644 --- a/src/modules/vulkan/vulkan.c +++ b/src/modules/vulkan/vulkan.c @@ -5,7 +5,7 @@ #include "modules/vulkan/vulkan.h" #include "util/stringUtils.h" -#define FF_VULKAN_NUM_FORMAT_ARGS 3 +#define FF_VULKAN_NUM_FORMAT_ARGS 4 void ffPrintVulkan(FFVulkanOptions* options) { @@ -43,11 +43,12 @@ void ffPrintVulkan(FFVulkanOptions* options) } 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->apiVersion}, - {FF_FORMAT_ARG_TYPE_STRBUF, &vulkan->conformanceVersion} - }); + {FF_FORMAT_ARG_TYPE_STRBUF, &vulkan->conformanceVersion}, + {FF_FORMAT_ARG_TYPE_STRBUF, &vulkan->instanceVersion}, + })); } } @@ -144,12 +145,12 @@ void ffGenerateVulkanJsonResult(FF_MAYBE_UNUSED FFVulkanOptions* options, yyjson 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", "API version", "Conformance version", "Instance version", - }); + })); } void ffInitVulkanOptions(FFVulkanOptions* options) diff --git a/src/modules/wallpaper/wallpaper.c b/src/modules/wallpaper/wallpaper.c index 6559929fb..cb1339597 100644 --- a/src/modules/wallpaper/wallpaper.c +++ b/src/modules/wallpaper/wallpaper.c @@ -35,10 +35,10 @@ void ffPrintWallpaper(FFWallpaperOptions* options) } 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_STRBUF, &fullpath}, - }); + })); } } @@ -91,9 +91,10 @@ void ffGenerateWallpaperJsonResult(FF_MAYBE_UNUSED FFWallpaperOptions* options, void ffPrintWallpaperHelpFormat(void) { - ffPrintModuleFormatHelp(FF_WALLPAPER_MODULE_NAME, "{1}", FF_WALLPAPER_NUM_FORMAT_ARGS, (const char* []) { - "Wallpaper image file" - }); + FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_WALLPAPER_MODULE_NAME, "{1}", FF_WALLPAPER_NUM_FORMAT_ARGS, ((const char* []) { + "File name", + "Full path", + })); } void ffInitWallpaperOptions(FFWallpaperOptions* options) diff --git a/src/modules/weather/weather.c b/src/modules/weather/weather.c index 3bb8d5e02..0bc3016ab 100644 --- a/src/modules/weather/weather.c +++ b/src/modules/weather/weather.c @@ -25,9 +25,9 @@ void ffPrintWeather(FFWeatherOptions* options) } 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} - }); + })); } } @@ -127,9 +127,9 @@ void ffGenerateWeatherJsonResult(FFWeatherOptions* options, yyjson_mut_doc* doc, 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" - }); + })); } void ffInitWeatherOptions(FFWeatherOptions* options) diff --git a/src/modules/wifi/wifi.c b/src/modules/wifi/wifi.c index 0f4a58ae5..bea1054ad 100644 --- a/src/modules/wifi/wifi.c +++ b/src/modules/wifi/wifi.c @@ -46,7 +46,7 @@ void ffPrintWifi(FFWifiOptions* options) } 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.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.txRate}, {FF_FORMAT_ARG_TYPE_STRBUF, &item->conn.security}, - }); + })); } ffStrbufDestroy(&item->inf.description); @@ -154,7 +154,7 @@ void ffGenerateWifiJsonResult(FF_MAYBE_UNUSED FFWifiOptions* options, yyjson_mut 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 status", "Connection status", @@ -165,7 +165,7 @@ void ffPrintWifiHelpFormat(void) "Connection RX rate", "Connection TX rate", "Connection Security algorithm" - }); + })); } void ffInitWifiOptions(FFWifiOptions* options) diff --git a/src/modules/wm/wm.c b/src/modules/wm/wm.c index b8cdd04c3..ad2a14c82 100644 --- a/src/modules/wm/wm.c +++ b/src/modules/wm/wm.c @@ -45,12 +45,12 @@ void ffPrintWM(FFWMOptions* options) } 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->wmPrettyName}, {FF_FORMAT_ARG_TYPE_STRBUF, &result->wmProtocolName}, {FF_FORMAT_ARG_TYPE_STRBUF, &pluginName}, - }); + })); } } @@ -127,12 +127,12 @@ void ffGenerateWMJsonResult(FF_MAYBE_UNUSED FFWMOptions* options, yyjson_mut_doc 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 pretty name", "WM protocol name", "WM plugin name" - }); + })); } void ffInitWMOptions(FFWMOptions* options) diff --git a/src/modules/wmtheme/wmtheme.c b/src/modules/wmtheme/wmtheme.c index a7ca585ce..11f68e584 100644 --- a/src/modules/wmtheme/wmtheme.c +++ b/src/modules/wmtheme/wmtheme.c @@ -19,9 +19,9 @@ void ffPrintWMTheme(FFWMThemeOptions* options) } 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} - }); + })); } } else @@ -79,9 +79,9 @@ void ffGenerateWMThemeJsonResult(FF_MAYBE_UNUSED FFWMThemeOptions* options, yyjs 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" - }); + })); } void ffInitWMThemeOptions(FFWMThemeOptions* options)