mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 02:14:37 +02:00
better result handling of calculation functions
This commit is contained in:
+2
-1
@@ -64,8 +64,9 @@ set(SRCS
|
||||
src/common/logo.c
|
||||
src/common/format.c
|
||||
src/common/parsing.c
|
||||
src/common/calculateOS.c
|
||||
src/common/calculatePlasma.c
|
||||
src/common/calculateGtk.c
|
||||
src/common/calculateGTK.c
|
||||
src/common/calculateTerminal.c
|
||||
src/common/calculateWM.c
|
||||
src/modules/break.c
|
||||
|
||||
@@ -4,34 +4,34 @@
|
||||
#include <pthread.h>
|
||||
#include <dconf/client/dconf-client.h>
|
||||
|
||||
static inline bool allPropertiesSet(FFgtkval* gtkval)
|
||||
static inline bool allPropertiesSet(FFGTKResult* result)
|
||||
{
|
||||
return
|
||||
gtkval->theme.length > 0 &&
|
||||
gtkval->icons.length > 0 &&
|
||||
gtkval->font.length > 0;
|
||||
result->theme.length > 0 &&
|
||||
result->icons.length > 0 &&
|
||||
result->font.length > 0;
|
||||
}
|
||||
|
||||
static inline void initGtkval(FFgtkval* gtkval)
|
||||
static inline void initresult(FFGTKResult* result)
|
||||
{
|
||||
ffStrbufInit(>kval->theme);
|
||||
ffStrbufInit(>kval->icons);
|
||||
ffStrbufInit(>kval->font);
|
||||
ffStrbufInit(&result->theme);
|
||||
ffStrbufInit(&result->icons);
|
||||
ffStrbufInit(&result->font);
|
||||
}
|
||||
|
||||
static inline void applyGTKDConfSettings(FFgtkval* gtkval, const gchar* themeName, const gchar* iconsName, const gchar* fontName)
|
||||
static inline void applyGTKDConfSettings(FFGTKResult* result, const gchar* themeName, const gchar* iconsName, const gchar* fontName)
|
||||
{
|
||||
if(gtkval->theme.length == 0)
|
||||
ffStrbufAppendS(>kval->theme, themeName);
|
||||
if(result->theme.length == 0)
|
||||
ffStrbufAppendS(&result->theme, themeName);
|
||||
|
||||
if(gtkval->icons.length == 0)
|
||||
ffStrbufAppendS(>kval->icons, iconsName);
|
||||
if(result->icons.length == 0)
|
||||
ffStrbufAppendS(&result->icons, iconsName);
|
||||
|
||||
if(gtkval->font.length == 0)
|
||||
ffStrbufAppendS(>kval->font, fontName);
|
||||
if(result->font.length == 0)
|
||||
ffStrbufAppendS(&result->font, fontName);
|
||||
}
|
||||
|
||||
static void parseGTKDConfSettings(FFinstance* instance, FFgtkval* gtkval)
|
||||
static void parseGTKDConfSettings(FFinstance* instance, FFGTKResult* result)
|
||||
{
|
||||
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
@@ -45,7 +45,7 @@ static void parseGTKDConfSettings(FFinstance* instance, FFgtkval* gtkval)
|
||||
|
||||
if(init)
|
||||
{
|
||||
applyGTKDConfSettings(gtkval, themeName, iconsName, fontName);
|
||||
applyGTKDConfSettings(result, themeName, iconsName, fontName);
|
||||
pthread_mutex_unlock(&mutex);
|
||||
return;
|
||||
}
|
||||
@@ -102,11 +102,11 @@ static void parseGTKDConfSettings(FFinstance* instance, FFgtkval* gtkval)
|
||||
|
||||
dlclose(dconf);
|
||||
|
||||
applyGTKDConfSettings(gtkval, themeName, iconsName, fontName);
|
||||
applyGTKDConfSettings(result, themeName, iconsName, fontName);
|
||||
pthread_mutex_unlock(&mutex);
|
||||
}
|
||||
|
||||
static void parseGTKConfigFile(FFstrbuf* fileName, FFgtkval* gtkval)
|
||||
static void parseGTKConfigFile(FFstrbuf* fileName, FFGTKResult* result)
|
||||
{
|
||||
FILE* file = fopen(fileName->chars, "r");
|
||||
if(file == NULL)
|
||||
@@ -117,22 +117,22 @@ static void parseGTKConfigFile(FFstrbuf* fileName, FFgtkval* gtkval)
|
||||
|
||||
while(getline(&line, &len, file) != -1)
|
||||
{
|
||||
if(gtkval->theme.length == 0)
|
||||
if(result->theme.length == 0)
|
||||
{
|
||||
sscanf(line, "gtk-theme-name=%[^\n]", gtkval->theme.chars);
|
||||
sscanf(line, "gtk-theme-name=\"%[^\"]+", gtkval->theme.chars);
|
||||
sscanf(line, "gtk-theme-name=%[^\n]", result->theme.chars);
|
||||
sscanf(line, "gtk-theme-name=\"%[^\"]+", result->theme.chars);
|
||||
}
|
||||
|
||||
if(gtkval->icons.length == 0)
|
||||
if(result->icons.length == 0)
|
||||
{
|
||||
sscanf(line, "gtk-icon-theme-name=%[^\n]", gtkval->icons.chars);
|
||||
sscanf(line, "gtk-icon-theme-name=\"%[^\"]+", gtkval->icons.chars);
|
||||
sscanf(line, "gtk-icon-theme-name=%[^\n]", result->icons.chars);
|
||||
sscanf(line, "gtk-icon-theme-name=\"%[^\"]+", result->icons.chars);
|
||||
}
|
||||
|
||||
if(gtkval->font.length == 0)
|
||||
if(result->font.length == 0)
|
||||
{
|
||||
sscanf(line, "gtk-font-name=%[^\n]", gtkval->font.chars);
|
||||
sscanf(line, "gtk-font-name=\"%[^\"]+", gtkval->font.chars);
|
||||
sscanf(line, "gtk-font-name=%[^\n]", result->font.chars);
|
||||
sscanf(line, "gtk-font-name=\"%[^\"]+", result->font.chars);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,12 +141,12 @@ static void parseGTKConfigFile(FFstrbuf* fileName, FFgtkval* gtkval)
|
||||
|
||||
fclose(file);
|
||||
|
||||
ffStrbufRecalculateLength(>kval->theme);
|
||||
ffStrbufRecalculateLength(>kval->icons);
|
||||
ffStrbufRecalculateLength(>kval->font);
|
||||
ffStrbufRecalculateLength(&result->theme);
|
||||
ffStrbufRecalculateLength(&result->icons);
|
||||
ffStrbufRecalculateLength(&result->font);
|
||||
}
|
||||
|
||||
static void calculateGTKFromConfigDir(const char* configDir, const char* version, FFgtkval* gtkval)
|
||||
static void calculateGTKFromConfigDir(const char* configDir, const char* version, FFGTKResult* result)
|
||||
{
|
||||
// <configdir>/gtk-<version>.0/settings.ini
|
||||
FFstrbuf file1;
|
||||
@@ -155,9 +155,9 @@ static void calculateGTKFromConfigDir(const char* configDir, const char* version
|
||||
ffStrbufAppendS(&file1, "/gtk-");
|
||||
ffStrbufAppendS(&file1, version);
|
||||
ffStrbufAppendS(&file1, ".0/settings.ini");
|
||||
parseGTKConfigFile(&file1, gtkval);
|
||||
parseGTKConfigFile(&file1, result);
|
||||
ffStrbufDestroy(&file1);
|
||||
if(allPropertiesSet(gtkval))
|
||||
if(allPropertiesSet(result))
|
||||
return;
|
||||
|
||||
// <configdir>/gtk-<version>.0/gtkrc
|
||||
@@ -167,9 +167,9 @@ static void calculateGTKFromConfigDir(const char* configDir, const char* version
|
||||
ffStrbufAppendS(&file2, "/gtk-");
|
||||
ffStrbufAppendS(&file2, version);
|
||||
ffStrbufAppendS(&file2, ".0/gtkrc");
|
||||
parseGTKConfigFile(&file2, gtkval);
|
||||
parseGTKConfigFile(&file2, result);
|
||||
ffStrbufDestroy(&file2);
|
||||
if(allPropertiesSet(gtkval))
|
||||
if(allPropertiesSet(result))
|
||||
return;
|
||||
|
||||
// <configdir>/gtkrc-<version>.0
|
||||
@@ -179,9 +179,9 @@ static void calculateGTKFromConfigDir(const char* configDir, const char* version
|
||||
ffStrbufAppendS(&file3, "/gtkrc-");
|
||||
ffStrbufAppendS(&file3, version);
|
||||
ffStrbufAppendS(&file3, ".0");
|
||||
parseGTKConfigFile(&file3, gtkval);
|
||||
parseGTKConfigFile(&file3, result);
|
||||
ffStrbufDestroy(&file3);
|
||||
if(allPropertiesSet(gtkval))
|
||||
if(allPropertiesSet(result))
|
||||
return;
|
||||
|
||||
// <configdir>/.gtkrc-<version>.0
|
||||
@@ -191,11 +191,11 @@ static void calculateGTKFromConfigDir(const char* configDir, const char* version
|
||||
ffStrbufAppendS(&file4, "/.gtkrc-");
|
||||
ffStrbufAppendS(&file4, version);
|
||||
ffStrbufAppendS(&file4, ".0");
|
||||
parseGTKConfigFile(&file4, gtkval);
|
||||
parseGTKConfigFile(&file4, result);
|
||||
ffStrbufDestroy(&file4);
|
||||
}
|
||||
|
||||
static void calculateGTK(FFinstance* instance, const char* version, FFgtkval* gtkval)
|
||||
static void calculateGTK(FFinstance* instance, const char* version, FFGTKResult* result)
|
||||
{
|
||||
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
@@ -204,7 +204,7 @@ static void calculateGTK(FFinstance* instance, const char* version, FFgtkval* gt
|
||||
static bool xdgIsDifferent;
|
||||
static bool init = false;
|
||||
|
||||
initGtkval(gtkval);
|
||||
initresult(result);
|
||||
|
||||
pthread_mutex_lock(&mutex);
|
||||
|
||||
@@ -228,52 +228,57 @@ static void calculateGTK(FFinstance* instance, const char* version, FFgtkval* gt
|
||||
if(xdgIsDifferent)
|
||||
{
|
||||
// $XDG_CONFIG_HOME
|
||||
calculateGTKFromConfigDir(xdgConfigDir.chars, version, gtkval);
|
||||
if(allPropertiesSet(gtkval))
|
||||
calculateGTKFromConfigDir(xdgConfigDir.chars, version, result);
|
||||
if(allPropertiesSet(result))
|
||||
return;
|
||||
}
|
||||
|
||||
// /home/<user>/.config
|
||||
calculateGTKFromConfigDir(configDir.chars, version, gtkval);
|
||||
if(allPropertiesSet(gtkval))
|
||||
calculateGTKFromConfigDir(configDir.chars, version, result);
|
||||
if(allPropertiesSet(result))
|
||||
return;
|
||||
|
||||
// /home/<user>
|
||||
calculateGTKFromConfigDir(instance->state.passwd->pw_dir, version, gtkval);
|
||||
if(allPropertiesSet(gtkval))
|
||||
calculateGTKFromConfigDir(instance->state.passwd->pw_dir, version, result);
|
||||
if(allPropertiesSet(result))
|
||||
return;
|
||||
|
||||
parseGTKDConfSettings(instance, gtkval);
|
||||
if(allPropertiesSet(gtkval))
|
||||
parseGTKDConfSettings(instance, result);
|
||||
if(allPropertiesSet(result))
|
||||
return;
|
||||
|
||||
// /etc
|
||||
calculateGTKFromConfigDir("/etc/", version, gtkval);
|
||||
calculateGTKFromConfigDir("/etc/", version, result);
|
||||
}
|
||||
|
||||
#define FF_CALCULATE_GTK_IMPL(version) \
|
||||
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; \
|
||||
static FFGTKResult result; \
|
||||
static bool init = false; \
|
||||
pthread_mutex_lock(&mutex); \
|
||||
if(init){ \
|
||||
pthread_mutex_unlock(&mutex);\
|
||||
return; \
|
||||
return &result; \
|
||||
} \
|
||||
init = true; \
|
||||
calculateGTK(instance, #version, &instance->state.gtk##version); \
|
||||
pthread_mutex_unlock(&mutex);
|
||||
ffStrbufInit(&result.theme); \
|
||||
ffStrbufInit(&result.icons); \
|
||||
ffStrbufInit(&result.font); \
|
||||
calculateGTK(instance, #version, &result); \
|
||||
pthread_mutex_unlock(&mutex); \
|
||||
return &result;
|
||||
|
||||
void ffCalculateGTK2(FFinstance* instance)
|
||||
const FFGTKResult* ffCalculateGTK2(FFinstance* instance)
|
||||
{
|
||||
FF_CALCULATE_GTK_IMPL(2)
|
||||
}
|
||||
|
||||
void ffCalculateGTK3(FFinstance* instance)
|
||||
const FFGTKResult* ffCalculateGTK3(FFinstance* instance)
|
||||
{
|
||||
FF_CALCULATE_GTK_IMPL(3)
|
||||
}
|
||||
|
||||
void ffCalculateGTK4(FFinstance* instance)
|
||||
const FFGTKResult* ffCalculateGTK4(FFinstance* instance)
|
||||
{
|
||||
FF_CALCULATE_GTK_IMPL(4)
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
#include "fastfetch.h"
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
const FFOSResult* ffCalculateOS(FFinstance* instance)
|
||||
{
|
||||
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
static FFOSResult result;
|
||||
static bool init = false;
|
||||
pthread_mutex_lock(&mutex);
|
||||
if(init)
|
||||
{
|
||||
pthread_mutex_unlock(&mutex);
|
||||
return &result;
|
||||
}
|
||||
init = true;
|
||||
|
||||
FILE* osRelease = fopen("/etc/os-release", "r");
|
||||
|
||||
if(osRelease == NULL)
|
||||
osRelease = fopen("/usr/lib/os-release", "r");
|
||||
|
||||
ffStrbufInitA(&result.error, 64);
|
||||
if(osRelease == NULL)
|
||||
{
|
||||
ffStrbufAppendS(&result.error, "couldn't read /etc/os-release nor /usr/lib/os-release");
|
||||
return &result;
|
||||
}
|
||||
|
||||
ffStrbufInitA(&result.systemName, 256);
|
||||
ffStrbufInitA(&result.name, 256);
|
||||
ffStrbufInitA(&result.prettyName, 256);
|
||||
ffStrbufInitA(&result.id, 256);
|
||||
ffStrbufInitA(&result.idLike, 256);
|
||||
ffStrbufInitA(&result.variant, 256);
|
||||
ffStrbufInitA(&result.variantID, 256);
|
||||
ffStrbufInitA(&result.version, 256);
|
||||
ffStrbufInitA(&result.versionID, 256);
|
||||
ffStrbufInitA(&result.codename, 256);
|
||||
ffStrbufInitA(&result.buildID, 256);
|
||||
ffStrbufInitA(&result.architecture, 256);
|
||||
ffStrbufInitA(&result.error, 256);
|
||||
|
||||
ffStrbufSetS(&result.systemName, instance->state.utsname.sysname);
|
||||
ffStrbufSetS(&result.architecture, instance->state.utsname.machine);
|
||||
|
||||
char* line = NULL;
|
||||
size_t len = 0;
|
||||
|
||||
// Documentation of the fields:
|
||||
// https://www.freedesktop.org/software/systemd/man/os-release.html
|
||||
while (getline(&line, &len, osRelease) != -1)
|
||||
{
|
||||
sscanf(line, "NAME=%[^\n]", result.name.chars);
|
||||
sscanf(line, "NAME=\"%[^\"]+", result.name.chars);
|
||||
sscanf(line, "PRETTY_NAME=%[^\n]", result.prettyName.chars);
|
||||
sscanf(line, "PRETTY_NAME=\"%[^\"]+", result.prettyName.chars);
|
||||
sscanf(line, "ID=%[^\n]", result.id.chars);
|
||||
sscanf(line, "ID=\"%[^\"]+", result.id.chars);
|
||||
sscanf(line, "ID_LIKE=%[^\n]", result.idLike.chars);
|
||||
sscanf(line, "ID_LIKE=\"%[^\"]+", result.idLike.chars);
|
||||
sscanf(line, "VARIANT=%[^\n]", result.variant.chars);
|
||||
sscanf(line, "VARIANT=\"%[^\"]+", result.variant.chars);
|
||||
sscanf(line, "VARIANT_ID=%[^\n]", result.variantID.chars);
|
||||
sscanf(line, "VARIANT_ID=\"%[^\"]+", result.variantID.chars);
|
||||
sscanf(line, "VERSION=%[^\n]", result.version.chars);
|
||||
sscanf(line, "VERSION=\"%[^\"]+", result.version.chars);
|
||||
sscanf(line, "VERSION_ID=%[^\n]", result.versionID.chars);
|
||||
sscanf(line, "VERSION_ID=\"%[^\"]+", result.versionID.chars);
|
||||
sscanf(line, "VERSION_CODENAME=%[^\n]", result.codename.chars);
|
||||
sscanf(line, "VERSION_CODENAME=\"%[^\"]+", result.codename.chars);
|
||||
sscanf(line, "BUILD_ID=%[^\n]", result.buildID.chars);
|
||||
sscanf(line, "BUILD_ID=\"%[^\"]+", result.buildID.chars);
|
||||
}
|
||||
|
||||
ffStrbufRecalculateLength(&result.systemName);
|
||||
ffStrbufRecalculateLength(&result.name);
|
||||
ffStrbufRecalculateLength(&result.prettyName);
|
||||
ffStrbufRecalculateLength(&result.id);
|
||||
ffStrbufRecalculateLength(&result.idLike);
|
||||
ffStrbufRecalculateLength(&result.variant);
|
||||
ffStrbufRecalculateLength(&result.variantID);
|
||||
ffStrbufRecalculateLength(&result.version);
|
||||
ffStrbufRecalculateLength(&result.versionID);
|
||||
ffStrbufRecalculateLength(&result.codename);
|
||||
ffStrbufRecalculateLength(&result.buildID);
|
||||
ffStrbufRecalculateLength(&result.architecture);
|
||||
ffStrbufRecalculateLength(&result.error);
|
||||
|
||||
if(line != NULL)
|
||||
free(line);
|
||||
|
||||
fclose(osRelease);
|
||||
|
||||
pthread_mutex_unlock(&mutex);
|
||||
|
||||
return &result;
|
||||
}
|
||||
@@ -11,25 +11,23 @@ typedef enum PlasmaCategory
|
||||
PLASMA_CATEGORY_OTHER
|
||||
} PlasmaCategory;
|
||||
|
||||
void ffCalculatePlasma(FFinstance* instance)
|
||||
const FFPlasmaResult* ffCalculatePlasma(FFinstance* instance)
|
||||
{
|
||||
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
static FFPlasmaResult result;
|
||||
static bool init = false;
|
||||
|
||||
pthread_mutex_lock(&mutex);
|
||||
|
||||
if(init)
|
||||
{
|
||||
pthread_mutex_unlock(&mutex);
|
||||
return;
|
||||
return &result;
|
||||
}
|
||||
|
||||
init = true;
|
||||
|
||||
ffStrbufInit(&instance->state.plasma.widgetStyle);
|
||||
ffStrbufInit(&instance->state.plasma.colorScheme);
|
||||
ffStrbufInit(&instance->state.plasma.icons);
|
||||
ffStrbufInit(&instance->state.plasma.font);
|
||||
ffStrbufInit(&result.widgetStyle);
|
||||
ffStrbufInit(&result.colorScheme);
|
||||
ffStrbufInit(&result.icons);
|
||||
ffStrbufInit(&result.font);
|
||||
|
||||
FF_STRBUF_CREATE(kdeglobalsFile);
|
||||
ffStrbufAppendS(&kdeglobalsFile, instance->state.passwd->pw_dir);
|
||||
@@ -40,7 +38,7 @@ void ffCalculatePlasma(FFinstance* instance)
|
||||
{
|
||||
ffStrbufDestroy(&kdeglobalsFile);
|
||||
pthread_mutex_unlock(&mutex);
|
||||
return;
|
||||
return &result;
|
||||
}
|
||||
|
||||
char* line = NULL;
|
||||
@@ -69,28 +67,28 @@ void ffCalculatePlasma(FFinstance* instance)
|
||||
|
||||
if(category == PLASMA_CATEGORY_KDE)
|
||||
{
|
||||
sscanf(line, "widgetStyle=%[^\n]", instance->state.plasma.widgetStyle.chars);
|
||||
sscanf(line, "widgetStyle=\"%[^\"]+", instance->state.plasma.widgetStyle.chars);
|
||||
sscanf(line, "widgetStyle=%[^\n]", result.widgetStyle.chars);
|
||||
sscanf(line, "widgetStyle=\"%[^\"]+", result.widgetStyle.chars);
|
||||
}
|
||||
else if(category == PLASMA_CATEGORY_GENERAL)
|
||||
{
|
||||
sscanf(line, "ColorScheme=%[^\n]", instance->state.plasma.colorScheme.chars);
|
||||
sscanf(line, "ColorScheme=\"%[^\"]+", instance->state.plasma.colorScheme.chars);
|
||||
sscanf(line, "ColorScheme=%[^\n]", result.colorScheme.chars);
|
||||
sscanf(line, "ColorScheme=\"%[^\"]+", result.colorScheme.chars);
|
||||
|
||||
sscanf(line, "font=%[^\n]", instance->state.plasma.font.chars);
|
||||
sscanf(line, "font=\"%[^\"]+", instance->state.plasma.font.chars);
|
||||
sscanf(line, "font=%[^\n]", result.font.chars);
|
||||
sscanf(line, "font=\"%[^\"]+", result.font.chars);
|
||||
}
|
||||
else if(category == PLASMA_CATEGORY_ICONS)
|
||||
{
|
||||
sscanf(line, "Theme=%[^\n]", instance->state.plasma.icons.chars);
|
||||
sscanf(line, "Theme=\"%[^\"]+", instance->state.plasma.icons.chars);
|
||||
sscanf(line, "Theme=%[^\n]", result.icons.chars);
|
||||
sscanf(line, "Theme=\"%[^\"]+", result.icons.chars);
|
||||
}
|
||||
}
|
||||
|
||||
ffStrbufRecalculateLength(&instance->state.plasma.widgetStyle);
|
||||
ffStrbufRecalculateLength(&instance->state.plasma.colorScheme);
|
||||
ffStrbufRecalculateLength(&instance->state.plasma.icons);
|
||||
ffStrbufRecalculateLength(&instance->state.plasma.font);
|
||||
ffStrbufRecalculateLength(&result.widgetStyle);
|
||||
ffStrbufRecalculateLength(&result.colorScheme);
|
||||
ffStrbufRecalculateLength(&result.icons);
|
||||
ffStrbufRecalculateLength(&result.font);
|
||||
|
||||
if(line != NULL)
|
||||
free(line);
|
||||
@@ -100,17 +98,19 @@ void ffCalculatePlasma(FFinstance* instance)
|
||||
|
||||
//In Plasma the default value is never set in the config file, but the whole key-value is discarded.
|
||||
///We must set these values by our self if the file exists (it always does here)
|
||||
if(instance->state.plasma.widgetStyle.length == 0)
|
||||
ffStrbufAppendS(&instance->state.plasma.widgetStyle, "Breeze");
|
||||
if(result.widgetStyle.length == 0)
|
||||
ffStrbufAppendS(&result.widgetStyle, "Breeze");
|
||||
|
||||
if(instance->state.plasma.colorScheme.length == 0)
|
||||
ffStrbufAppendS(&instance->state.plasma.colorScheme, "BreezeLight");
|
||||
if(result.colorScheme.length == 0)
|
||||
ffStrbufAppendS(&result.colorScheme, "BreezeLight");
|
||||
|
||||
if(instance->state.plasma.icons.length == 0)
|
||||
ffStrbufAppendS(&instance->state.plasma.icons, "Breeze");
|
||||
if(result.icons.length == 0)
|
||||
ffStrbufAppendS(&result.icons, "Breeze");
|
||||
|
||||
if(instance->state.plasma.font.length == 0)
|
||||
ffStrbufAppendS(&instance->state.plasma.font, "Noto Sans, 10");
|
||||
if(result.font.length == 0)
|
||||
ffStrbufAppendS(&result.font, "Noto Sans, 10");
|
||||
|
||||
pthread_mutex_unlock(&mutex);
|
||||
|
||||
return &result;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <unistd.h>
|
||||
#include <pthread.h>
|
||||
|
||||
static void getTerminalName(FFinstance* instance, const char* pid)
|
||||
static void getTerminalName(FFinstance* instance, const char* pid, FFTerminalResult* result)
|
||||
{
|
||||
char statFile[234];
|
||||
sprintf(statFile, "/proc/%s/stat", pid);
|
||||
@@ -12,7 +12,7 @@ static void getTerminalName(FFinstance* instance, const char* pid)
|
||||
FILE* stat = fopen(statFile, "r");
|
||||
if(stat == NULL)
|
||||
{
|
||||
ffStrbufSetF(&instance->state.terminal.error, "fopen(\"%s\", \"r\") == NULL", statFile);
|
||||
ffStrbufSetF(&result->error, "fopen(\"%s\", \"r\") == NULL", statFile);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ static void getTerminalName(FFinstance* instance, const char* pid)
|
||||
char ppid[256];
|
||||
if(fscanf(stat, "%*s (%[^)])%*s%s", name, ppid) != 2)
|
||||
{
|
||||
ffStrbufSetS(&instance->state.terminal.error, "fscanf(stat, \"%*s (%[^)])%*s%s\", name, ppid) != 2");
|
||||
ffStrbufSetS(&result->error, "fscanf(stat, \"%*s (%[^)])%*s%s\", name, ppid) != 2");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -37,42 +37,43 @@ static void getTerminalName(FFinstance* instance, const char* pid)
|
||||
strcasecmp(name, "doas") == 0 ||
|
||||
strcasecmp(name, "strace") == 0 )
|
||||
{
|
||||
getTerminalName(instance, ppid);
|
||||
getTerminalName(instance, ppid, result);
|
||||
return;
|
||||
}
|
||||
|
||||
char cmdlineFile[234];
|
||||
sprintf(cmdlineFile, "/proc/%s/cmdline", pid);
|
||||
|
||||
ffGetFileContent(cmdlineFile, &instance->state.terminal.exeName);
|
||||
ffStrbufSubstrBeforeFirstC(&instance->state.terminal.exeName, '\0');
|
||||
ffStrbufSubstrAfterLastC(&instance->state.terminal.exeName, '/');
|
||||
ffGetFileContent(cmdlineFile, &result->exeName);
|
||||
ffStrbufSubstrBeforeFirstC(&result->exeName, '\0');
|
||||
ffStrbufSubstrAfterLastC(&result->exeName, '/');
|
||||
|
||||
ffStrbufSetS(&instance->state.terminal.processName, name);
|
||||
ffStrbufSetS(&result->processName, name);
|
||||
}
|
||||
|
||||
void ffCalculateTerminal(FFinstance* instance)
|
||||
const FFTerminalResult* ffCalculateTerminal(FFinstance* instance)
|
||||
{
|
||||
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
static FFTerminalResult result;
|
||||
static bool init = false;
|
||||
|
||||
pthread_mutex_lock(&mutex);
|
||||
|
||||
if(init)
|
||||
{
|
||||
pthread_mutex_unlock(&mutex);
|
||||
return;
|
||||
return &result;
|
||||
}
|
||||
init = true;
|
||||
|
||||
ffStrbufInit(&instance->state.terminal.exeName);
|
||||
ffStrbufInit(&instance->state.terminal.processName);
|
||||
ffStrbufInit(&instance->state.terminal.error);
|
||||
ffStrbufInit(&result.exeName);
|
||||
ffStrbufInit(&result.processName);
|
||||
ffStrbufInit(&result.error);
|
||||
|
||||
char ppid[256];
|
||||
sprintf(ppid, "%i", getppid());
|
||||
|
||||
getTerminalName(instance, ppid);
|
||||
getTerminalName(instance, ppid, &result);
|
||||
|
||||
pthread_mutex_unlock(&mutex);
|
||||
|
||||
return &result;
|
||||
}
|
||||
|
||||
+19
-17
@@ -3,31 +3,31 @@
|
||||
#include <dirent.h>
|
||||
#include <pthread.h>
|
||||
|
||||
void ffCalculateWM(FFinstance* instance)
|
||||
const FFWMResult* ffCalculateWM(FFinstance* instance)
|
||||
{
|
||||
UNUSED(instance);
|
||||
|
||||
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
static FFWMResult result;
|
||||
static bool init = false;
|
||||
|
||||
pthread_mutex_lock(&mutex);
|
||||
|
||||
if(init)
|
||||
{
|
||||
pthread_mutex_unlock(&mutex);
|
||||
return;
|
||||
return &result;
|
||||
}
|
||||
|
||||
init = true;
|
||||
|
||||
ffStrbufInit(&instance->state.wm.processName);
|
||||
ffStrbufInit(&instance->state.wm.prettyName);
|
||||
ffStrbufInit(&instance->state.wm.error);
|
||||
ffStrbufInit(&result.processName);
|
||||
ffStrbufInit(&result.prettyName);
|
||||
ffStrbufInit(&result.error);
|
||||
|
||||
DIR* proc = opendir("/proc/");
|
||||
if(proc == NULL)
|
||||
{
|
||||
ffStrbufSetS(&instance->state.wm.error, "opendir(\"/proc/\") == NULL");
|
||||
ffStrbufSetS(&result.error, "opendir(\"/proc/\") == NULL");
|
||||
pthread_mutex_unlock(&mutex);
|
||||
return;
|
||||
return &result;
|
||||
}
|
||||
|
||||
struct dirent* dirent;
|
||||
@@ -40,22 +40,24 @@ void ffCalculateWM(FFinstance* instance)
|
||||
char path[20];
|
||||
sprintf(path, "/proc/%.8s/comm", dirent->d_name);
|
||||
|
||||
ffGetFileContent(path, &instance->state.wm.processName);
|
||||
ffGetFileContent(path, &result.processName);
|
||||
|
||||
if(ffStrbufIgnCaseCompS(&instance->state.wm.processName, "kwin_wayland") == 0 || ffStrbufIgnCaseCompS(&instance->state.wm.processName, "kwin_x11") == 0)
|
||||
ffStrbufSetS(&instance->state.wm.prettyName, "KWin");
|
||||
if(ffStrbufIgnCaseCompS(&result.processName, "kwin_wayland") == 0 || ffStrbufIgnCaseCompS(&result.processName, "kwin_x11") == 0)
|
||||
ffStrbufSetS(&result.prettyName, "KWin");
|
||||
|
||||
if(instance->state.wm.prettyName.length > 0)
|
||||
if(result.prettyName.length > 0)
|
||||
break;
|
||||
}
|
||||
|
||||
closedir(proc);
|
||||
|
||||
if(instance->state.wm.prettyName.length == 0)
|
||||
if(result.prettyName.length == 0)
|
||||
{
|
||||
ffStrbufSetS(&instance->state.wm.error, "No process name matches the name of known display managers");
|
||||
ffStrbufClear(&instance->state.wm.processName);
|
||||
ffStrbufSetS(&result.error, "No process name matches the name of known display managers");
|
||||
ffStrbufClear(&result.processName);
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&mutex);
|
||||
|
||||
return &result;
|
||||
}
|
||||
|
||||
@@ -83,14 +83,6 @@ void ffInitInstance(FFinstance* instance)
|
||||
ffCacheValidate(instance);
|
||||
}
|
||||
|
||||
void ffCalculatePlasmaAndGtk(FFinstance* instance)
|
||||
{
|
||||
ffCalculatePlasma(instance);
|
||||
ffCalculateGTK2(instance);
|
||||
ffCalculateGTK3(instance);
|
||||
ffCalculateGTK3(instance);
|
||||
}
|
||||
|
||||
static void ffCleanup(FFinstance* instance)
|
||||
{
|
||||
UNUSED(instance);
|
||||
|
||||
+60
-40
@@ -6,6 +6,9 @@
|
||||
#include <sys/stat.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#define FF_IO_CACHE_VALUE_EXTENSION "ffcv"
|
||||
#define FF_IO_CACHE_SPLIT_EXTENSION "ffcs"
|
||||
|
||||
void ffPrintLogoAndKey(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat)
|
||||
{
|
||||
ffPrintLogoLine(instance);
|
||||
@@ -120,29 +123,41 @@ static void appendCacheDir(FFinstance* instance, FFstrbuf* buffer)
|
||||
ffStrbufAppend(buffer, &cacheDir);
|
||||
}
|
||||
|
||||
static inline void getCacheFileValue(FFinstance* instance, const char* moduleName, FFstrbuf* cacheFilePath)
|
||||
void ffGetCacheFilePath(FFinstance* instance, const char* moduleName, const char* extension, FFstrbuf* buffer)
|
||||
{
|
||||
appendCacheDir(instance, cacheFilePath);
|
||||
ffStrbufAppendS(cacheFilePath, moduleName);
|
||||
ffStrbufAppendS(cacheFilePath, ".ffcv");
|
||||
appendCacheDir(instance, buffer);
|
||||
ffStrbufAppendS(buffer, moduleName);
|
||||
|
||||
if(extension != NULL)
|
||||
{
|
||||
ffStrbufAppendC(buffer, '.');
|
||||
ffStrbufAppendS(buffer, extension);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void getCacheFileSplit(FFinstance* instance, const char* moduleName, FFstrbuf* cacheFilePath)
|
||||
void ffReadCacheFile(FFinstance* instance, const char* moduleName, const char* extension, FFstrbuf* buffer)
|
||||
{
|
||||
appendCacheDir(instance, cacheFilePath);
|
||||
ffStrbufAppendS(cacheFilePath, moduleName);
|
||||
ffStrbufAppendS(cacheFilePath, ".ffcs");
|
||||
FFstrbuf path;
|
||||
ffStrbufInitA(&path, 64);
|
||||
ffGetCacheFilePath(instance, moduleName, extension, &path);
|
||||
ffAppendFileContent(path.chars, buffer);
|
||||
ffStrbufDestroy(&path);
|
||||
}
|
||||
|
||||
void ffWriteCacheFile(FFinstance* instance, const char* moduleName, const char* extension, FFstrbuf* content)
|
||||
{
|
||||
FFstrbuf path;
|
||||
ffStrbufInitA(&path, 64);
|
||||
ffGetCacheFilePath(instance, moduleName, extension, &path);
|
||||
ffWriteFileContent(path.chars, content);
|
||||
ffStrbufDestroy(&path);
|
||||
}
|
||||
|
||||
static bool printCachedValue(FFinstance* instance, const char* moduleName, const FFstrbuf* customKeyFormat)
|
||||
{
|
||||
FFstrbuf cacheFilePath;
|
||||
ffStrbufInitA(&cacheFilePath, 64);
|
||||
getCacheFileValue(instance, moduleName, &cacheFilePath);
|
||||
|
||||
FFstrbuf content;
|
||||
ffStrbufInitA(&content, 512);
|
||||
ffAppendFileContent(cacheFilePath.chars, &content);
|
||||
ffReadCacheFile(instance, moduleName, FF_IO_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
|
||||
|
||||
@@ -163,28 +178,21 @@ static bool printCachedValue(FFinstance* instance, const char* moduleName, const
|
||||
}
|
||||
|
||||
ffStrbufDestroy(&content);
|
||||
ffStrbufDestroy(&cacheFilePath);
|
||||
|
||||
return moduleCounter > 1;
|
||||
}
|
||||
|
||||
static bool printCachedFormat(FFinstance* instance, const char* moduleName, const FFstrbuf* customKeyFormat, const FFstrbuf* formatString, uint32_t numArgs)
|
||||
{
|
||||
FFstrbuf cacheFilePath;
|
||||
ffStrbufInitA(&cacheFilePath, 64);
|
||||
getCacheFileSplit(instance, moduleName, &cacheFilePath);
|
||||
|
||||
FFstrbuf content;
|
||||
ffStrbufInitA(&content, 512);
|
||||
ffAppendFileContent(cacheFilePath.chars, &content);
|
||||
ffReadCacheFile(instance, moduleName, FF_IO_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;
|
||||
|
||||
//Strbuf adds an extra nullbyte at chars[length]. We want this one to be the end of the last value to test for index == length
|
||||
if(content.chars[content.length - 1] == '\0')
|
||||
ffStrbufSubstrBefore(&content, content.length - 1);
|
||||
|
||||
uint8_t moduleCounter = 1;
|
||||
|
||||
FFformatarg arguments[numArgs];
|
||||
@@ -211,7 +219,6 @@ static bool printCachedFormat(FFinstance* instance, const char* moduleName, cons
|
||||
}
|
||||
|
||||
ffStrbufDestroy(&content);
|
||||
ffStrbufDestroy(&cacheFilePath);
|
||||
|
||||
return moduleCounter > 1;
|
||||
}
|
||||
@@ -269,47 +276,44 @@ void ffPrintAndSaveToCache(FFinstance* instance, const char* moduleName, const F
|
||||
|
||||
void ffCacheValidate(FFinstance* instance)
|
||||
{
|
||||
FFstrbuf cacheFilePath;
|
||||
ffStrbufInitA(&cacheFilePath, 64);
|
||||
appendCacheDir(instance, &cacheFilePath);
|
||||
ffStrbufAppendS(&cacheFilePath, "cacheversion.ffv");
|
||||
FFstrbuf path;
|
||||
ffStrbufInitA(&path, 64);
|
||||
ffGetCacheFilePath(instance, "cacheversion", "ffv", &path);
|
||||
|
||||
FFstrbuf content;
|
||||
ffStrbufInit(&content);
|
||||
ffAppendFileContent(cacheFilePath.chars, &content);
|
||||
ffAppendFileContent(path.chars, &content);
|
||||
|
||||
if(ffStrbufCompS(&content, FASTFETCH_PROJECT_VERSION) == 0)
|
||||
{
|
||||
ffStrbufDestroy(&content);
|
||||
ffStrbufDestroy(&cacheFilePath);
|
||||
ffStrbufDestroy(&path);
|
||||
return;
|
||||
}
|
||||
|
||||
instance->config.recache = true;
|
||||
|
||||
FILE* versionFile = fopen(cacheFilePath.chars, "w");
|
||||
if(versionFile == NULL)
|
||||
return;
|
||||
|
||||
fputs(FASTFETCH_PROJECT_VERSION, versionFile);
|
||||
|
||||
fclose(versionFile);
|
||||
FFstrbuf version;
|
||||
ffStrbufInit(&version);
|
||||
ffStrbufAppendS(&version, FASTFETCH_PROJECT_VERSION);
|
||||
ffWriteFileContent(path.chars, &version);
|
||||
ffStrbufDestroy(&version);
|
||||
|
||||
ffStrbufDestroy(&content);
|
||||
ffStrbufDestroy(&cacheFilePath);
|
||||
ffStrbufDestroy(&path);
|
||||
}
|
||||
|
||||
void ffCacheOpenWrite(FFinstance* instance, const char* moduleName, FFcache* cache)
|
||||
{
|
||||
FFstrbuf cacheFileValue;
|
||||
ffStrbufInitA(&cacheFileValue, 64);
|
||||
getCacheFileValue(instance, moduleName, &cacheFileValue);
|
||||
ffGetCacheFilePath(instance, moduleName, FF_IO_CACHE_VALUE_EXTENSION, &cacheFileValue);
|
||||
cache->value = fopen(cacheFileValue.chars, "w");
|
||||
ffStrbufDestroy(&cacheFileValue);
|
||||
|
||||
FFstrbuf cacheFileSplit;
|
||||
ffStrbufInitA(&cacheFileSplit, 64);
|
||||
getCacheFileSplit(instance, moduleName, &cacheFileSplit);
|
||||
ffGetCacheFilePath(instance, moduleName, FF_IO_CACHE_SPLIT_EXTENSION, &cacheFileSplit);
|
||||
cache->split = fopen(cacheFileSplit.chars, "w");
|
||||
ffStrbufDestroy(&cacheFileSplit);
|
||||
}
|
||||
@@ -358,6 +362,22 @@ void ffParsePropFileHome(FFinstance* instance, const char* relativeFile, const c
|
||||
ffStrbufDestroy(&absolutePath);
|
||||
}
|
||||
|
||||
void ffWriteFDContent(int fd, const FFstrbuf* content)
|
||||
{
|
||||
write(fd, content->chars, content->length);
|
||||
}
|
||||
|
||||
void ffWriteFileContent(const char* fileName, const FFstrbuf* content)
|
||||
{
|
||||
int fd = open(fileName, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
|
||||
if(fd == -1)
|
||||
return;
|
||||
|
||||
ffWriteFDContent(fd, content);
|
||||
|
||||
close(fd);
|
||||
}
|
||||
|
||||
void ffAppendFDContent(int fd, FFstrbuf* buffer)
|
||||
{
|
||||
ssize_t readed;
|
||||
|
||||
+38
-23
@@ -170,7 +170,7 @@ static void loadManjaroLogo(FFlogo *logo, bool doColor)
|
||||
/* color = light green */
|
||||
const char* color = doColor ? "\033[92m" : "";
|
||||
strcpy(logo->color, "\033[92m");
|
||||
|
||||
|
||||
sprintf(logo->chars[0], FASTFETCH_TEXT_MODIFIER_BOLT"%s██████████████████ ████████"FASTFETCH_TEXT_MODIFIER_RESET, color);
|
||||
sprintf(logo->chars[1], FASTFETCH_TEXT_MODIFIER_BOLT"%s██████████████████ ████████"FASTFETCH_TEXT_MODIFIER_RESET, color);
|
||||
sprintf(logo->chars[2], FASTFETCH_TEXT_MODIFIER_BOLT"%s██████████████████ ████████"FASTFETCH_TEXT_MODIFIER_RESET, color);
|
||||
@@ -226,29 +226,19 @@ void ffLoadLogoSet(FFconfig* config, const char* logo)
|
||||
config->logo_spacing = 0; //This is wanted in most cases, so just set it
|
||||
}
|
||||
else if(strcasecmp(logo, "arch") == 0)
|
||||
{
|
||||
loadArchLogo(&config->logo, config->colorLogo);
|
||||
}
|
||||
else if(strcasecmp(logo, "artix") == 0)
|
||||
{
|
||||
loadArtixLogo(&config->logo, config->colorLogo);
|
||||
}
|
||||
else if(strcasecmp(logo, "ubuntu") == 0)
|
||||
{
|
||||
loadUbuntuLogo(&config->logo, config->colorLogo);
|
||||
}
|
||||
else if(strcasecmp(logo, "debian") == 0)
|
||||
{
|
||||
loadDebianLogo(&config->logo, config->colorLogo);
|
||||
}
|
||||
else if(strcasecmp(logo, "manjaro") == 0)
|
||||
{
|
||||
loadManjaroLogo(&config->logo, config->colorLogo);
|
||||
}
|
||||
else if(strcasecmp(logo, "void") == 0)
|
||||
{
|
||||
loadVoidLogo(&config->logo, config->colorLogo);
|
||||
}
|
||||
else if(strcasecmp(logo, "unknown") == 0)
|
||||
loadUnknownLogo(&config->logo);
|
||||
else
|
||||
{
|
||||
if(config->showErrors)
|
||||
@@ -257,20 +247,45 @@ void ffLoadLogoSet(FFconfig* config, const char* logo)
|
||||
}
|
||||
}
|
||||
|
||||
void ffLoadLogo(FFconfig* config)
|
||||
void ffLoadLogo(FFinstance* instance)
|
||||
{
|
||||
char id[256];
|
||||
ffParsePropFile("/etc/os-release", "ID=%[^\n]", id);
|
||||
if(id[0] == '\0')
|
||||
FFstrbuf cacheFilePath;
|
||||
ffStrbufInitA(&cacheFilePath, 64);
|
||||
ffGetCacheFilePath(instance, "logo.ffcl", NULL, &cacheFilePath);
|
||||
|
||||
if(!instance->config.recache)
|
||||
{
|
||||
if(config->showErrors)
|
||||
puts(FASTFETCH_TEXT_MODIFIER_ERROR"Error: \"ID=%[^\\n]\" not found in \"/etc/os-release\""FASTFETCH_TEXT_MODIFIER_RESET);
|
||||
loadUnknownLogo(&config->logo);
|
||||
FFstrbuf content;
|
||||
ffStrbufInit(&content);
|
||||
ffAppendFileContent(cacheFilePath.chars, &content);
|
||||
|
||||
if(content.length > 0)
|
||||
{
|
||||
ffLoadLogoSet(&instance->config, content.chars);
|
||||
ffStrbufDestroy(&content);
|
||||
ffStrbufDestroy(&cacheFilePath);
|
||||
return;
|
||||
}
|
||||
|
||||
ffStrbufDestroy(&content);
|
||||
}
|
||||
|
||||
const FFOSResult* result = ffCalculateOS(instance);
|
||||
|
||||
if(result->id.length > 0)
|
||||
{
|
||||
ffLoadLogoSet(&instance->config, result->id.chars);
|
||||
ffWriteFileContent(cacheFilePath.chars, &result->id);
|
||||
}
|
||||
else if(result->name.length > 0)
|
||||
{
|
||||
ffLoadLogoSet(&instance->config, result->name.chars);
|
||||
ffWriteFileContent(cacheFilePath.chars, &result->name);
|
||||
}
|
||||
else
|
||||
{
|
||||
ffLoadLogoSet(config, id);
|
||||
}
|
||||
loadUnknownLogo(&instance->config.logo);
|
||||
|
||||
ffStrbufDestroy(&cacheFilePath);
|
||||
}
|
||||
|
||||
void ffPrintLogoLine(FFinstance* instance)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "fastfetch.h"
|
||||
|
||||
void ffGetGtkPretty(FFstrbuf* buffer, FFstrbuf* gtk2, FFstrbuf* gtk3, FFstrbuf* gtk4)
|
||||
void ffGetGtkPretty(FFstrbuf* buffer, const FFstrbuf* gtk2, const FFstrbuf* gtk3, const FFstrbuf* gtk4)
|
||||
{
|
||||
if(gtk2->length > 0 && gtk3->length > 0 && gtk4->length > 0)
|
||||
{
|
||||
|
||||
+2
-2
@@ -90,7 +90,7 @@ static inline void printHelp()
|
||||
" --uptime-key <key>\n"
|
||||
" --packages-key <key>\n"
|
||||
" --shell-key <key>\n"
|
||||
" --resolution-key <key>\n"
|
||||
" --resolution-key <key>: takes the resolution index as argument\n"
|
||||
" --de-key <key>\n"
|
||||
" --wm-key <key>\n"
|
||||
" --wm-theme-key <key>\n"
|
||||
@@ -785,7 +785,7 @@ static void applyData(FFinstance* instance, FFdata* data)
|
||||
{
|
||||
//We must do this after parsing all options because of color options
|
||||
if(data->logoName.length == 0)
|
||||
ffLoadLogo(&instance->config);
|
||||
ffLoadLogo(instance);
|
||||
else
|
||||
ffLoadLogoSet(&instance->config, data->logoName.chars);
|
||||
|
||||
|
||||
+60
-43
@@ -43,7 +43,7 @@ typedef struct FFconfig
|
||||
bool colorLogo;
|
||||
bool showErrors;
|
||||
bool recache;
|
||||
bool cacheSave; //This is only set to true when using arguments, because we dont want so save this values
|
||||
bool cacheSave;
|
||||
bool printRemainingLogo;
|
||||
|
||||
FFstrbuf osFormat;
|
||||
@@ -99,12 +99,51 @@ typedef struct FFconfig
|
||||
|
||||
} FFconfig;
|
||||
|
||||
typedef struct FFgtkval
|
||||
typedef struct FFOSResult
|
||||
{
|
||||
FFstrbuf systemName;
|
||||
FFstrbuf name;
|
||||
FFstrbuf prettyName;
|
||||
FFstrbuf id;
|
||||
FFstrbuf idLike;
|
||||
FFstrbuf variant;
|
||||
FFstrbuf variantID;
|
||||
FFstrbuf version;
|
||||
FFstrbuf versionID;
|
||||
FFstrbuf codename;
|
||||
FFstrbuf buildID;
|
||||
FFstrbuf architecture;
|
||||
FFstrbuf error;
|
||||
} FFOSResult;
|
||||
|
||||
typedef struct FFPlasmaResult
|
||||
{
|
||||
FFstrbuf widgetStyle;
|
||||
FFstrbuf colorScheme;
|
||||
FFstrbuf icons;
|
||||
FFstrbuf font;
|
||||
} FFPlasmaResult;
|
||||
|
||||
typedef struct FFGTKResult
|
||||
{
|
||||
FFstrbuf theme;
|
||||
FFstrbuf icons;
|
||||
FFstrbuf font;
|
||||
} FFgtkval;
|
||||
} FFGTKResult;
|
||||
|
||||
typedef struct FFTerminalResult
|
||||
{
|
||||
FFstrbuf exeName;
|
||||
FFstrbuf processName;
|
||||
FFstrbuf error;
|
||||
} FFTerminalResult;
|
||||
|
||||
typedef struct FFWMResult
|
||||
{
|
||||
FFstrbuf processName;
|
||||
FFstrbuf prettyName;
|
||||
FFstrbuf error;
|
||||
} FFWMResult;
|
||||
|
||||
typedef struct FFstate
|
||||
{
|
||||
@@ -112,35 +151,6 @@ typedef struct FFstate
|
||||
struct passwd* passwd;
|
||||
struct utsname utsname;
|
||||
struct sysinfo sysinfo;
|
||||
|
||||
//Values needed in more than one module / calculated together / calculated in extra threads
|
||||
|
||||
struct
|
||||
{
|
||||
FFstrbuf widgetStyle;
|
||||
FFstrbuf colorScheme;
|
||||
FFstrbuf icons;
|
||||
FFstrbuf font;
|
||||
} plasma;
|
||||
|
||||
FFgtkval gtk2;
|
||||
FFgtkval gtk3;
|
||||
FFgtkval gtk4;
|
||||
|
||||
struct
|
||||
{
|
||||
FFstrbuf exeName;
|
||||
FFstrbuf processName;
|
||||
FFstrbuf error;
|
||||
} terminal;
|
||||
|
||||
struct
|
||||
{
|
||||
FFstrbuf processName;
|
||||
FFstrbuf prettyName;
|
||||
FFstrbuf error;
|
||||
} wm;
|
||||
|
||||
} FFstate;
|
||||
|
||||
typedef struct FFinstance
|
||||
@@ -151,13 +161,13 @@ typedef struct FFinstance
|
||||
|
||||
typedef enum FFformatargtype
|
||||
{
|
||||
FF_FORMAT_ARG_TYPE_NULL,
|
||||
FF_FORMAT_ARG_TYPE_UINT,
|
||||
FF_FORMAT_ARG_TYPE_UINT8,
|
||||
FF_FORMAT_ARG_TYPE_INT,
|
||||
FF_FORMAT_ARG_TYPE_STRING,
|
||||
FF_FORMAT_ARG_TYPE_STRBUF,
|
||||
FF_FORMAT_ARG_TYPE_DOUBLE,
|
||||
FF_FORMAT_ARG_TYPE_NULL
|
||||
FF_FORMAT_ARG_TYPE_DOUBLE
|
||||
} FFformatargtype;
|
||||
|
||||
typedef struct FFformatarg
|
||||
@@ -179,7 +189,6 @@ typedef struct FFcache
|
||||
//common/init.c
|
||||
void ffInitInstance(FFinstance* instance);
|
||||
void ffFinish(FFinstance* instance);
|
||||
void ffCalculatePlasmaAndGtk(FFinstance* instance);
|
||||
|
||||
//common/threading.c
|
||||
void ffStartCalculationThreads(FFinstance* instance);
|
||||
@@ -188,6 +197,9 @@ void ffStartCalculationThreads(FFinstance* instance);
|
||||
void ffPrintLogoAndKey(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat);
|
||||
void ffPrintError(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, const FFstrbuf* formatString, uint32_t numFormatArgs, const char* message, ...);
|
||||
void ffPrintFormatString(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, const FFstrbuf* formatString, const FFstrbuf* error, uint32_t numArgs, const FFformatarg* arguments);
|
||||
void ffGetCacheFilePath(FFinstance* instance, const char* moduleName, const char* extension, FFstrbuf* buffer);
|
||||
void ffReadCacheFile(FFinstance* instance, const char* moduleName, const char* extension, FFstrbuf* buffer);
|
||||
void ffWriteCacheFile(FFinstance* instance, const char* moduleName, const char* extension, FFstrbuf* content);
|
||||
bool ffPrintFromCache(FFinstance* instance, const char* moduleName, const FFstrbuf* customKeyFormat, const FFstrbuf* formatString, uint32_t numArgs);
|
||||
void ffPrintAndSaveToCache(FFinstance* instance, const char* moduleName, const FFstrbuf* customKeyFormat, const FFstrbuf* value, const FFstrbuf* formatString, uint32_t numArgs, const FFformatarg* arguments);
|
||||
void ffPrintAndAppendToCache(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, FFcache* cache, const FFstrbuf* value, const FFstrbuf* formatString, uint32_t numArgs, const FFformatarg* arguments);
|
||||
@@ -199,6 +211,8 @@ void ffCacheClose(FFcache* cache);
|
||||
void ffAppendFDContent(int fd, FFstrbuf* buffer);
|
||||
void ffAppendFileContent(const char* fileName, FFstrbuf* buffer);
|
||||
void ffGetFileContent(const char* fileName, FFstrbuf* buffer);
|
||||
void ffWriteFDContent(int fd, const FFstrbuf* content);
|
||||
void ffWriteFileContent(const char* fileName, const FFstrbuf* buffer);
|
||||
|
||||
void ffParsePropFile(const char* file, const char* regex, char* buffer);
|
||||
void ffParsePropFileHome(FFinstance* instance, const char* relativeFile, const char* regex, char* buffer);
|
||||
@@ -208,7 +222,7 @@ void ffProcessGetStdOut(FFstrbuf* buffer, char* const argv[]);
|
||||
|
||||
//common/logo.c
|
||||
void ffLoadLogoSet(FFconfig* config, const char* logo);
|
||||
void ffLoadLogo(FFconfig* config);
|
||||
void ffLoadLogo(FFinstance* instance);
|
||||
void ffPrintLogoLine(FFinstance* instance);
|
||||
void ffPrintRemainingLogo(FFinstance* instance);
|
||||
|
||||
@@ -222,23 +236,26 @@ void ffFormatAppendFormatArg(FFstrbuf* buffer, const FFformatarg* formatarg);
|
||||
void ffParseFormatString(FFstrbuf* buffer, const FFstrbuf* formatstr, const FFstrbuf* error, uint32_t numArgs, const FFformatarg* arguments);
|
||||
|
||||
//common/parsing.c
|
||||
void ffGetGtkPretty(FFstrbuf* buffer, FFstrbuf* gtk2, FFstrbuf* gtk3, FFstrbuf* gtk4);
|
||||
void ffGetGtkPretty(FFstrbuf* buffer, const FFstrbuf* gtk2, const FFstrbuf* gtk3, const FFstrbuf* gtk4);
|
||||
void ffGetFont(const char* font, FFstrbuf* name, double* size);
|
||||
void ffGetFontPretty(FFstrbuf* buffer, const FFstrbuf* name, double size);
|
||||
|
||||
//common/calculateOS.c
|
||||
const FFOSResult* ffCalculateOS(FFinstance* instance);
|
||||
|
||||
//common/calculatePlasma.c
|
||||
void ffCalculatePlasma(FFinstance* instance);
|
||||
const FFPlasmaResult* ffCalculatePlasma(FFinstance* instance);
|
||||
|
||||
//common/calculateGTK.c
|
||||
void ffCalculateGTK2(FFinstance* instance);
|
||||
void ffCalculateGTK4(FFinstance* instance);
|
||||
void ffCalculateGTK3(FFinstance* instance);
|
||||
const FFGTKResult* ffCalculateGTK2(FFinstance* instance);
|
||||
const FFGTKResult* ffCalculateGTK4(FFinstance* instance);
|
||||
const FFGTKResult* ffCalculateGTK3(FFinstance* instance);
|
||||
|
||||
//common/calculateWM.c
|
||||
void ffCalculateWM(FFinstance* instance);
|
||||
const FFWMResult* ffCalculateWM(FFinstance* instance);
|
||||
|
||||
//common/calculateTerminal.c
|
||||
void ffCalculateTerminal(FFinstance* instance);
|
||||
const FFTerminalResult* ffCalculateTerminal(FFinstance* instance);
|
||||
|
||||
/********************/
|
||||
/* Module functions */
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ int main(int argc, char** argv)
|
||||
UNUSED(argv);
|
||||
|
||||
FFinstance instance;
|
||||
ffInitInstance(&instance);
|
||||
ffInitInstance(&instance); //This also applys default configuration to instance.config
|
||||
|
||||
//Configuration
|
||||
ffLoadLogoSet(&instance.config, "arch");
|
||||
|
||||
+14
-11
@@ -5,9 +5,12 @@
|
||||
|
||||
void ffPrintFont(FFinstance* instance)
|
||||
{
|
||||
ffCalculatePlasmaAndGtk(instance);
|
||||
const FFstrbuf* plasma = &ffCalculatePlasma(instance)->font;
|
||||
const FFstrbuf* gtk2 = &ffCalculateGTK2(instance)->font;
|
||||
const FFstrbuf* gtk3 = &ffCalculateGTK3(instance)->font;
|
||||
const FFstrbuf* gtk4 = &ffCalculateGTK4(instance)->font;
|
||||
|
||||
if(instance->state.plasma.font.length == 0 && instance->state.gtk2.font.length == 0 && instance->state.gtk3.font.length == 0 && instance->state.gtk4.font.length == 0)
|
||||
if(plasma->length == 0 && gtk2->length == 0 && gtk3->length == 0 && gtk4->length == 0)
|
||||
{
|
||||
ffPrintError(instance, FF_FONT_MODULE_NAME, 0, &instance->config.fontKey, &instance->config.fontFormat, FF_FONT_NUM_FORMAT_ARGS, "No fonts found");
|
||||
return;
|
||||
@@ -15,25 +18,25 @@ void ffPrintFont(FFinstance* instance)
|
||||
|
||||
FF_STRBUF_CREATE(plasmaName);
|
||||
double plasmaSize;
|
||||
ffGetFont(instance->state.plasma.font.chars, &plasmaName, &plasmaSize);
|
||||
ffGetFont(plasma->chars, &plasmaName, &plasmaSize);
|
||||
FF_STRBUF_CREATE(plasmaPretty);
|
||||
ffGetFontPretty(&plasmaPretty, &plasmaName, plasmaSize);
|
||||
|
||||
FF_STRBUF_CREATE(gtk2Name);
|
||||
double gtk2Size;
|
||||
ffGetFont(instance->state.gtk2.font.chars, >k2Name, >k2Size);
|
||||
ffGetFont(gtk2->chars, >k2Name, >k2Size);
|
||||
FF_STRBUF_CREATE(gtk2Pretty);
|
||||
ffGetFontPretty(>k2Pretty, >k2Name, gtk2Size);
|
||||
|
||||
FF_STRBUF_CREATE(gtk3Name);
|
||||
double gtk3Size;
|
||||
ffGetFont(instance->state.gtk3.font.chars, >k3Name, >k3Size);
|
||||
ffGetFont(gtk3->chars, >k3Name, >k3Size);
|
||||
FF_STRBUF_CREATE(gtk3Pretty);
|
||||
ffGetFontPretty(>k3Pretty, >k3Name, gtk3Size);
|
||||
|
||||
FF_STRBUF_CREATE(gtk4Name);
|
||||
double gtk4Size;
|
||||
ffGetFont(instance->state.gtk4.font.chars, >k4Name, >k4Size);
|
||||
ffGetFont(gtk4->chars, >k4Name, >k4Size);
|
||||
FF_STRBUF_CREATE(gtk4Pretty);
|
||||
ffGetFontPretty(>k4Pretty, >k4Name, gtk4Size);
|
||||
|
||||
@@ -43,7 +46,7 @@ void ffPrintFont(FFinstance* instance)
|
||||
if(instance->config.fontFormat.length == 0)
|
||||
{
|
||||
ffPrintLogoAndKey(instance, FF_FONT_MODULE_NAME, 0, &instance->config.fontKey);
|
||||
if(instance->state.plasma.font.length > 0)
|
||||
if(plasma->length > 0)
|
||||
{
|
||||
ffStrbufWriteTo(&plasmaPretty, stdout);
|
||||
fputs(" [Plasma]", stdout);
|
||||
@@ -56,19 +59,19 @@ void ffPrintFont(FFinstance* instance)
|
||||
else
|
||||
{
|
||||
ffPrintFormatString(instance, FF_FONT_MODULE_NAME, 0, &instance->config.fontKey, &instance->config.fontFormat, NULL, FF_FONT_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &instance->state.plasma.font},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, plasma},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &plasmaName},
|
||||
{FF_FORMAT_ARG_TYPE_DOUBLE, &plasmaSize},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &plasmaPretty},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &instance->state.gtk2.font},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, gtk2},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, >k2Name},
|
||||
{FF_FORMAT_ARG_TYPE_DOUBLE, >k2Size},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, >k2Pretty},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &instance->state.gtk3.font},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, gtk3},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, >k3Name},
|
||||
{FF_FORMAT_ARG_TYPE_DOUBLE, >k3Size},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, >k3Pretty},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &instance->state.gtk4.font},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, gtk4},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, >k4Name},
|
||||
{FF_FORMAT_ARG_TYPE_DOUBLE, >k4Size},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, >k4Pretty},
|
||||
|
||||
+13
-9
@@ -5,24 +5,28 @@
|
||||
|
||||
void ffPrintIcons(FFinstance* instance)
|
||||
{
|
||||
ffCalculatePlasmaAndGtk(instance);
|
||||
const FFstrbuf* plasma = &ffCalculatePlasma(instance)->icons;
|
||||
const FFstrbuf* gtk2 = &ffCalculateGTK2(instance)->icons;
|
||||
const FFstrbuf* gtk3 = &ffCalculateGTK3(instance)->icons;
|
||||
const FFstrbuf* gtk4 = &ffCalculateGTK4(instance)->icons;
|
||||
|
||||
if(instance->state.plasma.icons.length == 0 && instance->state.gtk2.icons.length == 0 && instance->state.gtk3.icons.length == 0 && instance->state.gtk4.icons.length == 0)
|
||||
|
||||
if(plasma->length == 0 && gtk2->length == 0 && gtk3->length == 0 && gtk4->length == 0)
|
||||
{
|
||||
ffPrintError(instance, FF_ICONS_MODULE_NAME, 0, &instance->config.iconsKey, &instance->config.iconsFormat, FF_ICONS_NUM_FORMAT_ARGS, "No icons could be found");
|
||||
return;
|
||||
}
|
||||
|
||||
FF_STRBUF_CREATE(gtkPretty);
|
||||
ffGetGtkPretty(>kPretty, &instance->state.gtk2.icons, &instance->state.gtk3.icons, &instance->state.gtk4.icons);
|
||||
ffGetGtkPretty(>kPretty, gtk2, gtk3, gtk4);
|
||||
|
||||
if(instance->config.iconsFormat.length == 0)
|
||||
{
|
||||
ffPrintLogoAndKey(instance, FF_ICONS_MODULE_NAME, 0, &instance->config.iconsKey);
|
||||
|
||||
if(instance->state.plasma.icons.length > 0)
|
||||
if(plasma->length > 0)
|
||||
{
|
||||
ffStrbufWriteTo(&instance->state.plasma.icons, stdout);
|
||||
ffStrbufWriteTo(plasma, stdout);
|
||||
fputs(" [Plasma]", stdout);
|
||||
|
||||
if(gtkPretty.length > 0)
|
||||
@@ -34,10 +38,10 @@ void ffPrintIcons(FFinstance* instance)
|
||||
else
|
||||
{
|
||||
ffPrintFormatString(instance, FF_ICONS_MODULE_NAME, 0, &instance->config.iconsKey, &instance->config.iconsFormat, NULL, FF_ICONS_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &instance->state.plasma.icons},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &instance->state.gtk2.icons},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &instance->state.gtk3.icons},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &instance->state.gtk4.icons},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, plasma},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, gtk2},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, gtk3},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, gtk4},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, >kPretty}
|
||||
});
|
||||
}
|
||||
|
||||
+30
-79
@@ -8,103 +8,54 @@ void ffPrintOS(FFinstance* instance)
|
||||
if(ffPrintFromCache(instance, FF_OS_MODULE_NAME, &instance->config.osKey, &instance->config.osFormat, FF_OS_NUM_FORMAT_ARGS))
|
||||
return;
|
||||
|
||||
FILE* osRelease = fopen("/etc/os-release", "r");
|
||||
const FFOSResult* result = ffCalculateOS(instance);
|
||||
|
||||
if(osRelease == NULL)
|
||||
osRelease = fopen("/usr/lib/os-release", "r");
|
||||
|
||||
if(osRelease == NULL)
|
||||
if(result->error.length > 0)
|
||||
{
|
||||
ffPrintError(instance, FF_OS_MODULE_NAME, 0, &instance->config.osKey, &instance->config.osFormat, FF_OS_NUM_FORMAT_ARGS, "couldn't read /etc/os-release nor /usr/lib/os-release");
|
||||
ffPrintError(instance, FF_OS_MODULE_NAME, 0, &instance->config.osKey, &instance->config.osFormat, FF_OS_NUM_FORMAT_ARGS, result->error.chars);
|
||||
return;
|
||||
}
|
||||
|
||||
// Documentation of the fields:
|
||||
// https://www.freedesktop.org/software/systemd/man/os-release.html
|
||||
|
||||
char name[128]; name[0] = '\0';
|
||||
char prettyName[128]; prettyName[0] = '\0';
|
||||
char id[128]; id[0] = '\0';
|
||||
char idLike[128]; idLike[0] = '\0';
|
||||
char variant[128]; variant[0] = '\0';
|
||||
char variantId[128]; variantId[0] = '\0';
|
||||
char version[128]; version[0] = '\0';
|
||||
char versionId[128]; versionId[0] = '\0';
|
||||
char versionCodename[128]; versionCodename[0] = '\0';
|
||||
char buildId[128]; buildId[0] = '\0';
|
||||
|
||||
char* line = NULL;
|
||||
size_t len = 0;
|
||||
|
||||
while (getline(&line, &len, osRelease) != -1)
|
||||
{
|
||||
sscanf(line, "NAME=%[^\n]", name);
|
||||
sscanf(line, "NAME=\"%[^\"]+", name);
|
||||
sscanf(line, "PRETTY_NAME=%[^\n]", prettyName);
|
||||
sscanf(line, "PRETTY_NAME=\"%[^\"]+", prettyName);
|
||||
sscanf(line, "ID=%[^\n]", id);
|
||||
sscanf(line, "ID=\"%[^\"]+", id);
|
||||
sscanf(line, "ID_LIKE=%[^\n]", idLike);
|
||||
sscanf(line, "ID_LIKE=\"%[^\"]+", idLike);
|
||||
sscanf(line, "VARIANT=%[^\n]", variant);
|
||||
sscanf(line, "VARIANT=\"%[^\"]+", variant);
|
||||
sscanf(line, "VARIANT_ID=%[^\n]", variantId);
|
||||
sscanf(line, "VARIANT_ID=\"%[^\"]+", variantId);
|
||||
sscanf(line, "VERSION=%[^\n]", version);
|
||||
sscanf(line, "VERSION=\"%[^\"]+", version);
|
||||
sscanf(line, "VERSION_ID=%[^\n]", versionId);
|
||||
sscanf(line, "VERSION_ID=\"%[^\"]+", versionId);
|
||||
sscanf(line, "VERSION_CODENAME=%[^\n]", versionCodename);
|
||||
sscanf(line, "VERSION_CODENAME=\"%[^\"]+", versionCodename);
|
||||
sscanf(line, "BUILD_ID=%[^\n]", buildId);
|
||||
sscanf(line, "BUILD_ID=\"%[^\"]+", buildId);
|
||||
}
|
||||
|
||||
if(line != NULL)
|
||||
free(line);
|
||||
|
||||
fclose(osRelease);
|
||||
|
||||
FF_STRBUF_CREATE(os);
|
||||
|
||||
if(prettyName[0] != '\0')
|
||||
if(result->prettyName.length > 0)
|
||||
{
|
||||
ffStrbufAppendS(&os, prettyName);
|
||||
ffStrbufAppend(&os, &result->prettyName);
|
||||
}
|
||||
else if(name[0] == '\0' && id[0] == '\0')
|
||||
else if(result->name.length == 0 && result->id.length == 0)
|
||||
{
|
||||
ffStrbufAppendS(&os, instance->state.utsname.sysname);
|
||||
ffStrbufAppend(&os, &result->systemName);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(name[0] != '\0')
|
||||
ffStrbufAppendS(&os, name);
|
||||
if(result->name.length > 0)
|
||||
ffStrbufAppend(&os, &result->name);
|
||||
else
|
||||
ffStrbufAppendS(&os, id);
|
||||
ffStrbufAppend(&os, &result->id);
|
||||
|
||||
if(version[0] != '\0')
|
||||
if(result->version.length > 0)
|
||||
{
|
||||
ffStrbufAppendC(&os, ' ');
|
||||
ffStrbufAppendS(&os, version);
|
||||
ffStrbufAppend(&os, &result->version);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(versionId[0] != '\0')
|
||||
if(result->versionID.length > 0)
|
||||
{
|
||||
ffStrbufAppendC(&os, ' ');
|
||||
ffStrbufAppendS(&os, versionId);
|
||||
ffStrbufAppend(&os, &result->versionID);
|
||||
}
|
||||
|
||||
if(variant[0] != '\0')
|
||||
if(result->variant.length > 0)
|
||||
{
|
||||
ffStrbufAppendS(&os, " (");
|
||||
ffStrbufAppendS(&os, variant);
|
||||
ffStrbufAppend(&os, &result->variant);
|
||||
ffStrbufAppendC(&os, ')');
|
||||
}
|
||||
else if(variantId[0] != '\0')
|
||||
else if(result->variantID.length > 0)
|
||||
{
|
||||
ffStrbufAppendS(&os, " (");
|
||||
ffStrbufAppendS(&os, variantId);
|
||||
ffStrbufAppend(&os, &result->variantID);
|
||||
ffStrbufAppendC(&os, ')');
|
||||
}
|
||||
}
|
||||
@@ -114,18 +65,18 @@ void ffPrintOS(FFinstance* instance)
|
||||
ffStrbufAppendS(&os, instance->state.utsname.machine);
|
||||
|
||||
ffPrintAndSaveToCache(instance, FF_OS_MODULE_NAME, &instance->config.osKey, &os, &instance->config.osFormat, FF_OS_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_STRING, instance->state.utsname.sysname},
|
||||
{FF_FORMAT_ARG_TYPE_STRING, name},
|
||||
{FF_FORMAT_ARG_TYPE_STRING, prettyName},
|
||||
{FF_FORMAT_ARG_TYPE_STRING, id},
|
||||
{FF_FORMAT_ARG_TYPE_STRING, idLike},
|
||||
{FF_FORMAT_ARG_TYPE_STRING, variant},
|
||||
{FF_FORMAT_ARG_TYPE_STRING, variantId},
|
||||
{FF_FORMAT_ARG_TYPE_STRING, version},
|
||||
{FF_FORMAT_ARG_TYPE_STRING, versionId},
|
||||
{FF_FORMAT_ARG_TYPE_STRING, versionCodename},
|
||||
{FF_FORMAT_ARG_TYPE_STRING, buildId},
|
||||
{FF_FORMAT_ARG_TYPE_STRING, instance->state.utsname.machine}
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->systemName},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->name},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->prettyName},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->id},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->idLike},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->variant},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->variantID},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->version},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->versionID},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->codename},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->buildID},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->architecture}
|
||||
});
|
||||
|
||||
ffStrbufDestroy(&os);
|
||||
|
||||
+10
-10
@@ -5,26 +5,26 @@
|
||||
|
||||
void ffPrintTerminal(FFinstance* instance)
|
||||
{
|
||||
ffCalculateTerminal(instance);
|
||||
const FFTerminalResult* result = ffCalculateTerminal(instance);
|
||||
|
||||
if(instance->state.terminal.error.length > 0)
|
||||
if(result->error.length > 0)
|
||||
{
|
||||
ffPrintError(instance, FF_TERMINAL_MODULE_NAME, 0, &instance->config.terminalKey, &instance->config.terminalFormat, FF_TERMINAL_NUM_FORMAT_ARGS, instance->state.terminal.error.chars);
|
||||
ffPrintError(instance, FF_TERMINAL_MODULE_NAME, 0, &instance->config.terminalKey, &instance->config.terminalFormat, FF_TERMINAL_NUM_FORMAT_ARGS, result->error.chars);
|
||||
return;
|
||||
}
|
||||
|
||||
if(instance->state.terminal.exeName.length == 0 && instance->state.terminal.processName.length == 0)
|
||||
if(result->exeName.length == 0 && result->processName.length == 0)
|
||||
{
|
||||
ffPrintError(instance, FF_TERMINAL_MODULE_NAME, 0, &instance->config.terminalKey, &instance->config.terminalFormat, FF_TERMINAL_NUM_FORMAT_ARGS, "Terminal names not set");
|
||||
return;
|
||||
}
|
||||
|
||||
FFstrbuf* name;
|
||||
const FFstrbuf* name;
|
||||
|
||||
if(ffStrbufStartsWith(&instance->state.terminal.exeName, &instance->state.terminal.processName))
|
||||
name = &instance->state.terminal.exeName;
|
||||
if(ffStrbufStartsWith(&result->exeName, &result->processName))
|
||||
name = &result->exeName;
|
||||
else
|
||||
name = &instance->state.terminal.processName;
|
||||
name = &result->processName;
|
||||
|
||||
if(instance->config.terminalFormat.length == 0)
|
||||
{
|
||||
@@ -34,8 +34,8 @@ void ffPrintTerminal(FFinstance* instance)
|
||||
else
|
||||
{
|
||||
ffPrintFormatString(instance, FF_TERMINAL_MODULE_NAME, 0, &instance->config.terminalKey, &instance->config.terminalFormat, NULL, FF_TERMINAL_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &instance->state.terminal.exeName},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &instance->state.terminal.processName},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->exeName},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->processName},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, name}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -68,18 +68,18 @@ static void printTTY(FFinstance* instance)
|
||||
|
||||
void ffPrintTerminalFont(FFinstance* instance)
|
||||
{
|
||||
ffCalculateTerminal(instance);
|
||||
const FFTerminalResult* result = ffCalculateTerminal(instance);
|
||||
|
||||
if(instance->state.terminal.exeName.length == 0)
|
||||
if(result->exeName.length == 0)
|
||||
{
|
||||
ffPrintError(instance, FF_TERMFONT_MODULE_NAME, 0, &instance->config.termFontKey, &instance->config.termFontFormat, FF_TERMFONT_NUM_FORMAT_ARGS, "Terminal font needs successfull terminal detection");
|
||||
return;
|
||||
}
|
||||
|
||||
if(ffStrbufIgnCaseCompS(&instance->state.terminal.exeName, "konsole") == 0)
|
||||
if(ffStrbufIgnCaseCompS(&result->exeName, "konsole") == 0)
|
||||
printKonsole(instance);
|
||||
else if(ffStrbufStartsWithIgnCaseS(&instance->state.terminal.exeName, "login"))
|
||||
else if(ffStrbufStartsWithIgnCaseS(&result->exeName, "login"))
|
||||
printTTY(instance);
|
||||
else
|
||||
ffPrintError(instance, FF_TERMFONT_MODULE_NAME, 0, &instance->config.termFontKey, &instance->config.termFontFormat, FF_TERMFONT_NUM_FORMAT_ARGS, "Terminal Font", "Unknown terminal: %s", instance->state.terminal.exeName.chars);
|
||||
ffPrintError(instance, FF_TERMFONT_MODULE_NAME, 0, &instance->config.termFontKey, &instance->config.termFontFormat, FF_TERMFONT_NUM_FORMAT_ARGS, "Terminal Font", "Unknown terminal: %s", result->exeName.chars);
|
||||
}
|
||||
|
||||
+21
-18
@@ -5,54 +5,57 @@
|
||||
|
||||
void ffPrintTheme(FFinstance* instance)
|
||||
{
|
||||
ffCalculatePlasmaAndGtk(instance);
|
||||
const FFPlasmaResult* plasma = ffCalculatePlasma(instance);
|
||||
const FFstrbuf* gtk2 = &ffCalculateGTK2(instance)->theme;
|
||||
const FFstrbuf* gtk3 = &ffCalculateGTK3(instance)->theme;
|
||||
const FFstrbuf* gtk4 = &ffCalculateGTK4(instance)->theme;
|
||||
|
||||
if(instance->state.plasma.widgetStyle.length == 0 && instance->state.plasma.colorScheme.length == 0 && instance->state.gtk2.theme.length == 0 && instance->state.gtk3.theme.length == 0 && instance->state.gtk4.theme.length == 0)
|
||||
if(plasma->widgetStyle.length == 0 && plasma->colorScheme.length == 0 && gtk2->length == 0 && gtk3->length == 0 && gtk4->length == 0)
|
||||
{
|
||||
ffPrintError(instance, FF_THEME_MODULE_NAME, 0, &instance->config.themeKey, &instance->config.themeFormat, FF_THEME_NUM_FORMAT_ARGS, "No themes found");
|
||||
return;
|
||||
}
|
||||
|
||||
FF_STRBUF_CREATE(plasmaColorPretty);
|
||||
if(ffStrbufStartsWithIgnCase(&instance->state.plasma.colorScheme, &instance->state.plasma.widgetStyle))
|
||||
ffStrbufAppendNS(&plasmaColorPretty, instance->state.plasma.colorScheme.length - instance->state.plasma.widgetStyle.length, &instance->state.plasma.colorScheme.chars[instance->state.plasma.widgetStyle.length]);
|
||||
if(ffStrbufStartsWithIgnCase(&plasma->colorScheme, &plasma->widgetStyle))
|
||||
ffStrbufAppendNS(&plasmaColorPretty, plasma->colorScheme.length - plasma->widgetStyle.length, &plasma->colorScheme.chars[plasma->widgetStyle.length]);
|
||||
else
|
||||
ffStrbufAppend(&plasmaColorPretty, &instance->state.plasma.colorScheme);
|
||||
ffStrbufAppend(&plasmaColorPretty, &plasma->colorScheme);
|
||||
|
||||
ffStrbufTrim(&plasmaColorPretty, ' ');
|
||||
|
||||
FF_STRBUF_CREATE(gtkPretty);
|
||||
ffGetGtkPretty(>kPretty, &instance->state.gtk2.theme, &instance->state.gtk3.theme, &instance->state.gtk4.theme);
|
||||
ffGetGtkPretty(>kPretty, gtk2, gtk3, gtk4);
|
||||
|
||||
if(instance->config.themeFormat.length == 0)
|
||||
{
|
||||
ffPrintLogoAndKey(instance, FF_THEME_MODULE_NAME, 0, &instance->config.themeKey);
|
||||
|
||||
if(instance->state.plasma.widgetStyle.length > 0)
|
||||
if(plasma->widgetStyle.length > 0)
|
||||
{
|
||||
ffStrbufWriteTo(&instance->state.plasma.widgetStyle, stdout);
|
||||
ffStrbufWriteTo(&plasma->widgetStyle, stdout);
|
||||
|
||||
if(instance->state.plasma.colorScheme.length > 0)
|
||||
if(plasma->colorScheme.length > 0)
|
||||
{
|
||||
fputs(" (", stdout);
|
||||
|
||||
if(plasmaColorPretty.length > 0)
|
||||
ffStrbufWriteTo(&plasmaColorPretty, stdout);
|
||||
else
|
||||
ffStrbufWriteTo(&instance->state.plasma.colorScheme, stdout);
|
||||
ffStrbufWriteTo(&plasma->colorScheme, stdout);
|
||||
|
||||
putchar(')');
|
||||
}
|
||||
}
|
||||
else if(instance->state.plasma.colorScheme.length > 0)
|
||||
else if(plasma->colorScheme.length > 0)
|
||||
{
|
||||
if(plasmaColorPretty.length > 0)
|
||||
ffStrbufWriteTo(&plasmaColorPretty, stdout);
|
||||
else
|
||||
ffStrbufWriteTo(&instance->state.plasma.colorScheme, stdout);
|
||||
ffStrbufWriteTo(&plasma->colorScheme, stdout);
|
||||
}
|
||||
|
||||
if(instance->state.plasma.widgetStyle.length > 0 || instance->state.plasma.colorScheme.length > 0)
|
||||
if(plasma->widgetStyle.length > 0 || plasma->colorScheme.length > 0)
|
||||
{
|
||||
fputs(" [Plasma]", stdout);
|
||||
|
||||
@@ -65,12 +68,12 @@ void ffPrintTheme(FFinstance* instance)
|
||||
else
|
||||
{
|
||||
ffPrintFormatString(instance, FF_THEME_MODULE_NAME, 0, &instance->config.themeKey, &instance->config.themeFormat, NULL, FF_THEME_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &instance->state.plasma.widgetStyle},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &instance->state.plasma.colorScheme},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &plasma->widgetStyle},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &plasma->colorScheme},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &plasmaColorPretty},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &instance->state.gtk2.theme},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &instance->state.gtk3.theme},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &instance->state.gtk4.theme},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, gtk2},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, gtk3},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, gtk4},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, >kPretty}
|
||||
});
|
||||
}
|
||||
|
||||
+9
-9
@@ -5,15 +5,15 @@
|
||||
|
||||
void ffPrintWM(FFinstance* instance)
|
||||
{
|
||||
ffCalculateWM(instance);
|
||||
const FFWMResult* result = ffCalculateWM(instance);
|
||||
|
||||
if(instance->state.wm.error.length > 0)
|
||||
if(result->error.length > 0)
|
||||
{
|
||||
ffPrintError(instance, FF_WM_MODULE_NAME, 0, &instance->config.wmKey, &instance->config.wmFormat, FF_WM_NUM_FORMAT_ARGS, instance->state.wm.error.chars);
|
||||
ffPrintError(instance, FF_WM_MODULE_NAME, 0, &instance->config.wmKey, &instance->config.wmFormat, FF_WM_NUM_FORMAT_ARGS, result->error.chars);
|
||||
return;
|
||||
}
|
||||
|
||||
if(instance->state.wm.prettyName.length == 0 && instance->state.wm.processName.length == 0)
|
||||
if(result->prettyName.length == 0 && result->processName.length == 0)
|
||||
{
|
||||
ffPrintError(instance, FF_WM_MODULE_NAME, 0, &instance->config.wmKey, &instance->config.wmFormat, FF_WM_NUM_FORMAT_ARGS, "No wm name provided");
|
||||
return;
|
||||
@@ -22,16 +22,16 @@ void ffPrintWM(FFinstance* instance)
|
||||
if(instance->config.wmFormat.length == 0)
|
||||
{
|
||||
ffPrintLogoAndKey(instance, "WM", 0, &instance->config.wmKey);
|
||||
if(instance->state.wm.prettyName.length > 0)
|
||||
ffStrbufPutTo(&instance->state.wm.prettyName, stdout);
|
||||
if(result->prettyName.length > 0)
|
||||
ffStrbufPutTo(&result->prettyName, stdout);
|
||||
else
|
||||
ffStrbufPutTo(&instance->state.wm.processName, stdout);
|
||||
ffStrbufPutTo(&result->processName, stdout);
|
||||
}
|
||||
else
|
||||
{
|
||||
ffPrintFormatString(instance, FF_WM_MODULE_NAME, 0, &instance->config.wmKey, &instance->config.wmFormat, NULL, FF_WM_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &instance->state.wm.processName},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &instance->state.wm.prettyName}
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->processName},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->prettyName}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,16 +35,16 @@ static void printKWin(FFinstance* instance)
|
||||
|
||||
void ffPrintWMTheme(FFinstance* instance)
|
||||
{
|
||||
ffCalculateWM(instance);
|
||||
const FFWMResult* result = ffCalculateWM(instance);
|
||||
|
||||
if(instance->state.wm.prettyName.length == 0)
|
||||
if(result->prettyName.length == 0)
|
||||
{
|
||||
ffPrintError(instance, FF_WMTHEME_MODULE_NAME, 0, &instance->config.wmThemeKey, &instance->config.wmThemeFormat, FF_WMTHEME_NUM_FORMAT_ARGS, "WM Theme needs sucessfull WM detection");
|
||||
return;
|
||||
}
|
||||
|
||||
if(ffStrbufIgnCaseCompS(&instance->state.wm.prettyName, "KWin") == 0)
|
||||
if(ffStrbufIgnCaseCompS(&result->prettyName, "KWin") == 0)
|
||||
printKWin(instance);
|
||||
else
|
||||
ffPrintError(instance, FF_WMTHEME_MODULE_NAME, 0, &instance->config.wmThemeKey, &instance->config.wmThemeFormat, FF_WMTHEME_NUM_FORMAT_ARGS, "Unknown WM: %s", instance->state.wm.prettyName.chars);
|
||||
ffPrintError(instance, FF_WMTHEME_MODULE_NAME, 0, &instance->config.wmThemeKey, &instance->config.wmThemeFormat, FF_WMTHEME_NUM_FORMAT_ARGS, "Unknown WM: %s", result->prettyName.chars);
|
||||
}
|
||||
|
||||
+12
-12
@@ -252,32 +252,32 @@ void ffStrbufPutTo(const FFstrbuf* strbuf, FILE* file)
|
||||
fputc('\n', file);
|
||||
}
|
||||
|
||||
int ffStrbufComp(FFstrbuf* strbuf, const FFstrbuf* comp)
|
||||
int ffStrbufComp(const FFstrbuf* strbuf, const FFstrbuf* comp)
|
||||
{
|
||||
return ffStrbufCompNS(strbuf, comp->length, comp->chars);
|
||||
}
|
||||
|
||||
int ffStrbufCompS(FFstrbuf* strbuf, const char* comp)
|
||||
int ffStrbufCompS(const FFstrbuf* strbuf, const char* comp)
|
||||
{
|
||||
return strcmp(strbuf->chars, comp);
|
||||
}
|
||||
|
||||
int ffStrbufCompNS(FFstrbuf* strbuf, uint32_t length, const char* comp)
|
||||
int ffStrbufCompNS(const FFstrbuf* strbuf, uint32_t length, const char* comp)
|
||||
{
|
||||
return strncasecmp(strbuf->chars, comp, length);
|
||||
}
|
||||
|
||||
int ffStrbufIgnCaseComp(FFstrbuf* strbuf, const FFstrbuf* comp)
|
||||
int ffStrbufIgnCaseComp(const FFstrbuf* strbuf, const FFstrbuf* comp)
|
||||
{
|
||||
return ffStrbufIgnCaseCompNS(strbuf, comp->length, comp->chars);
|
||||
}
|
||||
|
||||
int ffStrbufIgnCaseCompS(FFstrbuf* strbuf, const char* comp)
|
||||
int ffStrbufIgnCaseCompS(const FFstrbuf* strbuf, const char* comp)
|
||||
{
|
||||
return strcasecmp(strbuf->chars, comp);
|
||||
}
|
||||
|
||||
int ffStrbufIgnCaseCompNS(FFstrbuf* strbuf, uint32_t length, const char* comp)
|
||||
int ffStrbufIgnCaseCompNS(const FFstrbuf* strbuf, uint32_t length, const char* comp)
|
||||
{
|
||||
return strncasecmp(strbuf->chars, comp, length);
|
||||
}
|
||||
@@ -413,12 +413,12 @@ void ffStrbufSubstrAfterLastC(FFstrbuf* strbuf, const char c)
|
||||
ffStrbufSubstrAfter(strbuf, index);
|
||||
}
|
||||
|
||||
bool ffStrbufStartsWith(FFstrbuf* strbuf, FFstrbuf* start)
|
||||
bool ffStrbufStartsWith(const FFstrbuf* strbuf, const FFstrbuf* start)
|
||||
{
|
||||
return ffStrbufStartsWithNS(strbuf, start->length, start->chars);
|
||||
}
|
||||
|
||||
bool ffStrbufStartsWithS(FFstrbuf* strbuf, const char* start)
|
||||
bool ffStrbufStartsWithS(const FFstrbuf* strbuf, const char* start)
|
||||
{
|
||||
for(uint32_t i = 0; start[i] != '\0'; i++)
|
||||
{
|
||||
@@ -431,7 +431,7 @@ bool ffStrbufStartsWithS(FFstrbuf* strbuf, const char* start)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ffStrbufStartsWithNS(FFstrbuf* strbuf, uint32_t length, const char* start)
|
||||
bool ffStrbufStartsWithNS(const FFstrbuf* strbuf, uint32_t length, const char* start)
|
||||
{
|
||||
for(uint32_t i = 0; i < length; i++)
|
||||
{
|
||||
@@ -444,12 +444,12 @@ bool ffStrbufStartsWithNS(FFstrbuf* strbuf, uint32_t length, const char* start)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ffStrbufStartsWithIgnCase(FFstrbuf* strbuf, FFstrbuf* start)
|
||||
bool ffStrbufStartsWithIgnCase(const FFstrbuf* strbuf, const FFstrbuf* start)
|
||||
{
|
||||
return ffStrbufStartsWithNS(strbuf, start->length, start->chars);
|
||||
}
|
||||
|
||||
bool ffStrbufStartsWithIgnCaseS(FFstrbuf* strbuf, const char* start)
|
||||
bool ffStrbufStartsWithIgnCaseS(const FFstrbuf* strbuf, const char* start)
|
||||
{
|
||||
for(uint32_t i = 0; start[i] != '\0'; i++)
|
||||
{
|
||||
@@ -462,7 +462,7 @@ bool ffStrbufStartsWithIgnCaseS(FFstrbuf* strbuf, const char* start)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ffStrbufStartsWithIgnCaseNS(FFstrbuf* strbuf, uint32_t length, const char* start)
|
||||
bool ffStrbufStartsWithIgnCaseNS(const FFstrbuf* strbuf, uint32_t length, const char* start)
|
||||
{
|
||||
for(uint32_t i = 0; i < length; i++)
|
||||
{
|
||||
|
||||
+13
-12
@@ -56,12 +56,13 @@ char ffStrbufGetC(FFstrbuf* strbuf, uint32_t index);
|
||||
void ffStrbufWriteTo(const FFstrbuf* strbuf, FILE* file);
|
||||
void ffStrbufPutTo(const FFstrbuf* strbuf, FILE* file);
|
||||
|
||||
int ffStrbufComp(FFstrbuf* strbuf, const FFstrbuf* comp);
|
||||
int ffStrbufCompS(FFstrbuf* strbuf, const char* comp);
|
||||
int ffStrbufCompNS(FFstrbuf* strbuf, uint32_t length, const char* comp);
|
||||
int ffStrbufIgnCaseComp(FFstrbuf* strbuf, const FFstrbuf* comp);
|
||||
int ffStrbufIgnCaseCompS(FFstrbuf* strbuf, const char* comp);
|
||||
int ffStrbufIgnCaseCompNS(FFstrbuf* strbuf, uint32_t length, const char* comp);
|
||||
int ffStrbufComp(const FFstrbuf* strbuf, const FFstrbuf* comp);
|
||||
int ffStrbufCompS(const FFstrbuf* strbuf, const char* comp);
|
||||
int ffStrbufCompNS(const FFstrbuf* strbuf, uint32_t length, const char* comp);
|
||||
|
||||
int ffStrbufIgnCaseComp(const FFstrbuf* strbuf, const FFstrbuf* comp);
|
||||
int ffStrbufIgnCaseCompS(const FFstrbuf* strbuf, const char* comp);
|
||||
int ffStrbufIgnCaseCompNS(const FFstrbuf* strbuf, uint32_t length, const char* comp);
|
||||
|
||||
void ffStrbufTrimLeft(FFstrbuf* strbuf, char c);
|
||||
void ffStrbufTrimRight(FFstrbuf* strbuf, char c);
|
||||
@@ -80,13 +81,13 @@ void ffStrbufSubstrBeforeFirstC(FFstrbuf* strbuf, const char c);
|
||||
void ffStrbufSubstrAfter(FFstrbuf* strbuf, uint32_t index);
|
||||
void ffStrbufSubstrAfterLastC(FFstrbuf* strbuf, const char c);
|
||||
|
||||
bool ffStrbufStartsWith(FFstrbuf* strbuf, FFstrbuf* start);
|
||||
bool ffStrbufStartsWithS(FFstrbuf* strbuf, const char* start);
|
||||
bool ffStrbufStartsWithNS(FFstrbuf* strbuf, uint32_t length, const char* start);
|
||||
bool ffStrbufStartsWith(const FFstrbuf* strbuf, const FFstrbuf* start);
|
||||
bool ffStrbufStartsWithS(const FFstrbuf* strbuf, const char* start);
|
||||
bool ffStrbufStartsWithNS(const FFstrbuf* strbuf, uint32_t length, const char* start);
|
||||
|
||||
bool ffStrbufStartsWithIgnCase(FFstrbuf* strbuf, FFstrbuf* start);
|
||||
bool ffStrbufStartsWithIgnCaseS(FFstrbuf* strbuf, const char* start);
|
||||
bool ffStrbufStartsWithIgnCaseNS(FFstrbuf* strbuf, uint32_t length, const char* start);
|
||||
bool ffStrbufStartsWithIgnCase(const FFstrbuf* strbuf, const FFstrbuf* start);
|
||||
bool ffStrbufStartsWithIgnCaseS(const FFstrbuf* strbuf, const char* start);
|
||||
bool ffStrbufStartsWithIgnCaseNS(const FFstrbuf* strbuf, uint32_t length, const char* start);
|
||||
|
||||
void ffStrbufRecalculateLength(FFstrbuf* strbuf);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user