mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-11-06 05:04:17 +01:00
Chore: run clang-format
```bash find . -type f \( -name "*.c" -o -name "*.h" -o -name "*.cpp" -o -name "*.hpp" \) ! -path "src/3rdparty/*" -print0 | xargs -0 clang-format -i ```
This commit is contained in:
@@ -7,97 +7,115 @@
|
||||
|
||||
#define FF_BLUETOOTHRADIO_DISPLAY_NAME "Bluetooth Radio"
|
||||
|
||||
static void printDevice(FFBluetoothRadioOptions* options, const FFBluetoothRadioResult* radio, uint8_t index)
|
||||
{
|
||||
static void printDevice(FFBluetoothRadioOptions* options, const FFBluetoothRadioResult* radio, uint8_t index) {
|
||||
FF_STRBUF_AUTO_DESTROY key = ffStrbufCreate();
|
||||
if (options->moduleArgs.key.length == 0)
|
||||
{
|
||||
if (options->moduleArgs.key.length == 0) {
|
||||
ffStrbufAppendF(&key, "%s (%s)", FF_BLUETOOTHRADIO_DISPLAY_NAME, radio->name.chars);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
FF_PARSE_FORMAT_STRING_CHECKED(&key, &options->moduleArgs.key, ((FFformatarg[]) {
|
||||
FF_ARG(index, "index"),
|
||||
FF_ARG(radio->name, "name"),
|
||||
FF_ARG(options->moduleArgs.keyIcon, "icon"),
|
||||
}));
|
||||
FF_ARG(index, "index"),
|
||||
FF_ARG(radio->name, "name"),
|
||||
FF_ARG(options->moduleArgs.keyIcon, "icon"),
|
||||
}));
|
||||
}
|
||||
|
||||
const char* version = NULL;
|
||||
|
||||
switch (radio->lmpVersion < 0 ? -radio->lmpVersion : radio->lmpVersion)
|
||||
{
|
||||
case 0: version = "1.0b"; break;
|
||||
case 1: version = "1.1"; break;
|
||||
case 2: version = "1.2"; break;
|
||||
case 3: version = "2.0"; break;
|
||||
case 4: version = "2.1"; break;
|
||||
case 5: version = "3.0"; break;
|
||||
case 6: version = "4.0"; break;
|
||||
case 7: version = "4.1"; break;
|
||||
case 8: version = "4.2"; break;
|
||||
case 9: version = "5.0"; break;
|
||||
case 10: version = "5.1"; break;
|
||||
case 11: version = "5.2"; break;
|
||||
case 12: version = "5.3"; break;
|
||||
case 13: version = "5.4"; break;
|
||||
switch (radio->lmpVersion < 0 ? -radio->lmpVersion : radio->lmpVersion) {
|
||||
case 0:
|
||||
version = "1.0b";
|
||||
break;
|
||||
case 1:
|
||||
version = "1.1";
|
||||
break;
|
||||
case 2:
|
||||
version = "1.2";
|
||||
break;
|
||||
case 3:
|
||||
version = "2.0";
|
||||
break;
|
||||
case 4:
|
||||
version = "2.1";
|
||||
break;
|
||||
case 5:
|
||||
version = "3.0";
|
||||
break;
|
||||
case 6:
|
||||
version = "4.0";
|
||||
break;
|
||||
case 7:
|
||||
version = "4.1";
|
||||
break;
|
||||
case 8:
|
||||
version = "4.2";
|
||||
break;
|
||||
case 9:
|
||||
version = "5.0";
|
||||
break;
|
||||
case 10:
|
||||
version = "5.1";
|
||||
break;
|
||||
case 11:
|
||||
version = "5.2";
|
||||
break;
|
||||
case 12:
|
||||
version = "5.3";
|
||||
break;
|
||||
case 13:
|
||||
version = "5.4";
|
||||
break;
|
||||
}
|
||||
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
{
|
||||
if (options->moduleArgs.outputFormat.length == 0) {
|
||||
ffPrintLogoAndKey(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY);
|
||||
|
||||
if (version)
|
||||
if (version) {
|
||||
printf("Bluetooth %s%s (%s)\n", version, (radio->lmpVersion < 0 ? "+" : ""), radio->vendor.chars);
|
||||
else
|
||||
} else {
|
||||
ffStrbufPutTo(&radio->vendor, stdout);
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
} else {
|
||||
FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, ((FFformatarg[]) {
|
||||
FF_ARG(radio->name, "name"),
|
||||
FF_ARG(radio->address, "address"),
|
||||
FF_ARG(radio->lmpVersion, "lmp-version"),
|
||||
FF_ARG(radio->lmpSubversion, "lmp-subversion"),
|
||||
FF_ARG(version, "version"),
|
||||
FF_ARG(radio->vendor, "vendor"),
|
||||
FF_ARG(radio->discoverable, "discoverable"),
|
||||
FF_ARG(radio->connectable, "connectable"),
|
||||
}));
|
||||
FF_ARG(radio->name, "name"),
|
||||
FF_ARG(radio->address, "address"),
|
||||
FF_ARG(radio->lmpVersion, "lmp-version"),
|
||||
FF_ARG(radio->lmpSubversion, "lmp-subversion"),
|
||||
FF_ARG(version, "version"),
|
||||
FF_ARG(radio->vendor, "vendor"),
|
||||
FF_ARG(radio->discoverable, "discoverable"),
|
||||
FF_ARG(radio->connectable, "connectable"),
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
bool ffPrintBluetoothRadio(FFBluetoothRadioOptions* options)
|
||||
{
|
||||
FF_LIST_AUTO_DESTROY radios = ffListCreate(sizeof (FFBluetoothRadioResult));
|
||||
bool ffPrintBluetoothRadio(FFBluetoothRadioOptions* options) {
|
||||
FF_LIST_AUTO_DESTROY radios = ffListCreate(sizeof(FFBluetoothRadioResult));
|
||||
const char* error = ffDetectBluetoothRadio(&radios);
|
||||
|
||||
if(error)
|
||||
{
|
||||
if (error) {
|
||||
ffPrintError(FF_BLUETOOTHRADIO_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "%s", error);
|
||||
return false;
|
||||
}
|
||||
|
||||
uint8_t index = 0;
|
||||
FF_LIST_FOR_EACH(FFBluetoothRadioResult, radio, radios)
|
||||
{
|
||||
if (!radio->enabled)
|
||||
FF_LIST_FOR_EACH (FFBluetoothRadioResult, radio, radios) {
|
||||
if (!radio->enabled) {
|
||||
continue;
|
||||
}
|
||||
|
||||
index++;
|
||||
printDevice(options, radio, index);
|
||||
}
|
||||
|
||||
if (index == 0)
|
||||
{
|
||||
if (radios.length > 0)
|
||||
if (index == 0) {
|
||||
if (radios.length > 0) {
|
||||
ffPrintError(FF_BLUETOOTHRADIO_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Bluetooth radios found but none enabled");
|
||||
else
|
||||
} else {
|
||||
ffPrintError(FF_BLUETOOTHRADIO_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "No devices detected");
|
||||
}
|
||||
}
|
||||
|
||||
FF_LIST_FOR_EACH(FFBluetoothRadioResult, radio, radios)
|
||||
{
|
||||
FF_LIST_FOR_EACH (FFBluetoothRadioResult, radio, radios) {
|
||||
ffStrbufDestroy(&radio->name);
|
||||
ffStrbufDestroy(&radio->address);
|
||||
ffStrbufDestroy(&radio->vendor);
|
||||
@@ -105,58 +123,54 @@ bool ffPrintBluetoothRadio(FFBluetoothRadioOptions* options)
|
||||
return true;
|
||||
}
|
||||
|
||||
void ffParseBluetoothRadioJsonObject(FFBluetoothRadioOptions* options, yyjson_val* module)
|
||||
{
|
||||
void ffParseBluetoothRadioJsonObject(FFBluetoothRadioOptions* options, yyjson_val* module) {
|
||||
yyjson_val *key, *val;
|
||||
size_t idx, max;
|
||||
yyjson_obj_foreach(module, idx, max, key, val)
|
||||
{
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs))
|
||||
yyjson_obj_foreach (module, idx, max, key, val) {
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ffPrintError(FF_BLUETOOTHRADIO_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Unknown JSON key %s", unsafe_yyjson_get_str(key));
|
||||
}
|
||||
}
|
||||
|
||||
void ffGenerateBluetoothRadioJsonConfig(FFBluetoothRadioOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module)
|
||||
{
|
||||
void ffGenerateBluetoothRadioJsonConfig(FFBluetoothRadioOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) {
|
||||
ffJsonConfigGenerateModuleArgsConfig(doc, module, &options->moduleArgs);
|
||||
}
|
||||
|
||||
bool ffGenerateBluetoothRadioJsonResult(FF_MAYBE_UNUSED FFBluetoothRadioOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module)
|
||||
{
|
||||
bool ffGenerateBluetoothRadioJsonResult(FF_MAYBE_UNUSED FFBluetoothRadioOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) {
|
||||
FF_LIST_AUTO_DESTROY results = ffListCreate(sizeof(FFBluetoothRadioResult));
|
||||
|
||||
const char* error = ffDetectBluetoothRadio(&results);
|
||||
if (error)
|
||||
{
|
||||
if (error) {
|
||||
yyjson_mut_obj_add_str(doc, module, "error", error);
|
||||
return false;
|
||||
}
|
||||
|
||||
yyjson_mut_val* arr = yyjson_mut_obj_add_arr(doc, module, "result");
|
||||
|
||||
FF_LIST_FOR_EACH(FFBluetoothRadioResult, item, results)
|
||||
{
|
||||
FF_LIST_FOR_EACH (FFBluetoothRadioResult, item, results) {
|
||||
yyjson_mut_val* obj = yyjson_mut_arr_add_obj(doc, arr);
|
||||
yyjson_mut_obj_add_strbuf(doc, obj, "name", &item->name);
|
||||
yyjson_mut_obj_add_strbuf(doc, obj, "address", &item->address);
|
||||
if (item->lmpVersion == INT_MIN)
|
||||
if (item->lmpVersion == INT_MIN) {
|
||||
yyjson_mut_obj_add_null(doc, obj, "lmpVersion");
|
||||
else
|
||||
} else {
|
||||
yyjson_mut_obj_add_int(doc, obj, "lmpVersion", item->lmpVersion);
|
||||
if (item->lmpSubversion == INT_MIN)
|
||||
}
|
||||
if (item->lmpSubversion == INT_MIN) {
|
||||
yyjson_mut_obj_add_null(doc, obj, "lmpSubversion");
|
||||
else
|
||||
} else {
|
||||
yyjson_mut_obj_add_int(doc, obj, "lmpSubversion", item->lmpSubversion);
|
||||
}
|
||||
yyjson_mut_obj_add_strbuf(doc, obj, "vendor", &item->vendor);
|
||||
yyjson_mut_obj_add_bool(doc, obj, "enabled", item->enabled);
|
||||
yyjson_mut_obj_add_bool(doc, obj, "discoverable", item->discoverable);
|
||||
yyjson_mut_obj_add_bool(doc, obj, "connectable", item->connectable);
|
||||
}
|
||||
|
||||
FF_LIST_FOR_EACH(FFBluetoothRadioResult, radio, results)
|
||||
{
|
||||
FF_LIST_FOR_EACH (FFBluetoothRadioResult, radio, results) {
|
||||
ffStrbufDestroy(&radio->name);
|
||||
ffStrbufDestroy(&radio->address);
|
||||
ffStrbufDestroy(&radio->vendor);
|
||||
@@ -165,13 +179,11 @@ bool ffGenerateBluetoothRadioJsonResult(FF_MAYBE_UNUSED FFBluetoothRadioOptions*
|
||||
return true;
|
||||
}
|
||||
|
||||
void ffInitBluetoothRadioOptions(FFBluetoothRadioOptions* options)
|
||||
{
|
||||
void ffInitBluetoothRadioOptions(FFBluetoothRadioOptions* options) {
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
}
|
||||
|
||||
void ffDestroyBluetoothRadioOptions(FFBluetoothRadioOptions* options)
|
||||
{
|
||||
void ffDestroyBluetoothRadioOptions(FFBluetoothRadioOptions* options) {
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
@@ -193,5 +205,4 @@ FFModuleBaseInfo ffBluetoothRadioModuleInfo = {
|
||||
{"Vendor", "vendor"},
|
||||
{"Discoverable", "discoverable"},
|
||||
{"Connectable / Pairable", "connectable"},
|
||||
}))
|
||||
};
|
||||
}))};
|
||||
|
||||
@@ -3,8 +3,7 @@
|
||||
#include "common/option.h"
|
||||
#include "common/percent.h"
|
||||
|
||||
typedef struct FFBluetoothRadioOptions
|
||||
{
|
||||
typedef struct FFBluetoothRadioOptions {
|
||||
FFModuleArgs moduleArgs;
|
||||
} FFBluetoothRadioOptions;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user