mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-30 17:41:41 +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:
@@ -2,8 +2,7 @@
|
||||
|
||||
#include "common/option.h"
|
||||
|
||||
typedef enum __attribute__((__packed__)) FFPackagesFlags
|
||||
{
|
||||
typedef enum __attribute__((__packed__)) FFPackagesFlags {
|
||||
FF_PACKAGES_FLAG_NONE = 0,
|
||||
FF_PACKAGES_FLAG_APK_BIT = 1ULL << 0,
|
||||
FF_PACKAGES_FLAG_BREW_BIT = 1ULL << 1,
|
||||
@@ -42,8 +41,7 @@ typedef enum __attribute__((__packed__)) FFPackagesFlags
|
||||
} FFPackagesFlags;
|
||||
static_assert(sizeof(FFPackagesFlags) == sizeof(uint64_t), "");
|
||||
|
||||
typedef struct FFPackagesOptions
|
||||
{
|
||||
typedef struct FFPackagesOptions {
|
||||
FFModuleArgs moduleArgs;
|
||||
|
||||
FFPackagesFlags disabled;
|
||||
|
||||
+176
-174
@@ -4,15 +4,13 @@
|
||||
#include "detection/packages/packages.h"
|
||||
#include "modules/packages/packages.h"
|
||||
|
||||
bool ffPrintPackages(FFPackagesOptions* options)
|
||||
{
|
||||
bool ffPrintPackages(FFPackagesOptions* options) {
|
||||
FFPackagesResult counts = {};
|
||||
ffStrbufInit(&counts.pacmanBranch);
|
||||
|
||||
const char* error = ffDetectPackages(&counts, options);
|
||||
|
||||
if(error)
|
||||
{
|
||||
if (error) {
|
||||
ffPrintError(FF_PACKAGES_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "%s", error);
|
||||
return false;
|
||||
}
|
||||
@@ -25,50 +23,47 @@ bool ffPrintPackages(FFPackagesOptions* options)
|
||||
uint32_t amAll = counts.amSystem + counts.amUser;
|
||||
uint32_t scoopAll = counts.scoopUser + counts.scoopGlobal;
|
||||
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
{
|
||||
if (options->moduleArgs.outputFormat.length == 0) {
|
||||
ffPrintLogoAndKey(FF_PACKAGES_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT);
|
||||
|
||||
#define FF_PRINT_PACKAGE_NAME(var, name) {\
|
||||
if(counts.var > 0) \
|
||||
{ \
|
||||
printf("%u (%s)", counts.var, (name)); \
|
||||
if((all -= counts.var) > 0) \
|
||||
fputs(", ", stdout); \
|
||||
} \
|
||||
}
|
||||
#define FF_PRINT_PACKAGE_NAME(var, name) \
|
||||
{ \
|
||||
if (counts.var > 0) { \
|
||||
printf("%u (%s)", counts.var, (name)); \
|
||||
if ((all -= counts.var) > 0) \
|
||||
fputs(", ", stdout); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define FF_PRINT_PACKAGE(name) FF_PRINT_PACKAGE_NAME(name, #name)
|
||||
#define FF_PRINT_PACKAGE(name) FF_PRINT_PACKAGE_NAME(name, #name)
|
||||
|
||||
#define FF_PRINT_PACKAGE_ALL(name) {\
|
||||
if(name ## All > 0) \
|
||||
{ \
|
||||
printf("%u (%s)", name ## All, #name); \
|
||||
if((all -= name ## All) > 0) \
|
||||
fputs(", ", stdout); \
|
||||
} \
|
||||
}
|
||||
#define FF_PRINT_PACKAGE_ALL(name) \
|
||||
{ \
|
||||
if (name##All > 0) { \
|
||||
printf("%u (%s)", name##All, #name); \
|
||||
if ((all -= name##All) > 0) \
|
||||
fputs(", ", stdout); \
|
||||
} \
|
||||
}
|
||||
|
||||
uint32_t all = counts.all;
|
||||
if(counts.pacman > 0)
|
||||
{
|
||||
if (counts.pacman > 0) {
|
||||
printf("%u (pacman)", counts.pacman);
|
||||
if(counts.pacmanBranch.length > 0)
|
||||
if (counts.pacmanBranch.length > 0) {
|
||||
printf("[%s]", counts.pacmanBranch.chars);
|
||||
if((all -= counts.pacman) > 0)
|
||||
}
|
||||
if ((all -= counts.pacman) > 0) {
|
||||
printf(", ");
|
||||
}
|
||||
};
|
||||
FF_PRINT_PACKAGE(dpkg)
|
||||
FF_PRINT_PACKAGE(rpm)
|
||||
FF_PRINT_PACKAGE(emerge)
|
||||
FF_PRINT_PACKAGE(eopkg)
|
||||
FF_PRINT_PACKAGE(xbps)
|
||||
if (options->combined)
|
||||
{
|
||||
if (options->combined) {
|
||||
FF_PRINT_PACKAGE_ALL(nix);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
FF_PRINT_PACKAGE_NAME(nixSystem, "nix-system")
|
||||
FF_PRINT_PACKAGE_NAME(nixUser, "nix-user")
|
||||
FF_PRINT_PACKAGE_NAME(nixDefault, "nix-default")
|
||||
@@ -77,41 +72,29 @@ bool ffPrintPackages(FFPackagesOptions* options)
|
||||
FF_PRINT_PACKAGE(pkg)
|
||||
FF_PRINT_PACKAGE(pkgsrc)
|
||||
FF_PRINT_PACKAGE(kiss)
|
||||
if (options->combined)
|
||||
{
|
||||
if (options->combined) {
|
||||
FF_PRINT_PACKAGE_ALL(hpkg)
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
FF_PRINT_PACKAGE_NAME(hpkgSystem, counts.hpkgUser ? "hpkg-system" : "hpkg")
|
||||
FF_PRINT_PACKAGE_NAME(hpkgUser, "hpkg-user")
|
||||
}
|
||||
if (options->combined)
|
||||
{
|
||||
if (options->combined) {
|
||||
FF_PRINT_PACKAGE_ALL(flatpak);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
FF_PRINT_PACKAGE_NAME(flatpakSystem, counts.flatpakUser ? "flatpak-system" : "flatpak")
|
||||
FF_PRINT_PACKAGE_NAME(flatpakUser, "flatpak-user")
|
||||
}
|
||||
FF_PRINT_PACKAGE(snap)
|
||||
if (options->combined)
|
||||
{
|
||||
if (options->combined) {
|
||||
FF_PRINT_PACKAGE_ALL(brew);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
FF_PRINT_PACKAGE_NAME(brew, "brew")
|
||||
FF_PRINT_PACKAGE_NAME(brewCask, "brew-cask")
|
||||
}
|
||||
FF_PRINT_PACKAGE(macports)
|
||||
if (options->combined)
|
||||
{
|
||||
if (options->combined) {
|
||||
FF_PRINT_PACKAGE_ALL(scoop);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
FF_PRINT_PACKAGE_NAME(scoopUser, counts.scoopGlobal ? "scoop-user" : "scoop")
|
||||
FF_PRINT_PACKAGE_NAME(scoopGlobal, "scoop-global")
|
||||
}
|
||||
@@ -120,24 +103,18 @@ bool ffPrintPackages(FFPackagesOptions* options)
|
||||
FF_PRINT_PACKAGE(paludis)
|
||||
FF_PRINT_PACKAGE(winget)
|
||||
FF_PRINT_PACKAGE(opkg)
|
||||
if (options->combined)
|
||||
{
|
||||
if (options->combined) {
|
||||
FF_PRINT_PACKAGE_ALL(am);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
FF_PRINT_PACKAGE_NAME(amSystem, "am")
|
||||
FF_PRINT_PACKAGE_NAME(amUser, "appman")
|
||||
}
|
||||
FF_PRINT_PACKAGE(sorcery)
|
||||
FF_PRINT_PACKAGE(lpkg)
|
||||
FF_PRINT_PACKAGE(lpkgbuild)
|
||||
if (options->combined)
|
||||
{
|
||||
if (options->combined) {
|
||||
FF_PRINT_PACKAGE_ALL(guix);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
FF_PRINT_PACKAGE_NAME(guixSystem, "guix-system")
|
||||
FF_PRINT_PACKAGE_NAME(guixUser, "guix-user")
|
||||
FF_PRINT_PACKAGE_NAME(guixHome, "guix-home")
|
||||
@@ -150,60 +127,58 @@ bool ffPrintPackages(FFPackagesOptions* options)
|
||||
FF_PRINT_PACKAGE(moss)
|
||||
|
||||
putchar('\n');
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_PACKAGES_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){
|
||||
FF_ARG(counts.all, "all"),
|
||||
FF_ARG(counts.pacman, "pacman"),
|
||||
FF_ARG(counts.pacmanBranch, "pacman-branch"),
|
||||
FF_ARG(counts.dpkg, "dpkg"),
|
||||
FF_ARG(counts.rpm, "rpm"),
|
||||
FF_ARG(counts.emerge, "emerge"),
|
||||
FF_ARG(counts.eopkg, "eopkg"),
|
||||
FF_ARG(counts.xbps, "xbps"),
|
||||
FF_ARG(counts.nixSystem, "nix-system"),
|
||||
FF_ARG(counts.nixUser, "nix-user"),
|
||||
FF_ARG(counts.nixDefault, "nix-default"),
|
||||
FF_ARG(counts.apk, "apk"),
|
||||
FF_ARG(counts.pkg, "pkg"),
|
||||
FF_ARG(counts.flatpakSystem, "flatpak-system"),
|
||||
FF_ARG(counts.flatpakUser, "flatpak-user"),
|
||||
FF_ARG(counts.snap, "snap"),
|
||||
FF_ARG(counts.brew, "brew"),
|
||||
FF_ARG(counts.brewCask, "brew-cask"),
|
||||
FF_ARG(counts.macports, "macports"),
|
||||
FF_ARG(counts.scoopUser, "scoop-user"),
|
||||
FF_ARG(counts.scoopGlobal, "scoop-global"),
|
||||
FF_ARG(counts.choco, "choco"),
|
||||
FF_ARG(counts.pkgtool, "pkgtool"),
|
||||
FF_ARG(counts.paludis, "paludis"),
|
||||
FF_ARG(counts.winget, "winget"),
|
||||
FF_ARG(counts.opkg, "opkg"),
|
||||
FF_ARG(counts.amSystem, "am-system"),
|
||||
FF_ARG(counts.sorcery, "sorcery"),
|
||||
FF_ARG(counts.lpkg, "lpkg"),
|
||||
FF_ARG(counts.lpkgbuild, "lpkgbuild"),
|
||||
FF_ARG(counts.guixSystem, "guix-system"),
|
||||
FF_ARG(counts.guixUser, "guix-user"),
|
||||
FF_ARG(counts.guixHome, "guix-home"),
|
||||
FF_ARG(counts.linglong, "linglong"),
|
||||
FF_ARG(counts.pacstall, "pacstall"),
|
||||
FF_ARG(counts.mport, "mport"),
|
||||
FF_ARG(counts.amUser, "am-user"),
|
||||
FF_ARG(counts.pkgsrc, "pkgsrc"),
|
||||
FF_ARG(counts.hpkgSystem, "hpkg-system"),
|
||||
FF_ARG(counts.hpkgUser, "hpkg-user"),
|
||||
FF_ARG(counts.pisi, "pisi"),
|
||||
FF_ARG(counts.soar, "soar"),
|
||||
FF_ARG(counts.kiss, "kiss"),
|
||||
FF_ARG(counts.moss, "moss"),
|
||||
FF_ARG(nixAll, "nix-all"),
|
||||
FF_ARG(flatpakAll, "flatpak-all"),
|
||||
FF_ARG(brewAll, "brew-all"),
|
||||
FF_ARG(guixAll, "guix-all"),
|
||||
FF_ARG(hpkgAll, "hpkg-all"),
|
||||
}));
|
||||
} else {
|
||||
FF_PRINT_FORMAT_CHECKED(FF_PACKAGES_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) {
|
||||
FF_ARG(counts.all, "all"),
|
||||
FF_ARG(counts.pacman, "pacman"),
|
||||
FF_ARG(counts.pacmanBranch, "pacman-branch"),
|
||||
FF_ARG(counts.dpkg, "dpkg"),
|
||||
FF_ARG(counts.rpm, "rpm"),
|
||||
FF_ARG(counts.emerge, "emerge"),
|
||||
FF_ARG(counts.eopkg, "eopkg"),
|
||||
FF_ARG(counts.xbps, "xbps"),
|
||||
FF_ARG(counts.nixSystem, "nix-system"),
|
||||
FF_ARG(counts.nixUser, "nix-user"),
|
||||
FF_ARG(counts.nixDefault, "nix-default"),
|
||||
FF_ARG(counts.apk, "apk"),
|
||||
FF_ARG(counts.pkg, "pkg"),
|
||||
FF_ARG(counts.flatpakSystem, "flatpak-system"),
|
||||
FF_ARG(counts.flatpakUser, "flatpak-user"),
|
||||
FF_ARG(counts.snap, "snap"),
|
||||
FF_ARG(counts.brew, "brew"),
|
||||
FF_ARG(counts.brewCask, "brew-cask"),
|
||||
FF_ARG(counts.macports, "macports"),
|
||||
FF_ARG(counts.scoopUser, "scoop-user"),
|
||||
FF_ARG(counts.scoopGlobal, "scoop-global"),
|
||||
FF_ARG(counts.choco, "choco"),
|
||||
FF_ARG(counts.pkgtool, "pkgtool"),
|
||||
FF_ARG(counts.paludis, "paludis"),
|
||||
FF_ARG(counts.winget, "winget"),
|
||||
FF_ARG(counts.opkg, "opkg"),
|
||||
FF_ARG(counts.amSystem, "am-system"),
|
||||
FF_ARG(counts.sorcery, "sorcery"),
|
||||
FF_ARG(counts.lpkg, "lpkg"),
|
||||
FF_ARG(counts.lpkgbuild, "lpkgbuild"),
|
||||
FF_ARG(counts.guixSystem, "guix-system"),
|
||||
FF_ARG(counts.guixUser, "guix-user"),
|
||||
FF_ARG(counts.guixHome, "guix-home"),
|
||||
FF_ARG(counts.linglong, "linglong"),
|
||||
FF_ARG(counts.pacstall, "pacstall"),
|
||||
FF_ARG(counts.mport, "mport"),
|
||||
FF_ARG(counts.amUser, "am-user"),
|
||||
FF_ARG(counts.pkgsrc, "pkgsrc"),
|
||||
FF_ARG(counts.hpkgSystem, "hpkg-system"),
|
||||
FF_ARG(counts.hpkgUser, "hpkg-user"),
|
||||
FF_ARG(counts.pisi, "pisi"),
|
||||
FF_ARG(counts.soar, "soar"),
|
||||
FF_ARG(counts.kiss, "kiss"),
|
||||
FF_ARG(counts.moss, "moss"),
|
||||
FF_ARG(nixAll, "nix-all"),
|
||||
FF_ARG(flatpakAll, "flatpak-all"),
|
||||
FF_ARG(brewAll, "brew-all"),
|
||||
FF_ARG(guixAll, "guix-all"),
|
||||
FF_ARG(hpkgAll, "hpkg-all"),
|
||||
}));
|
||||
}
|
||||
|
||||
ffStrbufDestroy(&counts.pacmanBranch);
|
||||
@@ -211,87 +186,111 @@ bool ffPrintPackages(FFPackagesOptions* options)
|
||||
return true;
|
||||
}
|
||||
|
||||
void ffParsePackagesJsonObject(FFPackagesOptions* options, yyjson_val* module)
|
||||
{
|
||||
void ffParsePackagesJsonObject(FFPackagesOptions* 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, "disabled"))
|
||||
{
|
||||
if (!yyjson_is_null(val) && !yyjson_is_arr(val))
|
||||
{
|
||||
if (unsafe_yyjson_equals_str(key, "disabled")) {
|
||||
if (!yyjson_is_null(val) && !yyjson_is_arr(val)) {
|
||||
ffPrintError(FF_PACKAGES_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Invalid JSON value for %s", unsafe_yyjson_get_str(key));
|
||||
continue;
|
||||
}
|
||||
|
||||
options->disabled = FF_PACKAGES_FLAG_NONE;
|
||||
|
||||
if (yyjson_is_arr(val))
|
||||
{
|
||||
if (yyjson_is_arr(val)) {
|
||||
yyjson_val* flagObj;
|
||||
size_t flagIdx, flagMax;
|
||||
yyjson_arr_foreach(val, flagIdx, flagMax, flagObj)
|
||||
{
|
||||
if (!yyjson_is_str(flagObj))
|
||||
{
|
||||
yyjson_arr_foreach (val, flagIdx, flagMax, flagObj) {
|
||||
if (!yyjson_is_str(flagObj)) {
|
||||
ffPrintError(FF_PACKAGES_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Invalid JSON value for %s", unsafe_yyjson_get_str(key));
|
||||
continue;
|
||||
}
|
||||
const char* flag = unsafe_yyjson_get_str(flagObj);
|
||||
|
||||
#define FF_TEST_PACKAGE_NAME(name) else if (ffStrEqualsIgnCase(flag, #name)) { options->disabled |= FF_PACKAGES_FLAG_ ## name ## _BIT; }
|
||||
switch (toupper(flag[0]))
|
||||
{
|
||||
case 'A': if (false);
|
||||
#define FF_TEST_PACKAGE_NAME(name) \
|
||||
else if (ffStrEqualsIgnCase(flag, #name)) { \
|
||||
options->disabled |= FF_PACKAGES_FLAG_##name##_BIT; \
|
||||
}
|
||||
switch (toupper(flag[0])) {
|
||||
case 'A':
|
||||
if (false)
|
||||
;
|
||||
FF_TEST_PACKAGE_NAME(APK)
|
||||
FF_TEST_PACKAGE_NAME(AM)
|
||||
break;
|
||||
case 'B': if (false);
|
||||
case 'B':
|
||||
if (false)
|
||||
;
|
||||
FF_TEST_PACKAGE_NAME(BREW)
|
||||
break;
|
||||
case 'C': if (false);
|
||||
case 'C':
|
||||
if (false)
|
||||
;
|
||||
FF_TEST_PACKAGE_NAME(CHOCO)
|
||||
break;
|
||||
case 'D': if (false);
|
||||
case 'D':
|
||||
if (false)
|
||||
;
|
||||
FF_TEST_PACKAGE_NAME(DPKG)
|
||||
break;
|
||||
case 'E': if (false);
|
||||
case 'E':
|
||||
if (false)
|
||||
;
|
||||
FF_TEST_PACKAGE_NAME(EMERGE)
|
||||
FF_TEST_PACKAGE_NAME(EOPKG)
|
||||
break;
|
||||
case 'F': if (false);
|
||||
case 'F':
|
||||
if (false)
|
||||
;
|
||||
FF_TEST_PACKAGE_NAME(FLATPAK)
|
||||
break;
|
||||
case 'G': if (false);
|
||||
case 'G':
|
||||
if (false)
|
||||
;
|
||||
FF_TEST_PACKAGE_NAME(GUIX)
|
||||
break;
|
||||
case 'H': if (false);
|
||||
case 'H':
|
||||
if (false)
|
||||
;
|
||||
FF_TEST_PACKAGE_NAME(HPKG)
|
||||
break;
|
||||
case 'K': if (false);
|
||||
case 'K':
|
||||
if (false)
|
||||
;
|
||||
FF_TEST_PACKAGE_NAME(KISS)
|
||||
break;
|
||||
case 'L': if (false);
|
||||
case 'L':
|
||||
if (false)
|
||||
;
|
||||
FF_TEST_PACKAGE_NAME(LPKG)
|
||||
FF_TEST_PACKAGE_NAME(LPKGBUILD)
|
||||
FF_TEST_PACKAGE_NAME(LINGLONG)
|
||||
break;
|
||||
case 'M': if (false);
|
||||
case 'M':
|
||||
if (false)
|
||||
;
|
||||
FF_TEST_PACKAGE_NAME(MACPORTS)
|
||||
FF_TEST_PACKAGE_NAME(MPORT)
|
||||
FF_TEST_PACKAGE_NAME(MOSS)
|
||||
break;
|
||||
case 'N': if (false);
|
||||
case 'N':
|
||||
if (false)
|
||||
;
|
||||
FF_TEST_PACKAGE_NAME(NIX)
|
||||
break;
|
||||
case 'O': if (false);
|
||||
case 'O':
|
||||
if (false)
|
||||
;
|
||||
FF_TEST_PACKAGE_NAME(OPKG)
|
||||
break;
|
||||
case 'P': if (false);
|
||||
case 'P':
|
||||
if (false)
|
||||
;
|
||||
FF_TEST_PACKAGE_NAME(PACMAN)
|
||||
FF_TEST_PACKAGE_NAME(PACSTALL)
|
||||
FF_TEST_PACKAGE_NAME(PALUDIS)
|
||||
@@ -300,30 +299,37 @@ void ffParsePackagesJsonObject(FFPackagesOptions* options, yyjson_val* module)
|
||||
FF_TEST_PACKAGE_NAME(PKGTOOL)
|
||||
FF_TEST_PACKAGE_NAME(PKGSRC)
|
||||
break;
|
||||
case 'R': if (false);
|
||||
case 'R':
|
||||
if (false)
|
||||
;
|
||||
FF_TEST_PACKAGE_NAME(RPM)
|
||||
break;
|
||||
case 'S': if (false);
|
||||
case 'S':
|
||||
if (false)
|
||||
;
|
||||
FF_TEST_PACKAGE_NAME(SCOOP)
|
||||
FF_TEST_PACKAGE_NAME(SNAP)
|
||||
FF_TEST_PACKAGE_NAME(SOAR)
|
||||
FF_TEST_PACKAGE_NAME(SORCERY)
|
||||
break;
|
||||
case 'W': if (false);
|
||||
case 'W':
|
||||
if (false)
|
||||
;
|
||||
FF_TEST_PACKAGE_NAME(WINGET)
|
||||
break;
|
||||
case 'X': if (false);
|
||||
case 'X':
|
||||
if (false)
|
||||
;
|
||||
FF_TEST_PACKAGE_NAME(XBPS)
|
||||
break;
|
||||
}
|
||||
#undef FF_TEST_PACKAGE_NAME
|
||||
#undef FF_TEST_PACKAGE_NAME
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (unsafe_yyjson_equals_str(key, "combined"))
|
||||
{
|
||||
if (unsafe_yyjson_equals_str(key, "combined")) {
|
||||
options->combined = yyjson_get_bool(val);
|
||||
continue;
|
||||
}
|
||||
@@ -332,18 +338,19 @@ void ffParsePackagesJsonObject(FFPackagesOptions* options, yyjson_val* module)
|
||||
}
|
||||
}
|
||||
|
||||
void ffGeneratePackagesJsonConfig(FFPackagesOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module)
|
||||
{
|
||||
void ffGeneratePackagesJsonConfig(FFPackagesOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) {
|
||||
ffJsonConfigGenerateModuleArgsConfig(doc, module, &options->moduleArgs);
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY buf = ffStrbufCreate();
|
||||
yyjson_mut_val* arr = yyjson_mut_obj_add_arr(doc, module, "disabled");
|
||||
#define FF_TEST_PACKAGE_NAME(name) else if ((options->disabled & FF_PACKAGES_FLAG_ ## name ## _BIT)) { \
|
||||
ffStrbufSetS(&buf, #name); \
|
||||
ffStrbufLowerCase(&buf); \
|
||||
yyjson_mut_arr_add_strbuf(doc, arr, &buf); \
|
||||
#define FF_TEST_PACKAGE_NAME(name) \
|
||||
else if ((options->disabled & FF_PACKAGES_FLAG_##name##_BIT)) { \
|
||||
ffStrbufSetS(&buf, #name); \
|
||||
ffStrbufLowerCase(&buf); \
|
||||
yyjson_mut_arr_add_strbuf(doc, arr, &buf); \
|
||||
}
|
||||
if (false);
|
||||
if (false)
|
||||
;
|
||||
FF_TEST_PACKAGE_NAME(AM)
|
||||
FF_TEST_PACKAGE_NAME(APK)
|
||||
FF_TEST_PACKAGE_NAME(BREW)
|
||||
@@ -377,27 +384,25 @@ void ffGeneratePackagesJsonConfig(FFPackagesOptions* options, yyjson_mut_doc* do
|
||||
FF_TEST_PACKAGE_NAME(SORCERY)
|
||||
FF_TEST_PACKAGE_NAME(WINGET)
|
||||
FF_TEST_PACKAGE_NAME(XBPS)
|
||||
#undef FF_TEST_PACKAGE_NAME
|
||||
#undef FF_TEST_PACKAGE_NAME
|
||||
|
||||
yyjson_mut_obj_add_bool(doc, module, "combined", options->combined);
|
||||
}
|
||||
|
||||
bool ffGeneratePackagesJsonResult(FF_MAYBE_UNUSED FFPackagesOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module)
|
||||
{
|
||||
bool ffGeneratePackagesJsonResult(FF_MAYBE_UNUSED FFPackagesOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) {
|
||||
FFPackagesResult counts = {};
|
||||
ffStrbufInit(&counts.pacmanBranch);
|
||||
|
||||
const char* error = ffDetectPackages(&counts, options);
|
||||
|
||||
if(error)
|
||||
{
|
||||
if (error) {
|
||||
yyjson_mut_obj_add_str(doc, module, "error", error);
|
||||
return false;
|
||||
}
|
||||
|
||||
yyjson_mut_val* obj = yyjson_mut_obj_add_obj(doc, module, "result");
|
||||
|
||||
#define FF_APPEND_PACKAGE_COUNT(name) yyjson_mut_obj_add_uint(doc, obj, #name, counts.name);
|
||||
#define FF_APPEND_PACKAGE_COUNT(name) yyjson_mut_obj_add_uint(doc, obj, #name, counts.name);
|
||||
|
||||
FF_APPEND_PACKAGE_COUNT(all)
|
||||
FF_APPEND_PACKAGE_COUNT(amSystem)
|
||||
@@ -445,16 +450,14 @@ bool ffGeneratePackagesJsonResult(FF_MAYBE_UNUSED FFPackagesOptions* options, yy
|
||||
return true;
|
||||
}
|
||||
|
||||
void ffInitPackagesOptions(FFPackagesOptions* options)
|
||||
{
|
||||
void ffInitPackagesOptions(FFPackagesOptions* options) {
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
|
||||
options->disabled = FF_PACKAGES_DISABLE_LIST;
|
||||
options->combined = false;
|
||||
}
|
||||
|
||||
void ffDestroyPackagesOptions(FFPackagesOptions* options)
|
||||
{
|
||||
void ffDestroyPackagesOptions(FFPackagesOptions* options) {
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
@@ -517,5 +520,4 @@ FFModuleBaseInfo ffPackagesModuleInfo = {
|
||||
{"Total number of all brew packages", "brew-all"},
|
||||
{"Total number of all guix packages", "guix-all"},
|
||||
{"Total number of all hpkg packages", "hpkg-all"},
|
||||
}))
|
||||
};
|
||||
}))};
|
||||
|
||||
Reference in New Issue
Block a user