mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-11-09 22:50:38 +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:
+41
-58
@@ -4,8 +4,7 @@
|
||||
#include "detection/opengl/opengl.h"
|
||||
#include "modules/opengl/opengl.h"
|
||||
|
||||
bool ffPrintOpenGL(FFOpenGLOptions* options)
|
||||
{
|
||||
bool ffPrintOpenGL(FFOpenGLOptions* options) {
|
||||
bool success = false;
|
||||
FFOpenGLResult result;
|
||||
ffStrbufInit(&result.version);
|
||||
@@ -15,26 +14,20 @@ bool ffPrintOpenGL(FFOpenGLOptions* options)
|
||||
ffStrbufInit(&result.library);
|
||||
|
||||
const char* error = ffDetectOpenGL(options, &result);
|
||||
if(error)
|
||||
{
|
||||
if (error) {
|
||||
ffPrintError(FF_OPENGL_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "%s", error);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
{
|
||||
} else {
|
||||
if (options->moduleArgs.outputFormat.length == 0) {
|
||||
ffPrintLogoAndKey(FF_OPENGL_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT);
|
||||
puts(result.version.chars);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
FF_PRINT_FORMAT_CHECKED(FF_OPENGL_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) {
|
||||
FF_ARG(result.version, "version"),
|
||||
FF_ARG(result.renderer, "renderer"),
|
||||
FF_ARG(result.vendor, "vendor"),
|
||||
FF_ARG(result.slv, "slv"),
|
||||
FF_ARG(result.library, "library"),
|
||||
}));
|
||||
FF_ARG(result.version, "version"),
|
||||
FF_ARG(result.renderer, "renderer"),
|
||||
FF_ARG(result.vendor, "vendor"),
|
||||
FF_ARG(result.slv, "slv"),
|
||||
FF_ARG(result.library, "library"),
|
||||
}));
|
||||
}
|
||||
success = true;
|
||||
}
|
||||
@@ -48,28 +41,27 @@ bool ffPrintOpenGL(FFOpenGLOptions* options)
|
||||
return success;
|
||||
}
|
||||
|
||||
void ffParseOpenGLJsonObject(FFOpenGLOptions* options, yyjson_val* module)
|
||||
{
|
||||
void ffParseOpenGLJsonObject(FFOpenGLOptions* 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;
|
||||
}
|
||||
|
||||
if (unsafe_yyjson_equals_str(key, "library"))
|
||||
{
|
||||
if (unsafe_yyjson_equals_str(key, "library")) {
|
||||
int value;
|
||||
const char* error = ffJsonConfigParseEnum(val, &value, (FFKeyValuePair[]) {
|
||||
{ "auto", FF_OPENGL_LIBRARY_AUTO },
|
||||
{ "egl", FF_OPENGL_LIBRARY_EGL },
|
||||
{ "glx", FF_OPENGL_LIBRARY_GLX },
|
||||
{},
|
||||
});
|
||||
if (error)
|
||||
{"auto", FF_OPENGL_LIBRARY_AUTO},
|
||||
{"egl", FF_OPENGL_LIBRARY_EGL},
|
||||
{"glx", FF_OPENGL_LIBRARY_GLX},
|
||||
{},
|
||||
});
|
||||
if (error) {
|
||||
ffPrintError(FF_OPENGL_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Invalid %s value: %s", unsafe_yyjson_get_str(key), error);
|
||||
else
|
||||
} else {
|
||||
options->library = (FFOpenGLLibrary) value;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -77,26 +69,23 @@ void ffParseOpenGLJsonObject(FFOpenGLOptions* options, yyjson_val* module)
|
||||
}
|
||||
}
|
||||
|
||||
void ffGenerateOpenGLJsonConfig(FFOpenGLOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module)
|
||||
{
|
||||
void ffGenerateOpenGLJsonConfig(FFOpenGLOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) {
|
||||
ffJsonConfigGenerateModuleArgsConfig(doc, module, &options->moduleArgs);
|
||||
|
||||
switch (options->library)
|
||||
{
|
||||
case FF_OPENGL_LIBRARY_AUTO:
|
||||
yyjson_mut_obj_add_str(doc, module, "library", "auto");
|
||||
break;
|
||||
case FF_OPENGL_LIBRARY_EGL:
|
||||
yyjson_mut_obj_add_str(doc, module, "library", "egl");
|
||||
break;
|
||||
case FF_OPENGL_LIBRARY_GLX:
|
||||
yyjson_mut_obj_add_str(doc, module, "library", "glx");
|
||||
break;
|
||||
switch (options->library) {
|
||||
case FF_OPENGL_LIBRARY_AUTO:
|
||||
yyjson_mut_obj_add_str(doc, module, "library", "auto");
|
||||
break;
|
||||
case FF_OPENGL_LIBRARY_EGL:
|
||||
yyjson_mut_obj_add_str(doc, module, "library", "egl");
|
||||
break;
|
||||
case FF_OPENGL_LIBRARY_GLX:
|
||||
yyjson_mut_obj_add_str(doc, module, "library", "glx");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool ffGenerateOpenGLJsonResult(FF_MAYBE_UNUSED FFOpenGLOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module)
|
||||
{
|
||||
bool ffGenerateOpenGLJsonResult(FF_MAYBE_UNUSED FFOpenGLOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) {
|
||||
bool success = false;
|
||||
FFOpenGLResult result;
|
||||
ffStrbufInit(&result.version);
|
||||
@@ -106,12 +95,9 @@ bool ffGenerateOpenGLJsonResult(FF_MAYBE_UNUSED FFOpenGLOptions* options, yyjson
|
||||
ffStrbufInit(&result.library);
|
||||
|
||||
const char* error = ffDetectOpenGL(options, &result);
|
||||
if(error != NULL)
|
||||
{
|
||||
if (error != NULL) {
|
||||
yyjson_mut_obj_add_str(doc, module, "error", error);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
yyjson_mut_val* obj = yyjson_mut_obj_add_obj(doc, module, "result");
|
||||
yyjson_mut_obj_add_strbuf(doc, obj, "version", &result.version);
|
||||
yyjson_mut_obj_add_strbuf(doc, obj, "renderer", &result.renderer);
|
||||
@@ -130,15 +116,13 @@ bool ffGenerateOpenGLJsonResult(FF_MAYBE_UNUSED FFOpenGLOptions* options, yyjson
|
||||
return success;
|
||||
}
|
||||
|
||||
void ffInitOpenGLOptions(FFOpenGLOptions* options)
|
||||
{
|
||||
void ffInitOpenGLOptions(FFOpenGLOptions* options) {
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
|
||||
options->library = FF_OPENGL_LIBRARY_AUTO;
|
||||
}
|
||||
|
||||
void ffDestroyOpenGLOptions(FFOpenGLOptions* options)
|
||||
{
|
||||
void ffDestroyOpenGLOptions(FFOpenGLOptions* options) {
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
@@ -157,5 +141,4 @@ FFModuleBaseInfo ffOpenGLModuleInfo = {
|
||||
{"OpenGL vendor", "vendor"},
|
||||
{"OpenGL shading language version", "slv"},
|
||||
{"OpenGL library used", "library"},
|
||||
}))
|
||||
};
|
||||
}))};
|
||||
|
||||
@@ -2,15 +2,13 @@
|
||||
|
||||
#include "common/option.h"
|
||||
|
||||
typedef enum __attribute__((__packed__)) FFOpenGLLibrary
|
||||
{
|
||||
typedef enum __attribute__((__packed__)) FFOpenGLLibrary {
|
||||
FF_OPENGL_LIBRARY_AUTO,
|
||||
FF_OPENGL_LIBRARY_EGL,
|
||||
FF_OPENGL_LIBRARY_GLX,
|
||||
} FFOpenGLLibrary;
|
||||
|
||||
typedef struct FFOpenGLOptions
|
||||
{
|
||||
typedef struct FFOpenGLOptions {
|
||||
FFModuleArgs moduleArgs;
|
||||
|
||||
FFOpenGLLibrary library;
|
||||
|
||||
Reference in New Issue
Block a user