mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-29 08:13:44 +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:
+31
-49
@@ -5,62 +5,53 @@
|
||||
#include "detection/camera/camera.h"
|
||||
#include "modules/camera/camera.h"
|
||||
|
||||
static void printDevice(FFCameraOptions* options, const FFCameraResult* device, uint8_t index)
|
||||
{
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
{
|
||||
static void printDevice(FFCameraOptions* options, const FFCameraResult* device, uint8_t index) {
|
||||
if (options->moduleArgs.outputFormat.length == 0) {
|
||||
ffPrintLogoAndKey(FF_CAMERA_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT);
|
||||
|
||||
ffStrbufWriteTo(&device->name, stdout);
|
||||
if (device->colorspace.length > 0)
|
||||
{
|
||||
if (device->colorspace.length > 0) {
|
||||
fputs(" - ", stdout);
|
||||
ffStrbufWriteTo(&device->colorspace, stdout);
|
||||
}
|
||||
|
||||
if (device->width > 0 && device->height > 0)
|
||||
if (device->width > 0 && device->height > 0) {
|
||||
printf(" (%ux%u px)\n", (unsigned) device->width, (unsigned) device->height);
|
||||
else
|
||||
} else {
|
||||
putchar('\n');
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
} else {
|
||||
FF_PRINT_FORMAT_CHECKED(FF_CAMERA_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, (((FFformatarg[]) {
|
||||
FF_ARG(device->name, "name"),
|
||||
FF_ARG(device->vendor, "vendor"),
|
||||
FF_ARG(device->colorspace, "colorspace"),
|
||||
FF_ARG(device->id, "id"),
|
||||
FF_ARG(device->width, "width"),
|
||||
FF_ARG(device->height, "height"),
|
||||
})));
|
||||
FF_ARG(device->name, "name"),
|
||||
FF_ARG(device->vendor, "vendor"),
|
||||
FF_ARG(device->colorspace, "colorspace"),
|
||||
FF_ARG(device->id, "id"),
|
||||
FF_ARG(device->width, "width"),
|
||||
FF_ARG(device->height, "height"),
|
||||
})));
|
||||
}
|
||||
}
|
||||
|
||||
bool ffPrintCamera(FFCameraOptions* options)
|
||||
{
|
||||
bool ffPrintCamera(FFCameraOptions* options) {
|
||||
FF_LIST_AUTO_DESTROY result = ffListCreate(sizeof(FFCameraResult));
|
||||
const char* error = ffDetectCamera(&result);
|
||||
|
||||
if (error)
|
||||
{
|
||||
if (error) {
|
||||
ffPrintError(FF_CAMERA_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "%s", error);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (result.length == 0)
|
||||
{
|
||||
if (result.length == 0) {
|
||||
ffPrintError(FF_CAMERA_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "No camera found");
|
||||
return false;
|
||||
}
|
||||
|
||||
for(uint32_t i = 0; i < result.length; i++)
|
||||
{
|
||||
for (uint32_t i = 0; i < result.length; i++) {
|
||||
uint8_t index = (uint8_t) (result.length == 1 ? 0 : i + 1);
|
||||
printDevice(options, FF_LIST_GET(FFCameraResult, result, i), index);
|
||||
}
|
||||
|
||||
FF_LIST_FOR_EACH(FFCameraResult, dev, result)
|
||||
{
|
||||
FF_LIST_FOR_EACH (FFCameraResult, dev, result) {
|
||||
ffStrbufDestroy(&dev->name);
|
||||
ffStrbufDestroy(&dev->id);
|
||||
ffStrbufDestroy(&dev->colorspace);
|
||||
@@ -69,39 +60,34 @@ bool ffPrintCamera(FFCameraOptions* options)
|
||||
return true;
|
||||
}
|
||||
|
||||
void ffParseCameraJsonObject(FFCameraOptions* options, yyjson_val* module)
|
||||
{
|
||||
void ffParseCameraJsonObject(FFCameraOptions* 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_CAMERA_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Unknown JSON key %s", unsafe_yyjson_get_str(key));
|
||||
}
|
||||
}
|
||||
|
||||
void ffGenerateCameraJsonConfig(FFCameraOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module)
|
||||
{
|
||||
void ffGenerateCameraJsonConfig(FFCameraOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) {
|
||||
ffJsonConfigGenerateModuleArgsConfig(doc, module, &options->moduleArgs);
|
||||
}
|
||||
|
||||
bool ffGenerateCameraJsonResult(FF_MAYBE_UNUSED FFCameraOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module)
|
||||
{
|
||||
bool ffGenerateCameraJsonResult(FF_MAYBE_UNUSED FFCameraOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) {
|
||||
FF_LIST_AUTO_DESTROY result = ffListCreate(sizeof(FFCameraResult));
|
||||
const char* error = ffDetectCamera(&result);
|
||||
|
||||
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(FFCameraResult, dev, result)
|
||||
{
|
||||
FF_LIST_FOR_EACH (FFCameraResult, dev, result) {
|
||||
yyjson_mut_val* obj = yyjson_mut_arr_add_obj(doc, arr);
|
||||
yyjson_mut_obj_add_strbuf(doc, obj, "name", &dev->name);
|
||||
yyjson_mut_obj_add_strbuf(doc, obj, "vendor", &dev->vendor);
|
||||
@@ -111,8 +97,7 @@ bool ffGenerateCameraJsonResult(FF_MAYBE_UNUSED FFCameraOptions* options, yyjson
|
||||
yyjson_mut_obj_add_uint(doc, obj, "height", dev->height);
|
||||
}
|
||||
|
||||
FF_LIST_FOR_EACH(FFCameraResult, dev, result)
|
||||
{
|
||||
FF_LIST_FOR_EACH (FFCameraResult, dev, result) {
|
||||
ffStrbufDestroy(&dev->name);
|
||||
ffStrbufDestroy(&dev->id);
|
||||
ffStrbufDestroy(&dev->colorspace);
|
||||
@@ -121,13 +106,11 @@ bool ffGenerateCameraJsonResult(FF_MAYBE_UNUSED FFCameraOptions* options, yyjson
|
||||
return true;
|
||||
}
|
||||
|
||||
void ffInitCameraOptions(FFCameraOptions* options)
|
||||
{
|
||||
void ffInitCameraOptions(FFCameraOptions* options) {
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
}
|
||||
|
||||
void ffDestroyCameraOptions(FFCameraOptions* options)
|
||||
{
|
||||
void ffDestroyCameraOptions(FFCameraOptions* options) {
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
@@ -147,5 +130,4 @@ FFModuleBaseInfo ffCameraModuleInfo = {
|
||||
{"Identifier", "id"},
|
||||
{"Width (in px)", "width"},
|
||||
{"Height (in px)", "height"},
|
||||
}))
|
||||
};
|
||||
}))};
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
|
||||
#include "common/option.h"
|
||||
|
||||
typedef struct FFCameraOptions
|
||||
{
|
||||
typedef struct FFCameraOptions {
|
||||
FFModuleArgs moduleArgs;
|
||||
} FFCameraOptions;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user