master ohmu/fastfetch-openbsd / src / common / printing.h
ohmu  ·  2026-10-15
 1#pragma once
 2
 3#include "fastfetch.h"
 4#include "common/format.h"
 5
 6typedef enum FFPrintType: uint8_t {
 7    FF_PRINT_TYPE_DEFAULT = 0,
 8    FF_PRINT_TYPE_NO_CUSTOM_KEY = 1 << 0, // key has been formatted outside
 9    FF_PRINT_TYPE_NO_CUSTOM_KEY_COLOR = 1 << 1,
10    FF_PRINT_TYPE_NO_CUSTOM_KEY_WIDTH = 1 << 2,
11    FF_PRINT_TYPE_NO_CUSTOM_OUTPUT_FORMAT = 1 << 3, // reserved
12} FFPrintType;
13
14// Both `moduleName` and `moduleArgs` are optional and explicitly handled: a null `moduleName` is what
15// `--set-keyless` relies on, and a null `moduleArgs` (used by ffPrintError callers) skips the custom
16// key entirely. So neither takes `nonnull`.
17void ffPrintLogoAndKey(const char* moduleName, uint32_t moduleIndex, const FFModuleArgs* moduleArgs, FFPrintType printType);
18// Same for `moduleArgs`; `numArgs` / `arguments` are only read when `moduleArgs` is non-null, so
19// `arguments` is not `nonnull(6)` either. At least one caller discards the result, so not `nodiscard`.
20bool ffPrintFormat(const char* moduleName, uint32_t moduleIndex, const FFModuleArgs* moduleArgs, FFPrintType printType, uint32_t numArgs, const FFformatarg* arguments);
21#define FF_PRINT_FORMAT_CHECKED(moduleName, moduleIndex, moduleArgs, printType, arguments) \
22    ffPrintFormat((moduleName), (moduleIndex), (moduleArgs), (printType), (sizeof(arguments) / sizeof(*arguments)), (arguments));
23// `moduleName` / `moduleArgs` are forwarded to ffPrintLogoAndKey, which accepts null for both;
24// only `message` is dereferenced here (by `vprintf`).
25[[gnu::format(printf, 5, 6), gnu::nonnull(5)]] void ffPrintError(const char* moduleName, uint32_t moduleIndex, const FFModuleArgs* moduleArgs, FFPrintType printType, const char* message, ...);
26[[gnu::nonnull(1)]] void ffPrintColor(const FFstrbuf* colorValue);
27void ffPrintCharTimes(char c, uint32_t times);