mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-30 00:37:23 +01:00
Global: make FFinstance instance a global variable
As discussed in https://github.com/fastfetch-cli/fastfetch/discussions/473
This commit is contained in:
@@ -7,14 +7,14 @@
|
||||
|
||||
#define FF_BATTERY_NUM_FORMAT_ARGS 5
|
||||
|
||||
static void printBattery(FFinstance* instance, FFBatteryOptions* options, BatteryResult* result, uint8_t index)
|
||||
static void printBattery(FFBatteryOptions* options, BatteryResult* result, uint8_t index)
|
||||
{
|
||||
if(instance->config.battery.moduleArgs.outputFormat.length == 0)
|
||||
if(instance.config.battery.moduleArgs.outputFormat.length == 0)
|
||||
{
|
||||
ffPrintLogoAndKey(instance, FF_BATTERY_MODULE_NAME, index, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
ffPrintLogoAndKey(FF_BATTERY_MODULE_NAME, index, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
|
||||
bool showStatus =
|
||||
!(instance->config.percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT) &&
|
||||
!(instance.config.percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT) &&
|
||||
result->status.length > 0 &&
|
||||
ffStrbufIgnCaseCompS(&result->status, "Unknown") != 0;
|
||||
|
||||
@@ -22,22 +22,22 @@ static void printBattery(FFinstance* instance, FFBatteryOptions* options, Batter
|
||||
|
||||
if(result->capacity >= 0)
|
||||
{
|
||||
if(instance->config.percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
|
||||
if(instance.config.percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
|
||||
{
|
||||
if(result->capacity <= 20)
|
||||
ffAppendPercentBar(instance, &str, (uint8_t)result->capacity, 10, 10, 0);
|
||||
ffAppendPercentBar(&str, (uint8_t)result->capacity, 10, 10, 0);
|
||||
else if(result->capacity <= 50)
|
||||
ffAppendPercentBar(instance, &str, (uint8_t)result->capacity, 10, 0, 10);
|
||||
ffAppendPercentBar(&str, (uint8_t)result->capacity, 10, 0, 10);
|
||||
else
|
||||
ffAppendPercentBar(instance, &str, (uint8_t)result->capacity, 0, 10, 10);
|
||||
ffAppendPercentBar(&str, (uint8_t)result->capacity, 0, 10, 10);
|
||||
}
|
||||
|
||||
if(instance->config.percentType & FF_PERCENTAGE_TYPE_NUM_BIT)
|
||||
if(instance.config.percentType & FF_PERCENTAGE_TYPE_NUM_BIT)
|
||||
{
|
||||
if(str.length > 0)
|
||||
ffStrbufAppendC(&str, ' ');
|
||||
|
||||
ffAppendPercentNum(instance, &str, (uint8_t) result->capacity, 51, 21, str.length > 0);
|
||||
ffAppendPercentNum(&str, (uint8_t) result->capacity, 51, 21, str.length > 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ static void printBattery(FFinstance* instance, FFBatteryOptions* options, Batter
|
||||
}
|
||||
else
|
||||
{
|
||||
ffPrintFormat(instance, FF_BATTERY_MODULE_NAME, index, &options->moduleArgs, FF_BATTERY_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||
ffPrintFormat(FF_BATTERY_MODULE_NAME, index, &options->moduleArgs, 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},
|
||||
@@ -72,23 +72,23 @@ static void printBattery(FFinstance* instance, FFBatteryOptions* options, Batter
|
||||
}
|
||||
}
|
||||
|
||||
void ffPrintBattery(FFinstance* instance, FFBatteryOptions* options)
|
||||
void ffPrintBattery(FFBatteryOptions* options)
|
||||
{
|
||||
FFlist results;
|
||||
ffListInitA(&results, sizeof(BatteryResult), 0);
|
||||
|
||||
const char* error = ffDetectBattery(instance, options, &results);
|
||||
const char* error = ffDetectBattery(options, &results);
|
||||
|
||||
if (error)
|
||||
{
|
||||
ffPrintError(instance, FF_BATTERY_MODULE_NAME, 0, &options->moduleArgs, "%s", error);
|
||||
ffPrintError(FF_BATTERY_MODULE_NAME, 0, &options->moduleArgs, "%s", error);
|
||||
}
|
||||
else
|
||||
{
|
||||
for(uint8_t i = 0; i < (uint8_t) results.length; i++)
|
||||
{
|
||||
BatteryResult* result = ffListGet(&results, i);
|
||||
printBattery(instance, options, result, i);
|
||||
printBattery(options, result, i);
|
||||
|
||||
ffStrbufDestroy(&result->manufacturer);
|
||||
ffStrbufDestroy(&result->modelName);
|
||||
@@ -96,7 +96,7 @@ void ffPrintBattery(FFinstance* instance, FFBatteryOptions* options)
|
||||
ffStrbufDestroy(&result->status);
|
||||
}
|
||||
if(results.length == 0)
|
||||
ffPrintError(instance, FF_BATTERY_MODULE_NAME, 0, &options->moduleArgs, "No batteries found");
|
||||
ffPrintError(FF_BATTERY_MODULE_NAME, 0, &options->moduleArgs, "No batteries found");
|
||||
}
|
||||
|
||||
ffListDestroy(&results);
|
||||
@@ -146,7 +146,7 @@ void ffDestroyBatteryOptions(FFBatteryOptions* options)
|
||||
#endif
|
||||
}
|
||||
|
||||
void ffParseBatteryJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
void ffParseBatteryJsonObject(yyjson_val* module)
|
||||
{
|
||||
FFBatteryOptions __attribute__((__cleanup__(ffDestroyBatteryOptions))) options;
|
||||
ffInitBatteryOptions(&options);
|
||||
@@ -178,9 +178,9 @@ void ffParseBatteryJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
continue;
|
||||
}
|
||||
|
||||
ffPrintError(instance, FF_BATTERY_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
ffPrintError(FF_BATTERY_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
}
|
||||
}
|
||||
|
||||
ffPrintBattery(instance, &options);
|
||||
ffPrintBattery(&options);
|
||||
}
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
|
||||
#define FF_BATTERY_MODULE_NAME "Battery"
|
||||
|
||||
void ffPrintBattery(FFinstance* instance, FFBatteryOptions* options);
|
||||
void ffPrintBattery(FFBatteryOptions* options);
|
||||
|
||||
void ffInitBatteryOptions(FFBatteryOptions* options);
|
||||
bool ffParseBatteryCommandOptions(FFBatteryOptions* options, const char* key, const char* value);
|
||||
void ffDestroyBatteryOptions(FFBatteryOptions* options);
|
||||
void ffParseBatteryJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
void ffParseBatteryJsonObject(yyjson_val* module);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#define FF_BIOS_NUM_FORMAT_ARGS 4
|
||||
|
||||
void ffPrintBios(FFinstance* instance, FFBiosOptions* options)
|
||||
void ffPrintBios(FFBiosOptions* options)
|
||||
{
|
||||
FFBiosResult bios;
|
||||
ffStrbufInit(&bios.date);
|
||||
@@ -18,19 +18,19 @@ void ffPrintBios(FFinstance* instance, FFBiosOptions* options)
|
||||
|
||||
if(error)
|
||||
{
|
||||
ffPrintError(instance, FF_BIOS_MODULE_NAME, 0, &options->moduleArgs, "%s", error);
|
||||
ffPrintError(FF_BIOS_MODULE_NAME, 0, &options->moduleArgs, "%s", error);
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if(bios.version.length == 0)
|
||||
{
|
||||
ffPrintError(instance, FF_BIOS_MODULE_NAME, 0, &options->moduleArgs, "bios_version is not set.");
|
||||
ffPrintError(FF_BIOS_MODULE_NAME, 0, &options->moduleArgs, "bios_version is not set.");
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
{
|
||||
ffPrintLogoAndKey(instance, FF_BIOS_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
ffPrintLogoAndKey(FF_BIOS_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
ffStrbufWriteTo(&bios.version, stdout);
|
||||
if (bios.biosRelease.length)
|
||||
printf(" (%s)", bios.biosRelease.chars);
|
||||
@@ -38,7 +38,7 @@ void ffPrintBios(FFinstance* instance, FFBiosOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
ffPrintFormat(instance, FF_BIOS_MODULE_NAME, 0, &options->moduleArgs, FF_BIOS_NUM_FORMAT_ARGS, (FFformatarg[]) {
|
||||
ffPrintFormat(FF_BIOS_MODULE_NAME, 0, &options->moduleArgs, FF_BIOS_NUM_FORMAT_ARGS, (FFformatarg[]) {
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &bios.date},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &bios.biosRelease},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &bios.vendor},
|
||||
@@ -74,7 +74,7 @@ void ffDestroyBiosOptions(FFBiosOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
void ffParseBiosJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
void ffParseBiosJsonObject(yyjson_val* module)
|
||||
{
|
||||
FFBiosOptions __attribute__((__cleanup__(ffDestroyBiosOptions))) options;
|
||||
ffInitBiosOptions(&options);
|
||||
@@ -92,9 +92,9 @@ void ffParseBiosJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs))
|
||||
continue;
|
||||
|
||||
ffPrintError(instance, FF_BIOS_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
ffPrintError(FF_BIOS_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
}
|
||||
}
|
||||
|
||||
ffPrintBios(instance, &options);
|
||||
ffPrintBios(&options);
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
#define FF_BIOS_MODULE_NAME "Bios"
|
||||
|
||||
void ffPrintBios(FFinstance* instance, FFBiosOptions* options);
|
||||
void ffPrintBios(FFBiosOptions* options);
|
||||
void ffInitBiosOptions(FFBiosOptions* options);
|
||||
bool ffParseBiosCommandOptions(FFBiosOptions* options, const char* key, const char* value);
|
||||
void ffDestroyBiosOptions(FFBiosOptions* options);
|
||||
void ffParseBiosJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
void ffParseBiosJsonObject(yyjson_val* module);
|
||||
|
||||
@@ -6,11 +6,11 @@
|
||||
|
||||
#define FF_BLUETOOTH_NUM_FORMAT_ARGS 4
|
||||
|
||||
static void printDevice(FFinstance* instance, FFBluetoothOptions* options, const FFBluetoothDevice* device, uint8_t index)
|
||||
static void printDevice(FFBluetoothOptions* options, const FFBluetoothDevice* device, uint8_t index)
|
||||
{
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
{
|
||||
ffPrintLogoAndKey(instance, FF_BLUETOOTH_MODULE_NAME, index, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
ffPrintLogoAndKey(FF_BLUETOOTH_MODULE_NAME, index, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
ffStrbufWriteTo(&device->name, stdout);
|
||||
|
||||
if(device->battery > 0)
|
||||
@@ -20,7 +20,7 @@ static void printDevice(FFinstance* instance, FFBluetoothOptions* options, const
|
||||
}
|
||||
else
|
||||
{
|
||||
ffPrintFormat(instance, FF_BLUETOOTH_MODULE_NAME, index, &options->moduleArgs, FF_BLUETOOTH_NUM_FORMAT_ARGS, (FFformatarg[]) {
|
||||
ffPrintFormat(FF_BLUETOOTH_MODULE_NAME, index, &options->moduleArgs, 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},
|
||||
@@ -29,14 +29,14 @@ static void printDevice(FFinstance* instance, FFBluetoothOptions* options, const
|
||||
}
|
||||
}
|
||||
|
||||
void ffPrintBluetooth(FFinstance* instance, FFBluetoothOptions* options)
|
||||
void ffPrintBluetooth(FFBluetoothOptions* options)
|
||||
{
|
||||
FF_LIST_AUTO_DESTROY devices = ffListCreate(sizeof (FFBluetoothDevice));
|
||||
const char* error = ffDetectBluetooth(instance, &devices);
|
||||
const char* error = ffDetectBluetooth(&devices);
|
||||
|
||||
if(error)
|
||||
{
|
||||
ffPrintError(instance, FF_BLUETOOTH_MODULE_NAME, 0, &options->moduleArgs, "%s", error);
|
||||
ffPrintError(FF_BLUETOOTH_MODULE_NAME, 0, &options->moduleArgs, "%s", error);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -52,14 +52,14 @@ void ffPrintBluetooth(FFinstance* instance, FFBluetoothOptions* options)
|
||||
|
||||
if(filtered.length == 0)
|
||||
{
|
||||
ffPrintError(instance, FF_BLUETOOTH_MODULE_NAME, 0, &options->moduleArgs, "No bluetooth devices found");
|
||||
ffPrintError(FF_BLUETOOTH_MODULE_NAME, 0, &options->moduleArgs, "No bluetooth devices found");
|
||||
return;
|
||||
}
|
||||
|
||||
for(uint32_t i = 0; i < filtered.length; i++)
|
||||
{
|
||||
uint8_t index = (uint8_t) (filtered.length == 1 ? 0 : i + 1);
|
||||
printDevice(instance, options, *(FFBluetoothDevice**)ffListGet(&filtered, i), index);
|
||||
printDevice(options, *(FFBluetoothDevice**)ffListGet(&filtered, i), index);
|
||||
}
|
||||
|
||||
FF_LIST_FOR_EACH(FFBluetoothDevice, device, devices)
|
||||
@@ -94,7 +94,7 @@ void ffDestroyBluetoothOptions(FFBluetoothOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
void ffParseBluetoothJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
void ffParseBluetoothJsonObject(yyjson_val* module)
|
||||
{
|
||||
FFBluetoothOptions __attribute__((__cleanup__(ffDestroyBluetoothOptions))) options;
|
||||
ffInitBluetoothOptions(&options);
|
||||
@@ -118,9 +118,9 @@ void ffParseBluetoothJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
continue;
|
||||
}
|
||||
|
||||
ffPrintError(instance, FF_BLUETOOTH_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
ffPrintError(FF_BLUETOOTH_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
}
|
||||
}
|
||||
|
||||
ffPrintBluetooth(instance, &options);
|
||||
ffPrintBluetooth(&options);
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
#define FF_BLUETOOTH_MODULE_NAME "Bluetooth"
|
||||
|
||||
void ffPrintBluetooth(FFinstance* instance, FFBluetoothOptions* options);
|
||||
void ffPrintBluetooth(FFBluetoothOptions* options);
|
||||
void ffInitBluetoothOptions(FFBluetoothOptions* options);
|
||||
bool ffParseBluetoothCommandOptions(FFBluetoothOptions* options, const char* key, const char* value);
|
||||
void ffDestroyBluetoothOptions(FFBluetoothOptions* options);
|
||||
void ffParseBluetoothJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
void ffParseBluetoothJsonObject(yyjson_val* module);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#define FF_BOARD_NUM_FORMAT_ARGS 3
|
||||
|
||||
void ffPrintBoard(FFinstance* instance, FFBoardOptions* options)
|
||||
void ffPrintBoard(FFBoardOptions* options)
|
||||
{
|
||||
FFBoardResult result;
|
||||
ffStrbufInit(&result.name);
|
||||
@@ -16,19 +16,19 @@ void ffPrintBoard(FFinstance* instance, FFBoardOptions* options)
|
||||
|
||||
if(error)
|
||||
{
|
||||
ffPrintError(instance, FF_BOARD_MODULE_NAME, 0, &options->moduleArgs, "%s", error);
|
||||
ffPrintError(FF_BOARD_MODULE_NAME, 0, &options->moduleArgs, "%s", error);
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if(result.name.length == 0)
|
||||
{
|
||||
ffPrintError(instance, FF_BOARD_MODULE_NAME, 0, &options->moduleArgs, "board_name is not set.");
|
||||
ffPrintError(FF_BOARD_MODULE_NAME, 0, &options->moduleArgs, "board_name is not set.");
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
{
|
||||
ffPrintLogoAndKey(instance, FF_BOARD_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
ffPrintLogoAndKey(FF_BOARD_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
ffStrbufWriteTo(&result.name, stdout);
|
||||
if (result.version.length)
|
||||
printf(" (%s)", result.version.chars);
|
||||
@@ -36,7 +36,7 @@ void ffPrintBoard(FFinstance* instance, FFBoardOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
ffPrintFormat(instance, FF_BOARD_MODULE_NAME, 0, &options->moduleArgs, FF_BOARD_NUM_FORMAT_ARGS, (FFformatarg[]) {
|
||||
ffPrintFormat(FF_BOARD_MODULE_NAME, 0, &options->moduleArgs, 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},
|
||||
@@ -70,7 +70,7 @@ void ffDestroyBoardOptions(FFBoardOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
void ffParseBoardJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
void ffParseBoardJsonObject(yyjson_val* module)
|
||||
{
|
||||
FFBoardOptions __attribute__((__cleanup__(ffDestroyBoardOptions))) options;
|
||||
ffInitBoardOptions(&options);
|
||||
@@ -88,9 +88,9 @@ void ffParseBoardJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs))
|
||||
continue;
|
||||
|
||||
ffPrintError(instance, FF_BOARD_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
ffPrintError(FF_BOARD_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
}
|
||||
}
|
||||
|
||||
ffPrintBoard(instance, &options);
|
||||
ffPrintBoard(&options);
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
#define FF_BOARD_MODULE_NAME "Board"
|
||||
|
||||
void ffPrintBoard(FFinstance* instance, FFBoardOptions* options);
|
||||
void ffPrintBoard(FFBoardOptions* options);
|
||||
void ffInitBoardOptions(FFBoardOptions* options);
|
||||
bool ffParseBoardCommandOptions(FFBoardOptions* options, const char* key, const char* value);
|
||||
void ffDestroyBoardOptions(FFBoardOptions* options);
|
||||
void ffParseBoardJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
void ffParseBoardJsonObject(yyjson_val* module);
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
#include "common/printing.h"
|
||||
#include "modules/break/break.h"
|
||||
|
||||
void ffPrintBreak(FFinstance* instance)
|
||||
void ffPrintBreak(void)
|
||||
{
|
||||
ffLogoPrintLine(instance);
|
||||
ffLogoPrintLine();
|
||||
putchar('\n');
|
||||
}
|
||||
|
||||
void ffParseBreakJsonObject(FFinstance* instance, FF_MAYBE_UNUSED yyjson_val* module)
|
||||
void ffParseBreakJsonObject(FF_MAYBE_UNUSED yyjson_val* module)
|
||||
{
|
||||
return ffPrintBreak(instance);
|
||||
return ffPrintBreak();
|
||||
}
|
||||
|
||||
@@ -4,5 +4,5 @@
|
||||
|
||||
#define FF_BREAK_MODULE_NAME "Break"
|
||||
|
||||
void ffPrintBreak(FFinstance* instance);
|
||||
void ffParseBreakJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
void ffPrintBreak();
|
||||
void ffParseBreakJsonObject(yyjson_val* module);
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#define FF_BRIGHTNESS_NUM_FORMAT_ARGS 2
|
||||
|
||||
void ffPrintBrightness(FFinstance* instance, FFBrightnessOptions* options)
|
||||
void ffPrintBrightness(FFBrightnessOptions* options)
|
||||
{
|
||||
FF_LIST_AUTO_DESTROY result = ffListCreate(sizeof(FFBrightnessResult));
|
||||
|
||||
@@ -15,13 +15,13 @@ void ffPrintBrightness(FFinstance* instance, FFBrightnessOptions* options)
|
||||
|
||||
if(error)
|
||||
{
|
||||
ffPrintError(instance, FF_BRIGHTNESS_MODULE_NAME, 0, &options->moduleArgs, "%s", error);
|
||||
ffPrintError(FF_BRIGHTNESS_MODULE_NAME, 0, &options->moduleArgs, "%s", error);
|
||||
return;
|
||||
}
|
||||
|
||||
if(result.length == 0)
|
||||
{
|
||||
ffPrintError(instance, FF_BRIGHTNESS_MODULE_NAME, 0, &options->moduleArgs, "No result is detected.");
|
||||
ffPrintError(FF_BRIGHTNESS_MODULE_NAME, 0, &options->moduleArgs, "No result is detected.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -44,26 +44,26 @@ void ffPrintBrightness(FFinstance* instance, FFBrightnessOptions* options)
|
||||
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
{
|
||||
ffPrintLogoAndKey(instance, key.chars, 0, NULL, &options->moduleArgs.keyColor);
|
||||
ffPrintLogoAndKey(key.chars, 0, NULL, &options->moduleArgs.keyColor);
|
||||
|
||||
if (instance->config.percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
|
||||
if (instance.config.percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
|
||||
{
|
||||
ffAppendPercentBar(instance, &str, (uint8_t) (item->value + 0.5), 0, 10, 10);
|
||||
ffAppendPercentBar(&str, (uint8_t) (item->value + 0.5), 0, 10, 10);
|
||||
}
|
||||
|
||||
if(instance->config.percentType & FF_PERCENTAGE_TYPE_NUM_BIT)
|
||||
if(instance.config.percentType & FF_PERCENTAGE_TYPE_NUM_BIT)
|
||||
{
|
||||
if(str.length > 0)
|
||||
ffStrbufAppendC(&str, ' ');
|
||||
|
||||
ffAppendPercentNum(instance, &str, (uint8_t) (item->value + 0.5), 10, 10, str.length > 0);
|
||||
ffAppendPercentNum(&str, (uint8_t) (item->value + 0.5), 10, 10, str.length > 0);
|
||||
}
|
||||
|
||||
ffStrbufPutTo(&str, stdout);
|
||||
}
|
||||
else
|
||||
{
|
||||
ffPrintFormatString(instance, key.chars, 0, NULL, &options->moduleArgs.keyColor, &options->moduleArgs.outputFormat, FF_BRIGHTNESS_NUM_FORMAT_ARGS, (FFformatarg[]) {
|
||||
ffPrintFormatString(key.chars, 0, NULL, &options->moduleArgs.keyColor, &options->moduleArgs.outputFormat, FF_BRIGHTNESS_NUM_FORMAT_ARGS, (FFformatarg[]) {
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &item->value},
|
||||
{FF_FORMAT_ARG_TYPE_FLOAT, &item->name}
|
||||
});
|
||||
@@ -95,7 +95,7 @@ void ffDestroyBrightnessOptions(FFBrightnessOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
void ffParseBrightnessJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
void ffParseBrightnessJsonObject(yyjson_val* module)
|
||||
{
|
||||
FFBrightnessOptions __attribute__((__cleanup__(ffDestroyBrightnessOptions))) options;
|
||||
ffInitBrightnessOptions(&options);
|
||||
@@ -113,9 +113,9 @@ void ffParseBrightnessJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs))
|
||||
continue;
|
||||
|
||||
ffPrintError(instance, FF_BRIGHTNESS_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
ffPrintError(FF_BRIGHTNESS_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
}
|
||||
}
|
||||
|
||||
ffPrintBrightness(instance, &options);
|
||||
ffPrintBrightness(&options);
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
#define FF_BRIGHTNESS_MODULE_NAME "Brightness"
|
||||
|
||||
void ffPrintBrightness(FFinstance* instance, FFBrightnessOptions* options);
|
||||
void ffPrintBrightness(FFBrightnessOptions* options);
|
||||
void ffInitBrightnessOptions(FFBrightnessOptions* options);
|
||||
bool ffParseBrightnessCommandOptions(FFBrightnessOptions* options, const char* key, const char* value);
|
||||
void ffDestroyBrightnessOptions(FFBrightnessOptions* options);
|
||||
void ffParseBrightnessJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
void ffParseBrightnessJsonObject(yyjson_val* module);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#define FF_CHASSIS_NUM_FORMAT_ARGS 3
|
||||
|
||||
void ffPrintChassis(FFinstance* instance, FFChassisOptions* options)
|
||||
void ffPrintChassis(FFChassisOptions* options)
|
||||
{
|
||||
FFChassisResult result;
|
||||
ffStrbufInit(&result.type);
|
||||
@@ -17,19 +17,19 @@ void ffPrintChassis(FFinstance* instance, FFChassisOptions* options)
|
||||
|
||||
if(error)
|
||||
{
|
||||
ffPrintError(instance, FF_CHASSIS_MODULE_NAME, 0, &options->moduleArgs, "%s", error);
|
||||
ffPrintError(FF_CHASSIS_MODULE_NAME, 0, &options->moduleArgs, "%s", error);
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if(result.type.length == 0)
|
||||
{
|
||||
ffPrintError(instance, FF_CHASSIS_MODULE_NAME, 0, &options->moduleArgs, "chassis_type is not set by O.E.M.");
|
||||
ffPrintError(FF_CHASSIS_MODULE_NAME, 0, &options->moduleArgs, "chassis_type is not set by O.E.M.");
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
{
|
||||
ffPrintLogoAndKey(instance, FF_CHASSIS_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
ffPrintLogoAndKey(FF_CHASSIS_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
ffStrbufWriteTo(&result.type, stdout);
|
||||
if (result.version.length)
|
||||
printf(" (%s)", result.version.chars);
|
||||
@@ -37,7 +37,7 @@ void ffPrintChassis(FFinstance* instance, FFChassisOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
ffPrintFormat(instance, FF_CHASSIS_MODULE_NAME, 0, &options->moduleArgs, FF_CHASSIS_NUM_FORMAT_ARGS, (FFformatarg[]) {
|
||||
ffPrintFormat(FF_CHASSIS_MODULE_NAME, 0, &options->moduleArgs, 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},
|
||||
@@ -71,7 +71,7 @@ void ffDestroyChassisOptions(FFChassisOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
void ffParseChassisJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
void ffParseChassisJsonObject(yyjson_val* module)
|
||||
{
|
||||
FFChassisOptions __attribute__((__cleanup__(ffDestroyChassisOptions))) options;
|
||||
ffInitChassisOptions(&options);
|
||||
@@ -89,9 +89,9 @@ void ffParseChassisJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs))
|
||||
continue;
|
||||
|
||||
ffPrintError(instance, FF_CHASSIS_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
ffPrintError(FF_CHASSIS_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
}
|
||||
}
|
||||
|
||||
ffPrintChassis(instance, &options);
|
||||
ffPrintChassis(&options);
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
#define FF_CHASSIS_MODULE_NAME "Chassis"
|
||||
|
||||
void ffPrintChassis(FFinstance* instance, FFChassisOptions* options);
|
||||
void ffPrintChassis(FFChassisOptions* options);
|
||||
void ffInitChassisOptions(FFChassisOptions* options);
|
||||
bool ffParseChassisCommandOptions(FFChassisOptions* options, const char* key, const char* value);
|
||||
void ffDestroyChassisOptions(FFChassisOptions* options);
|
||||
void ffParseChassisJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
void ffParseChassisJsonObject(yyjson_val* module);
|
||||
|
||||
@@ -4,12 +4,12 @@
|
||||
#include "modules/colors/colors.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
void ffPrintColors(FFinstance* instance, FFColorsOptions* options)
|
||||
void ffPrintColors(FFColorsOptions* options)
|
||||
{
|
||||
if(instance->config.pipe)
|
||||
if(instance.config.pipe)
|
||||
return;
|
||||
|
||||
ffLogoPrintLine(instance);
|
||||
ffLogoPrintLine();
|
||||
|
||||
if(options->paddingLeft > 0)
|
||||
ffPrintCharTimes(' ', options->paddingLeft);
|
||||
@@ -23,7 +23,7 @@ void ffPrintColors(FFinstance* instance, FFColorsOptions* options)
|
||||
|
||||
puts(FASTFETCH_TEXT_MODIFIER_RESET);
|
||||
|
||||
ffLogoPrintLine(instance);
|
||||
ffLogoPrintLine();
|
||||
|
||||
if(options->paddingLeft > 0)
|
||||
ffPrintCharTimes(' ', options->paddingLeft);
|
||||
@@ -94,7 +94,7 @@ void ffDestroyColorsOptions(FF_MAYBE_UNUSED FFColorsOptions* options)
|
||||
{
|
||||
}
|
||||
|
||||
void ffParseColorsJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
void ffParseColorsJsonObject(yyjson_val* module)
|
||||
{
|
||||
FFColorsOptions __attribute__((__cleanup__(ffDestroyColorsOptions))) options;
|
||||
ffInitColorsOptions(&options);
|
||||
@@ -122,7 +122,7 @@ void ffParseColorsJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
{},
|
||||
});
|
||||
if (error)
|
||||
ffPrintErrorString(instance, FF_COLORS_MODULE_NAME, 0, NULL, NULL, "Invalid %s value: %s", key, error);
|
||||
ffPrintErrorString(FF_COLORS_MODULE_NAME, 0, NULL, NULL, "Invalid %s value: %s", key, error);
|
||||
else
|
||||
options.symbol = (FFColorsSymbol) value;
|
||||
continue;
|
||||
@@ -134,9 +134,9 @@ void ffParseColorsJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
continue;
|
||||
}
|
||||
|
||||
ffPrintErrorString(instance, FF_COLORS_MODULE_NAME, 0, NULL, NULL, "Unknown JSON key %s", key);
|
||||
ffPrintErrorString(FF_COLORS_MODULE_NAME, 0, NULL, NULL, "Unknown JSON key %s", key);
|
||||
}
|
||||
}
|
||||
|
||||
ffPrintColors(instance, &options);
|
||||
ffPrintColors(&options);
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
#define FF_COLORS_MODULE_NAME "Colors"
|
||||
|
||||
void ffPrintColors(FFinstance* instance, FFColorsOptions* options);
|
||||
void ffPrintColors(FFColorsOptions* options);
|
||||
void ffInitColorsOptions(FFColorsOptions* options);
|
||||
void ffDestroyColorsOptions(FFColorsOptions* options);
|
||||
bool ffParseColorsCommandOptions(FFColorsOptions* options, const char* key, const char* value);
|
||||
void ffParseColorsJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
void ffParseColorsJsonObject(yyjson_val* module);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "modules/command/command.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
void ffPrintCommand(FFinstance* instance, FFCommandOptions* options)
|
||||
void ffPrintCommand(FFCommandOptions* options)
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY result = ffStrbufCreate();
|
||||
const char* error = ffProcessAppendStdOut(&result, (char* const[]){
|
||||
@@ -20,17 +20,17 @@ void ffPrintCommand(FFinstance* instance, FFCommandOptions* options)
|
||||
|
||||
if(error)
|
||||
{
|
||||
ffPrintError(instance, FF_COMMAND_MODULE_NAME, 0, &options->moduleArgs, "%s", error);
|
||||
ffPrintError(FF_COMMAND_MODULE_NAME, 0, &options->moduleArgs, "%s", error);
|
||||
return;
|
||||
}
|
||||
|
||||
if(!result.length)
|
||||
{
|
||||
ffPrintError(instance, FF_COMMAND_MODULE_NAME, 0, &options->moduleArgs, "No result printed");
|
||||
ffPrintError(FF_COMMAND_MODULE_NAME, 0, &options->moduleArgs, "No result printed");
|
||||
return;
|
||||
}
|
||||
|
||||
ffPrintLogoAndKey(instance, FF_COMMAND_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
ffPrintLogoAndKey(FF_COMMAND_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
ffStrbufPutTo(&result, stdout);
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ void ffDestroyCommandOptions(FFCommandOptions* options)
|
||||
ffStrbufDestroy(&options->text);
|
||||
}
|
||||
|
||||
void ffParseCommandJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
void ffParseCommandJsonObject(yyjson_val* module)
|
||||
{
|
||||
FFCommandOptions __attribute__((__cleanup__(ffDestroyCommandOptions))) options;
|
||||
ffInitCommandOptions(&options);
|
||||
@@ -111,9 +111,9 @@ void ffParseCommandJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
continue;
|
||||
}
|
||||
|
||||
ffPrintError(instance, FF_COMMAND_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
ffPrintError(FF_COMMAND_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
}
|
||||
}
|
||||
|
||||
ffPrintCommand(instance, &options);
|
||||
ffPrintCommand(&options);
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
#define FF_COMMAND_MODULE_NAME "Command"
|
||||
|
||||
void ffPrintCommand(FFinstance* instance, FFCommandOptions* options);
|
||||
void ffPrintCommand(FFCommandOptions* options);
|
||||
void ffInitCommandOptions(FFCommandOptions* options);
|
||||
bool ffParseCommandCommandOptions(FFCommandOptions* options, const char* key, const char* value);
|
||||
void ffDestroyCommandOptions(FFCommandOptions* options);
|
||||
void ffParseCommandJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
void ffParseCommandJsonObject(yyjson_val* module);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#define FF_CPU_NUM_FORMAT_ARGS 8
|
||||
|
||||
void ffPrintCPU(FFinstance* instance, FFCPUOptions* options)
|
||||
void ffPrintCPU(FFCPUOptions* options)
|
||||
{
|
||||
FFCPUResult cpu;
|
||||
cpu.temperature = FF_CPU_TEMP_UNSET;
|
||||
@@ -15,21 +15,21 @@ void ffPrintCPU(FFinstance* instance, FFCPUOptions* options)
|
||||
ffStrbufInit(&cpu.name);
|
||||
ffStrbufInit(&cpu.vendor);
|
||||
|
||||
const char* error = ffDetectCPU(instance, options, &cpu);
|
||||
const char* error = ffDetectCPU(options, &cpu);
|
||||
|
||||
if(error)
|
||||
{
|
||||
ffPrintError(instance, FF_CPU_MODULE_NAME, 0, &options->moduleArgs, "%s", error);
|
||||
ffPrintError(FF_CPU_MODULE_NAME, 0, &options->moduleArgs, "%s", error);
|
||||
}
|
||||
else if(cpu.vendor.length == 0 && cpu.name.length == 0 && cpu.coresOnline <= 1)
|
||||
{
|
||||
ffPrintError(instance, FF_CPU_MODULE_NAME, 0, &options->moduleArgs, "No CPU detected");
|
||||
ffPrintError(FF_CPU_MODULE_NAME, 0, &options->moduleArgs, "No CPU detected");
|
||||
}
|
||||
else
|
||||
{
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
{
|
||||
ffPrintLogoAndKey(instance, FF_CPU_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
ffPrintLogoAndKey(FF_CPU_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
|
||||
if(cpu.name.length > 0)
|
||||
ffStrbufWriteTo(&cpu.name, stdout);
|
||||
@@ -54,7 +54,7 @@ void ffPrintCPU(FFinstance* instance, FFCPUOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
ffPrintFormat(instance, FF_CPU_MODULE_NAME, 0, &options->moduleArgs, FF_CPU_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||
ffPrintFormat(FF_CPU_MODULE_NAME, 0, &options->moduleArgs, 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},
|
||||
@@ -99,7 +99,7 @@ void ffDestroyCPUOptions(FFCPUOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
void ffParseCPUJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
void ffParseCPUJsonObject(yyjson_val* module)
|
||||
{
|
||||
FFCPUOptions __attribute__((__cleanup__(ffDestroyCPUOptions))) options;
|
||||
ffInitCPUOptions(&options);
|
||||
@@ -123,9 +123,9 @@ void ffParseCPUJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
continue;
|
||||
}
|
||||
|
||||
ffPrintError(instance, FF_CPU_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
ffPrintError(FF_CPU_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
}
|
||||
}
|
||||
|
||||
ffPrintCPU(instance, &options);
|
||||
ffPrintCPU(&options);
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
#define FF_CPU_MODULE_NAME "CPU"
|
||||
|
||||
void ffPrintCPU(FFinstance* instance, FFCPUOptions* options);
|
||||
void ffPrintCPU(FFCPUOptions* options);
|
||||
void ffInitCPUOptions(FFCPUOptions* options);
|
||||
bool ffParseCPUCommandOptions(FFCPUOptions* options, const char* key, const char* value);
|
||||
void ffDestroyCPUOptions(FFCPUOptions* options);
|
||||
void ffParseCPUJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
void ffParseCPUJsonObject(yyjson_val* module);
|
||||
|
||||
@@ -8,35 +8,35 @@
|
||||
#define FF_CPUUSAGE_DISPLAY_NAME "CPU Usage"
|
||||
#define FF_CPUUSAGE_NUM_FORMAT_ARGS 1
|
||||
|
||||
void ffPrintCPUUsage(FFinstance* instance, FFCPUUsageOptions* options)
|
||||
void ffPrintCPUUsage(FFCPUUsageOptions* options)
|
||||
{
|
||||
double percentage = 0.0/0.0;
|
||||
const char* error = ffGetCpuUsageResult(&percentage);
|
||||
|
||||
if(error)
|
||||
{
|
||||
ffPrintError(instance, FF_CPUUSAGE_DISPLAY_NAME, 0, &options->moduleArgs, "%s", error);
|
||||
ffPrintError(FF_CPUUSAGE_DISPLAY_NAME, 0, &options->moduleArgs, "%s", error);
|
||||
return;
|
||||
}
|
||||
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
{
|
||||
ffPrintLogoAndKey(instance, FF_CPUUSAGE_DISPLAY_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
ffPrintLogoAndKey(FF_CPUUSAGE_DISPLAY_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY str = ffStrbufCreate();
|
||||
if(instance->config.percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
|
||||
ffAppendPercentBar(instance, &str, (uint8_t)percentage, 0, 5, 8);
|
||||
if(instance->config.percentType & FF_PERCENTAGE_TYPE_NUM_BIT)
|
||||
if(instance.config.percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
|
||||
ffAppendPercentBar(&str, (uint8_t)percentage, 0, 5, 8);
|
||||
if(instance.config.percentType & FF_PERCENTAGE_TYPE_NUM_BIT)
|
||||
{
|
||||
if(str.length > 0)
|
||||
ffStrbufAppendC(&str, ' ');
|
||||
ffAppendPercentNum(instance, &str, (uint8_t) percentage, 50, 80, str.length > 0);
|
||||
ffAppendPercentNum(&str, (uint8_t) percentage, 50, 80, str.length > 0);
|
||||
}
|
||||
ffStrbufPutTo(&str, stdout);
|
||||
}
|
||||
else
|
||||
{
|
||||
ffPrintFormat(instance, FF_CPUUSAGE_DISPLAY_NAME, 0, &options->moduleArgs, FF_CPUUSAGE_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||
ffPrintFormat(FF_CPUUSAGE_DISPLAY_NAME, 0, &options->moduleArgs, FF_CPUUSAGE_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_DOUBLE, &percentage}
|
||||
});
|
||||
}
|
||||
@@ -63,7 +63,7 @@ void ffDestroyCPUUsageOptions(FFCPUUsageOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
void ffParseCPUUsageJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
void ffParseCPUUsageJsonObject(yyjson_val* module)
|
||||
{
|
||||
FFCPUUsageOptions __attribute__((__cleanup__(ffDestroyCPUUsageOptions))) options;
|
||||
ffInitCPUUsageOptions(&options);
|
||||
@@ -81,9 +81,9 @@ void ffParseCPUUsageJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs))
|
||||
continue;
|
||||
|
||||
ffPrintError(instance, FF_CPUUSAGE_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
ffPrintError(FF_CPUUSAGE_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
}
|
||||
}
|
||||
|
||||
ffPrintCPUUsage(instance, &options);
|
||||
ffPrintCPUUsage(&options);
|
||||
}
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
|
||||
void ffPrepareCPUUsage();
|
||||
|
||||
void ffPrintCPUUsage(FFinstance* instance, FFCPUUsageOptions* options);
|
||||
void ffPrintCPUUsage(FFCPUUsageOptions* options);
|
||||
void ffInitCPUUsageOptions(FFCPUUsageOptions* options);
|
||||
bool ffParseCPUUsageCommandOptions(FFCPUUsageOptions* options, const char* key, const char* value);
|
||||
void ffDestroyCPUUsageOptions(FFCPUUsageOptions* options);
|
||||
void ffParseCPUUsageJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
void ffParseCPUUsageJsonObject(yyjson_val* module);
|
||||
|
||||
@@ -6,17 +6,17 @@
|
||||
|
||||
#define FF_CURSOR_NUM_FORMAT_ARGS 2
|
||||
|
||||
void ffPrintCursor(FFinstance* instance, FFCursorOptions* options)
|
||||
void ffPrintCursor(FFCursorOptions* options)
|
||||
{
|
||||
FFCursorResult result;
|
||||
ffStrbufInit(&result.error);
|
||||
ffStrbufInit(&result.theme);
|
||||
ffStrbufInit(&result.size);
|
||||
|
||||
ffDetectCursor(instance, &result);
|
||||
ffDetectCursor(&result);
|
||||
|
||||
if(result.error.length)
|
||||
ffPrintError(instance, FF_CURSOR_MODULE_NAME, 0, &options->moduleArgs, "%s", result.error.chars);
|
||||
ffPrintError(FF_CURSOR_MODULE_NAME, 0, &options->moduleArgs, "%s", result.error.chars);
|
||||
else
|
||||
{
|
||||
ffStrbufRemoveIgnCaseEndS(&result.theme, "cursors");
|
||||
@@ -28,7 +28,7 @@ void ffPrintCursor(FFinstance* instance, FFCursorOptions* options)
|
||||
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
{
|
||||
ffPrintLogoAndKey(instance, FF_CURSOR_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
ffPrintLogoAndKey(FF_CURSOR_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
ffStrbufWriteTo(&result.theme, stdout);
|
||||
|
||||
if(result.size.length > 0)
|
||||
@@ -38,7 +38,7 @@ void ffPrintCursor(FFinstance* instance, FFCursorOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
ffPrintFormat(instance, FF_CURSOR_MODULE_NAME, 0, &options->moduleArgs, FF_CURSOR_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||
ffPrintFormat(FF_CURSOR_MODULE_NAME, 0, &options->moduleArgs, FF_CURSOR_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result.theme},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result.size}
|
||||
});
|
||||
@@ -71,7 +71,7 @@ void ffDestroyCursorOptions(FFCursorOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
void ffParseCursorJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
void ffParseCursorJsonObject(yyjson_val* module)
|
||||
{
|
||||
FFCursorOptions __attribute__((__cleanup__(ffDestroyCursorOptions))) options;
|
||||
ffInitCursorOptions(&options);
|
||||
@@ -89,9 +89,9 @@ void ffParseCursorJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs))
|
||||
continue;
|
||||
|
||||
ffPrintError(instance, FF_CURSOR_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
ffPrintError(FF_CURSOR_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
}
|
||||
}
|
||||
|
||||
ffPrintCursor(instance, &options);
|
||||
ffPrintCursor(&options);
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
#define FF_CURSOR_MODULE_NAME "Cursor"
|
||||
|
||||
void ffPrintCursor(FFinstance* instance, FFCursorOptions* options);
|
||||
void ffPrintCursor(FFCursorOptions* options);
|
||||
void ffInitCursorOptions(FFCursorOptions* options);
|
||||
bool ffParseCursorCommandOptions(FFCursorOptions* options, const char* key, const char* value);
|
||||
void ffDestroyCursorOptions(FFCursorOptions* options);
|
||||
void ffParseCursorJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
void ffParseCursorJsonObject(yyjson_val* module);
|
||||
|
||||
@@ -4,15 +4,15 @@
|
||||
#include "util/textModifier.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
void ffPrintCustom(FFinstance* instance, FFCustomOptions* options)
|
||||
void ffPrintCustom(FFCustomOptions* options)
|
||||
{
|
||||
if (options->moduleArgs.outputFormat.length == 0)
|
||||
{
|
||||
ffPrintError(instance, FF_CUSTOM_MODULE_NAME, 0, &options->moduleArgs, "output format must be set for custom module");
|
||||
ffPrintError(FF_CUSTOM_MODULE_NAME, 0, &options->moduleArgs, "output format must be set for custom module");
|
||||
return;
|
||||
}
|
||||
|
||||
ffPrintLogoAndKey(instance, options->moduleArgs.key.length == 0 ? NULL : FF_CUSTOM_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
ffPrintLogoAndKey(options->moduleArgs.key.length == 0 ? NULL : FF_CUSTOM_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
ffPrintUserString(options->moduleArgs.outputFormat.chars);
|
||||
puts(FASTFETCH_TEXT_MODIFIER_RESET);
|
||||
}
|
||||
@@ -38,7 +38,7 @@ void ffDestroyCustomOptions(FFCustomOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
void ffParseCustomJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
void ffParseCustomJsonObject(yyjson_val* module)
|
||||
{
|
||||
FFCustomOptions __attribute__((__cleanup__(ffDestroyCustomOptions))) options;
|
||||
ffInitCustomOptions(&options);
|
||||
@@ -56,9 +56,9 @@ void ffParseCustomJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs))
|
||||
continue;
|
||||
|
||||
ffPrintError(instance, FF_CUSTOM_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
ffPrintError(FF_CUSTOM_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
}
|
||||
}
|
||||
|
||||
ffPrintCustom(instance, &options);
|
||||
ffPrintCustom(&options);
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
#define FF_CUSTOM_MODULE_NAME "Custom"
|
||||
|
||||
void ffPrintCustom(FFinstance* instance, FFCustomOptions* options);
|
||||
void ffPrintCustom(FFCustomOptions* options);
|
||||
void ffInitCustomOptions(FFCustomOptions* options);
|
||||
bool ffParseCustomCommandOptions(FFCustomOptions* options, const char* key, const char* value);
|
||||
void ffDestroyCustomOptions(FFCustomOptions* options);
|
||||
void ffParseCustomJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
void ffParseCustomJsonObject(yyjson_val* module);
|
||||
|
||||
@@ -7,10 +7,10 @@
|
||||
#define FF_DATETIME_DISPLAY_NAME "Date & Time"
|
||||
#define FF_DATETIME_NUM_FORMAT_ARGS 20
|
||||
|
||||
void ffPrintDateTimeFormat(FFinstance* instance, const char* moduleName, const FFModuleArgs* moduleArgs)
|
||||
void ffPrintDateTimeFormat(const char* moduleName, const FFModuleArgs* moduleArgs)
|
||||
{
|
||||
const FFDateTimeResult* result = ffDetectDateTime(instance);
|
||||
ffPrintFormat(instance, moduleName, 0, moduleArgs, FF_DATETIME_NUM_FORMAT_ARGS, (FFformatarg[]) {
|
||||
const FFDateTimeResult* result = ffDetectDateTime();
|
||||
ffPrintFormat(moduleName, 0, moduleArgs, 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
|
||||
@@ -34,16 +34,16 @@ void ffPrintDateTimeFormat(FFinstance* instance, const char* moduleName, const F
|
||||
});
|
||||
}
|
||||
|
||||
void ffPrintDateTime(FFinstance* instance, FFDateTimeOptions* options)
|
||||
void ffPrintDateTime(FFDateTimeOptions* options)
|
||||
{
|
||||
if(options->moduleArgs.outputFormat.length > 0)
|
||||
{
|
||||
ffPrintDateTimeFormat(instance, FF_DATETIME_DISPLAY_NAME, &options->moduleArgs);
|
||||
ffPrintDateTimeFormat(FF_DATETIME_DISPLAY_NAME, &options->moduleArgs);
|
||||
return;
|
||||
}
|
||||
|
||||
const FFDateTimeResult* datetime = ffDetectDateTime(instance);
|
||||
ffPrintLogoAndKey(instance, FF_DATETIME_DISPLAY_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
const FFDateTimeResult* datetime = ffDetectDateTime();
|
||||
ffPrintLogoAndKey(FF_DATETIME_DISPLAY_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
|
||||
//yyyy-MM-dd HH:mm:ss
|
||||
printf("%u-%s-%02u %s:%s:%s\n", datetime->year, datetime->monthPretty.chars, datetime->dayInMonth, datetime->hourPretty.chars, datetime->minutePretty.chars, datetime->secondPretty.chars);
|
||||
@@ -70,7 +70,7 @@ void ffDestroyDateTimeOptions(FFDateTimeOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
void ffParseDateTimeJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
void ffParseDateTimeJsonObject(yyjson_val* module)
|
||||
{
|
||||
FFDateTimeOptions __attribute__((__cleanup__(ffDestroyDateTimeOptions))) options;
|
||||
ffInitDateTimeOptions(&options);
|
||||
@@ -88,9 +88,9 @@ void ffParseDateTimeJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs))
|
||||
continue;
|
||||
|
||||
ffPrintError(instance, FF_DATETIME_DISPLAY_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
ffPrintError(FF_DATETIME_DISPLAY_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
}
|
||||
}
|
||||
|
||||
ffPrintDateTime(instance, &options);
|
||||
ffPrintDateTime(&options);
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
#define FF_DATETIME_MODULE_NAME "DateTime"
|
||||
|
||||
void ffPrintDateTime(FFinstance* instance, FFDateTimeOptions* options);
|
||||
void ffPrintDateTime(FFDateTimeOptions* options);
|
||||
void ffInitDateTimeOptions(FFDateTimeOptions* options);
|
||||
bool ffParseDateTimeCommandOptions(FFDateTimeOptions* options, const char* key, const char* value);
|
||||
void ffDestroyDateTimeOptions(FFDateTimeOptions* options);
|
||||
void ffParseDateTimeJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
void ffParseDateTimeJsonObject(yyjson_val* module);
|
||||
|
||||
+8
-8
@@ -6,19 +6,19 @@
|
||||
|
||||
#define FF_DE_NUM_FORMAT_ARGS 3
|
||||
|
||||
void ffPrintDE(FFinstance* instance, FFDEOptions* options)
|
||||
void ffPrintDE(FFDEOptions* options)
|
||||
{
|
||||
const FFDisplayServerResult* result = ffConnectDisplayServer(instance);
|
||||
const FFDisplayServerResult* result = ffConnectDisplayServer();
|
||||
|
||||
if(result->dePrettyName.length == 0)
|
||||
{
|
||||
ffPrintError(instance, FF_DE_MODULE_NAME, 0, &options->moduleArgs, "No DE found");
|
||||
ffPrintError(FF_DE_MODULE_NAME, 0, &options->moduleArgs, "No DE found");
|
||||
return;
|
||||
}
|
||||
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
{
|
||||
ffPrintLogoAndKey(instance, FF_DE_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
ffPrintLogoAndKey(FF_DE_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
|
||||
ffStrbufWriteTo(&result->dePrettyName, stdout);
|
||||
|
||||
@@ -32,7 +32,7 @@ void ffPrintDE(FFinstance* instance, FFDEOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
ffPrintFormat(instance, FF_DE_MODULE_NAME, 0, &options->moduleArgs, FF_DE_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||
ffPrintFormat(FF_DE_MODULE_NAME, 0, &options->moduleArgs, 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, &result->deVersion}
|
||||
@@ -61,7 +61,7 @@ void ffDestroyDEOptions(FFDEOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
void ffParseDEJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
void ffParseDEJsonObject(yyjson_val* module)
|
||||
{
|
||||
FFDEOptions __attribute__((__cleanup__(ffDestroyDEOptions))) options;
|
||||
ffInitDEOptions(&options);
|
||||
@@ -79,9 +79,9 @@ void ffParseDEJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs))
|
||||
continue;
|
||||
|
||||
ffPrintError(instance, FF_DE_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
ffPrintError(FF_DE_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
}
|
||||
}
|
||||
|
||||
ffPrintDE(instance, &options);
|
||||
ffPrintDE(&options);
|
||||
}
|
||||
|
||||
+2
-2
@@ -4,8 +4,8 @@
|
||||
|
||||
#define FF_DE_MODULE_NAME "DE"
|
||||
|
||||
void ffPrintDE(FFinstance* instance, FFDEOptions* options);
|
||||
void ffPrintDE(FFDEOptions* options);
|
||||
void ffInitDEOptions(FFDEOptions* options);
|
||||
bool ffParseDECommandOptions(FFDEOptions* options, const char* key, const char* value);
|
||||
void ffDestroyDEOptions(FFDEOptions* options);
|
||||
void ffParseDEJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
void ffParseDEJsonObject(yyjson_val* module);
|
||||
|
||||
+25
-25
@@ -9,7 +9,7 @@
|
||||
#define FF_DISK_NUM_FORMAT_ARGS 10
|
||||
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
||||
|
||||
static void printDisk(FFinstance* instance, FFDiskOptions* options, const FFDisk* disk)
|
||||
static void printDisk(FFDiskOptions* options, const FFDisk* disk)
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY key = ffStrbufCreate();
|
||||
|
||||
@@ -25,40 +25,40 @@ static void printDisk(FFinstance* instance, FFDiskOptions* options, const FFDisk
|
||||
}
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY usedPretty = ffStrbufCreate();
|
||||
ffParseSize(disk->bytesUsed, instance->config.binaryPrefixType, &usedPretty);
|
||||
ffParseSize(disk->bytesUsed, instance.config.binaryPrefixType, &usedPretty);
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY totalPretty = ffStrbufCreate();
|
||||
ffParseSize(disk->bytesTotal, instance->config.binaryPrefixType, &totalPretty);
|
||||
ffParseSize(disk->bytesTotal, instance.config.binaryPrefixType, &totalPretty);
|
||||
|
||||
uint8_t bytesPercentage = disk->bytesTotal > 0 ? (uint8_t) (((long double) disk->bytesUsed / (long double) disk->bytesTotal) * 100.0) : 0;
|
||||
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
{
|
||||
ffPrintLogoAndKey(instance, key.chars, 0, NULL, &options->moduleArgs.keyColor);
|
||||
ffPrintLogoAndKey(key.chars, 0, NULL, &options->moduleArgs.keyColor);
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY str = ffStrbufCreate();
|
||||
|
||||
if(disk->bytesTotal > 0)
|
||||
{
|
||||
if(instance->config.percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
|
||||
if(instance.config.percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
|
||||
{
|
||||
ffAppendPercentBar(instance, &str, bytesPercentage, 0, 5, 8);
|
||||
ffAppendPercentBar(&str, bytesPercentage, 0, 5, 8);
|
||||
ffStrbufAppendC(&str, ' ');
|
||||
}
|
||||
|
||||
if(!(instance->config.percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT))
|
||||
if(!(instance.config.percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT))
|
||||
ffStrbufAppendF(&str, "%s / %s ", usedPretty.chars, totalPretty.chars);
|
||||
|
||||
if(instance->config.percentType & FF_PERCENTAGE_TYPE_NUM_BIT)
|
||||
if(instance.config.percentType & FF_PERCENTAGE_TYPE_NUM_BIT)
|
||||
{
|
||||
ffAppendPercentNum(instance, &str, (uint8_t) bytesPercentage, 50, 80, str.length > 0);
|
||||
ffAppendPercentNum(&str, (uint8_t) bytesPercentage, 50, 80, str.length > 0);
|
||||
ffStrbufAppendC(&str, ' ');
|
||||
}
|
||||
}
|
||||
else
|
||||
ffStrbufAppendS(&str, "Unknown ");
|
||||
|
||||
if(!(instance->config.percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT))
|
||||
if(!(instance.config.percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT))
|
||||
{
|
||||
if(disk->filesystem.length)
|
||||
ffStrbufAppendF(&str, "- %s ", disk->filesystem.chars);
|
||||
@@ -80,7 +80,7 @@ static void printDisk(FFinstance* instance, FFDiskOptions* options, const FFDisk
|
||||
|
||||
bool isExternal = !!(disk->type & FF_DISK_TYPE_EXTERNAL_BIT);
|
||||
bool isHidden = !!(disk->type & FF_DISK_TYPE_HIDDEN_BIT);
|
||||
ffPrintFormatString(instance, key.chars, 0, NULL, &options->moduleArgs.keyColor, &options->moduleArgs.outputFormat, FF_DISK_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||
ffPrintFormatString(key.chars, 0, NULL, &options->moduleArgs.keyColor, &options->moduleArgs.outputFormat, FF_DISK_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &usedPretty},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &totalPretty},
|
||||
{FF_FORMAT_ARG_TYPE_UINT8, &bytesPercentage},
|
||||
@@ -95,22 +95,22 @@ static void printDisk(FFinstance* instance, FFDiskOptions* options, const FFDisk
|
||||
}
|
||||
}
|
||||
|
||||
static void printMountpoint(FFinstance* instance, FFDiskOptions* options, const FFlist* disks, const char* mountpoint)
|
||||
static void printMountpoint(FFDiskOptions* options, const FFlist* disks, const char* mountpoint)
|
||||
{
|
||||
for(uint32_t i = disks->length; i > 0; i--)
|
||||
{
|
||||
FFDisk* disk = ffListGet(disks, i - 1);
|
||||
if(strncmp(mountpoint, disk->mountpoint.chars, disk->mountpoint.length) == 0)
|
||||
{
|
||||
printDisk(instance, options, disk);
|
||||
printDisk(options, disk);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ffPrintError(instance, FF_DISK_MODULE_NAME, 0, &options->moduleArgs, "No disk found for mountpoint: %s", mountpoint);
|
||||
ffPrintError(FF_DISK_MODULE_NAME, 0, &options->moduleArgs, "No disk found for mountpoint: %s", mountpoint);
|
||||
}
|
||||
|
||||
static void printMountpoints(FFinstance* instance, FFDiskOptions* options, const FFlist* disks)
|
||||
static void printMountpoints(FFDiskOptions* options, const FFlist* disks)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
const char separator = ';';
|
||||
@@ -127,38 +127,38 @@ static void printMountpoints(FFinstance* instance, FFDiskOptions* options, const
|
||||
uint32_t colonIndex = ffStrbufNextIndexC(&mountpoints, startIndex, separator);
|
||||
mountpoints.chars[colonIndex] = '\0';
|
||||
|
||||
printMountpoint(instance, options, disks, mountpoints.chars + startIndex);
|
||||
printMountpoint(options, disks, mountpoints.chars + startIndex);
|
||||
|
||||
startIndex = colonIndex + 1;
|
||||
}
|
||||
}
|
||||
|
||||
static void printAutodetected(FFinstance* instance, FFDiskOptions* options, const FFlist* disks)
|
||||
static void printAutodetected(FFDiskOptions* options, const FFlist* disks)
|
||||
{
|
||||
FF_LIST_FOR_EACH(FFDisk, disk, *disks)
|
||||
{
|
||||
if(!(disk->type & options->showTypes))
|
||||
continue;
|
||||
|
||||
printDisk(instance, options, disk);
|
||||
printDisk(options, disk);
|
||||
}
|
||||
}
|
||||
|
||||
void ffPrintDisk(FFinstance* instance, FFDiskOptions* options)
|
||||
void ffPrintDisk(FFDiskOptions* options)
|
||||
{
|
||||
FF_LIST_AUTO_DESTROY disks = ffListCreate(sizeof (FFDisk));
|
||||
const char* error = ffDetectDisks(&disks);
|
||||
|
||||
if(error)
|
||||
{
|
||||
ffPrintError(instance, FF_DISK_MODULE_NAME, 0, &options->moduleArgs, "%s", error);
|
||||
ffPrintError(FF_DISK_MODULE_NAME, 0, &options->moduleArgs, "%s", error);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(options->folders.length == 0)
|
||||
printAutodetected(instance, options, &disks);
|
||||
printAutodetected(options, &disks);
|
||||
else
|
||||
printMountpoints(instance, options, &disks);
|
||||
printMountpoints(options, &disks);
|
||||
}
|
||||
|
||||
FF_LIST_FOR_EACH(FFDisk, disk, disks)
|
||||
@@ -245,7 +245,7 @@ void ffDestroyDiskOptions(FFDiskOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
void ffParseDiskJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
void ffParseDiskJsonObject(yyjson_val* module)
|
||||
{
|
||||
FFDiskOptions __attribute__((__cleanup__(ffDestroyDiskOptions))) options;
|
||||
ffInitDiskOptions(&options);
|
||||
@@ -305,9 +305,9 @@ void ffParseDiskJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
continue;
|
||||
}
|
||||
|
||||
ffPrintError(instance, FF_DISK_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
ffPrintError(FF_DISK_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
}
|
||||
}
|
||||
|
||||
ffPrintDisk(instance, &options);
|
||||
ffPrintDisk(&options);
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
#define FF_DISK_MODULE_NAME "Disk"
|
||||
|
||||
void ffPrintDisk(FFinstance* instance, FFDiskOptions* options);
|
||||
void ffPrintDisk(FFDiskOptions* options);
|
||||
void ffInitDiskOptions(FFDiskOptions* options);
|
||||
bool ffParseDiskCommandOptions(FFDiskOptions* options, const char* key, const char* value);
|
||||
void ffDestroyDiskOptions(FFDiskOptions* options);
|
||||
void ffParseDiskJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
void ffParseDiskJsonObject(yyjson_val* module);
|
||||
|
||||
@@ -6,24 +6,24 @@
|
||||
|
||||
#define FF_DISPLAY_NUM_FORMAT_ARGS 8
|
||||
|
||||
void ffPrintDisplay(FFinstance* instance, FFDisplayOptions* options)
|
||||
void ffPrintDisplay(FFDisplayOptions* options)
|
||||
{
|
||||
#ifdef __ANDROID__
|
||||
ffPrintError(instance, FF_DISPLAY_MODULE_NAME, 0, &instance->config.display.moduleArgs, "Display detection is not supported on Android");
|
||||
ffPrintError(FF_DISPLAY_MODULE_NAME, 0, &instance.config.display.moduleArgs, "Display detection is not supported on Android");
|
||||
return;
|
||||
#endif
|
||||
|
||||
const FFDisplayServerResult* dsResult = ffConnectDisplayServer(instance);
|
||||
const FFDisplayServerResult* dsResult = ffConnectDisplayServer();
|
||||
|
||||
if(dsResult->displays.length == 0)
|
||||
{
|
||||
ffPrintError(instance, FF_DISPLAY_MODULE_NAME, 0, &instance->config.display.moduleArgs, "Couldn't detect display");
|
||||
ffPrintError(FF_DISPLAY_MODULE_NAME, 0, &instance.config.display.moduleArgs, "Couldn't detect display");
|
||||
return;
|
||||
}
|
||||
|
||||
if (options->compactType != FF_DISPLAY_COMPACT_TYPE_NONE)
|
||||
{
|
||||
ffPrintLogoAndKey(instance, FF_DISPLAY_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
ffPrintLogoAndKey(FF_DISPLAY_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
|
||||
int index = 0;
|
||||
FF_LIST_FOR_EACH(FFDisplayResult, result, dsResult->displays)
|
||||
@@ -72,7 +72,7 @@ void ffPrintDisplay(FFinstance* instance, FFDisplayOptions* options)
|
||||
{FF_FORMAT_ARG_TYPE_STRING, displayType},
|
||||
});
|
||||
}
|
||||
ffPrintLogoAndKey(instance, key.chars, 0, NULL, &options->moduleArgs.keyColor);
|
||||
ffPrintLogoAndKey(key.chars, 0, NULL, &options->moduleArgs.keyColor);
|
||||
|
||||
printf("%ix%i", result->width, result->height);
|
||||
|
||||
@@ -96,7 +96,7 @@ void ffPrintDisplay(FFinstance* instance, FFDisplayOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
ffPrintFormat(instance, FF_DISPLAY_MODULE_NAME, moduleIndex, &options->moduleArgs, FF_DISPLAY_NUM_FORMAT_ARGS, (FFformatarg[]) {
|
||||
ffPrintFormat(FF_DISPLAY_MODULE_NAME, moduleIndex, &options->moduleArgs, 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},
|
||||
@@ -151,7 +151,7 @@ void ffDestroyDisplayOptions(FFDisplayOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
void ffParseDisplayJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
void ffParseDisplayJsonObject(yyjson_val* module)
|
||||
{
|
||||
FFDisplayOptions __attribute__((__cleanup__(ffDestroyDisplayOptions))) options;
|
||||
ffInitDisplayOptions(&options);
|
||||
@@ -179,7 +179,7 @@ void ffParseDisplayJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
{},
|
||||
});
|
||||
if (error)
|
||||
ffPrintError(instance, FF_DISPLAY_MODULE_NAME, 0, &options.moduleArgs, "Invalid %s value: %s", key, error);
|
||||
ffPrintError(FF_DISPLAY_MODULE_NAME, 0, &options.moduleArgs, "Invalid %s value: %s", key, error);
|
||||
else
|
||||
options.compactType = (FFDisplayCompactType) value;
|
||||
continue;
|
||||
@@ -191,9 +191,9 @@ void ffParseDisplayJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
continue;
|
||||
}
|
||||
|
||||
ffPrintError(instance, FF_DISPLAY_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
ffPrintError(FF_DISPLAY_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
}
|
||||
}
|
||||
|
||||
ffPrintDisplay(instance, &options);
|
||||
ffPrintDisplay(&options);
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
#define FF_DISPLAY_MODULE_NAME "Display"
|
||||
|
||||
void ffPrintDisplay(FFinstance* instance, FFDisplayOptions* options);
|
||||
void ffPrintDisplay(FFDisplayOptions* options);
|
||||
void ffInitDisplayOptions(FFDisplayOptions* options);
|
||||
bool ffParseDisplayCommandOptions(FFDisplayOptions* options, const char* key, const char* value);
|
||||
void ffDestroyDisplayOptions(FFDisplayOptions* options);
|
||||
void ffParseDisplayJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
void ffParseDisplayJsonObject(yyjson_val* module);
|
||||
|
||||
@@ -6,29 +6,29 @@
|
||||
|
||||
#define FF_FONT_NUM_FORMAT_ARGS (FF_DETECT_FONT_NUM_FONTS + 1)
|
||||
|
||||
void ffPrintFont(FFinstance* instance, FFFontOptions* options)
|
||||
void ffPrintFont(FFFontOptions* options)
|
||||
{
|
||||
FFFontResult font;
|
||||
for(uint32_t i = 0; i < FF_DETECT_FONT_NUM_FONTS; ++i)
|
||||
ffStrbufInit(&font.fonts[i]);
|
||||
ffStrbufInit(&font.display);
|
||||
|
||||
const char* error = ffDetectFont(instance, &font);
|
||||
const char* error = ffDetectFont(&font);
|
||||
|
||||
if(error)
|
||||
{
|
||||
ffPrintError(instance, FF_FONT_MODULE_NAME, 0, &options->moduleArgs, "%s", error);
|
||||
ffPrintError(FF_FONT_MODULE_NAME, 0, &options->moduleArgs, "%s", error);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
{
|
||||
ffPrintLogoAndKey(instance, FF_FONT_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
ffPrintLogoAndKey(FF_FONT_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
ffStrbufPutTo(&font.display, stdout);
|
||||
}
|
||||
else
|
||||
{
|
||||
ffPrintFormat(instance, FF_FONT_MODULE_NAME, 0, &options->moduleArgs, FF_FONT_NUM_FORMAT_ARGS, (FFformatarg[]) {
|
||||
ffPrintFormat(FF_FONT_MODULE_NAME, 0, &options->moduleArgs, 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]},
|
||||
@@ -64,7 +64,7 @@ void ffDestroyFontOptions(FFFontOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
void ffParseFontJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
void ffParseFontJsonObject(yyjson_val* module)
|
||||
{
|
||||
FFFontOptions __attribute__((__cleanup__(ffDestroyFontOptions))) options;
|
||||
ffInitFontOptions(&options);
|
||||
@@ -82,9 +82,9 @@ void ffParseFontJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs))
|
||||
continue;
|
||||
|
||||
ffPrintError(instance, FF_FONT_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
ffPrintError(FF_FONT_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
}
|
||||
}
|
||||
|
||||
ffPrintFont(instance, &options);
|
||||
ffPrintFont(&options);
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
#define FF_FONT_MODULE_NAME "Font"
|
||||
|
||||
void ffPrintFont(FFinstance* instance, FFFontOptions* options);
|
||||
void ffPrintFont(FFFontOptions* options);
|
||||
void ffInitFontOptions(FFFontOptions* options);
|
||||
bool ffParseFontCommandOptions(FFFontOptions* options, const char* key, const char* value);
|
||||
void ffDestroyFontOptions(FFFontOptions* options);
|
||||
void ffParseFontJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
void ffParseFontJsonObject(yyjson_val* module);
|
||||
|
||||
@@ -6,44 +6,44 @@
|
||||
|
||||
#define FF_GAMEPAD_NUM_FORMAT_ARGS 2
|
||||
|
||||
static void printDevice(FFinstance* instance, FFGamepadOptions* options, const FFGamepadDevice* device, uint8_t index)
|
||||
static void printDevice(FFGamepadOptions* options, const FFGamepadDevice* device, uint8_t index)
|
||||
{
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
{
|
||||
ffPrintLogoAndKey(instance, FF_GAMEPAD_MODULE_NAME, index, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
ffPrintLogoAndKey(FF_GAMEPAD_MODULE_NAME, index, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
ffStrbufPutTo(&device->name, stdout);
|
||||
}
|
||||
else
|
||||
{
|
||||
ffPrintFormat(instance, FF_GAMEPAD_MODULE_NAME, index, &options->moduleArgs, FF_GAMEPAD_NUM_FORMAT_ARGS, (FFformatarg[]) {
|
||||
ffPrintFormat(FF_GAMEPAD_MODULE_NAME, index, &options->moduleArgs, FF_GAMEPAD_NUM_FORMAT_ARGS, (FFformatarg[]) {
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &device->name},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &device->identifier},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void ffPrintGamepad(FFinstance* instance, FFGamepadOptions* options)
|
||||
void ffPrintGamepad(FFGamepadOptions* options)
|
||||
{
|
||||
FF_LIST_AUTO_DESTROY result = ffListCreate(sizeof(FFGamepadDevice));
|
||||
|
||||
const char* error = ffDetectGamepad(instance, &result);
|
||||
const char* error = ffDetectGamepad(&result);
|
||||
|
||||
if(error)
|
||||
{
|
||||
ffPrintError(instance, FF_GAMEPAD_MODULE_NAME, 0, &options->moduleArgs, "%s", error);
|
||||
ffPrintError(FF_GAMEPAD_MODULE_NAME, 0, &options->moduleArgs, "%s", error);
|
||||
return;
|
||||
}
|
||||
|
||||
if(!result.length)
|
||||
{
|
||||
ffPrintError(instance, FF_GAMEPAD_MODULE_NAME, 0, &options->moduleArgs, "No devices detected");
|
||||
ffPrintError(FF_GAMEPAD_MODULE_NAME, 0, &options->moduleArgs, "No devices detected");
|
||||
return;
|
||||
}
|
||||
|
||||
uint8_t index = 0;
|
||||
FF_LIST_FOR_EACH(FFGamepadDevice, device, result)
|
||||
{
|
||||
printDevice(instance, options, device, result.length > 1 ? ++index : 0);
|
||||
printDevice(options, device, result.length > 1 ? ++index : 0);
|
||||
ffStrbufDestroy(&device->identifier);
|
||||
ffStrbufDestroy(&device->name);
|
||||
}
|
||||
@@ -70,7 +70,7 @@ void ffDestroyGamepadOptions(FFGamepadOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
void ffParseGamepadJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
void ffParseGamepadJsonObject(yyjson_val* module)
|
||||
{
|
||||
FFGamepadOptions __attribute__((__cleanup__(ffDestroyGamepadOptions))) options;
|
||||
ffInitGamepadOptions(&options);
|
||||
@@ -88,9 +88,9 @@ void ffParseGamepadJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs))
|
||||
continue;
|
||||
|
||||
ffPrintError(instance, FF_GAMEPAD_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
ffPrintError(FF_GAMEPAD_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
}
|
||||
}
|
||||
|
||||
ffPrintGamepad(instance, &options);
|
||||
ffPrintGamepad(&options);
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
#define FF_GAMEPAD_MODULE_NAME "Gamepad"
|
||||
|
||||
void ffPrintGamepad(FFinstance* instance, FFGamepadOptions* options);
|
||||
void ffPrintGamepad(FFGamepadOptions* options);
|
||||
void ffInitGamepadOptions(FFGamepadOptions* options);
|
||||
bool ffParseGamepadCommandOptions(FFGamepadOptions* options, const char* key, const char* value);
|
||||
void ffDestroyGamepadOptions(FFGamepadOptions* options);
|
||||
void ffParseGamepadJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
void ffParseGamepadJsonObject(yyjson_val* module);
|
||||
|
||||
+15
-15
@@ -11,11 +11,11 @@
|
||||
|
||||
#define FF_GPU_NUM_FORMAT_ARGS 6
|
||||
|
||||
static void printGPUResult(FFinstance* instance, FFGPUOptions* options, uint8_t index, const FFGPUResult* gpu)
|
||||
static void printGPUResult(FFGPUOptions* options, uint8_t index, const FFGPUResult* gpu)
|
||||
{
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
{
|
||||
ffPrintLogoAndKey(instance, FF_GPU_MODULE_NAME, index, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
ffPrintLogoAndKey(FF_GPU_MODULE_NAME, index, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY output = ffStrbufCreateA(gpu->vendor.length + 1 + gpu->name.length);
|
||||
|
||||
@@ -39,14 +39,14 @@ static void printGPUResult(FFinstance* instance, FFGPUOptions* options, uint8_t
|
||||
|
||||
if(gpu->dedicated.used != FF_GPU_VMEM_SIZE_UNSET)
|
||||
{
|
||||
ffParseSize(gpu->dedicated.used, instance->config.binaryPrefixType, &output);
|
||||
ffParseSize(gpu->dedicated.used, instance.config.binaryPrefixType, &output);
|
||||
ffStrbufAppendS(&output, " / ");
|
||||
}
|
||||
ffParseSize(gpu->dedicated.total, instance->config.binaryPrefixType, &output);
|
||||
ffParseSize(gpu->dedicated.total, instance.config.binaryPrefixType, &output);
|
||||
if(gpu->dedicated.used != FF_GPU_VMEM_SIZE_UNSET)
|
||||
{
|
||||
ffStrbufAppendS(&output, ", ");
|
||||
ffAppendPercentNum(instance, &output, (uint8_t) (gpu->dedicated.used * 100 / gpu->dedicated.total), 50, 80, false);
|
||||
ffAppendPercentNum(&output, (uint8_t) (gpu->dedicated.used * 100 / gpu->dedicated.total), 50, 80, false);
|
||||
}
|
||||
ffStrbufAppendC(&output, ')');
|
||||
}
|
||||
@@ -63,7 +63,7 @@ static void printGPUResult(FFinstance* instance, FFGPUOptions* options, uint8_t
|
||||
else
|
||||
type = "Unknown";
|
||||
|
||||
ffPrintFormat(instance, FF_GPU_MODULE_NAME, index, &options->moduleArgs, FF_GPU_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||
ffPrintFormat(FF_GPU_MODULE_NAME, index, &options->moduleArgs, 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},
|
||||
@@ -74,13 +74,13 @@ static void printGPUResult(FFinstance* instance, FFGPUOptions* options, uint8_t
|
||||
}
|
||||
}
|
||||
|
||||
void ffPrintGPU(FFinstance* instance, FFGPUOptions* options)
|
||||
void ffPrintGPU(FFGPUOptions* options)
|
||||
{
|
||||
FF_LIST_AUTO_DESTROY gpus = ffListCreate(sizeof (FFGPUResult));
|
||||
const char* error = ffDetectGPU(instance, options, &gpus);
|
||||
const char* error = ffDetectGPU(options, &gpus);
|
||||
if (error)
|
||||
{
|
||||
ffPrintError(instance, FF_GPU_MODULE_NAME, 0, &options->moduleArgs, "%s", error);
|
||||
ffPrintError(FF_GPU_MODULE_NAME, 0, &options->moduleArgs, "%s", error);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -99,10 +99,10 @@ void ffPrintGPU(FFinstance* instance, FFGPUOptions* options)
|
||||
}
|
||||
|
||||
for(uint32_t i = 0; i < selectedGPUs.length; i++)
|
||||
printGPUResult(instance, 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)
|
||||
ffPrintError(instance, FF_GPU_MODULE_NAME, 0, &options->moduleArgs, "No GPUs found");
|
||||
ffPrintError(FF_GPU_MODULE_NAME, 0, &options->moduleArgs, "No GPUs found");
|
||||
|
||||
FF_LIST_FOR_EACH(FFGPUResult, gpu, gpus)
|
||||
{
|
||||
@@ -159,7 +159,7 @@ void ffDestroyGPUOptions(FFGPUOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
void ffParseGPUJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
void ffParseGPUJsonObject(yyjson_val* module)
|
||||
{
|
||||
FFGPUOptions __attribute__((__cleanup__(ffDestroyGPUOptions))) options;
|
||||
ffInitGPUOptions(&options);
|
||||
@@ -199,15 +199,15 @@ void ffParseGPUJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
{},
|
||||
});
|
||||
if (error)
|
||||
ffPrintError(instance, FF_GPU_MODULE_NAME, 0, &options.moduleArgs, "Invalid %s value: %s", key, error);
|
||||
ffPrintError(FF_GPU_MODULE_NAME, 0, &options.moduleArgs, "Invalid %s value: %s", key, error);
|
||||
else
|
||||
options.hideType = (FFGPUType) value;
|
||||
continue;
|
||||
}
|
||||
|
||||
ffPrintError(instance, FF_GPU_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
ffPrintError(FF_GPU_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
}
|
||||
}
|
||||
|
||||
ffPrintGPU(instance, &options);
|
||||
ffPrintGPU(&options);
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
#define FF_GPU_MODULE_NAME "GPU"
|
||||
|
||||
void ffPrintGPU(FFinstance* instance, FFGPUOptions* options);
|
||||
void ffPrintGPU(FFGPUOptions* options);
|
||||
void ffInitGPUOptions(FFGPUOptions* options);
|
||||
bool ffParseGPUCommandOptions(FFGPUOptions* options, const char* key, const char* value);
|
||||
void ffDestroyGPUOptions(FFGPUOptions* options);
|
||||
void ffParseGPUJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
void ffParseGPUJsonObject(yyjson_val* module);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#define FF_HOST_NUM_FORMAT_ARGS 5
|
||||
|
||||
void ffPrintHost(FFinstance* instance, FFHostOptions* options)
|
||||
void ffPrintHost(FFHostOptions* options)
|
||||
{
|
||||
FFHostResult host;
|
||||
ffStrbufInit(&host.productFamily);
|
||||
@@ -18,19 +18,19 @@ void ffPrintHost(FFinstance* instance, FFHostOptions* options)
|
||||
|
||||
if(error)
|
||||
{
|
||||
ffPrintError(instance, FF_HOST_MODULE_NAME, 0, &options->moduleArgs, "%s", error);
|
||||
ffPrintError(FF_HOST_MODULE_NAME, 0, &options->moduleArgs, "%s", error);
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if(host.productFamily.length == 0 && host.productName.length == 0)
|
||||
{
|
||||
ffPrintError(instance, 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, "neither product_family nor product_name is set by O.E.M.");
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
{
|
||||
ffPrintLogoAndKey(instance, FF_HOST_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
ffPrintLogoAndKey(FF_HOST_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY output = ffStrbufCreate();
|
||||
|
||||
@@ -48,7 +48,7 @@ void ffPrintHost(FFinstance* instance, FFHostOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
ffPrintFormat(instance, FF_HOST_MODULE_NAME, 0, &options->moduleArgs, FF_HOST_NUM_FORMAT_ARGS, (FFformatarg[]) {
|
||||
ffPrintFormat(FF_HOST_MODULE_NAME, 0, &options->moduleArgs, FF_HOST_NUM_FORMAT_ARGS, (FFformatarg[]) {
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &host.productFamily},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &host.productName},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &host.productVersion},
|
||||
@@ -86,7 +86,7 @@ void ffDestroyHostOptions(FFHostOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
void ffParseHostJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
void ffParseHostJsonObject(yyjson_val* module)
|
||||
{
|
||||
FFHostOptions __attribute__((__cleanup__(ffDestroyHostOptions))) options;
|
||||
ffInitHostOptions(&options);
|
||||
@@ -104,9 +104,9 @@ void ffParseHostJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs))
|
||||
continue;
|
||||
|
||||
ffPrintError(instance, FF_HOST_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
ffPrintError(FF_HOST_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
}
|
||||
}
|
||||
|
||||
ffPrintHost(instance, &options);
|
||||
ffPrintHost(&options);
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
#define FF_HOST_MODULE_NAME "Host"
|
||||
|
||||
void ffPrintHost(FFinstance* instance, FFHostOptions* options);
|
||||
void ffPrintHost(FFHostOptions* options);
|
||||
void ffInitHostOptions(FFHostOptions* options);
|
||||
bool ffParseHostCommandOptions(FFHostOptions* options, const char* key, const char* value);
|
||||
void ffDestroyHostOptions(FFHostOptions* options);
|
||||
void ffParseHostJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
void ffParseHostJsonObject(yyjson_val* module);
|
||||
|
||||
@@ -6,25 +6,25 @@
|
||||
|
||||
#define FF_ICONS_NUM_FORMAT_ARGS 1
|
||||
|
||||
void ffPrintIcons(FFinstance* instance, FFIconsOptions* options)
|
||||
void ffPrintIcons(FFIconsOptions* options)
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY icons = ffStrbufCreate();
|
||||
const char* error = ffDetectIcons(instance, &icons);
|
||||
const char* error = ffDetectIcons(&icons);
|
||||
|
||||
if(error)
|
||||
{
|
||||
ffPrintError(instance, FF_ICONS_MODULE_NAME, 0, &options->moduleArgs, "%s", error);
|
||||
ffPrintError(FF_ICONS_MODULE_NAME, 0, &options->moduleArgs, "%s", error);
|
||||
return;
|
||||
}
|
||||
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
{
|
||||
ffPrintLogoAndKey(instance, FF_ICONS_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
ffPrintLogoAndKey(FF_ICONS_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
ffStrbufPutTo(&icons, stdout);
|
||||
}
|
||||
else
|
||||
{
|
||||
ffPrintFormat(instance, FF_ICONS_MODULE_NAME, 0, &options->moduleArgs, FF_ICONS_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||
ffPrintFormat(FF_ICONS_MODULE_NAME, 0, &options->moduleArgs, FF_ICONS_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &icons}
|
||||
});
|
||||
}
|
||||
@@ -51,7 +51,7 @@ void ffDestroyIconsOptions(FFIconsOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
void ffParseIconsJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
void ffParseIconsJsonObject(yyjson_val* module)
|
||||
{
|
||||
FFIconsOptions __attribute__((__cleanup__(ffDestroyIconsOptions))) options;
|
||||
ffInitIconsOptions(&options);
|
||||
@@ -69,9 +69,9 @@ void ffParseIconsJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs))
|
||||
continue;
|
||||
|
||||
ffPrintError(instance, FF_ICONS_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
ffPrintError(FF_ICONS_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
}
|
||||
}
|
||||
|
||||
ffPrintIcons(instance, &options);
|
||||
ffPrintIcons(&options);
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
#define FF_ICONS_MODULE_NAME "Icons"
|
||||
|
||||
void ffPrintIcons(FFinstance* instance, FFIconsOptions* options);
|
||||
void ffPrintIcons(FFIconsOptions* options);
|
||||
void ffInitIconsOptions(FFIconsOptions* options);
|
||||
bool ffParseIconsCommandOptions(FFIconsOptions* options, const char* key, const char* value);
|
||||
void ffDestroyIconsOptions(FFIconsOptions* options);
|
||||
void ffParseIconsJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
void ffParseIconsJsonObject(yyjson_val* module);
|
||||
|
||||
+13
-13
@@ -5,27 +5,27 @@
|
||||
|
||||
#define FF_KERNEL_NUM_FORMAT_ARGS 4
|
||||
|
||||
void ffPrintKernel(FFinstance* instance, FFKernelOptions* options)
|
||||
void ffPrintKernel(FFKernelOptions* options)
|
||||
{
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
{
|
||||
ffPrintLogoAndKey(instance, FF_KERNEL_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
ffStrbufWriteTo(&instance->state.platform.systemRelease, stdout);
|
||||
ffPrintLogoAndKey(FF_KERNEL_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
ffStrbufWriteTo(&instance.state.platform.systemRelease, stdout);
|
||||
|
||||
#ifdef _WIN32
|
||||
if(instance->state.platform.systemVersion.length > 0)
|
||||
printf(" (%s)", instance->state.platform.systemVersion.chars);
|
||||
if(instance.state.platform.systemVersion.length > 0)
|
||||
printf(" (%s)", instance.state.platform.systemVersion.chars);
|
||||
#endif
|
||||
|
||||
putchar('\n');
|
||||
}
|
||||
else
|
||||
{
|
||||
ffPrintFormat(instance, FF_KERNEL_MODULE_NAME, 0, &options->moduleArgs, FF_KERNEL_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &instance->state.platform.systemName},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &instance->state.platform.systemRelease},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &instance->state.platform.systemVersion},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &instance->state.platform.systemArchitecture}
|
||||
ffPrintFormat(FF_KERNEL_MODULE_NAME, 0, &options->moduleArgs, FF_KERNEL_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &instance.state.platform.systemName},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &instance.state.platform.systemRelease},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &instance.state.platform.systemVersion},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &instance.state.platform.systemArchitecture}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -51,7 +51,7 @@ void ffDestroyKernelOptions(FFKernelOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
void ffParseKernelJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
void ffParseKernelJsonObject(yyjson_val* module)
|
||||
{
|
||||
FFKernelOptions __attribute__((__cleanup__(ffDestroyKernelOptions))) options;
|
||||
ffInitKernelOptions(&options);
|
||||
@@ -69,9 +69,9 @@ void ffParseKernelJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs))
|
||||
continue;
|
||||
|
||||
ffPrintError(instance, FF_KERNEL_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
ffPrintError(FF_KERNEL_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
}
|
||||
}
|
||||
|
||||
ffPrintKernel(instance, &options);
|
||||
ffPrintKernel(&options);
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
#define FF_KERNEL_MODULE_NAME "Kernel"
|
||||
|
||||
void ffPrintKernel(FFinstance* instance, FFKernelOptions* options);
|
||||
void ffPrintKernel(FFKernelOptions* options);
|
||||
void ffInitKernelOptions(FFKernelOptions* options);
|
||||
bool ffParseKernelCommandOptions(FFKernelOptions* options, const char* key, const char* value);
|
||||
void ffDestroyKernelOptions(FFKernelOptions* options);
|
||||
void ffParseKernelJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
void ffParseKernelJsonObject(yyjson_val* module);
|
||||
|
||||
+8
-8
@@ -6,7 +6,7 @@
|
||||
|
||||
#define FF_LM_NUM_FORMAT_ARGS 2
|
||||
|
||||
void ffPrintLM(FFinstance* instance, FFLMOptions* options)
|
||||
void ffPrintLM(FFLMOptions* options)
|
||||
{
|
||||
FFLMResult result;
|
||||
ffStrbufInit(&result.service);
|
||||
@@ -15,19 +15,19 @@ void ffPrintLM(FFinstance* instance, FFLMOptions* options)
|
||||
|
||||
if(error)
|
||||
{
|
||||
ffPrintError(instance, FF_LM_MODULE_NAME, 0, &options->moduleArgs, "%s", error);
|
||||
ffPrintError(FF_LM_MODULE_NAME, 0, &options->moduleArgs, "%s", error);
|
||||
return;
|
||||
}
|
||||
|
||||
if(result.service.length == 0)
|
||||
{
|
||||
ffPrintError(instance, FF_LM_MODULE_NAME, 0, &options->moduleArgs, "No LM service found");
|
||||
ffPrintError(FF_LM_MODULE_NAME, 0, &options->moduleArgs, "No LM service found");
|
||||
return;
|
||||
}
|
||||
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
{
|
||||
ffPrintLogoAndKey(instance, FF_LM_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
ffPrintLogoAndKey(FF_LM_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
ffStrbufWriteTo(&result.service, stdout);
|
||||
if(result.type.length)
|
||||
printf(" (%s)", result.type.chars);
|
||||
@@ -35,7 +35,7 @@ void ffPrintLM(FFinstance* instance, FFLMOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
ffPrintFormat(instance, FF_LM_MODULE_NAME, 0, &options->moduleArgs, FF_LM_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||
ffPrintFormat(FF_LM_MODULE_NAME, 0, &options->moduleArgs, FF_LM_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result.service},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result.type},
|
||||
});
|
||||
@@ -65,7 +65,7 @@ void ffDestroyLMOptions(FFLMOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
void ffParseLMJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
void ffParseLMJsonObject(yyjson_val* module)
|
||||
{
|
||||
FFLMOptions __attribute__((__cleanup__(ffDestroyLMOptions))) options;
|
||||
ffInitLMOptions(&options);
|
||||
@@ -83,9 +83,9 @@ void ffParseLMJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs))
|
||||
continue;
|
||||
|
||||
ffPrintError(instance, FF_LM_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
ffPrintError(FF_LM_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
}
|
||||
}
|
||||
|
||||
ffPrintLM(instance, &options);
|
||||
ffPrintLM(&options);
|
||||
}
|
||||
|
||||
+2
-2
@@ -4,8 +4,8 @@
|
||||
|
||||
#define FF_LM_MODULE_NAME "LM"
|
||||
|
||||
void ffPrintLM(FFinstance* instance, FFLMOptions* options);
|
||||
void ffPrintLM(FFLMOptions* options);
|
||||
void ffInitLMOptions(FFLMOptions* options);
|
||||
bool ffParseLMCommandOptions(FFLMOptions* options, const char* key, const char* value);
|
||||
void ffDestroyLMOptions(FFLMOptions* options);
|
||||
void ffParseLMJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
void ffParseLMJsonObject(yyjson_val* module);
|
||||
|
||||
@@ -6,25 +6,25 @@
|
||||
|
||||
#define FF_LOCALE_NUM_FORMAT_ARGS 1
|
||||
|
||||
void ffPrintLocale(FFinstance* instance, FFLocaleOptions* options)
|
||||
void ffPrintLocale(FFLocaleOptions* options)
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY locale = ffStrbufCreate();
|
||||
|
||||
ffDetectLocale(&locale);
|
||||
if(locale.length == 0)
|
||||
{
|
||||
ffPrintError(instance, FF_LOCALE_MODULE_NAME, 0, &options->moduleArgs, "No locale found");
|
||||
ffPrintError(FF_LOCALE_MODULE_NAME, 0, &options->moduleArgs, "No locale found");
|
||||
return;
|
||||
}
|
||||
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
{
|
||||
ffPrintLogoAndKey(instance, FF_LOCALE_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
ffPrintLogoAndKey(FF_LOCALE_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
ffStrbufPutTo(&locale, stdout);
|
||||
}
|
||||
else
|
||||
{
|
||||
ffPrintFormat(instance, FF_LOCALE_MODULE_NAME, 0, &options->moduleArgs, FF_LOCALE_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||
ffPrintFormat(FF_LOCALE_MODULE_NAME, 0, &options->moduleArgs, FF_LOCALE_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &locale}
|
||||
});
|
||||
}
|
||||
@@ -51,7 +51,7 @@ void ffDestroyLocaleOptions(FFLocaleOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
void ffParseLocaleJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
void ffParseLocaleJsonObject(yyjson_val* module)
|
||||
{
|
||||
FFLocaleOptions __attribute__((__cleanup__(ffDestroyLocaleOptions))) options;
|
||||
ffInitLocaleOptions(&options);
|
||||
@@ -69,9 +69,9 @@ void ffParseLocaleJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs))
|
||||
continue;
|
||||
|
||||
ffPrintError(instance, FF_LOCALE_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
ffPrintError(FF_LOCALE_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
}
|
||||
}
|
||||
|
||||
ffPrintLocale(instance, &options);
|
||||
ffPrintLocale(&options);
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
#define FF_LOCALE_MODULE_NAME "Locale"
|
||||
|
||||
void ffPrintLocale(FFinstance* instance, FFLocaleOptions* options);
|
||||
void ffPrintLocale(FFLocaleOptions* options);
|
||||
void ffInitLocaleOptions(FFLocaleOptions* options);
|
||||
bool ffParseLocaleCommandOptions(FFLocaleOptions* options, const char* key, const char* value);
|
||||
void ffDestroyLocaleOptions(FFLocaleOptions* options);
|
||||
void ffParseLocaleJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
void ffParseLocaleJsonObject(yyjson_val* module);
|
||||
|
||||
@@ -54,7 +54,7 @@ static void printIp(FFLocalIpResult* ip)
|
||||
}
|
||||
}
|
||||
|
||||
void ffPrintLocalIp(FFinstance* instance, FFLocalIpOptions* options)
|
||||
void ffPrintLocalIp(FFLocalIpOptions* options)
|
||||
{
|
||||
FF_LIST_AUTO_DESTROY results = ffListCreate(sizeof(FFLocalIpResult));
|
||||
|
||||
@@ -62,13 +62,13 @@ void ffPrintLocalIp(FFinstance* instance, FFLocalIpOptions* options)
|
||||
|
||||
if(error)
|
||||
{
|
||||
ffPrintError(instance, FF_LOCALIP_DISPLAY_NAME, 0, &options->moduleArgs, "%s", error);
|
||||
ffPrintError(FF_LOCALIP_DISPLAY_NAME, 0, &options->moduleArgs, "%s", error);
|
||||
return;
|
||||
}
|
||||
|
||||
if(results.length == 0)
|
||||
{
|
||||
ffPrintError(instance, FF_LOCALIP_DISPLAY_NAME, 0, &options->moduleArgs, "Failed to detect any IPs");
|
||||
ffPrintError(FF_LOCALIP_DISPLAY_NAME, 0, &options->moduleArgs, "Failed to detect any IPs");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ void ffPrintLocalIp(FFinstance* instance, FFLocalIpOptions* options)
|
||||
|
||||
if (options->showType & FF_LOCALIP_TYPE_COMPACT_BIT)
|
||||
{
|
||||
ffPrintLogoAndKey(instance, FF_LOCALIP_DISPLAY_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
ffPrintLogoAndKey(FF_LOCALIP_DISPLAY_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
|
||||
FF_LIST_FOR_EACH(FFLocalIpResult, ip, results)
|
||||
{
|
||||
@@ -94,13 +94,13 @@ void ffPrintLocalIp(FFinstance* instance, FFLocalIpOptions* options)
|
||||
formatKey(options, ip, &key);
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
{
|
||||
ffPrintLogoAndKey(instance, key.chars, 0, NULL, &options->moduleArgs.keyColor);
|
||||
ffPrintLogoAndKey(key.chars, 0, NULL, &options->moduleArgs.keyColor);
|
||||
printIp(ip);
|
||||
putchar('\n');
|
||||
}
|
||||
else
|
||||
{
|
||||
ffPrintFormatString(instance, key.chars, 0, NULL, &options->moduleArgs.keyColor, &options->moduleArgs.outputFormat, FF_LOCALIP_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||
ffPrintFormatString(key.chars, 0, NULL, &options->moduleArgs.keyColor, &options->moduleArgs.outputFormat, 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},
|
||||
@@ -195,7 +195,7 @@ void ffDestroyLocalIpOptions(FFLocalIpOptions* options)
|
||||
ffStrbufDestroy(&options->namePrefix);
|
||||
}
|
||||
|
||||
void ffParseLocalIpJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
void ffParseLocalIpJsonObject(yyjson_val* module)
|
||||
{
|
||||
FFLocalIpOptions __attribute__((__cleanup__(ffDestroyLocalIpOptions))) options;
|
||||
ffInitLocalIpOptions(&options);
|
||||
@@ -264,9 +264,9 @@ void ffParseLocalIpJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
continue;
|
||||
}
|
||||
|
||||
ffPrintError(instance, FF_LOCALIP_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
ffPrintError(FF_LOCALIP_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
}
|
||||
}
|
||||
|
||||
ffPrintLocalIp(instance, &options);
|
||||
ffPrintLocalIp(&options);
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
#define FF_LOCALIP_MODULE_NAME "LocalIp"
|
||||
|
||||
void ffPrintLocalIp(FFinstance* instance, FFLocalIpOptions* options);
|
||||
void ffPrintLocalIp(FFLocalIpOptions* options);
|
||||
void ffInitLocalIpOptions(FFLocalIpOptions* options);
|
||||
bool ffParseLocalIpCommandOptions(FFLocalIpOptions* options, const char* key, const char* value);
|
||||
void ffDestroyLocalIpOptions(FFLocalIpOptions* options);
|
||||
void ffParseLocalIpJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
void ffParseLocalIpJsonObject(yyjson_val* module);
|
||||
|
||||
@@ -43,13 +43,13 @@ static bool artistInSongTitle(const FFstrbuf* song, const FFstrbuf* artist)
|
||||
return false;
|
||||
}
|
||||
|
||||
void ffPrintMedia(FFinstance* instance, FFMediaOptions* options)
|
||||
void ffPrintMedia(FFMediaOptions* options)
|
||||
{
|
||||
const FFMediaResult* media = ffDetectMedia(instance);
|
||||
const FFMediaResult* media = ffDetectMedia();
|
||||
|
||||
if(media->error.length > 0)
|
||||
{
|
||||
ffPrintError(instance, FF_MEDIA_MODULE_NAME, 0, &options->moduleArgs, "%s", media->error.chars);
|
||||
ffPrintError(FF_MEDIA_MODULE_NAME, 0, &options->moduleArgs, "%s", media->error.chars);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ void ffPrintMedia(FFinstance* instance, FFMediaOptions* options)
|
||||
if(artistInSongTitle(&songPretty, &artistPretty))
|
||||
ffStrbufClear(&artistPretty);
|
||||
|
||||
ffPrintLogoAndKey(instance, FF_MEDIA_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
ffPrintLogoAndKey(FF_MEDIA_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
|
||||
if(artistPretty.length > 0)
|
||||
{
|
||||
@@ -95,7 +95,7 @@ void ffPrintMedia(FFinstance* instance, FFMediaOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
ffPrintFormat(instance, FF_MEDIA_MODULE_NAME, 0, &options->moduleArgs, FF_MEDIA_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||
ffPrintFormat(FF_MEDIA_MODULE_NAME, 0, &options->moduleArgs, 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},
|
||||
@@ -126,7 +126,7 @@ void ffDestroyMediaOptions(FFMediaOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
void ffParseMediaJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
void ffParseMediaJsonObject(yyjson_val* module)
|
||||
{
|
||||
FFMediaOptions __attribute__((__cleanup__(ffDestroyMediaOptions))) options;
|
||||
ffInitMediaOptions(&options);
|
||||
@@ -144,9 +144,9 @@ void ffParseMediaJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs))
|
||||
continue;
|
||||
|
||||
ffPrintError(instance, FF_MEDIA_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
ffPrintError(FF_MEDIA_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
}
|
||||
}
|
||||
|
||||
ffPrintMedia(instance, &options);
|
||||
ffPrintMedia(&options);
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
#define FF_MEDIA_MODULE_NAME "Media"
|
||||
|
||||
void ffPrintMedia(FFinstance* instance, FFMediaOptions* options);
|
||||
void ffPrintMedia(FFMediaOptions* options);
|
||||
void ffInitMediaOptions(FFMediaOptions* options);
|
||||
bool ffParseMediaCommandOptions(FFMediaOptions* options, const char* key, const char* value);
|
||||
void ffDestroyMediaOptions(FFMediaOptions* options);
|
||||
void ffParseMediaJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
void ffParseMediaJsonObject(yyjson_val* module);
|
||||
|
||||
+14
-14
@@ -8,22 +8,22 @@
|
||||
|
||||
#define FF_MEMORY_NUM_FORMAT_ARGS 3
|
||||
|
||||
void ffPrintMemory(FFinstance* instance, FFMemoryOptions* options)
|
||||
void ffPrintMemory(FFMemoryOptions* options)
|
||||
{
|
||||
FFMemoryResult storage;
|
||||
const char* error = ffDetectMemory(&storage);
|
||||
|
||||
if(error)
|
||||
{
|
||||
ffPrintError(instance, FF_MEMORY_MODULE_NAME, 0, &options->moduleArgs, "%s", error);
|
||||
ffPrintError(FF_MEMORY_MODULE_NAME, 0, &options->moduleArgs, "%s", error);
|
||||
return;
|
||||
}
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY usedPretty = ffStrbufCreate();
|
||||
ffParseSize(storage.bytesUsed, instance->config.binaryPrefixType, &usedPretty);
|
||||
ffParseSize(storage.bytesUsed, instance.config.binaryPrefixType, &usedPretty);
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY totalPretty = ffStrbufCreate();
|
||||
ffParseSize(storage.bytesTotal, instance->config.binaryPrefixType, &totalPretty);
|
||||
ffParseSize(storage.bytesTotal, instance.config.binaryPrefixType, &totalPretty);
|
||||
|
||||
uint8_t percentage = storage.bytesTotal == 0
|
||||
? 0
|
||||
@@ -31,24 +31,24 @@ void ffPrintMemory(FFinstance* instance, FFMemoryOptions* options)
|
||||
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
{
|
||||
ffPrintLogoAndKey(instance, FF_MEMORY_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
ffPrintLogoAndKey(FF_MEMORY_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
if (storage.bytesTotal == 0)
|
||||
puts("Disabled");
|
||||
else
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY str = ffStrbufCreate();
|
||||
|
||||
if(instance->config.percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
|
||||
if(instance.config.percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
|
||||
{
|
||||
ffAppendPercentBar(instance, &str, percentage, 0, 5, 8);
|
||||
ffAppendPercentBar(&str, percentage, 0, 5, 8);
|
||||
ffStrbufAppendC(&str, ' ');
|
||||
}
|
||||
|
||||
if(!(instance->config.percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT))
|
||||
if(!(instance.config.percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT))
|
||||
ffStrbufAppendF(&str, "%s / %s ", usedPretty.chars, totalPretty.chars);
|
||||
|
||||
if(instance->config.percentType & FF_PERCENTAGE_TYPE_NUM_BIT)
|
||||
ffAppendPercentNum(instance, &str, (uint8_t) percentage, 50, 80, str.length > 0);
|
||||
if(instance.config.percentType & FF_PERCENTAGE_TYPE_NUM_BIT)
|
||||
ffAppendPercentNum(&str, (uint8_t) percentage, 50, 80, str.length > 0);
|
||||
|
||||
ffStrbufTrimRight(&str, ' ');
|
||||
ffStrbufPutTo(&str, stdout);
|
||||
@@ -56,7 +56,7 @@ void ffPrintMemory(FFinstance* instance, FFMemoryOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
ffPrintFormat(instance, FF_MEMORY_MODULE_NAME, 0, &options->moduleArgs, FF_MEMORY_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||
ffPrintFormat(FF_MEMORY_MODULE_NAME, 0, &options->moduleArgs, FF_MEMORY_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &usedPretty},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &totalPretty},
|
||||
{FF_FORMAT_ARG_TYPE_UINT8, &percentage},
|
||||
@@ -85,7 +85,7 @@ void ffDestroyMemoryOptions(FFMemoryOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
void ffParseMemoryJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
void ffParseMemoryJsonObject(yyjson_val* module)
|
||||
{
|
||||
FFMemoryOptions __attribute__((__cleanup__(ffDestroyMemoryOptions))) options;
|
||||
ffInitMemoryOptions(&options);
|
||||
@@ -103,9 +103,9 @@ void ffParseMemoryJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs))
|
||||
continue;
|
||||
|
||||
ffPrintError(instance, FF_MEMORY_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
ffPrintError(FF_MEMORY_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
}
|
||||
}
|
||||
|
||||
ffPrintMemory(instance, &options);
|
||||
ffPrintMemory(&options);
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
#define FF_MEMORY_MODULE_NAME "Memory"
|
||||
|
||||
void ffPrintMemory(FFinstance* instance, FFMemoryOptions* options);
|
||||
void ffPrintMemory(FFMemoryOptions* options);
|
||||
void ffInitMemoryOptions(FFMemoryOptions* options);
|
||||
bool ffParseMemoryCommandOptions(FFMemoryOptions* options, const char* key, const char* value);
|
||||
void ffDestroyMemoryOptions(FFMemoryOptions* options);
|
||||
void ffParseMemoryJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
void ffParseMemoryJsonObject(yyjson_val* module);
|
||||
|
||||
@@ -6,27 +6,27 @@
|
||||
|
||||
#define FF_OPENCL_NUM_FORMAT_ARGS 3
|
||||
|
||||
void ffPrintOpenCL(FFinstance* instance, FFOpenCLOptions* options)
|
||||
void ffPrintOpenCL(FFOpenCLOptions* options)
|
||||
{
|
||||
FFOpenCLResult opencl;
|
||||
ffStrbufInit(&opencl.version);
|
||||
ffStrbufInit(&opencl.device);
|
||||
ffStrbufInit(&opencl.vendor);
|
||||
|
||||
const char* error = ffDetectOpenCL(instance, &opencl);
|
||||
const char* error = ffDetectOpenCL(&opencl);
|
||||
|
||||
if(error != NULL)
|
||||
ffPrintError(instance, FF_OPENCL_MODULE_NAME, 0, &options->moduleArgs, "%s", error);
|
||||
ffPrintError(FF_OPENCL_MODULE_NAME, 0, &options->moduleArgs, "%s", error);
|
||||
else
|
||||
{
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
{
|
||||
ffPrintLogoAndKey(instance, FF_OPENCL_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
ffPrintLogoAndKey(FF_OPENCL_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
ffStrbufPutTo(&opencl.version, stdout);
|
||||
}
|
||||
else
|
||||
{
|
||||
ffPrintFormat(instance, FF_OPENCL_MODULE_NAME, 0, &options->moduleArgs, FF_OPENCL_NUM_FORMAT_ARGS, (FFformatarg[]) {
|
||||
ffPrintFormat(FF_OPENCL_MODULE_NAME, 0, &options->moduleArgs, 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},
|
||||
@@ -60,7 +60,7 @@ void ffDestroyOpenCLOptions(FFOpenCLOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
void ffParseOpenCLJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
void ffParseOpenCLJsonObject(yyjson_val* module)
|
||||
{
|
||||
FFOpenCLOptions __attribute__((__cleanup__(ffDestroyOpenCLOptions))) options;
|
||||
ffInitOpenCLOptions(&options);
|
||||
@@ -78,9 +78,9 @@ void ffParseOpenCLJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs))
|
||||
continue;
|
||||
|
||||
ffPrintError(instance, FF_OPENCL_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
ffPrintError(FF_OPENCL_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
}
|
||||
}
|
||||
|
||||
ffPrintOpenCL(instance, &options);
|
||||
ffPrintOpenCL(&options);
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
#define FF_OPENCL_MODULE_NAME "OpenCL"
|
||||
|
||||
void ffPrintOpenCL(FFinstance* instance, FFOpenCLOptions* options);
|
||||
void ffPrintOpenCL(FFOpenCLOptions* options);
|
||||
void ffInitOpenCLOptions(FFOpenCLOptions* options);
|
||||
bool ffParseOpenCLCommandOptions(FFOpenCLOptions* options, const char* key, const char* value);
|
||||
void ffDestroyOpenCLOptions(FFOpenCLOptions* options);
|
||||
void ffParseOpenCLJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
void ffParseOpenCLJsonObject(yyjson_val* module);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#define FF_OPENGL_NUM_FORMAT_ARGS 4
|
||||
|
||||
void ffPrintOpenGL(FFinstance* instance, FFOpenGLOptions* options)
|
||||
void ffPrintOpenGL(FFOpenGLOptions* options)
|
||||
{
|
||||
FFOpenGLResult result;
|
||||
ffStrbufInit(&result.version);
|
||||
@@ -14,21 +14,21 @@ void ffPrintOpenGL(FFinstance* instance, FFOpenGLOptions* options)
|
||||
ffStrbufInit(&result.vendor);
|
||||
ffStrbufInit(&result.slv);
|
||||
|
||||
const char* error = ffDetectOpenGL(instance, &result);
|
||||
const char* error = ffDetectOpenGL(&result);
|
||||
if(error)
|
||||
{
|
||||
ffPrintError(instance, FF_OPENGL_MODULE_NAME, 0, &options->moduleArgs, "%s", error);
|
||||
ffPrintError(FF_OPENGL_MODULE_NAME, 0, &options->moduleArgs, "%s", error);
|
||||
return;
|
||||
}
|
||||
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
{
|
||||
ffPrintLogoAndKey(instance, FF_OPENGL_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
ffPrintLogoAndKey(FF_OPENGL_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
puts(result.version.chars);
|
||||
}
|
||||
else
|
||||
{
|
||||
ffPrintFormat(instance, FF_OPENGL_MODULE_NAME, 0, &options->moduleArgs, FF_OPENGL_NUM_FORMAT_ARGS, (FFformatarg[]) {
|
||||
ffPrintFormat(FF_OPENGL_MODULE_NAME, 0, &options->moduleArgs, 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},
|
||||
@@ -80,7 +80,7 @@ void ffDestroyOpenGLOptions(FFOpenGLOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
void ffParseOpenGLJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
void ffParseOpenGLJsonObject(yyjson_val* module)
|
||||
{
|
||||
FFOpenGLOptions __attribute__((__cleanup__(ffDestroyOpenGLOptions))) options;
|
||||
ffInitOpenGLOptions(&options);
|
||||
@@ -110,16 +110,16 @@ void ffParseOpenGLJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
{},
|
||||
});
|
||||
if (error)
|
||||
ffPrintError(instance, FF_OPENGL_MODULE_NAME, 0, &options.moduleArgs, "Invalid %s value: %s", key, error);
|
||||
ffPrintError(FF_OPENGL_MODULE_NAME, 0, &options.moduleArgs, "Invalid %s value: %s", key, error);
|
||||
else
|
||||
options.library = (FFOpenGLLibrary) value;
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
|
||||
ffPrintError(instance, FF_OPENGL_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
ffPrintError(FF_OPENGL_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
}
|
||||
}
|
||||
|
||||
ffPrintOpenGL(instance, &options);
|
||||
ffPrintOpenGL(&options);
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
#define FF_OPENGL_MODULE_NAME "OpenGL"
|
||||
|
||||
void ffPrintOpenGL(FFinstance* instance, FFOpenGLOptions* options);
|
||||
void ffPrintOpenGL(FFOpenGLOptions* options);
|
||||
void ffInitOpenGLOptions(FFOpenGLOptions* options);
|
||||
bool ffParseOpenGLCommandOptions(FFOpenGLOptions* options, const char* key, const char* value);
|
||||
void ffDestroyOpenGLOptions(FFOpenGLOptions* options);
|
||||
void ffParseOpenGLJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
void ffParseOpenGLJsonObject(yyjson_val* module);
|
||||
|
||||
+19
-19
@@ -9,7 +9,7 @@
|
||||
|
||||
#define FF_OS_NUM_FORMAT_ARGS 12
|
||||
|
||||
static void buildOutputDefault(const FFinstance* instance, const FFOSResult* os, FFstrbuf* result)
|
||||
static void buildOutputDefault(const FFOSResult* os, FFstrbuf* result)
|
||||
{
|
||||
//Create the basic output
|
||||
if(os->name.length > 0)
|
||||
@@ -19,7 +19,7 @@ static void buildOutputDefault(const FFinstance* instance, const FFOSResult* os,
|
||||
else if(os->id.length > 0)
|
||||
ffStrbufAppend(result, &os->id);
|
||||
else
|
||||
ffStrbufAppend(result, &instance->state.platform.systemName);
|
||||
ffStrbufAppend(result, &instance.state.platform.systemName);
|
||||
|
||||
#ifdef __APPLE__
|
||||
if(os->codename.length > 0)
|
||||
@@ -64,14 +64,14 @@ static void buildOutputDefault(const FFinstance* instance, const FFOSResult* os,
|
||||
}
|
||||
|
||||
//Append architecture if it is missing
|
||||
if(ffStrbufFirstIndex(result, &instance->state.platform.systemArchitecture) == result->length)
|
||||
if(ffStrbufFirstIndex(result, &instance.state.platform.systemArchitecture) == result->length)
|
||||
{
|
||||
ffStrbufAppendC(result, ' ');
|
||||
ffStrbufAppend(result, &instance->state.platform.systemArchitecture);
|
||||
ffStrbufAppend(result, &instance.state.platform.systemArchitecture);
|
||||
}
|
||||
}
|
||||
|
||||
static void buildOutputNixOS(const FFinstance* instance, const FFOSResult* os, FFstrbuf* result)
|
||||
static void buildOutputNixOS(const FFOSResult* os, FFstrbuf* result)
|
||||
{
|
||||
ffStrbufAppendS(result, "NixOS");
|
||||
|
||||
@@ -89,20 +89,20 @@ static void buildOutputNixOS(const FFinstance* instance, const FFOSResult* os, F
|
||||
ffStrbufAppendC(result, ')');
|
||||
}
|
||||
|
||||
if(instance->state.platform.systemArchitecture.length > 0)
|
||||
if(instance.state.platform.systemArchitecture.length > 0)
|
||||
{
|
||||
ffStrbufAppendC(result, ' ');
|
||||
ffStrbufAppend(result, &instance->state.platform.systemArchitecture);
|
||||
ffStrbufAppend(result, &instance.state.platform.systemArchitecture);
|
||||
}
|
||||
}
|
||||
|
||||
void ffPrintOS(FFinstance* instance, FFOSOptions* options)
|
||||
void ffPrintOS(FFOSOptions* options)
|
||||
{
|
||||
const FFOSResult* os = ffDetectOS(instance);
|
||||
const FFOSResult* os = ffDetectOS();
|
||||
|
||||
if(os->name.length == 0 && os->prettyName.length == 0 && os->id.length == 0)
|
||||
{
|
||||
ffPrintError(instance, FF_OS_MODULE_NAME, 0, &options->moduleArgs, "Could not detect OS");
|
||||
ffPrintError(FF_OS_MODULE_NAME, 0, &options->moduleArgs, "Could not detect OS");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -111,17 +111,17 @@ void ffPrintOS(FFinstance* instance, FFOSOptions* options)
|
||||
FF_STRBUF_AUTO_DESTROY result = ffStrbufCreate();
|
||||
|
||||
if(ffStrbufIgnCaseCompS(&os->id, "nixos") == 0)
|
||||
buildOutputNixOS(instance, os, &result);
|
||||
buildOutputNixOS(os, &result);
|
||||
else
|
||||
buildOutputDefault(instance, os, &result);
|
||||
buildOutputDefault(os, &result);
|
||||
|
||||
ffPrintLogoAndKey(instance, FF_OS_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
ffPrintLogoAndKey(FF_OS_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
ffStrbufPutTo(&result, stdout);
|
||||
}
|
||||
else
|
||||
{
|
||||
ffPrintFormat(instance, FF_OS_MODULE_NAME, 0, &options->moduleArgs, FF_OS_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &instance->state.platform.systemName},
|
||||
ffPrintFormat(FF_OS_MODULE_NAME, 0, &options->moduleArgs, 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},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &os->id},
|
||||
@@ -132,7 +132,7 @@ void ffPrintOS(FFinstance* instance, FFOSOptions* options)
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &os->versionID},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &os->codename},
|
||||
{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}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -158,7 +158,7 @@ void ffDestroyOSOptions(FFOSOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
void ffParseOSJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
void ffParseOSJsonObject(yyjson_val* module)
|
||||
{
|
||||
FFOSOptions __attribute__((__cleanup__(ffDestroyOSOptions))) options;
|
||||
ffInitOSOptions(&options);
|
||||
@@ -176,9 +176,9 @@ void ffParseOSJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs))
|
||||
continue;
|
||||
|
||||
ffPrintError(instance, FF_OS_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
ffPrintError(FF_OS_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
}
|
||||
}
|
||||
|
||||
ffPrintOS(instance, &options);
|
||||
ffPrintOS(&options);
|
||||
}
|
||||
|
||||
+2
-2
@@ -4,8 +4,8 @@
|
||||
|
||||
#define FF_OS_MODULE_NAME "OS"
|
||||
|
||||
void ffPrintOS(FFinstance* instance, FFOSOptions* options);
|
||||
void ffPrintOS(FFOSOptions* options);
|
||||
void ffInitOSOptions(FFOSOptions* options);
|
||||
bool ffParseOSCommandOptions(FFOSOptions* options, const char* key, const char* value);
|
||||
void ffDestroyOSOptions(FFOSOptions* options);
|
||||
void ffParseOSJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
void ffParseOSJsonObject(yyjson_val* module);
|
||||
|
||||
@@ -6,22 +6,22 @@
|
||||
|
||||
#define FF_PACKAGES_NUM_FORMAT_ARGS 21
|
||||
|
||||
void ffPrintPackages(FFinstance* instance, FFPackagesOptions* options)
|
||||
void ffPrintPackages(FFPackagesOptions* options)
|
||||
{
|
||||
FFPackagesResult counts = {};
|
||||
ffStrbufInit(&counts.pacmanBranch);
|
||||
|
||||
const char* error = ffDetectPackages(instance, &counts);
|
||||
const char* error = ffDetectPackages(&counts);
|
||||
|
||||
if(error)
|
||||
{
|
||||
ffPrintError(instance, FF_PACKAGES_MODULE_NAME, 0, &options->moduleArgs, "%s", error);
|
||||
ffPrintError(FF_PACKAGES_MODULE_NAME, 0, &options->moduleArgs, "%s", error);
|
||||
return;
|
||||
}
|
||||
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
{
|
||||
ffPrintLogoAndKey(instance, FF_PACKAGES_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
ffPrintLogoAndKey(FF_PACKAGES_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
|
||||
#define FF_PRINT_PACKAGE_NAME(var, name) \
|
||||
if(counts.var > 0) \
|
||||
@@ -66,7 +66,7 @@ void ffPrintPackages(FFinstance* instance, FFPackagesOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
ffPrintFormat(instance, FF_PACKAGES_MODULE_NAME, 0, &options->moduleArgs, FF_PACKAGES_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||
ffPrintFormat(FF_PACKAGES_MODULE_NAME, 0, &options->moduleArgs, 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},
|
||||
@@ -115,7 +115,7 @@ void ffDestroyPackagesOptions(FFPackagesOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
void ffParsePackagesJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
void ffParsePackagesJsonObject(yyjson_val* module)
|
||||
{
|
||||
FFPackagesOptions __attribute__((__cleanup__(ffDestroyPackagesOptions))) options;
|
||||
ffInitPackagesOptions(&options);
|
||||
@@ -133,9 +133,9 @@ void ffParsePackagesJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs))
|
||||
continue;
|
||||
|
||||
ffPrintError(instance, FF_PACKAGES_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
ffPrintError(FF_PACKAGES_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
}
|
||||
}
|
||||
|
||||
ffPrintPackages(instance, &options);
|
||||
ffPrintPackages(&options);
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
#define FF_PACKAGES_MODULE_NAME "Packages"
|
||||
|
||||
void ffPrintPackages(FFinstance* instance, FFPackagesOptions* options);
|
||||
void ffPrintPackages(FFPackagesOptions* options);
|
||||
void ffInitPackagesOptions(FFPackagesOptions* options);
|
||||
bool ffParsePackagesCommandOptions(FFPackagesOptions* options, const char* key, const char* value);
|
||||
void ffDestroyPackagesOptions(FFPackagesOptions* options);
|
||||
void ffParsePackagesJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
void ffParsePackagesJsonObject(yyjson_val* module);
|
||||
|
||||
@@ -9,13 +9,13 @@
|
||||
#define FF_PLAYER_DISPLAY_NAME "Media Player"
|
||||
#define FF_PLAYER_NUM_FORMAT_ARGS 4
|
||||
|
||||
void ffPrintPlayer(FFinstance* instance, FFPlayerOptions* options)
|
||||
void ffPrintPlayer(FFPlayerOptions* options)
|
||||
{
|
||||
const FFMediaResult* media = ffDetectMedia(instance);
|
||||
const FFMediaResult* media = ffDetectMedia();
|
||||
|
||||
if(media->error.length > 0)
|
||||
{
|
||||
ffPrintError(instance, FF_PLAYER_DISPLAY_NAME, 0, &options->moduleArgs, "%s", media->error.chars);
|
||||
ffPrintError(FF_PLAYER_DISPLAY_NAME, 0, &options->moduleArgs, "%s", media->error.chars);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -59,12 +59,12 @@ void ffPrintPlayer(FFinstance* instance, FFPlayerOptions* options)
|
||||
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
{
|
||||
ffPrintLogoAndKey(instance, FF_PLAYER_DISPLAY_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
ffPrintLogoAndKey(FF_PLAYER_DISPLAY_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
ffStrbufPutTo(&playerPretty, stdout);
|
||||
}
|
||||
else
|
||||
{
|
||||
ffPrintFormat(instance, FF_PLAYER_DISPLAY_NAME, 0, &options->moduleArgs, FF_PLAYER_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||
ffPrintFormat(FF_PLAYER_DISPLAY_NAME, 0, &options->moduleArgs, 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},
|
||||
@@ -94,7 +94,7 @@ void ffDestroyPlayerOptions(FFPlayerOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
void ffParsePlayerJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
void ffParsePlayerJsonObject(yyjson_val* module)
|
||||
{
|
||||
FFPlayerOptions __attribute__((__cleanup__(ffDestroyPlayerOptions))) options;
|
||||
ffInitPlayerOptions(&options);
|
||||
@@ -112,9 +112,9 @@ void ffParsePlayerJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs))
|
||||
continue;
|
||||
|
||||
ffPrintError(instance, FF_PLAYER_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
ffPrintError(FF_PLAYER_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
}
|
||||
}
|
||||
|
||||
ffPrintPlayer(instance, &options);
|
||||
ffPrintPlayer(&options);
|
||||
}
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
|
||||
#define FF_PLAYER_MODULE_NAME "Player"
|
||||
|
||||
void ffPrintPlayer(FFinstance* instance, FFPlayerOptions* options);
|
||||
void ffPrintPlayer(FFPlayerOptions* options);
|
||||
void ffInitPlayerOptions(FFPlayerOptions* options);
|
||||
bool ffParsePlayerCommandOptions(FFPlayerOptions* options, const char* key, const char* value);
|
||||
void ffDestroyPlayerOptions(FFPlayerOptions* options);
|
||||
void ffParsePlayerJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
void ffParsePlayerJsonObject(yyjson_val* module);
|
||||
|
||||
@@ -7,20 +7,20 @@
|
||||
#define FF_POWERADAPTER_DISPLAY_NAME "Power Adapter"
|
||||
#define FF_POWERADAPTER_MODULE_ARGS 5
|
||||
|
||||
void ffPrintPowerAdapter(FFinstance* instance, FFPowerAdapterOptions* options)
|
||||
void ffPrintPowerAdapter(FFPowerAdapterOptions* options)
|
||||
{
|
||||
FFlist results;
|
||||
ffListInit(&results, sizeof(PowerAdapterResult));
|
||||
|
||||
const char* error = ffDetectPowerAdapterImpl(instance, &results);
|
||||
const char* error = ffDetectPowerAdapterImpl(&results);
|
||||
|
||||
if (error)
|
||||
{
|
||||
ffPrintError(instance, FF_POWERADAPTER_DISPLAY_NAME, 0, &options->moduleArgs, "%s", error);
|
||||
ffPrintError(FF_POWERADAPTER_DISPLAY_NAME, 0, &options->moduleArgs, "%s", error);
|
||||
}
|
||||
else if(results.length == 0)
|
||||
{
|
||||
ffPrintError(instance, FF_POWERADAPTER_DISPLAY_NAME, 0, &options->moduleArgs, "No power adapters found");
|
||||
ffPrintError(FF_POWERADAPTER_DISPLAY_NAME, 0, &options->moduleArgs, "No power adapters found");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -32,7 +32,7 @@ void ffPrintPowerAdapter(FFinstance* instance, FFPowerAdapterOptions* options)
|
||||
{
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
{
|
||||
ffPrintLogoAndKey(instance, FF_POWERADAPTER_DISPLAY_NAME, i, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
ffPrintLogoAndKey(FF_POWERADAPTER_DISPLAY_NAME, i, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
|
||||
if(result->name.length > 0)
|
||||
puts(result->name.chars);
|
||||
@@ -43,7 +43,7 @@ void ffPrintPowerAdapter(FFinstance* instance, FFPowerAdapterOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
ffPrintFormat(instance, FF_POWERADAPTER_DISPLAY_NAME, i, &options->moduleArgs, FF_POWERADAPTER_MODULE_ARGS, (FFformatarg[]){
|
||||
ffPrintFormat(FF_POWERADAPTER_DISPLAY_NAME, i, &options->moduleArgs, FF_POWERADAPTER_MODULE_ARGS, (FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_INT, &result->watts},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->name},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->manufacturer},
|
||||
@@ -84,7 +84,7 @@ void ffDestroyPowerAdapterOptions(FFPowerAdapterOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
void ffParsePowerAdapterJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
void ffParsePowerAdapterJsonObject(yyjson_val* module)
|
||||
{
|
||||
FFPowerAdapterOptions __attribute__((__cleanup__(ffDestroyPowerAdapterOptions))) options;
|
||||
ffInitPowerAdapterOptions(&options);
|
||||
@@ -102,9 +102,9 @@ void ffParsePowerAdapterJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs))
|
||||
continue;
|
||||
|
||||
ffPrintError(instance, FF_POWERADAPTER_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
ffPrintError(FF_POWERADAPTER_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
}
|
||||
}
|
||||
|
||||
ffPrintPowerAdapter(instance, &options);
|
||||
ffPrintPowerAdapter(&options);
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
#define FF_POWERADAPTER_MODULE_NAME "PowerAdapter"
|
||||
|
||||
void ffPrintPowerAdapter(FFinstance* instance, FFPowerAdapterOptions* options);
|
||||
void ffPrintPowerAdapter(FFPowerAdapterOptions* options);
|
||||
void ffInitPowerAdapterOptions(FFPowerAdapterOptions* options);
|
||||
bool ffParsePowerAdapterCommandOptions(FFPowerAdapterOptions* options, const char* key, const char* value);
|
||||
void ffDestroyPowerAdapterOptions(FFPowerAdapterOptions* options);
|
||||
void ffParsePowerAdapterJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
void ffParsePowerAdapterJsonObject(yyjson_val* module);
|
||||
|
||||
@@ -6,26 +6,26 @@
|
||||
|
||||
#define FF_PROCESSES_NUM_FORMAT_ARGS 1
|
||||
|
||||
void ffPrintProcesses(FFinstance* instance, FFProcessesOptions* options)
|
||||
void ffPrintProcesses(FFProcessesOptions* options)
|
||||
{
|
||||
uint32_t numProcesses = 0;
|
||||
const char* error = ffDetectProcesses(&numProcesses);
|
||||
|
||||
if(error)
|
||||
{
|
||||
ffPrintError(instance, FF_PROCESSES_MODULE_NAME, 0, &options->moduleArgs, "%s", error);
|
||||
ffPrintError(FF_PROCESSES_MODULE_NAME, 0, &options->moduleArgs, "%s", error);
|
||||
return;
|
||||
}
|
||||
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
{
|
||||
ffPrintLogoAndKey(instance, FF_PROCESSES_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
ffPrintLogoAndKey(FF_PROCESSES_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
|
||||
printf("%u\n", numProcesses);
|
||||
}
|
||||
else
|
||||
{
|
||||
ffPrintFormat(instance, FF_PROCESSES_MODULE_NAME, 0, &options->moduleArgs, FF_PROCESSES_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||
ffPrintFormat(FF_PROCESSES_MODULE_NAME, 0, &options->moduleArgs, FF_PROCESSES_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_UINT, &numProcesses}
|
||||
});
|
||||
}
|
||||
@@ -52,7 +52,7 @@ void ffDestroyProcessesOptions(FFProcessesOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
void ffParseProcessesJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
void ffParseProcessesJsonObject(yyjson_val* module)
|
||||
{
|
||||
FFProcessesOptions __attribute__((__cleanup__(ffDestroyProcessesOptions))) options;
|
||||
ffInitProcessesOptions(&options);
|
||||
@@ -70,9 +70,9 @@ void ffParseProcessesJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs))
|
||||
continue;
|
||||
|
||||
ffPrintError(instance, FF_PROCESSES_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
ffPrintError(FF_PROCESSES_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
}
|
||||
}
|
||||
|
||||
ffPrintProcesses(instance, &options);
|
||||
ffPrintProcesses(&options);
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
#define FF_PROCESSES_MODULE_NAME "Processes"
|
||||
|
||||
void ffPrintProcesses(FFinstance* instance, FFProcessesOptions* options);
|
||||
void ffPrintProcesses(FFProcessesOptions* options);
|
||||
void ffInitProcessesOptions(FFProcessesOptions* options);
|
||||
bool ffParseProcessesCommandOptions(FFProcessesOptions* options, const char* key, const char* value);
|
||||
void ffDestroyProcessesOptions(FFProcessesOptions* options);
|
||||
void ffParseProcessesJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
void ffParseProcessesJsonObject(yyjson_val* module);
|
||||
|
||||
@@ -32,14 +32,14 @@ void ffPreparePublicIp(FFPublicIpOptions* options)
|
||||
}
|
||||
}
|
||||
|
||||
void ffPrintPublicIp(FFinstance* instance, FFPublicIpOptions* options)
|
||||
void ffPrintPublicIp(FFPublicIpOptions* options)
|
||||
{
|
||||
if (status == -1)
|
||||
ffPreparePublicIp(options);
|
||||
|
||||
if (status == 0)
|
||||
{
|
||||
ffPrintError(instance, FF_PUBLICIP_DISPLAY_NAME, 0, &options->moduleArgs, "Failed to connect to an IP detection server");
|
||||
ffPrintError(FF_PUBLICIP_DISPLAY_NAME, 0, &options->moduleArgs, "Failed to connect to an IP detection server");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -49,18 +49,18 @@ void ffPrintPublicIp(FFinstance* instance, FFPublicIpOptions* options)
|
||||
|
||||
if (!success || result.length == 0)
|
||||
{
|
||||
ffPrintError(instance, FF_PUBLICIP_DISPLAY_NAME, 0, &options->moduleArgs, "Failed to receive the server response");
|
||||
ffPrintError(FF_PUBLICIP_DISPLAY_NAME, 0, &options->moduleArgs, "Failed to receive the server response");
|
||||
return;
|
||||
}
|
||||
|
||||
if (options->moduleArgs.outputFormat.length == 0)
|
||||
{
|
||||
ffPrintLogoAndKey(instance, FF_PUBLICIP_DISPLAY_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
ffPrintLogoAndKey(FF_PUBLICIP_DISPLAY_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
ffStrbufPutTo(&result, stdout);
|
||||
}
|
||||
else
|
||||
{
|
||||
ffPrintFormat(instance, FF_PUBLICIP_DISPLAY_NAME, 0, &options->moduleArgs, FF_PUBLICIP_NUM_FORMAT_ARGS, (FFformatarg[]) {
|
||||
ffPrintFormat(FF_PUBLICIP_DISPLAY_NAME, 0, &options->moduleArgs, FF_PUBLICIP_NUM_FORMAT_ARGS, (FFformatarg[]) {
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result}
|
||||
});
|
||||
}
|
||||
@@ -104,7 +104,7 @@ void ffDestroyPublicIpOptions(FFPublicIpOptions* options)
|
||||
ffStrbufDestroy(&options->url);
|
||||
}
|
||||
|
||||
void ffParsePublicIpJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
void ffParsePublicIpJsonObject(yyjson_val* module)
|
||||
{
|
||||
FFPublicIpOptions __attribute__((__cleanup__(ffDestroyPublicIpOptions))) options;
|
||||
ffInitPublicIpOptions(&options);
|
||||
@@ -134,9 +134,9 @@ void ffParsePublicIpJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
continue;
|
||||
}
|
||||
|
||||
ffPrintError(instance, FF_PUBLICIP_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
ffPrintError(FF_PUBLICIP_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
}
|
||||
}
|
||||
|
||||
ffPrintPublicIp(instance, &options);
|
||||
ffPrintPublicIp(&options);
|
||||
}
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
|
||||
void ffPreparePublicIp(FFPublicIpOptions* options);
|
||||
|
||||
void ffPrintPublicIp(FFinstance* instance, FFPublicIpOptions* options);
|
||||
void ffPrintPublicIp(FFPublicIpOptions* options);
|
||||
void ffInitPublicIpOptions(FFPublicIpOptions* options);
|
||||
bool ffParsePublicIpCommandOptions(FFPublicIpOptions* options, const char* key, const char* value);
|
||||
void ffDestroyPublicIpOptions(FFPublicIpOptions* options);
|
||||
void ffParsePublicIpJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
void ffParsePublicIpJsonObject(yyjson_val* module);
|
||||
|
||||
@@ -3,19 +3,19 @@
|
||||
#include "modules/separator/separator.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
void ffPrintSeparator(FFinstance* instance, FFSeparatorOptions* options)
|
||||
void ffPrintSeparator(FFSeparatorOptions* options)
|
||||
{
|
||||
uint32_t titleLength = instance->state.titleLength;
|
||||
uint32_t titleLength = instance.state.titleLength;
|
||||
if (titleLength == 0)
|
||||
{
|
||||
// Title was not printed, should we support this case?
|
||||
titleLength = instance->state.platform.userName.length + 1 + (instance->config.title.fdqn ?
|
||||
instance->state.platform.domainName.length :
|
||||
instance->state.platform.hostName.length
|
||||
titleLength = instance.state.platform.userName.length + 1 + (instance.config.title.fdqn ?
|
||||
instance.state.platform.domainName.length :
|
||||
instance.state.platform.hostName.length
|
||||
);
|
||||
}
|
||||
|
||||
ffLogoPrintLine(instance);
|
||||
ffLogoPrintLine();
|
||||
|
||||
if(options->string.length == 0)
|
||||
{
|
||||
@@ -59,7 +59,7 @@ void ffDestroySeparatorOptions(FFSeparatorOptions* options)
|
||||
ffStrbufDestroy(&options->string);
|
||||
}
|
||||
|
||||
void ffParseSeparatorJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
void ffParseSeparatorJsonObject(yyjson_val* module)
|
||||
{
|
||||
FFSeparatorOptions __attribute__((__cleanup__(ffDestroySeparatorOptions))) options;
|
||||
ffInitSeparatorOptions(&options);
|
||||
@@ -80,9 +80,9 @@ void ffParseSeparatorJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
continue;
|
||||
}
|
||||
|
||||
ffPrintErrorString(instance, FF_SEPARATOR_MODULE_NAME, 0, NULL, NULL, "Unknown JSON key %s", key);
|
||||
ffPrintErrorString(FF_SEPARATOR_MODULE_NAME, 0, NULL, NULL, "Unknown JSON key %s", key);
|
||||
}
|
||||
}
|
||||
|
||||
ffPrintSeparator(instance, &options);
|
||||
ffPrintSeparator(&options);
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
#define FF_SEPARATOR_MODULE_NAME "Separator"
|
||||
|
||||
void ffPrintSeparator(FFinstance* instance, FFSeparatorOptions* options);
|
||||
void ffPrintSeparator(FFSeparatorOptions* options);
|
||||
void ffInitSeparatorOptions(FFSeparatorOptions* options);
|
||||
bool ffParseSeparatorCommandOptions(FFSeparatorOptions* options, const char* key, const char* value);
|
||||
void ffDestroySeparatorOptions(FFSeparatorOptions* options);
|
||||
void ffParseSeparatorJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
void ffParseSeparatorJsonObject(yyjson_val* module);
|
||||
|
||||
@@ -6,19 +6,19 @@
|
||||
|
||||
#define FF_SHELL_NUM_FORMAT_ARGS 7
|
||||
|
||||
void ffPrintShell(FFinstance* instance, FFShellOptions* options)
|
||||
void ffPrintShell(FFShellOptions* options)
|
||||
{
|
||||
const FFTerminalShellResult* result = ffDetectTerminalShell(instance);
|
||||
const FFTerminalShellResult* result = ffDetectTerminalShell();
|
||||
|
||||
if(result->shellProcessName.length == 0)
|
||||
{
|
||||
ffPrintError(instance, FF_SHELL_MODULE_NAME, 0, &options->moduleArgs, "Couldn't detect shell");
|
||||
ffPrintError(FF_SHELL_MODULE_NAME, 0, &options->moduleArgs, "Couldn't detect shell");
|
||||
return;
|
||||
}
|
||||
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
{
|
||||
ffPrintLogoAndKey(instance, FF_SHELL_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
ffPrintLogoAndKey(FF_SHELL_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
ffStrbufWriteTo(&result->shellPrettyName, stdout);
|
||||
|
||||
if(result->shellVersion.length > 0)
|
||||
@@ -31,7 +31,7 @@ void ffPrintShell(FFinstance* instance, FFShellOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
ffPrintFormat(instance, FF_SHELL_MODULE_NAME, 0, &options->moduleArgs, FF_SHELL_NUM_FORMAT_ARGS, (FFformatarg[]) {
|
||||
ffPrintFormat(FF_SHELL_MODULE_NAME, 0, &options->moduleArgs, FF_SHELL_NUM_FORMAT_ARGS, (FFformatarg[]) {
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->shellProcessName},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->shellExe},
|
||||
{FF_FORMAT_ARG_TYPE_STRING, result->shellExeName},
|
||||
@@ -64,7 +64,7 @@ void ffDestroyShellOptions(FFShellOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
void ffParseShellJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
void ffParseShellJsonObject(yyjson_val* module)
|
||||
{
|
||||
FFShellOptions __attribute__((__cleanup__(ffDestroyShellOptions))) options;
|
||||
ffInitShellOptions(&options);
|
||||
@@ -82,9 +82,9 @@ void ffParseShellJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs))
|
||||
continue;
|
||||
|
||||
ffPrintError(instance, FF_SHELL_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
ffPrintError(FF_SHELL_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
}
|
||||
}
|
||||
|
||||
ffPrintShell(instance, &options);
|
||||
ffPrintShell(&options);
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
#define FF_SHELL_MODULE_NAME "Shell"
|
||||
|
||||
void ffPrintShell(FFinstance* instance, FFShellOptions* options);
|
||||
void ffPrintShell(FFShellOptions* options);
|
||||
void ffInitShellOptions(FFShellOptions* options);
|
||||
bool ffParseShellCommandOptions(FFShellOptions* options, const char* key, const char* value);
|
||||
void ffDestroyShellOptions(FFShellOptions* options);
|
||||
void ffParseShellJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
void ffParseShellJsonObject(yyjson_val* module);
|
||||
|
||||
+12
-12
@@ -6,11 +6,11 @@
|
||||
|
||||
#define FF_SOUND_NUM_FORMAT_ARGS 4
|
||||
|
||||
static void printDevice(FFinstance* instance, FFSoundOptions* options, const FFSoundDevice* device, uint8_t index)
|
||||
static void printDevice(FFSoundOptions* options, const FFSoundDevice* device, uint8_t index)
|
||||
{
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
{
|
||||
ffPrintLogoAndKey(instance, FF_SOUND_MODULE_NAME, index, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
ffPrintLogoAndKey(FF_SOUND_MODULE_NAME, index, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
ffStrbufWriteTo(&device->name, stdout);
|
||||
|
||||
if(device->volume != FF_SOUND_VOLUME_UNKNOWN)
|
||||
@@ -28,7 +28,7 @@ static void printDevice(FFinstance* instance, FFSoundOptions* options, const FFS
|
||||
}
|
||||
else
|
||||
{
|
||||
ffPrintFormat(instance, FF_SOUND_MODULE_NAME, index, &options->moduleArgs, FF_SOUND_NUM_FORMAT_ARGS, (FFformatarg[]) {
|
||||
ffPrintFormat(FF_SOUND_MODULE_NAME, index, &options->moduleArgs, FF_SOUND_NUM_FORMAT_ARGS, (FFformatarg[]) {
|
||||
{FF_FORMAT_ARG_TYPE_BOOL, &device->main},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &device->name},
|
||||
{FF_FORMAT_ARG_TYPE_UINT8, &device->volume},
|
||||
@@ -37,15 +37,15 @@ static void printDevice(FFinstance* instance, FFSoundOptions* options, const FFS
|
||||
}
|
||||
}
|
||||
|
||||
void ffPrintSound(FFinstance* instance, FFSoundOptions* options)
|
||||
void ffPrintSound(FFSoundOptions* options)
|
||||
{
|
||||
FF_LIST_AUTO_DESTROY result = ffListCreate(sizeof(FFSoundDevice));
|
||||
|
||||
const char* error = ffDetectSound(instance, &result);
|
||||
const char* error = ffDetectSound(&result);
|
||||
|
||||
if(error)
|
||||
{
|
||||
ffPrintError(instance, FF_SOUND_MODULE_NAME, 0, &options->moduleArgs, "%s", error);
|
||||
ffPrintError(FF_SOUND_MODULE_NAME, 0, &options->moduleArgs, "%s", error);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -65,14 +65,14 @@ void ffPrintSound(FFinstance* instance, FFSoundOptions* options)
|
||||
|
||||
if(filtered.length == 0)
|
||||
{
|
||||
ffPrintError(instance, FF_SOUND_MODULE_NAME, 0, &options->moduleArgs, "No active sound devices found");
|
||||
ffPrintError(FF_SOUND_MODULE_NAME, 0, &options->moduleArgs, "No active sound devices found");
|
||||
return;
|
||||
}
|
||||
|
||||
uint8_t index = 1;
|
||||
FF_LIST_FOR_EACH(FFSoundDevice*, device, filtered)
|
||||
{
|
||||
printDevice(instance, options, *device, filtered.length == 1 ? 0 : index++);
|
||||
printDevice(options, *device, filtered.length == 1 ? 0 : index++);
|
||||
}
|
||||
|
||||
FF_LIST_FOR_EACH(FFSoundDevice, device, result)
|
||||
@@ -117,7 +117,7 @@ void ffDestroySoundOptions(FFSoundOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
void ffParseSoundJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
void ffParseSoundJsonObject(yyjson_val* module)
|
||||
{
|
||||
FFSoundOptions __attribute__((__cleanup__(ffDestroySoundOptions))) options;
|
||||
ffInitSoundOptions(&options);
|
||||
@@ -145,15 +145,15 @@ void ffParseSoundJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
{},
|
||||
});
|
||||
if (error)
|
||||
ffPrintError(instance, FF_SOUND_MODULE_NAME, 0, &options.moduleArgs, "Invalid %s value: %s", key, error);
|
||||
ffPrintError(FF_SOUND_MODULE_NAME, 0, &options.moduleArgs, "Invalid %s value: %s", key, error);
|
||||
else
|
||||
options.soundType = (FFSoundType) value;
|
||||
continue;
|
||||
}
|
||||
|
||||
ffPrintError(instance, FF_SOUND_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
ffPrintError(FF_SOUND_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
}
|
||||
}
|
||||
|
||||
ffPrintSound(instance, &options);
|
||||
ffPrintSound(&options);
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
#define FF_SOUND_MODULE_NAME "Sound"
|
||||
|
||||
void ffPrintSound(FFinstance* instance, FFSoundOptions* options);
|
||||
void ffPrintSound(FFSoundOptions* options);
|
||||
void ffInitSoundOptions(FFSoundOptions* options);
|
||||
bool ffParseSoundCommandOptions(FFSoundOptions* options, const char* key, const char* value);
|
||||
void ffDestroySoundOptions(FFSoundOptions* options);
|
||||
void ffParseSoundJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
void ffParseSoundJsonObject(yyjson_val* module);
|
||||
|
||||
+14
-14
@@ -8,22 +8,22 @@
|
||||
|
||||
#define FF_SWAP_NUM_FORMAT_ARGS 3
|
||||
|
||||
void ffPrintSwap(FFinstance* instance, FFSwapOptions* options)
|
||||
void ffPrintSwap(FFSwapOptions* options)
|
||||
{
|
||||
FFSwapResult storage;
|
||||
const char* error = ffDetectSwap(&storage);
|
||||
|
||||
if(error)
|
||||
{
|
||||
ffPrintError(instance, FF_SWAP_MODULE_NAME, 0, &options->moduleArgs, "%s", error);
|
||||
ffPrintError(FF_SWAP_MODULE_NAME, 0, &options->moduleArgs, "%s", error);
|
||||
return;
|
||||
}
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY usedPretty = ffStrbufCreate();
|
||||
ffParseSize(storage.bytesUsed, instance->config.binaryPrefixType, &usedPretty);
|
||||
ffParseSize(storage.bytesUsed, instance.config.binaryPrefixType, &usedPretty);
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY totalPretty = ffStrbufCreate();
|
||||
ffParseSize(storage.bytesTotal, instance->config.binaryPrefixType, &totalPretty);
|
||||
ffParseSize(storage.bytesTotal, instance.config.binaryPrefixType, &totalPretty);
|
||||
|
||||
uint8_t percentage = storage.bytesTotal == 0
|
||||
? 0
|
||||
@@ -31,24 +31,24 @@ void ffPrintSwap(FFinstance* instance, FFSwapOptions* options)
|
||||
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
{
|
||||
ffPrintLogoAndKey(instance, FF_SWAP_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
ffPrintLogoAndKey(FF_SWAP_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
if (storage.bytesTotal == 0)
|
||||
puts("Disabled");
|
||||
else
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY str = ffStrbufCreate();
|
||||
|
||||
if(instance->config.percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
|
||||
if(instance.config.percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
|
||||
{
|
||||
ffAppendPercentBar(instance, &str, percentage, 0, 5, 8);
|
||||
ffAppendPercentBar(&str, percentage, 0, 5, 8);
|
||||
ffStrbufAppendC(&str, ' ');
|
||||
}
|
||||
|
||||
if(!(instance->config.percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT))
|
||||
if(!(instance.config.percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT))
|
||||
ffStrbufAppendF(&str, "%s / %s ", usedPretty.chars, totalPretty.chars);
|
||||
|
||||
if(instance->config.percentType & FF_PERCENTAGE_TYPE_NUM_BIT)
|
||||
ffAppendPercentNum(instance, &str, (uint8_t) percentage, 50, 80, str.length > 0);
|
||||
if(instance.config.percentType & FF_PERCENTAGE_TYPE_NUM_BIT)
|
||||
ffAppendPercentNum(&str, (uint8_t) percentage, 50, 80, str.length > 0);
|
||||
|
||||
ffStrbufTrimRight(&str, ' ');
|
||||
ffStrbufPutTo(&str, stdout);
|
||||
@@ -56,7 +56,7 @@ void ffPrintSwap(FFinstance* instance, FFSwapOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
ffPrintFormat(instance, FF_SWAP_MODULE_NAME, 0, &options->moduleArgs, FF_SWAP_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||
ffPrintFormat(FF_SWAP_MODULE_NAME, 0, &options->moduleArgs, FF_SWAP_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &usedPretty},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &totalPretty},
|
||||
{FF_FORMAT_ARG_TYPE_UINT8, &percentage},
|
||||
@@ -85,7 +85,7 @@ void ffDestroySwapOptions(FFSwapOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
void ffParseSwapJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
void ffParseSwapJsonObject(yyjson_val* module)
|
||||
{
|
||||
FFSwapOptions __attribute__((__cleanup__(ffDestroySwapOptions))) options;
|
||||
ffInitSwapOptions(&options);
|
||||
@@ -103,9 +103,9 @@ void ffParseSwapJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs))
|
||||
continue;
|
||||
|
||||
ffPrintError(instance, FF_SWAP_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
ffPrintError(FF_SWAP_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
}
|
||||
}
|
||||
|
||||
ffPrintSwap(instance, &options);
|
||||
ffPrintSwap(&options);
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
#define FF_SWAP_MODULE_NAME "Swap"
|
||||
|
||||
void ffPrintSwap(FFinstance* instance, FFSwapOptions* options);
|
||||
void ffPrintSwap(FFSwapOptions* options);
|
||||
void ffInitSwapOptions(FFSwapOptions* options);
|
||||
bool ffParseSwapCommandOptions(FFSwapOptions* options, const char* key, const char* value);
|
||||
void ffDestroySwapOptions(FFSwapOptions* options);
|
||||
void ffParseSwapJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
void ffParseSwapJsonObject(yyjson_val* module);
|
||||
|
||||
@@ -8,19 +8,19 @@
|
||||
|
||||
#define FF_TERMINAL_NUM_FORMAT_ARGS 10
|
||||
|
||||
void ffPrintTerminal(FFinstance* instance, FFTerminalOptions* options)
|
||||
void ffPrintTerminal(FFTerminalOptions* options)
|
||||
{
|
||||
const FFTerminalShellResult* result = ffDetectTerminalShell(instance);
|
||||
const FFTerminalShellResult* result = ffDetectTerminalShell();
|
||||
|
||||
if(result->terminalProcessName.length == 0)
|
||||
{
|
||||
ffPrintError(instance, FF_TERMINAL_MODULE_NAME, 0, &options->moduleArgs, "Couldn't detect terminal");
|
||||
ffPrintError(FF_TERMINAL_MODULE_NAME, 0, &options->moduleArgs, "Couldn't detect terminal");
|
||||
return;
|
||||
}
|
||||
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
{
|
||||
ffPrintLogoAndKey(instance, FF_TERMINAL_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
ffPrintLogoAndKey(FF_TERMINAL_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
|
||||
if(result->terminalVersion.length)
|
||||
printf("%s %s\n", result->terminalPrettyName.chars, result->terminalVersion.chars);
|
||||
@@ -29,7 +29,7 @@ void ffPrintTerminal(FFinstance* instance, FFTerminalOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
ffPrintFormat(instance, FF_TERMINAL_MODULE_NAME, 0, &options->moduleArgs, FF_TERMINAL_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||
ffPrintFormat(FF_TERMINAL_MODULE_NAME, 0, &options->moduleArgs, FF_TERMINAL_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->terminalProcessName},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->terminalExe},
|
||||
{FF_FORMAT_ARG_TYPE_STRING, result->terminalExeName},
|
||||
@@ -65,7 +65,7 @@ void ffDestroyTerminalOptions(FFTerminalOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
void ffParseTerminalJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
void ffParseTerminalJsonObject(yyjson_val* module)
|
||||
{
|
||||
FFTerminalOptions __attribute__((__cleanup__(ffDestroyTerminalOptions))) options;
|
||||
ffInitTerminalOptions(&options);
|
||||
@@ -83,9 +83,9 @@ void ffParseTerminalJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs))
|
||||
continue;
|
||||
|
||||
ffPrintError(instance, FF_TERMINAL_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
ffPrintError(FF_TERMINAL_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
}
|
||||
}
|
||||
|
||||
ffPrintTerminal(instance, &options);
|
||||
ffPrintTerminal(&options);
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
#define FF_TERMINAL_MODULE_NAME "Terminal"
|
||||
|
||||
void ffPrintTerminal(FFinstance* instance, FFTerminalOptions* options);
|
||||
void ffPrintTerminal(FFTerminalOptions* options);
|
||||
void ffInitTerminalOptions(FFTerminalOptions* options);
|
||||
bool ffParseTerminalCommandOptions(FFTerminalOptions* options, const char* key, const char* value);
|
||||
void ffDestroyTerminalOptions(FFTerminalOptions* options);
|
||||
void ffParseTerminalJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
void ffParseTerminalJsonObject(yyjson_val* module);
|
||||
|
||||
@@ -7,26 +7,26 @@
|
||||
#define FF_TERMINALFONT_DISPLAY_NAME "Terminal Font"
|
||||
#define FF_TERMINALFONT_NUM_FORMAT_ARGS 4
|
||||
|
||||
void ffPrintTerminalFont(FFinstance* instance, FFTerminalFontOptions* options)
|
||||
void ffPrintTerminalFont(FFTerminalFontOptions* options)
|
||||
{
|
||||
FFTerminalFontResult terminalFont;
|
||||
ffFontInit(&terminalFont.font);
|
||||
ffStrbufInit(&terminalFont.error);
|
||||
|
||||
if(!ffDetectTerminalFont(instance, &terminalFont))
|
||||
if(!ffDetectTerminalFont(&terminalFont))
|
||||
{
|
||||
ffPrintError(instance, FF_TERMINALFONT_DISPLAY_NAME, 0, &options->moduleArgs, "%s", terminalFont.error.chars);
|
||||
ffPrintError(FF_TERMINALFONT_DISPLAY_NAME, 0, &options->moduleArgs, "%s", terminalFont.error.chars);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
{
|
||||
ffPrintLogoAndKey(instance, FF_TERMINALFONT_DISPLAY_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
ffPrintLogoAndKey(FF_TERMINALFONT_DISPLAY_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
ffStrbufPutTo(&terminalFont.font.pretty, stdout);
|
||||
}
|
||||
else
|
||||
{
|
||||
ffPrintFormat(instance, FF_TERMINALFONT_DISPLAY_NAME, 0, &options->moduleArgs, FF_TERMINALFONT_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||
ffPrintFormat(FF_TERMINALFONT_DISPLAY_NAME, 0, &options->moduleArgs, 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},
|
||||
@@ -60,7 +60,7 @@ void ffDestroyTerminalFontOptions(FFTerminalFontOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
void ffParseTerminalFontJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
void ffParseTerminalFontJsonObject(yyjson_val* module)
|
||||
{
|
||||
FFTerminalFontOptions __attribute__((__cleanup__(ffDestroyTerminalFontOptions))) options;
|
||||
ffInitTerminalFontOptions(&options);
|
||||
@@ -78,9 +78,9 @@ void ffParseTerminalFontJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs))
|
||||
continue;
|
||||
|
||||
ffPrintError(instance, FF_TERMINALFONT_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
ffPrintError(FF_TERMINALFONT_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
}
|
||||
}
|
||||
|
||||
ffPrintTerminalFont(instance, &options);
|
||||
ffPrintTerminalFont(&options);
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
#define FF_TERMINALFONT_MODULE_NAME "TerminalFont"
|
||||
|
||||
void ffPrintTerminalFont(FFinstance* instance, FFTerminalFontOptions* options);
|
||||
void ffPrintTerminalFont(FFTerminalFontOptions* options);
|
||||
void ffInitTerminalFontOptions(FFTerminalFontOptions* options);
|
||||
bool ffParseTerminalFontCommandOptions(FFTerminalFontOptions* options, const char* key, const char* value);
|
||||
void ffDestroyTerminalFontOptions(FFTerminalFontOptions* options);
|
||||
void ffParseTerminalFontJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
void ffParseTerminalFontJsonObject(yyjson_val* module);
|
||||
|
||||
@@ -6,25 +6,25 @@
|
||||
|
||||
#define FF_THEME_NUM_FORMAT_ARGS 1
|
||||
|
||||
void ffPrintTheme(FFinstance* instance, FFThemeOptions* options)
|
||||
void ffPrintTheme(FFThemeOptions* options)
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY theme = ffStrbufCreate();
|
||||
const char* error = ffDetectTheme(instance, &theme);
|
||||
const char* error = ffDetectTheme(&theme);
|
||||
|
||||
if(error)
|
||||
{
|
||||
ffPrintError(instance, FF_THEME_MODULE_NAME, 0, &options->moduleArgs, "%s", error);
|
||||
ffPrintError(FF_THEME_MODULE_NAME, 0, &options->moduleArgs, "%s", error);
|
||||
return;
|
||||
}
|
||||
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
{
|
||||
ffPrintLogoAndKey(instance, FF_THEME_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
ffPrintLogoAndKey(FF_THEME_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
ffStrbufPutTo(&theme, stdout);
|
||||
}
|
||||
else
|
||||
{
|
||||
ffPrintFormat(instance, FF_THEME_MODULE_NAME, 0, &options->moduleArgs, FF_THEME_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||
ffPrintFormat(FF_THEME_MODULE_NAME, 0, &options->moduleArgs, FF_THEME_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &theme}
|
||||
});
|
||||
}
|
||||
@@ -51,7 +51,7 @@ void ffDestroyThemeOptions(FFThemeOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
void ffParseThemeJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
void ffParseThemeJsonObject(yyjson_val* module)
|
||||
{
|
||||
FFThemeOptions __attribute__((__cleanup__(ffDestroyThemeOptions))) options;
|
||||
ffInitThemeOptions(&options);
|
||||
@@ -69,9 +69,9 @@ void ffParseThemeJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs))
|
||||
continue;
|
||||
|
||||
ffPrintError(instance, FF_THEME_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
ffPrintError(FF_THEME_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
}
|
||||
}
|
||||
|
||||
ffPrintTheme(instance, &options);
|
||||
ffPrintTheme(&options);
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
#define FF_THEME_MODULE_NAME "Theme"
|
||||
|
||||
void ffPrintTheme(FFinstance* instance, FFThemeOptions* options);
|
||||
void ffPrintTheme(FFThemeOptions* options);
|
||||
void ffInitThemeOptions(FFThemeOptions* options);
|
||||
bool ffParseThemeCommandOptions(FFThemeOptions* options, const char* key, const char* value);
|
||||
void ffDestroyThemeOptions(FFThemeOptions* options);
|
||||
void ffParseThemeJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
void ffParseThemeJsonObject(yyjson_val* module);
|
||||
|
||||
+14
-14
@@ -4,32 +4,32 @@
|
||||
#include "util/textModifier.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
static inline void printTitlePart(FFinstance* instance, const FFstrbuf* content)
|
||||
static inline void printTitlePart(const FFstrbuf* content)
|
||||
{
|
||||
if(!instance->config.pipe)
|
||||
if(!instance.config.pipe)
|
||||
{
|
||||
fputs(FASTFETCH_TEXT_MODIFIER_BOLT, stdout);
|
||||
ffPrintColor(&instance->config.colorTitle);
|
||||
ffPrintColor(&instance.config.colorTitle);
|
||||
}
|
||||
|
||||
ffStrbufWriteTo(content, stdout);
|
||||
|
||||
if(!instance->config.pipe)
|
||||
if(!instance.config.pipe)
|
||||
fputs(FASTFETCH_TEXT_MODIFIER_RESET, stdout);
|
||||
}
|
||||
|
||||
void ffPrintTitle(FFinstance* instance, FFTitleOptions* options)
|
||||
void ffPrintTitle(FFTitleOptions* options)
|
||||
{
|
||||
ffLogoPrintLine(instance);
|
||||
ffLogoPrintLine();
|
||||
|
||||
printTitlePart(instance, &instance->state.platform.userName);
|
||||
printTitlePart(&instance.state.platform.userName);
|
||||
putchar('@');
|
||||
FFstrbuf* host = options->fdqn ?
|
||||
&instance->state.platform.domainName :
|
||||
&instance->state.platform.hostName;
|
||||
printTitlePart(instance, host);
|
||||
&instance.state.platform.domainName :
|
||||
&instance.state.platform.hostName;
|
||||
printTitlePart(host);
|
||||
|
||||
instance->state.titleLength = instance->state.platform.userName.length + host->length + 1;
|
||||
instance.state.titleLength = instance.state.platform.userName.length + host->length + 1;
|
||||
|
||||
putchar('\n');
|
||||
}
|
||||
@@ -59,7 +59,7 @@ void ffDestroyTitleOptions(FFTitleOptions* options)
|
||||
FF_UNUSED(options);
|
||||
}
|
||||
|
||||
void ffParseTitleJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
void ffParseTitleJsonObject(yyjson_val* module)
|
||||
{
|
||||
FFTitleOptions __attribute__((__cleanup__(ffDestroyTitleOptions))) options;
|
||||
ffInitTitleOptions(&options);
|
||||
@@ -80,9 +80,9 @@ void ffParseTitleJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
continue;
|
||||
}
|
||||
|
||||
ffPrintErrorString(instance, FF_TITLE_MODULE_NAME, 0, NULL, NULL, "Unknown JSON key %s", key);
|
||||
ffPrintErrorString(FF_TITLE_MODULE_NAME, 0, NULL, NULL, "Unknown JSON key %s", key);
|
||||
}
|
||||
}
|
||||
|
||||
ffPrintTitle(instance, &options);
|
||||
ffPrintTitle(&options);
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
#define FF_TITLE_MODULE_NAME "Title"
|
||||
|
||||
void ffPrintTitle(FFinstance* instance, FFTitleOptions* options);
|
||||
void ffPrintTitle(FFTitleOptions* options);
|
||||
void ffInitTitleOptions(FFTitleOptions* options);
|
||||
bool ffParseTitleCommandOptions(FFTitleOptions* options, const char* key, const char* value);
|
||||
void ffDestroyTitleOptions(FFTitleOptions* options);
|
||||
void ffParseTitleJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
void ffParseTitleJsonObject(yyjson_val* module);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#define FF_UPTIME_NUM_FORMAT_ARGS 4
|
||||
|
||||
void ffPrintUptime(FFinstance* instance, FFUptimeOptions* options)
|
||||
void ffPrintUptime(FFUptimeOptions* options)
|
||||
{
|
||||
uint64_t uptime;
|
||||
|
||||
@@ -14,7 +14,7 @@ void ffPrintUptime(FFinstance* instance, FFUptimeOptions* options)
|
||||
|
||||
if(error)
|
||||
{
|
||||
ffPrintError(instance, FF_UPTIME_MODULE_NAME, 0, &options->moduleArgs, "%s", error);
|
||||
ffPrintError(FF_UPTIME_MODULE_NAME, 0, &options->moduleArgs, "%s", error);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ void ffPrintUptime(FFinstance* instance, FFUptimeOptions* options)
|
||||
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
{
|
||||
ffPrintLogoAndKey(instance, FF_UPTIME_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
ffPrintLogoAndKey(FF_UPTIME_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
|
||||
if(days == 0 && hours == 0 && minutes == 0)
|
||||
{
|
||||
@@ -70,7 +70,7 @@ void ffPrintUptime(FFinstance* instance, FFUptimeOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
ffPrintFormat(instance, FF_UPTIME_MODULE_NAME, 0, &options->moduleArgs, FF_UPTIME_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||
ffPrintFormat(FF_UPTIME_MODULE_NAME, 0, &options->moduleArgs, FF_UPTIME_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_UINT, &days},
|
||||
{FF_FORMAT_ARG_TYPE_UINT, &hours},
|
||||
{FF_FORMAT_ARG_TYPE_UINT, &minutes},
|
||||
@@ -100,7 +100,7 @@ void ffDestroyUptimeOptions(FFUptimeOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
void ffParseUptimeJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
void ffParseUptimeJsonObject(yyjson_val* module)
|
||||
{
|
||||
FFUptimeOptions __attribute__((__cleanup__(ffDestroyUptimeOptions))) options;
|
||||
ffInitUptimeOptions(&options);
|
||||
@@ -118,9 +118,9 @@ void ffParseUptimeJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs))
|
||||
continue;
|
||||
|
||||
ffPrintError(instance, FF_UPTIME_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
ffPrintError(FF_UPTIME_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
}
|
||||
}
|
||||
|
||||
ffPrintUptime(instance, &options);
|
||||
ffPrintUptime(&options);
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
#define FF_UPTIME_MODULE_NAME "Uptime"
|
||||
|
||||
void ffPrintUptime(FFinstance* instance, FFUptimeOptions* options);
|
||||
void ffPrintUptime(FFUptimeOptions* options);
|
||||
void ffInitUptimeOptions(FFUptimeOptions* options);
|
||||
bool ffParseUptimeCommandOptions(FFUptimeOptions* options, const char* key, const char* value);
|
||||
void ffDestroyUptimeOptions(FFUptimeOptions* options);
|
||||
void ffParseUptimeJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
void ffParseUptimeJsonObject(yyjson_val* module);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#define FF_USERS_NUM_FORMAT_ARGS 1
|
||||
|
||||
void ffPrintUsers(FFinstance* instance, FFUsersOptions* options)
|
||||
void ffPrintUsers(FFUsersOptions* options)
|
||||
{
|
||||
FF_LIST_AUTO_DESTROY users = ffListCreate(sizeof(FFstrbuf));
|
||||
|
||||
@@ -16,7 +16,7 @@ void ffPrintUsers(FFinstance* instance, FFUsersOptions* options)
|
||||
|
||||
if(error.length > 0)
|
||||
{
|
||||
ffPrintError(instance, FF_USERS_MODULE_NAME, 0, &options->moduleArgs, "%*s", error.length, error.chars);
|
||||
ffPrintError(FF_USERS_MODULE_NAME, 0, &options->moduleArgs, "%*s", error.length, error.chars);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -32,12 +32,12 @@ void ffPrintUsers(FFinstance* instance, FFUsersOptions* options)
|
||||
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
{
|
||||
ffPrintLogoAndKey(instance, FF_USERS_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
ffPrintLogoAndKey(FF_USERS_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
puts(result.chars);
|
||||
}
|
||||
else
|
||||
{
|
||||
ffPrintFormat(instance, FF_USERS_MODULE_NAME, 0, &options->moduleArgs, FF_USERS_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||
ffPrintFormat(FF_USERS_MODULE_NAME, 0, &options->moduleArgs, FF_USERS_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result},
|
||||
});
|
||||
}
|
||||
@@ -64,7 +64,7 @@ void ffDestroyUsersOptions(FFUsersOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
void ffParseUsersJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
void ffParseUsersJsonObject(yyjson_val* module)
|
||||
{
|
||||
FFUsersOptions __attribute__((__cleanup__(ffDestroyUsersOptions))) options;
|
||||
ffInitUsersOptions(&options);
|
||||
@@ -82,9 +82,9 @@ void ffParseUsersJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs))
|
||||
continue;
|
||||
|
||||
ffPrintError(instance, FF_USERS_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
ffPrintError(FF_USERS_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
}
|
||||
}
|
||||
|
||||
ffPrintUsers(instance, &options);
|
||||
ffPrintUsers(&options);
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
#define FF_USERS_MODULE_NAME "Users"
|
||||
|
||||
void ffPrintUsers(FFinstance* instance, FFUsersOptions* options);
|
||||
void ffPrintUsers(FFUsersOptions* options);
|
||||
void ffInitUsersOptions(FFUsersOptions* options);
|
||||
bool ffParseUsersCommandOptions(FFUsersOptions* options, const char* key, const char* value);
|
||||
void ffDestroyUsersOptions(FFUsersOptions* options);
|
||||
void ffParseUsersJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
void ffParseUsersJsonObject(yyjson_val* module);
|
||||
|
||||
@@ -6,19 +6,19 @@
|
||||
|
||||
#define FF_VULKAN_NUM_FORMAT_ARGS 3
|
||||
|
||||
void ffPrintVulkan(FFinstance* instance, FFVulkanOptions* options)
|
||||
void ffPrintVulkan(FFVulkanOptions* options)
|
||||
{
|
||||
const FFVulkanResult* vulkan = ffDetectVulkan(instance);
|
||||
const FFVulkanResult* vulkan = ffDetectVulkan();
|
||||
|
||||
if(vulkan->error)
|
||||
{
|
||||
ffPrintError(instance, FF_VULKAN_MODULE_NAME, 0, &options->moduleArgs, "%s", vulkan->error);
|
||||
ffPrintError(FF_VULKAN_MODULE_NAME, 0, &options->moduleArgs, "%s", vulkan->error);
|
||||
return;
|
||||
}
|
||||
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
{
|
||||
ffPrintLogoAndKey(instance, FF_VULKAN_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
ffPrintLogoAndKey(FF_VULKAN_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
|
||||
if(vulkan->apiVersion.length > 0)
|
||||
{
|
||||
@@ -35,7 +35,7 @@ void ffPrintVulkan(FFinstance* instance, FFVulkanOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
ffPrintFormat(instance, FF_VULKAN_MODULE_NAME, 0, &options->moduleArgs, FF_VULKAN_NUM_FORMAT_ARGS, (FFformatarg[]) {
|
||||
ffPrintFormat(FF_VULKAN_MODULE_NAME, 0, &options->moduleArgs, 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}
|
||||
@@ -64,7 +64,7 @@ void ffDestroyVulkanOptions(FFVulkanOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
void ffParseVulkanJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
void ffParseVulkanJsonObject(yyjson_val* module)
|
||||
{
|
||||
FFVulkanOptions __attribute__((__cleanup__(ffDestroyVulkanOptions))) options;
|
||||
ffInitVulkanOptions(&options);
|
||||
@@ -82,9 +82,9 @@ void ffParseVulkanJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs))
|
||||
continue;
|
||||
|
||||
ffPrintError(instance, FF_VULKAN_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
ffPrintError(FF_VULKAN_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
}
|
||||
}
|
||||
|
||||
ffPrintVulkan(instance, &options);
|
||||
ffPrintVulkan(&options);
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
#define FF_VULKAN_MODULE_NAME "Vulkan"
|
||||
|
||||
void ffPrintVulkan(FFinstance* instance, FFVulkanOptions* options);
|
||||
void ffPrintVulkan(FFVulkanOptions* options);
|
||||
void ffInitVulkanOptions(FFVulkanOptions* options);
|
||||
bool ffParseVulkanCommandOptions(FFVulkanOptions* options, const char* key, const char* value);
|
||||
void ffDestroyVulkanOptions(FFVulkanOptions* options);
|
||||
void ffParseVulkanJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
void ffParseVulkanJsonObject(yyjson_val* module);
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
|
||||
#define FF_WALLPAPER_NUM_FORMAT_ARGS 2
|
||||
|
||||
void ffPrintWallpaper(FFinstance* instance, FFWallpaperOptions* options)
|
||||
void ffPrintWallpaper(FFWallpaperOptions* options)
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY fullpath = ffStrbufCreate();
|
||||
const char* error = ffDetectWallpaper(instance, &fullpath);
|
||||
const char* error = ffDetectWallpaper(&fullpath);
|
||||
|
||||
const uint32_t index = ffStrbufLastIndexC(&fullpath,
|
||||
#ifndef _WIN32
|
||||
@@ -24,18 +24,18 @@ void ffPrintWallpaper(FFinstance* instance, FFWallpaperOptions* options)
|
||||
|
||||
if(error)
|
||||
{
|
||||
ffPrintError(instance, FF_WALLPAPER_MODULE_NAME, 0, &options->moduleArgs, "%s", error);
|
||||
ffPrintError(FF_WALLPAPER_MODULE_NAME, 0, &options->moduleArgs, "%s", error);
|
||||
return;
|
||||
}
|
||||
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
{
|
||||
ffPrintLogoAndKey(instance, FF_WALLPAPER_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
ffPrintLogoAndKey(FF_WALLPAPER_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
puts(filename);
|
||||
}
|
||||
else
|
||||
{
|
||||
ffPrintFormat(instance, FF_WALLPAPER_MODULE_NAME, 0, &options->moduleArgs, FF_WALLPAPER_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||
ffPrintFormat(FF_WALLPAPER_MODULE_NAME, 0, &options->moduleArgs, FF_WALLPAPER_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_STRING, filename},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &fullpath},
|
||||
});
|
||||
@@ -63,7 +63,7 @@ void ffDestroyWallpaperOptions(FFWallpaperOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
void ffParseWallpaperJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
void ffParseWallpaperJsonObject(yyjson_val* module)
|
||||
{
|
||||
FFWallpaperOptions __attribute__((__cleanup__(ffDestroyWallpaperOptions))) options;
|
||||
ffInitWallpaperOptions(&options);
|
||||
@@ -81,9 +81,9 @@ void ffParseWallpaperJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs))
|
||||
continue;
|
||||
|
||||
ffPrintError(instance, FF_WALLPAPER_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
ffPrintError(FF_WALLPAPER_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
}
|
||||
}
|
||||
|
||||
ffPrintWallpaper(instance, &options);
|
||||
ffPrintWallpaper(&options);
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
#define FF_WALLPAPER_MODULE_NAME "Wallpaper"
|
||||
|
||||
void ffPrintWallpaper(FFinstance* instance, FFWallpaperOptions* options);
|
||||
void ffPrintWallpaper(FFWallpaperOptions* options);
|
||||
void ffInitWallpaperOptions(FFWallpaperOptions* options);
|
||||
bool ffParseWallpaperCommandOptions(FFWallpaperOptions* options, const char* key, const char* value);
|
||||
void ffDestroyWallpaperOptions(FFWallpaperOptions* options);
|
||||
void ffParseWallpaperJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
void ffParseWallpaperJsonObject(yyjson_val* module);
|
||||
|
||||
@@ -16,14 +16,14 @@ void ffPrepareWeather(FFWeatherOptions* options)
|
||||
status = ffNetworkingSendHttpRequest(&state, "wttr.in", path.chars, "User-Agent: curl/0.0.0\r\n");
|
||||
}
|
||||
|
||||
void ffPrintWeather(FFinstance* instance, FFWeatherOptions* options)
|
||||
void ffPrintWeather(FFWeatherOptions* options)
|
||||
{
|
||||
if(status == -1)
|
||||
ffPrepareWeather(options);
|
||||
|
||||
if(status == 0)
|
||||
{
|
||||
ffPrintError(instance, FF_WEATHER_MODULE_NAME, 0, &options->moduleArgs, "Failed to connect to 'wttr.in'");
|
||||
ffPrintError(FF_WEATHER_MODULE_NAME, 0, &options->moduleArgs, "Failed to connect to 'wttr.in'");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -33,18 +33,18 @@ void ffPrintWeather(FFinstance* instance, FFWeatherOptions* options)
|
||||
|
||||
if(!success || result.length == 0)
|
||||
{
|
||||
ffPrintError(instance, FF_WEATHER_MODULE_NAME, 0, &options->moduleArgs, "Failed to receive the server response");
|
||||
ffPrintError(FF_WEATHER_MODULE_NAME, 0, &options->moduleArgs, "Failed to receive the server response");
|
||||
return;
|
||||
}
|
||||
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
{
|
||||
ffPrintLogoAndKey(instance, FF_WEATHER_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
ffPrintLogoAndKey(FF_WEATHER_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
ffStrbufPutTo(&result, stdout);
|
||||
}
|
||||
else
|
||||
{
|
||||
ffPrintFormat(instance, FF_WEATHER_MODULE_NAME, 0, &options->moduleArgs, FF_WEATHER_NUM_FORMAT_ARGS, (FFformatarg[]) {
|
||||
ffPrintFormat(FF_WEATHER_MODULE_NAME, 0, &options->moduleArgs, FF_WEATHER_NUM_FORMAT_ARGS, (FFformatarg[]) {
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result}
|
||||
});
|
||||
}
|
||||
@@ -88,7 +88,7 @@ void ffDestroyWeatherOptions(FFWeatherOptions* options)
|
||||
ffStrbufDestroy(&options->outputFormat);
|
||||
}
|
||||
|
||||
void ffParseWeatherJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
void ffParseWeatherJsonObject(yyjson_val* module)
|
||||
{
|
||||
FFWeatherOptions __attribute__((__cleanup__(ffDestroyWeatherOptions))) options;
|
||||
ffInitWeatherOptions(&options);
|
||||
@@ -118,9 +118,9 @@ void ffParseWeatherJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
continue;
|
||||
}
|
||||
|
||||
ffPrintError(instance, FF_WEATHER_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
ffPrintError(FF_WEATHER_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
}
|
||||
}
|
||||
|
||||
ffPrintWeather(instance, &options);
|
||||
ffPrintWeather(&options);
|
||||
}
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
|
||||
void ffPrepareWeather(FFWeatherOptions* options);
|
||||
|
||||
void ffPrintWeather(FFinstance* instance, FFWeatherOptions* options);
|
||||
void ffPrintWeather(FFWeatherOptions* options);
|
||||
void ffInitWeatherOptions(FFWeatherOptions* options);
|
||||
bool ffParseWeatherCommandOptions(FFWeatherOptions* options, const char* key, const char* value);
|
||||
void ffDestroyWeatherOptions(FFWeatherOptions* options);
|
||||
void ffParseWeatherJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
void ffParseWeatherJsonObject(yyjson_val* module);
|
||||
|
||||
@@ -6,19 +6,19 @@
|
||||
|
||||
#define FF_WIFI_NUM_FORMAT_ARGS 10
|
||||
|
||||
void ffPrintWifi(FFinstance* instance, FFWifiOptions* options)
|
||||
void ffPrintWifi(FFWifiOptions* options)
|
||||
{
|
||||
FF_LIST_AUTO_DESTROY result = ffListCreate(sizeof(FFWifiResult));
|
||||
|
||||
const char* error = ffDetectWifi(instance, &result);
|
||||
const char* error = ffDetectWifi(&result);
|
||||
if(error)
|
||||
{
|
||||
ffPrintError(instance, FF_WIFI_MODULE_NAME, 0, &options->moduleArgs, "%s", error);
|
||||
ffPrintError(FF_WIFI_MODULE_NAME, 0, &options->moduleArgs, "%s", error);
|
||||
return;
|
||||
}
|
||||
if(!result.length)
|
||||
{
|
||||
ffPrintError(instance, FF_WIFI_MODULE_NAME, 0, &options->moduleArgs, "No Wifi interfaces found");
|
||||
ffPrintError(FF_WIFI_MODULE_NAME, 0, &options->moduleArgs, "No Wifi interfaces found");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ void ffPrintWifi(FFinstance* instance, FFWifiOptions* options)
|
||||
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
{
|
||||
ffPrintLogoAndKey(instance, FF_WIFI_MODULE_NAME, moduleIndex, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
ffPrintLogoAndKey(FF_WIFI_MODULE_NAME, moduleIndex, &options->moduleArgs.key, &options->moduleArgs.keyColor);
|
||||
if(item->conn.ssid.length)
|
||||
{
|
||||
ffStrbufWriteTo(&item->conn.ssid, stdout);
|
||||
@@ -46,7 +46,7 @@ void ffPrintWifi(FFinstance* instance, FFWifiOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
ffPrintFormat(instance, FF_WIFI_MODULE_NAME, moduleIndex, &options->moduleArgs, FF_WIFI_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||
ffPrintFormat(FF_WIFI_MODULE_NAME, moduleIndex, &options->moduleArgs, 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},
|
||||
@@ -91,7 +91,7 @@ void ffDestroyWifiOptions(FFWifiOptions* options)
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
void ffParseWifiJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
void ffParseWifiJsonObject(yyjson_val* module)
|
||||
{
|
||||
FFWifiOptions __attribute__((__cleanup__(ffDestroyWifiOptions))) options;
|
||||
ffInitWifiOptions(&options);
|
||||
@@ -109,9 +109,9 @@ void ffParseWifiJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs))
|
||||
continue;
|
||||
|
||||
ffPrintError(instance, FF_WIFI_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
ffPrintError(FF_WIFI_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
}
|
||||
}
|
||||
|
||||
ffPrintWifi(instance, &options);
|
||||
ffPrintWifi(&options);
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
#define FF_WIFI_MODULE_NAME "Wifi"
|
||||
|
||||
void ffPrintWifi(FFinstance* instance, FFWifiOptions* options);
|
||||
void ffPrintWifi(FFWifiOptions* options);
|
||||
void ffInitWifiOptions(FFWifiOptions* options);
|
||||
bool ffParseWifiCommandOptions(FFWifiOptions* options, const char* key, const char* value);
|
||||
void ffDestroyWifiOptions(FFWifiOptions* options);
|
||||
void ffParseWifiJsonObject(FFinstance* instance, yyjson_val* module);
|
||||
void ffParseWifiJsonObject(yyjson_val* module);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user