mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-12 09:58:03 +02:00
Merge pull request #352 from CarterLi/dev
Global: remove caching functions except image caching
This commit is contained in:
@@ -39,5 +39,5 @@ Output of `fastfetch --list-features`:
|
||||
|
||||
<!--
|
||||
If you get the following error: `Error: couldn't find config: [...]`, copy the files in [presets](../../presets/) to `/usr/share/fastfetch/presets/` or `~/.local/share/fastfetch/presets/`.
|
||||
If this isn't possible (or too much work) for you, post the output of `fastfetch --show-errors --recache --multithreading false --disable-linewrap false`.
|
||||
If this isn't possible (or too much work) for you, post the output of `fastfetch --show-errors --multithreading false --disable-linewrap false`.
|
||||
-->
|
||||
|
||||
@@ -35,7 +35,7 @@ jobs:
|
||||
uses: github/codeql-action/analyze@v2
|
||||
|
||||
- name: run fastfetch
|
||||
run: time ./fastfetch --recache --disable-linewrap false --hide-cursor false --show-errors true --load-config presets/all
|
||||
run: time ./fastfetch --disable-linewrap false --hide-cursor false --show-errors true --load-config presets/all
|
||||
|
||||
- name: run flashfetch
|
||||
run: time ./flashfetch
|
||||
@@ -81,7 +81,7 @@ jobs:
|
||||
uses: github/codeql-action/analyze@v2
|
||||
|
||||
- name: run fastfetch
|
||||
run: time ./fastfetch --recache --disable-linewrap false --hide-cursor false --show-errors true --load-config presets/all
|
||||
run: time ./fastfetch --disable-linewrap false --hide-cursor false --show-errors true --load-config presets/all
|
||||
|
||||
- name: run flashfetch
|
||||
run: time ./flashfetch
|
||||
@@ -113,7 +113,7 @@ jobs:
|
||||
run: |
|
||||
cmake -DSET_TWEAK=Off -DBUILD_TESTS=On .
|
||||
cmake --build . --target package
|
||||
time ./fastfetch --recache --disable-linewrap false --hide-cursor false --show-errors true --load-config presets/all
|
||||
time ./fastfetch --disable-linewrap false --hide-cursor false --show-errors true --load-config presets/all
|
||||
time ./flashfetch
|
||||
ctest
|
||||
|
||||
@@ -180,7 +180,7 @@ jobs:
|
||||
run: cp /clang64/bin/{libcjson,libOpenCL,vulkan-1}.dll .
|
||||
|
||||
- name: run fastfetch
|
||||
run: time ./fastfetch --recache --disable-linewrap false --hide-cursor false --show-errors true --load-config presets/all
|
||||
run: time ./fastfetch --disable-linewrap false --hide-cursor false --show-errors true --load-config presets/all
|
||||
|
||||
- name: run flashfetch
|
||||
run: time ./flashfetch
|
||||
@@ -254,7 +254,7 @@ jobs:
|
||||
run: cp /mingw64/bin/{libcjson,libOpenCL,vulkan-1}.dll .
|
||||
|
||||
- name: run fastfetch
|
||||
run: time ./fastfetch --recache --disable-linewrap false --hide-cursor false --show-errors true --load-config presets/all
|
||||
run: time ./fastfetch --disable-linewrap false --hide-cursor false --show-errors true --load-config presets/all
|
||||
|
||||
- name: run flashfetch
|
||||
run: time ./flashfetch
|
||||
|
||||
@@ -221,7 +221,6 @@ configure_file(src/fastfetch_config.h.in fastfetch_config.h)
|
||||
|
||||
set(LIBFASTFETCH_SRC
|
||||
src/common/bar.c
|
||||
src/common/caching.c
|
||||
src/common/font.c
|
||||
src/common/format.c
|
||||
src/common/init.c
|
||||
|
||||
@@ -169,8 +169,6 @@ __fastfetch_completion()
|
||||
|
||||
local FF_OPTIONS_BOOL=(
|
||||
"-r"
|
||||
"--recache"
|
||||
"--nocache"
|
||||
"--show-errors"
|
||||
"--logo-print-remaining"
|
||||
"--multithreading"
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
--disable-linewrap false
|
||||
--multithreading false
|
||||
--show-errors
|
||||
--recache
|
||||
|
||||
@@ -1,327 +0,0 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/caching.h"
|
||||
#include "common/io.h"
|
||||
#include "common/printing.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define FF_CACHE_VERSION_NAME "cacheversion"
|
||||
#define FF_CACHE_VERSION_EXTENSION "ffv"
|
||||
|
||||
#define FF_CACHE_VALUE_EXTENSION "ffcv"
|
||||
#define FF_CACHE_SPLIT_EXTENSION "ffcs"
|
||||
|
||||
#define FF_CACHE_EXTENSION_V1 "ffc1"
|
||||
|
||||
static void getCacheFilePath(const FFinstance* instance, const char* moduleName, const char* extension, FFstrbuf* buffer)
|
||||
{
|
||||
ffStrbufAppend(buffer, &instance->state.cacheDir);
|
||||
ffStrbufAppendS(buffer, moduleName);
|
||||
|
||||
if(extension != NULL)
|
||||
{
|
||||
ffStrbufAppendC(buffer, '.');
|
||||
ffStrbufAppendS(buffer, extension);
|
||||
}
|
||||
}
|
||||
|
||||
static void readCacheFile(FFinstance* instance, const char* moduleName, const char* extension, FFstrbuf* buffer)
|
||||
{
|
||||
FFstrbuf path;
|
||||
ffStrbufInitA(&path, 64);
|
||||
getCacheFilePath(instance, moduleName, extension, &path);
|
||||
ffAppendFileBuffer(path.chars, buffer);
|
||||
ffStrbufDestroy(&path);
|
||||
}
|
||||
|
||||
static void writeCacheFile(FFinstance* instance, const char* moduleName, const char* extension, FFstrbuf* content)
|
||||
{
|
||||
FFstrbuf path;
|
||||
ffStrbufInitA(&path, 64);
|
||||
getCacheFilePath(instance, moduleName, extension, &path);
|
||||
ffWriteFileBuffer(path.chars, content);
|
||||
ffStrbufDestroy(&path);
|
||||
}
|
||||
|
||||
void ffCacheValidate(FFinstance* instance)
|
||||
{
|
||||
FFstrbuf content;
|
||||
ffStrbufInit(&content);
|
||||
readCacheFile(instance, FF_CACHE_VERSION_NAME, FF_CACHE_VERSION_EXTENSION, &content);
|
||||
|
||||
const char exactVersion[] = FASTFETCH_PROJECT_VERSION FASTFETCH_PROJECT_VERSION_TWEAK;
|
||||
|
||||
bool isSameVersion = ffStrbufCompS(&content, exactVersion) == 0;
|
||||
ffStrbufDestroy(&content);
|
||||
if(isSameVersion)
|
||||
return;
|
||||
|
||||
instance->config.recache = true;
|
||||
|
||||
FFstrbuf version;
|
||||
ffStrbufInitA(&version, sizeof(exactVersion));
|
||||
ffStrbufAppendS(&version, exactVersion);
|
||||
writeCacheFile(instance, FF_CACHE_VERSION_NAME, FF_CACHE_VERSION_EXTENSION, &version);
|
||||
ffStrbufDestroy(&version);
|
||||
}
|
||||
|
||||
void ffCacheOpenWrite(FFinstance* instance, const char* moduleName, FFcache* cache)
|
||||
{
|
||||
FFstrbuf cacheFileValue;
|
||||
ffStrbufInitA(&cacheFileValue, 64);
|
||||
getCacheFilePath(instance, moduleName, FF_CACHE_VALUE_EXTENSION, &cacheFileValue);
|
||||
cache->value = fopen(cacheFileValue.chars, "w");
|
||||
ffStrbufDestroy(&cacheFileValue);
|
||||
|
||||
FFstrbuf cacheFileSplit;
|
||||
ffStrbufInitA(&cacheFileSplit, 64);
|
||||
getCacheFilePath(instance, moduleName, FF_CACHE_SPLIT_EXTENSION, &cacheFileSplit);
|
||||
cache->split = fopen(cacheFileSplit.chars, "w");
|
||||
ffStrbufDestroy(&cacheFileSplit);
|
||||
}
|
||||
|
||||
void ffCacheClose(FFcache* cache)
|
||||
{
|
||||
if(cache->value != NULL)
|
||||
fclose(cache->value);
|
||||
|
||||
if(cache->split != NULL)
|
||||
fclose(cache->split);
|
||||
}
|
||||
|
||||
static bool printCachedValue(FFinstance* instance, const char* moduleName, const FFModuleArgs* moduleArgs)
|
||||
{
|
||||
FFstrbuf content;
|
||||
ffStrbufInitA(&content, 512);
|
||||
readCacheFile(instance, moduleName, FF_CACHE_VALUE_EXTENSION, &content);
|
||||
|
||||
ffStrbufTrimRight(&content, '\0'); //Strbuf always appends a '\0' at the end. We want the last null byte to be at the position of the length
|
||||
|
||||
if(content.length == 0)
|
||||
{
|
||||
ffStrbufDestroy(&content);
|
||||
return false;
|
||||
}
|
||||
|
||||
uint8_t moduleCounter = 1;
|
||||
|
||||
uint32_t startIndex = 0;
|
||||
while(startIndex < content.length)
|
||||
{
|
||||
uint32_t nullByteIndex = ffStrbufNextIndexC(&content, startIndex, '\0');
|
||||
uint8_t moduleIndex = (moduleCounter == 1 && nullByteIndex == content.length) ? 0 : moduleCounter;
|
||||
ffPrintLogoAndKey(instance, moduleName, moduleIndex, &moduleArgs->key);
|
||||
puts(content.chars + startIndex);
|
||||
startIndex = nullByteIndex + 1;
|
||||
++moduleCounter;
|
||||
}
|
||||
|
||||
ffStrbufDestroy(&content);
|
||||
|
||||
return moduleCounter > 1;
|
||||
}
|
||||
|
||||
static bool printCachedFormat(FFinstance* instance, const char* moduleName, const FFModuleArgs* moduleArgs, uint32_t numArgs)
|
||||
{
|
||||
FFstrbuf content;
|
||||
ffStrbufInitA(&content, 512);
|
||||
readCacheFile(instance, moduleName, FF_CACHE_SPLIT_EXTENSION, &content);
|
||||
|
||||
ffStrbufTrimRight(&content, '\0'); //Strbuf always appends a '\0' at the end. We want the last null byte to be at the position of the length
|
||||
|
||||
if(content.length == 0)
|
||||
return false;
|
||||
|
||||
uint8_t moduleCounter = 1;
|
||||
|
||||
FFformatarg* arguments = calloc(numArgs, sizeof(FFformatarg));
|
||||
uint32_t argumentCounter = 0;
|
||||
|
||||
uint32_t startIndex = 0;
|
||||
while(startIndex < content.length)
|
||||
{
|
||||
arguments[argumentCounter].type = FF_FORMAT_ARG_TYPE_STRING;
|
||||
arguments[argumentCounter].value = &content.chars[startIndex];
|
||||
++argumentCounter;
|
||||
|
||||
uint32_t nullByteIndex = ffStrbufNextIndexC(&content, startIndex, '\0');
|
||||
|
||||
if(argumentCounter == numArgs)
|
||||
{
|
||||
uint8_t moduleIndex = (moduleCounter == 1 && nullByteIndex == content.length) ? 0 : moduleCounter;
|
||||
ffPrintFormat(instance, moduleName, moduleIndex, moduleArgs, numArgs, arguments);
|
||||
++moduleCounter;
|
||||
argumentCounter = 0;
|
||||
}
|
||||
|
||||
startIndex = nullByteIndex + 1;
|
||||
}
|
||||
|
||||
free(arguments);
|
||||
ffStrbufDestroy(&content);
|
||||
|
||||
return moduleCounter > 1;
|
||||
}
|
||||
|
||||
bool ffPrintFromCache(FFinstance* instance, const char* moduleName, const FFModuleArgs* moduleArgs, uint32_t numArgs)
|
||||
{
|
||||
if(instance->config.recache)
|
||||
return false;
|
||||
|
||||
if(moduleArgs->outputFormat.length == 0)
|
||||
return printCachedValue(instance, moduleName, moduleArgs);
|
||||
else
|
||||
return printCachedFormat(instance, moduleName, moduleArgs, numArgs);
|
||||
}
|
||||
|
||||
void ffPrintAndAppendToCache(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, FFcache* cache, const FFstrbuf* value, uint32_t numArgs, const FFformatarg* arguments)
|
||||
{
|
||||
if(moduleArgs->outputFormat.length == 0)
|
||||
{
|
||||
ffPrintLogoAndKey(instance, moduleName, moduleIndex, &moduleArgs->key);
|
||||
ffStrbufPutTo(value, stdout);
|
||||
}
|
||||
else
|
||||
{
|
||||
ffPrintFormat(instance, moduleName, moduleIndex, moduleArgs, numArgs, arguments);
|
||||
}
|
||||
|
||||
if(cache->value != NULL)
|
||||
{
|
||||
ffStrbufWriteTo(value, cache->value);
|
||||
fputc('\0', cache->value);
|
||||
}
|
||||
|
||||
if(cache->split == NULL)
|
||||
return;
|
||||
|
||||
for(uint32_t i = 0; i < numArgs; i++)
|
||||
{
|
||||
FFstrbuf buffer;
|
||||
ffStrbufInitA(&buffer, 64);
|
||||
ffFormatAppendFormatArg(&buffer, &arguments[i]);
|
||||
ffStrbufWriteTo(&buffer, cache->split);
|
||||
ffStrbufDestroy(&buffer);
|
||||
fputc('\0', cache->split);
|
||||
}
|
||||
}
|
||||
|
||||
void ffPrintAndWriteToCache(FFinstance* instance, const char* moduleName, const FFModuleArgs* moduleArgs, const FFstrbuf* value, uint32_t numArgs, const FFformatarg* arguments)
|
||||
{
|
||||
FFcache cache;
|
||||
ffCacheOpenWrite(instance, moduleName, &cache);
|
||||
ffPrintAndAppendToCache(instance, moduleName, 0, moduleArgs, &cache, value, numArgs, arguments);
|
||||
ffCacheClose(&cache);
|
||||
}
|
||||
|
||||
typedef struct FFCacheRead
|
||||
{
|
||||
FFstrbuf data;
|
||||
uint32_t position;
|
||||
} FFCacheRead;
|
||||
|
||||
static bool cacheReadStrbuf(FFCacheRead* cacheRead, FFstrbuf* strbuf)
|
||||
{
|
||||
if(cacheRead->position >= cacheRead->data.length)
|
||||
return false;
|
||||
|
||||
ffStrbufAppendS(strbuf, cacheRead->data.chars + cacheRead->position);
|
||||
cacheRead->position += strbuf->length + 1; // skip the null byte too
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool cacheReadData(FFCacheRead* cacheRead, size_t dataSize, void* data)
|
||||
{
|
||||
if(cacheRead->position + dataSize > cacheRead->data.length)
|
||||
return false;
|
||||
|
||||
memcpy(data, cacheRead->data.chars + cacheRead->position, dataSize);
|
||||
cacheRead->position += (uint32_t) dataSize;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool cacheResetStrbuf(FFCache* cache, FFstrbuf* strbuf)
|
||||
{
|
||||
FF_UNUSED(cache);
|
||||
ffStrbufClear(strbuf);
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool cacheResetData(FFCache* cacheRead, size_t dataSize, void* data)
|
||||
{
|
||||
FF_UNUSED(cacheRead, dataSize, data);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ffCacheRead(const FFinstance* instance, void* obj, const char* cacheName, FFCacheMethodCallback callback)
|
||||
{
|
||||
if(instance->config.recache)
|
||||
return false;
|
||||
|
||||
FFCacheRead cache;
|
||||
bool result;
|
||||
|
||||
FFstrbuf path;
|
||||
ffStrbufInitA(&path, 128);
|
||||
getCacheFilePath(instance, cacheName, FF_CACHE_EXTENSION_V1, &path);
|
||||
|
||||
cache.position = 0;
|
||||
|
||||
ffStrbufInitA(&cache.data, 256);
|
||||
result = ffAppendFileBuffer(path.chars, &cache.data);
|
||||
|
||||
if(result)
|
||||
result = callback(obj, &cache, (FFCacheMethodStrbuf) cacheReadStrbuf, (FFCacheMethodData) cacheReadData);
|
||||
|
||||
if(result)
|
||||
result = cache.position == cache.data.length;
|
||||
|
||||
if(!result)
|
||||
callback(obj, NULL, (FFCacheMethodStrbuf) cacheResetStrbuf, (FFCacheMethodData) cacheResetData);
|
||||
|
||||
ffStrbufDestroy(&cache.data);
|
||||
ffStrbufDestroy(&path);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
typedef struct FFCacheWrite
|
||||
{
|
||||
FFstrbuf data;
|
||||
} FFCacheWrite;
|
||||
|
||||
static bool cacheWriteStrbuf(FFCacheWrite* cacheWrite, FFstrbuf* strbuf)
|
||||
{
|
||||
ffStrbufEnsureFree(&cacheWrite->data, strbuf->length);
|
||||
memcpy(cacheWrite->data.chars + cacheWrite->data.length, strbuf->chars, strbuf->length +1); //Copy the nullbyte too
|
||||
cacheWrite->data.length += strbuf->length + 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool cacheWriteData(FFCacheWrite* cacheWrite, size_t dataSize, const void* data)
|
||||
{
|
||||
ffStrbufEnsureFree(&cacheWrite->data, (uint32_t) dataSize);
|
||||
memcpy(cacheWrite->data.chars + cacheWrite->data.length, data, dataSize);
|
||||
cacheWrite->data.length += (uint32_t) dataSize;
|
||||
return true;
|
||||
}
|
||||
|
||||
void ffCacheWrite(const FFinstance* instance, void* obj, const char* cacheName, FFCacheMethodCallback callback)
|
||||
{
|
||||
if(!instance->config.cacheSave)
|
||||
return;
|
||||
|
||||
FFCacheWrite cache;
|
||||
|
||||
FFstrbuf path;
|
||||
ffStrbufInitA(&path, 128);
|
||||
getCacheFilePath(instance, cacheName, FF_CACHE_EXTENSION_V1, &path);
|
||||
|
||||
ffStrbufInitA(&cache.data, 256);
|
||||
callback(obj, &cache, (FFCacheMethodStrbuf) cacheWriteStrbuf, (FFCacheMethodData) cacheWriteData);
|
||||
ffWriteFileBuffer(path.chars, &cache.data);
|
||||
|
||||
ffStrbufDestroy(&cache.data);
|
||||
ffStrbufDestroy(&path);
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef FF_INCLUDED_common_caching
|
||||
#define FF_INCLUDED_common_caching
|
||||
|
||||
#include "fastfetch.h"
|
||||
#include "common/format.h"
|
||||
|
||||
typedef struct FFcache
|
||||
{
|
||||
FILE* value;
|
||||
FILE* split;
|
||||
} FFcache;
|
||||
|
||||
void ffCacheValidate(FFinstance* instance);
|
||||
|
||||
void ffCacheOpenWrite(FFinstance* instance, const char* moduleName, FFcache* cache);
|
||||
void ffCacheClose(FFcache* cache);
|
||||
|
||||
bool ffPrintFromCache(FFinstance* instance, const char* moduleName, const FFModuleArgs* moduleArgs, uint32_t numArgs);
|
||||
void ffPrintAndAppendToCache(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, FFcache* cache, const FFstrbuf* value, uint32_t numArgs, const FFformatarg* arguments);
|
||||
void ffPrintAndWriteToCache(FFinstance* instance, const char* moduleName, const FFModuleArgs* moduleArgs, const FFstrbuf* value, uint32_t numArgs, const FFformatarg* arguments);
|
||||
|
||||
typedef void FFCache;
|
||||
|
||||
typedef bool(*FFCacheMethodStrbuf)(FFCache* cache, FFstrbuf* strbuf);
|
||||
typedef bool(*FFCacheMethodData)(FFCache* cache, size_t dataSize, void* data);
|
||||
typedef bool(*FFCacheMethodCallback)(void* data, FFCache* cache, FFCacheMethodStrbuf strbufMethod, FFCacheMethodData dataMethod);
|
||||
|
||||
bool ffCacheRead(const FFinstance* instance, void* obj, const char* cacheName, FFCacheMethodCallback callback);
|
||||
void ffCacheWrite(const FFinstance* instance, void* obj, const char* cacheName, FFCacheMethodCallback callback);
|
||||
|
||||
#endif
|
||||
@@ -1,5 +1,4 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/caching.h"
|
||||
#include "common/parsing.h"
|
||||
#include "common/thread.h"
|
||||
#include "detection/qt.h"
|
||||
@@ -96,34 +95,6 @@ static void initConfigDirs(FFstate* state)
|
||||
#undef FF_ENSURE_ONLY_ONCE_IN_LIST
|
||||
}
|
||||
|
||||
static void initCacheDir(FFstate* state)
|
||||
{
|
||||
ffStrbufInitA(&state->cacheDir, 64);
|
||||
|
||||
ffStrbufAppendS(&state->cacheDir, getenv("XDG_CACHE_HOME"));
|
||||
|
||||
if(state->cacheDir.length == 0)
|
||||
{
|
||||
ffStrbufAppendS(&state->cacheDir, state->passwd->pw_dir);
|
||||
ffStrbufAppendS(&state->cacheDir, "/.cache/");
|
||||
}
|
||||
else
|
||||
ffStrbufEnsureEndsWithC(&state->cacheDir, '/');
|
||||
|
||||
mkdir(state->cacheDir.chars
|
||||
#ifndef WIN32
|
||||
, S_IRWXU | S_IXGRP | S_IRGRP | S_IXOTH | S_IROTH
|
||||
#endif
|
||||
); //I hope everybody has a cache folder, but who knows
|
||||
|
||||
ffStrbufAppendS(&state->cacheDir, "fastfetch/");
|
||||
mkdir(state->cacheDir.chars
|
||||
#ifndef WIN32
|
||||
, S_IRWXU | S_IRGRP | S_IROTH
|
||||
#endif
|
||||
);
|
||||
}
|
||||
|
||||
static void initState(FFstate* state)
|
||||
{
|
||||
#ifdef WIN32
|
||||
@@ -146,7 +117,6 @@ static void initState(FFstate* state)
|
||||
#endif
|
||||
|
||||
initConfigDirs(state);
|
||||
initCacheDir(state);
|
||||
}
|
||||
|
||||
static void initModuleArg(FFModuleArgs* args)
|
||||
@@ -176,7 +146,6 @@ static void defaultConfig(FFinstance* instance)
|
||||
|
||||
instance->config.showErrors = false;
|
||||
instance->config.recache = false;
|
||||
instance->config.cacheSave = true;
|
||||
instance->config.allowSlowOperations = false;
|
||||
instance->config.disableLinewrap = true;
|
||||
instance->config.hideCursor = true;
|
||||
@@ -381,10 +350,6 @@ void ffStart(FFinstance* instance)
|
||||
sigaction(SIGQUIT, &action, NULL);
|
||||
#endif
|
||||
|
||||
//We do the cache validation here, so we can skip it if --recache is given
|
||||
if(!instance->config.recache)
|
||||
ffCacheValidate(instance);
|
||||
|
||||
//reset everything to default before we start printing
|
||||
if(!instance->config.pipe)
|
||||
fputs(FASTFETCH_TEXT_MODIFIER_RESET, stdout);
|
||||
@@ -503,8 +468,6 @@ static void destroyState(FFinstance* instance)
|
||||
for(uint32_t i = 0; i < instance->state.configDirs.length; ++i)
|
||||
ffStrbufDestroy((FFstrbuf*)ffListGet(&instance->state.configDirs, i));
|
||||
ffListDestroy(&instance->state.configDirs);
|
||||
|
||||
ffStrbufDestroy(&instance->state.cacheDir);
|
||||
}
|
||||
|
||||
void ffDestroyInstance(FFinstance* instance)
|
||||
|
||||
@@ -185,7 +185,6 @@
|
||||
# OS file option
|
||||
# Sets the path to the file containing the operating system information.
|
||||
# Should be a valid path to an existing file.
|
||||
# Note that you might need to run fastfetch with --recache once for it to take affect.
|
||||
# Default is /etc/os-release.
|
||||
#--os-file /etc/os-release
|
||||
|
||||
|
||||
@@ -14,8 +14,6 @@ Informative options:
|
||||
--print-structure: prints the default stucture and exits
|
||||
|
||||
General options:
|
||||
-r,--recache <?value>: generate new cached values
|
||||
--nocache <?value>: don't use cached values, but also don't overwrite existing ones
|
||||
--load-config <file>: load a config file or a preset (+)
|
||||
--multithreading <?value>: use multiple threads to detect values
|
||||
--stat <?value>: print time usage (in ms) for individual modules
|
||||
|
||||
+2
-25
@@ -1,34 +1,13 @@
|
||||
#include "cpu.h"
|
||||
#include "common/caching.h"
|
||||
#include "detection/internal.h"
|
||||
|
||||
#define FF_CPU_CACHE_NAME "cpu"
|
||||
|
||||
void ffDetectCPUImpl(const FFinstance* instance, FFCPUResult* cpu, bool cached);
|
||||
|
||||
static bool cacheCallback(FFCPUResult* cpu, FFCache* cache, FFCacheMethodStrbuf strbufMethod, FFCacheMethodData dataMethod)
|
||||
{
|
||||
return
|
||||
strbufMethod(cache, &cpu->vendor) &&
|
||||
strbufMethod(cache, &cpu->name) &&
|
||||
dataMethod(cache, sizeof(cpu->coresPhysical), &cpu->coresPhysical) &&
|
||||
dataMethod(cache, sizeof(cpu->coresLogical), &cpu->coresLogical) &&
|
||||
dataMethod(cache, sizeof(cpu->coresOnline), &cpu->coresOnline) &&
|
||||
dataMethod(cache, sizeof(cpu->frequencyMin), &cpu->frequencyMin) &&
|
||||
dataMethod(cache, sizeof(cpu->frequencyMax), &cpu->frequencyMax);
|
||||
}
|
||||
|
||||
void ffDetectCPUImpl(const FFinstance* instance, FFCPUResult* cpu);
|
||||
static void detectCPU(const FFinstance* instance, FFCPUResult* cpu)
|
||||
{
|
||||
ffStrbufInit(&cpu->name);
|
||||
ffStrbufInit(&cpu->vendor);
|
||||
|
||||
bool cached = ffCacheRead(instance, cpu, FF_CPU_CACHE_NAME, (FFCacheMethodCallback) cacheCallback);
|
||||
|
||||
ffDetectCPUImpl(instance, cpu, cached);
|
||||
|
||||
if(cached)
|
||||
return;
|
||||
ffDetectCPUImpl(instance, cpu);
|
||||
|
||||
const char* removeStrings[] = {
|
||||
" CPU", " FPU", " APU", " Processor",
|
||||
@@ -39,8 +18,6 @@ static void detectCPU(const FFinstance* instance, FFCPUResult* cpu)
|
||||
ffStrbufRemoveStringsA(&cpu->name, sizeof(removeStrings) / sizeof(removeStrings[0]), removeStrings);
|
||||
ffStrbufSubstrBeforeFirstC(&cpu->name, '@'); //Cut the speed output in the name as we append our own
|
||||
ffStrbufTrimRight(&cpu->name, ' '); //If we removed the @ in previous step there was most likely a space before it
|
||||
|
||||
ffCacheWrite(instance, cpu, FF_CPU_CACHE_NAME, (FFCacheMethodCallback) cacheCallback);
|
||||
}
|
||||
|
||||
const FFCPUResult* ffDetectCPU(const FFinstance* instance)
|
||||
|
||||
@@ -41,32 +41,29 @@ static double detectCpuTemp(const FFstrbuf* cpuName)
|
||||
return result;
|
||||
}
|
||||
|
||||
void ffDetectCPUImpl(const FFinstance* instance, FFCPUResult* cpu, bool cached)
|
||||
void ffDetectCPUImpl(const FFinstance* instance, FFCPUResult* cpu)
|
||||
{
|
||||
FF_UNUSED(instance);
|
||||
|
||||
if(!cached)
|
||||
{
|
||||
ffSysctlGetString("machdep.cpu.brand_string", &cpu->name);
|
||||
ffSysctlGetString("machdep.cpu.vendor", &cpu->vendor);
|
||||
ffSysctlGetString("machdep.cpu.brand_string", &cpu->name);
|
||||
ffSysctlGetString("machdep.cpu.vendor", &cpu->vendor);
|
||||
|
||||
cpu->coresPhysical = (uint16_t) ffSysctlGetInt("hw.physicalcpu_max", 1);
|
||||
if(cpu->coresPhysical == 1)
|
||||
cpu->coresPhysical = (uint16_t) ffSysctlGetInt("hw.physicalcpu", 1);
|
||||
cpu->coresPhysical = (uint16_t) ffSysctlGetInt("hw.physicalcpu_max", 1);
|
||||
if(cpu->coresPhysical == 1)
|
||||
cpu->coresPhysical = (uint16_t) ffSysctlGetInt("hw.physicalcpu", 1);
|
||||
|
||||
cpu->coresLogical = (uint16_t) ffSysctlGetInt("hw.logicalcpu_max", 1);
|
||||
if(cpu->coresLogical == 1)
|
||||
cpu->coresLogical = (uint16_t) ffSysctlGetInt("hw.ncpu", 1);
|
||||
cpu->coresLogical = (uint16_t) ffSysctlGetInt("hw.logicalcpu_max", 1);
|
||||
if(cpu->coresLogical == 1)
|
||||
cpu->coresLogical = (uint16_t) ffSysctlGetInt("hw.ncpu", 1);
|
||||
|
||||
cpu->coresOnline = (uint16_t) ffSysctlGetInt("hw.logicalcpu", 1);
|
||||
if(cpu->coresOnline == 1)
|
||||
cpu->coresOnline = (uint16_t) ffSysctlGetInt("hw.activecpu", 1);
|
||||
cpu->coresOnline = (uint16_t) ffSysctlGetInt("hw.logicalcpu", 1);
|
||||
if(cpu->coresOnline == 1)
|
||||
cpu->coresOnline = (uint16_t) ffSysctlGetInt("hw.activecpu", 1);
|
||||
|
||||
cpu->frequencyMin = getFrequency("hw.cpufrequency_min");
|
||||
cpu->frequencyMax = getFrequency("hw.cpufrequency_max");
|
||||
if(cpu->frequencyMax == 0.0)
|
||||
cpu->frequencyMax = getFrequency("hw.cpufrequency");
|
||||
}
|
||||
cpu->frequencyMin = getFrequency("hw.cpufrequency_min");
|
||||
cpu->frequencyMax = getFrequency("hw.cpufrequency_max");
|
||||
if(cpu->frequencyMax == 0.0)
|
||||
cpu->frequencyMax = getFrequency("hw.cpufrequency");
|
||||
|
||||
if (instance->config.cpuTemp)
|
||||
cpu->temperature = detectCpuTemp(&cpu->name);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "cpu.h"
|
||||
#include "common/sysctl.h"
|
||||
|
||||
void ffDetectCPUImpl(const FFinstance* instance, FFCPUResult* cpu, bool cached)
|
||||
void ffDetectCPUImpl(const FFinstance* instance, FFCPUResult* cpu)
|
||||
{
|
||||
FF_UNUSED(instance);
|
||||
|
||||
@@ -17,9 +17,6 @@ void ffDetectCPUImpl(const FFinstance* instance, FFCPUResult* cpu, bool cached)
|
||||
else
|
||||
cpu->temperature = FF_CPU_TEMP_UNSET;
|
||||
|
||||
if(cached)
|
||||
return;
|
||||
|
||||
ffSysctlGetString("hw.model", &cpu->name);
|
||||
|
||||
cpu->coresPhysical = (uint16_t) ffSysctlGetInt("hw.ncpu", 1);
|
||||
|
||||
@@ -82,16 +82,13 @@ static double detectCPUTemp(const FFinstance* instance)
|
||||
return FF_CPU_TEMP_UNSET;
|
||||
}
|
||||
|
||||
void ffDetectCPUImpl(const FFinstance* instance, FFCPUResult* cpu, bool cached)
|
||||
void ffDetectCPUImpl(const FFinstance* instance, FFCPUResult* cpu)
|
||||
{
|
||||
if(instance->config.cpuTemp)
|
||||
cpu->temperature = detectCPUTemp(instance);
|
||||
else
|
||||
cpu->temperature = FF_CPU_TEMP_UNSET;
|
||||
|
||||
if(cached)
|
||||
return;
|
||||
|
||||
FFstrbuf physicalCoresBuffer;
|
||||
ffStrbufInit(&physicalCoresBuffer);
|
||||
|
||||
|
||||
@@ -2,15 +2,11 @@
|
||||
#include "util/windows/registry.h"
|
||||
#include "util/mallocHelper.h"
|
||||
|
||||
void ffDetectCPUImpl(const FFinstance* instance, FFCPUResult* cpu, bool cached)
|
||||
void ffDetectCPUImpl(const FFinstance* instance, FFCPUResult* cpu)
|
||||
{
|
||||
FF_UNUSED(instance);
|
||||
|
||||
cpu->temperature = FF_CPU_TEMP_UNSET;
|
||||
|
||||
if(cached)
|
||||
return;
|
||||
|
||||
cpu->coresPhysical = cpu->coresLogical = cpu->coresOnline = 0;
|
||||
cpu->frequencyMax = cpu->frequencyMin = 0;
|
||||
ffStrbufInit(&cpu->name);
|
||||
|
||||
+1
-8
@@ -895,16 +895,9 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con
|
||||
///////////////////
|
||||
|
||||
else if(strcasecmp(key, "-r") == 0 || strcasecmp(key, "--recache") == 0)
|
||||
{
|
||||
//Set cacheSave as well, because the user expects the values to be cached when expliciting using --recache
|
||||
instance->config.recache = optionParseBoolean(value);
|
||||
instance->config.cacheSave = instance->config.recache;
|
||||
}
|
||||
else if(strcasecmp(key, "--nocache") == 0)
|
||||
{
|
||||
instance->config.recache = optionParseBoolean(value);
|
||||
instance->config.cacheSave = false;
|
||||
}
|
||||
fputs("`--nocache` are obsoleted. Caching functions other than image caching are removed.\n\n", stderr);
|
||||
else if(strcasecmp(key, "--load-config") == 0)
|
||||
optionParseConfigFile(instance, data, key, value);
|
||||
else if(strcasecmp(key, "--thread") == 0 || strcasecmp(key, "--multithreading") == 0)
|
||||
|
||||
@@ -85,7 +85,6 @@ typedef struct FFconfig
|
||||
|
||||
bool showErrors;
|
||||
bool recache;
|
||||
bool cacheSave;
|
||||
bool allowSlowOperations;
|
||||
bool disableLinewrap;
|
||||
bool hideCursor;
|
||||
|
||||
+14
-10
@@ -1,6 +1,5 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/printing.h"
|
||||
#include "common/caching.h"
|
||||
#include "detection/bios/bios.h"
|
||||
|
||||
#define FF_BIOS_MODULE_NAME "Bios"
|
||||
@@ -8,9 +7,6 @@
|
||||
|
||||
void ffPrintBios(FFinstance* instance)
|
||||
{
|
||||
if(ffPrintFromCache(instance, FF_BIOS_MODULE_NAME, &instance->config.bios, FF_BIOS_NUM_FORMAT_ARGS))
|
||||
return;
|
||||
|
||||
FFBiosResult result;
|
||||
ffDetectBios(&result);
|
||||
|
||||
@@ -26,12 +22,20 @@ void ffPrintBios(FFinstance* instance)
|
||||
goto exit;
|
||||
}
|
||||
|
||||
ffPrintAndWriteToCache(instance, FF_BIOS_MODULE_NAME, &instance->config.bios, &result.biosRelease, FF_BIOS_NUM_FORMAT_ARGS, (FFformatarg[]) {
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result.biosDate},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result.biosRelease},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result.biosVendor},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result.biosVersion},
|
||||
});
|
||||
if(instance->config.bios.outputFormat.length == 0)
|
||||
{
|
||||
ffPrintLogoAndKey(instance, FF_BIOS_MODULE_NAME, 0, &instance->config.bios.key);
|
||||
puts(result.biosRelease.chars);
|
||||
}
|
||||
else
|
||||
{
|
||||
ffPrintFormat(instance, FF_BIOS_MODULE_NAME, 0, &instance->config.bios, FF_BIOS_NUM_FORMAT_ARGS, (FFformatarg[]) {
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result.biosDate},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result.biosRelease},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result.biosVendor},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result.biosVersion},
|
||||
});
|
||||
}
|
||||
|
||||
exit:
|
||||
ffStrbufDestroy(&result.biosDate);
|
||||
|
||||
+13
-9
@@ -1,6 +1,5 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/printing.h"
|
||||
#include "common/caching.h"
|
||||
#include "detection/board/board.h"
|
||||
|
||||
#define FF_BOARD_MODULE_NAME "Board"
|
||||
@@ -8,9 +7,6 @@
|
||||
|
||||
void ffPrintBoard(FFinstance* instance)
|
||||
{
|
||||
if(ffPrintFromCache(instance, FF_BOARD_MODULE_NAME, &instance->config.board, FF_BOARD_NUM_FORMAT_ARGS))
|
||||
return;
|
||||
|
||||
FFBoardResult result;
|
||||
ffDetectBoard(&result);
|
||||
|
||||
@@ -26,11 +22,19 @@ void ffPrintBoard(FFinstance* instance)
|
||||
goto exit;
|
||||
}
|
||||
|
||||
ffPrintAndWriteToCache(instance, FF_BOARD_MODULE_NAME, &instance->config.board, &result.boardName, FF_BOARD_NUM_FORMAT_ARGS, (FFformatarg[]) {
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result.boardName},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result.boardVendor},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result.boardVersion},
|
||||
});
|
||||
if(instance->config.board.outputFormat.length == 0)
|
||||
{
|
||||
ffPrintLogoAndKey(instance, FF_BOARD_MODULE_NAME, 0, &instance->config.board.key);
|
||||
puts(result.boardName.chars);
|
||||
}
|
||||
else
|
||||
{
|
||||
ffPrintFormat(instance, FF_BOARD_MODULE_NAME, 0, &instance->config.board, FF_BOARD_NUM_FORMAT_ARGS, (FFformatarg[]) {
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result.boardName},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result.boardVendor},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result.boardVersion},
|
||||
});
|
||||
}
|
||||
|
||||
exit:
|
||||
ffStrbufDestroy(&result.boardName);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/printing.h"
|
||||
#include "common/caching.h"
|
||||
#include "detection/cpu/cpu.h"
|
||||
|
||||
#define FF_CPU_MODULE_NAME "CPU"
|
||||
|
||||
+35
-35
@@ -1,6 +1,5 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/printing.h"
|
||||
#include "common/caching.h"
|
||||
#include "detection/host/host.h"
|
||||
#include "detection/gpu/gpu.h"
|
||||
|
||||
@@ -9,41 +8,47 @@
|
||||
#define FF_GPU_MODULE_NAME "GPU"
|
||||
#define FF_GPU_NUM_FORMAT_ARGS 5
|
||||
|
||||
static void printGPUResult(FFinstance* instance, uint8_t index, FFcache* cache, FFGPUResult* gpu)
|
||||
static void printGPUResult(FFinstance* instance, uint8_t index, FFGPUResult* gpu)
|
||||
{
|
||||
FFstrbuf output;
|
||||
ffStrbufInitA(&output, gpu->vendor.length + 1 + gpu->name.length);
|
||||
|
||||
if(gpu->vendor.length > 0 && !ffStrbufStartsWith(&gpu->name, &gpu->vendor))
|
||||
if(instance->config.gpu.outputFormat.length == 0)
|
||||
{
|
||||
ffStrbufAppend(&output, &gpu->vendor);
|
||||
ffStrbufAppendC(&output, ' ');
|
||||
ffPrintLogoAndKey(instance, FF_GPU_MODULE_NAME, 0, &instance->config.gpu.key);
|
||||
|
||||
FFstrbuf output;
|
||||
ffStrbufInitA(&output, gpu->vendor.length + 1 + gpu->name.length);
|
||||
|
||||
if(gpu->vendor.length > 0 && !ffStrbufStartsWith(&gpu->name, &gpu->vendor))
|
||||
{
|
||||
ffStrbufAppend(&output, &gpu->vendor);
|
||||
ffStrbufAppendC(&output, ' ');
|
||||
}
|
||||
|
||||
ffStrbufAppend(&output, &gpu->name);
|
||||
|
||||
if(gpu->coreCount != FF_GPU_CORE_COUNT_UNSET)
|
||||
ffStrbufAppendF(&output, " (%d)", gpu->coreCount);
|
||||
|
||||
if(gpu->temperature == gpu->temperature) //FF_GPU_TEMP_UNSET
|
||||
ffStrbufAppendF(&output, " - %.1f°C", gpu->temperature);
|
||||
|
||||
ffStrbufPutTo(&output, stdout);
|
||||
|
||||
ffStrbufDestroy(&output);
|
||||
}
|
||||
else
|
||||
{
|
||||
ffPrintFormat(instance, FF_GPU_MODULE_NAME, index, &instance->config.gpu, FF_GPU_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &gpu->vendor},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &gpu->name},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &gpu->driver},
|
||||
{FF_FORMAT_ARG_TYPE_DOUBLE, &gpu->temperature},
|
||||
{FF_FORMAT_ARG_TYPE_INT, &gpu->coreCount},
|
||||
});
|
||||
}
|
||||
|
||||
ffStrbufAppend(&output, &gpu->name);
|
||||
|
||||
if(gpu->coreCount != FF_GPU_CORE_COUNT_UNSET)
|
||||
ffStrbufAppendF(&output, " (%d)", gpu->coreCount);
|
||||
|
||||
if(gpu->temperature == gpu->temperature) //FF_GPU_TEMP_UNSET
|
||||
ffStrbufAppendF(&output, " - %.1f°C", gpu->temperature);
|
||||
|
||||
ffPrintAndAppendToCache(instance, FF_GPU_MODULE_NAME, index, &instance->config.gpu, cache, &output, FF_GPU_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &gpu->vendor},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &gpu->name},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &gpu->driver},
|
||||
{FF_FORMAT_ARG_TYPE_DOUBLE, &gpu->temperature}, //FIXME: temperature shouldn't be cached
|
||||
{FF_FORMAT_ARG_TYPE_INT, &gpu->coreCount},
|
||||
});
|
||||
|
||||
ffStrbufDestroy(&output);
|
||||
}
|
||||
|
||||
void ffPrintGPU(FFinstance* instance)
|
||||
{
|
||||
if(ffPrintFromCache(instance, FF_GPU_MODULE_NAME, &instance->config.gpu, FF_GPU_NUM_FORMAT_ARGS))
|
||||
return;
|
||||
|
||||
const FFlist* gpus = ffDetectGPU(instance);
|
||||
|
||||
if(gpus->length == 0)
|
||||
@@ -52,11 +57,6 @@ void ffPrintGPU(FFinstance* instance)
|
||||
return;
|
||||
}
|
||||
|
||||
FFcache cache;
|
||||
ffCacheOpenWrite(instance, FF_GPU_MODULE_NAME, &cache);
|
||||
|
||||
for(uint8_t i = 0; i < (uint8_t) gpus->length; i++)
|
||||
printGPUResult(instance, gpus->length == 1 ? 0 : (uint8_t) (i + 1), &cache, ffListGet(gpus, i));
|
||||
|
||||
ffCacheClose(&cache);
|
||||
printGPUResult(instance, gpus->length == 1 ? 0 : (uint8_t) (i + 1), ffListGet(gpus, i));
|
||||
}
|
||||
|
||||
+32
-27
@@ -1,6 +1,5 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/printing.h"
|
||||
#include "common/caching.h"
|
||||
#include "detection/host/host.h"
|
||||
|
||||
#define FF_HOST_MODULE_NAME "Host"
|
||||
@@ -8,9 +7,6 @@
|
||||
|
||||
void ffPrintHost(FFinstance* instance)
|
||||
{
|
||||
if(ffPrintFromCache(instance, FF_HOST_MODULE_NAME, &instance->config.host, FF_HOST_NUM_FORMAT_ARGS))
|
||||
return;
|
||||
|
||||
const FFHostResult* host = ffDetectHost();
|
||||
|
||||
if(host->error.length > 0)
|
||||
@@ -25,29 +21,38 @@ void ffPrintHost(FFinstance* instance)
|
||||
return;
|
||||
}
|
||||
|
||||
FFstrbuf output;
|
||||
ffStrbufInit(&output);
|
||||
|
||||
if(host->productName.length > 0)
|
||||
ffStrbufAppend(&output, &host->productName);
|
||||
else
|
||||
ffStrbufAppend(&output, &host->productFamily);
|
||||
|
||||
if(host->productVersion.length > 0)
|
||||
if(instance->config.host.outputFormat.length == 0)
|
||||
{
|
||||
ffStrbufAppendF(&output, " (%s)", host->productVersion.chars);
|
||||
ffPrintLogoAndKey(instance, FF_HOST_MODULE_NAME, 0, &instance->config.host.key);
|
||||
|
||||
FFstrbuf output;
|
||||
ffStrbufInit(&output);
|
||||
|
||||
if(host->productName.length > 0)
|
||||
ffStrbufAppend(&output, &host->productName);
|
||||
else
|
||||
ffStrbufAppend(&output, &host->productFamily);
|
||||
|
||||
if(host->productVersion.length > 0)
|
||||
{
|
||||
ffStrbufAppendF(&output, " (%s)", host->productVersion.chars);
|
||||
}
|
||||
|
||||
ffStrbufPutTo(&output, stdout);
|
||||
|
||||
ffStrbufDestroy(&output);
|
||||
}
|
||||
else
|
||||
{
|
||||
ffPrintFormat(instance, FF_HOST_MODULE_NAME, 0, &instance->config.host, FF_HOST_NUM_FORMAT_ARGS, (FFformatarg[]) {
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &host->productFamily},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &host->productName},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &host->productVersion},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &host->productSku},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &host->chassisType},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &host->chassisVendor},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &host->chassisVersion},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &host->sysVendor}
|
||||
});
|
||||
}
|
||||
|
||||
ffPrintAndWriteToCache(instance, FF_HOST_MODULE_NAME, &instance->config.host, &output, FF_HOST_NUM_FORMAT_ARGS, (FFformatarg[]) {
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &host->productFamily},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &host->productName},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &host->productVersion},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &host->productSku},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &host->chassisType},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &host->chassisVendor},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &host->chassisVersion},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &host->sysVendor}
|
||||
});
|
||||
|
||||
ffStrbufDestroy(&output);
|
||||
}
|
||||
|
||||
+11
-7
@@ -1,5 +1,4 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/caching.h"
|
||||
#include "common/printing.h"
|
||||
#include "detection/locale/locale.h"
|
||||
|
||||
@@ -8,9 +7,6 @@
|
||||
|
||||
void ffPrintLocale(FFinstance* instance)
|
||||
{
|
||||
if(ffPrintFromCache(instance, FF_LOCALE_MODULE_NAME, &instance->config.locale, FF_LOCALE_NUM_FORMAT_ARGS))
|
||||
return;
|
||||
|
||||
FFstrbuf locale;
|
||||
ffStrbufInit(&locale);
|
||||
|
||||
@@ -21,9 +17,17 @@ void ffPrintLocale(FFinstance* instance)
|
||||
return;
|
||||
}
|
||||
|
||||
ffPrintAndWriteToCache(instance, FF_LOCALE_MODULE_NAME, &instance->config.locale, &locale, FF_LOCALE_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &locale}
|
||||
});
|
||||
if(instance->config.locale.outputFormat.length == 0)
|
||||
{
|
||||
ffPrintLogoAndKey(instance, FF_LOCALE_MODULE_NAME, 0, &instance->config.locale.key);
|
||||
ffStrbufPutTo(&locale, stdout);
|
||||
}
|
||||
else
|
||||
{
|
||||
ffPrintFormat(instance, FF_LOCALE_MODULE_NAME, 0, &instance->config.locale, FF_LOCALE_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &locale}
|
||||
});
|
||||
}
|
||||
|
||||
ffStrbufDestroy(&locale);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user