From 0c81d3e894d2ab0b17d116073ca18fe85b0725ae Mon Sep 17 00:00:00 2001 From: Linus Dierheimer Date: Tue, 26 Jul 2022 18:06:30 +0200 Subject: [PATCH] Refactor: move terminal/shell detection to own header --- src/detection/displayserver.h | 2 ++ src/detection/gtk.h | 2 +- src/detection/os.h | 2 +- src/detection/qt.h | 2 +- src/detection/terminalShell.c | 1 + src/detection/terminalshell.h | 26 ++++++++++++++++++++++++++ src/detection/title.h | 2 +- src/fastfetch.h | 19 ------------------- src/logo/logo.c | 1 + src/modules/shell.c | 1 + src/modules/terminal.c | 1 + src/modules/terminalfont.c | 1 + 12 files changed, 37 insertions(+), 23 deletions(-) create mode 100644 src/detection/terminalshell.h diff --git a/src/detection/displayserver.h b/src/detection/displayserver.h index d2075e85b..beafe73b0 100644 --- a/src/detection/displayserver.h +++ b/src/detection/displayserver.h @@ -3,6 +3,8 @@ #ifndef FF_INCLUDED_detection_displayserver #define FF_INCLUDED_detection_displayserver +#include "fastfetch.h" + typedef struct FFResolutionResult { uint32_t width; diff --git a/src/detection/gtk.h b/src/detection/gtk.h index 2f8324fbe..cd726c39d 100644 --- a/src/detection/gtk.h +++ b/src/detection/gtk.h @@ -3,7 +3,7 @@ #ifndef FF_INCLUDED_detection_gtk #define FF_INCLUDED_detection_gtk -#include "util/FFstrbuf.h" +#include "fastfetch.h" typedef struct FFGTKResult { diff --git a/src/detection/os.h b/src/detection/os.h index d78695b5f..cd59e5491 100644 --- a/src/detection/os.h +++ b/src/detection/os.h @@ -3,7 +3,7 @@ #ifndef FF_INCLUDED_detection_os #define FF_INCLUDED_detection_os -#include "util/FFstrbuf.h" +#include "fastfetch.h" typedef struct FFOSResult { diff --git a/src/detection/qt.h b/src/detection/qt.h index 70390e290..49dd93120 100644 --- a/src/detection/qt.h +++ b/src/detection/qt.h @@ -3,7 +3,7 @@ #ifndef FF_INCLUDED_detection_qt #define FF_INCLUDED_detection_qt -#include "util/FFstrbuf.h" +#include "fastfetch.h" typedef struct FFQtResult { diff --git a/src/detection/terminalShell.c b/src/detection/terminalShell.c index d4e8e4945..cbd8c4b2e 100644 --- a/src/detection/terminalShell.c +++ b/src/detection/terminalShell.c @@ -1,4 +1,5 @@ #include "fastfetch.h" +#include "detection/terminalshell.h" #include "common/io.h" #include "common/parsing.h" #include "common/processing.h" diff --git a/src/detection/terminalshell.h b/src/detection/terminalshell.h new file mode 100644 index 000000000..9687eba30 --- /dev/null +++ b/src/detection/terminalshell.h @@ -0,0 +1,26 @@ +#pragma once + +#ifndef FF_INCLUDED_detection_terminalshell +#define FF_INCLUDED_detection_terminalshell + +#include "fastfetch.h" + +typedef struct FFTerminalShellResult +{ + FFstrbuf shellProcessName; + FFstrbuf shellExe; + const char* shellExeName; //pointer to a char in shellExe + FFstrbuf shellVersion; + + FFstrbuf terminalProcessName; + FFstrbuf terminalExe; + const char* terminalExeName; //pointer to a char in terminalExe + + FFstrbuf userShellExe; + const char* userShellExeName; //pointer to a char in userShellExe + FFstrbuf userShellVersion; +} FFTerminalShellResult; + +const FFTerminalShellResult* ffDetectTerminalShell(FFinstance* instance); + +#endif diff --git a/src/detection/title.h b/src/detection/title.h index ee3017855..9dc31d312 100644 --- a/src/detection/title.h +++ b/src/detection/title.h @@ -3,7 +3,7 @@ #ifndef FF_INCLUDED_detection_title #define FF_INCLUDED_detection_title -#include "util/FFstrbuf.h" +#include "fastfetch.h" typedef struct FFTitleResult { diff --git a/src/fastfetch.h b/src/fastfetch.h index 86b9ed71b..ceccfa0d5 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -173,22 +173,6 @@ typedef struct FFinstance FFstate state; } FFinstance; -typedef struct FFTerminalShellResult -{ - FFstrbuf shellProcessName; - FFstrbuf shellExe; - const char* shellExeName; //pointer to a char in shellExe - FFstrbuf shellVersion; - - FFstrbuf terminalProcessName; - FFstrbuf terminalExe; - const char* terminalExeName; //pointer to a char in terminalExe - - FFstrbuf userShellExe; - const char* userShellExeName; //pointer to a char in userShellExe - FFstrbuf userShellVersion; -} FFTerminalShellResult; - typedef struct FFGPUResult { FFstrbuf vendor; @@ -279,9 +263,6 @@ void ffLogoBuiltinListAutocompletion(); // Detection functions // ///////////////////////// -//detection/terminalShell.c -const FFTerminalShellResult* ffDetectTerminalShell(FFinstance* instance); - //detection/temps.c (currently unused) const FFTempsResult* ffDetectTemps(const FFinstance* instance); diff --git a/src/logo/logo.c b/src/logo/logo.c index 608e506da..f6fd14bf4 100644 --- a/src/logo/logo.c +++ b/src/logo/logo.c @@ -2,6 +2,7 @@ #include "common/io.h" #include "common/printing.h" #include "detection/os.h" +#include "detection/terminalshell.h" #include #include diff --git a/src/modules/shell.c b/src/modules/shell.c index f68bca4be..3ea71f05e 100644 --- a/src/modules/shell.c +++ b/src/modules/shell.c @@ -1,5 +1,6 @@ #include "fastfetch.h" #include "common/printing.h" +#include "detection/terminalshell.h" #define FF_SHELL_MODULE_NAME "Shell" #define FF_SHELL_NUM_FORMAT_ARGS 7 diff --git a/src/modules/terminal.c b/src/modules/terminal.c index e3f56b852..7942f266b 100644 --- a/src/modules/terminal.c +++ b/src/modules/terminal.c @@ -1,5 +1,6 @@ #include "fastfetch.h" #include "common/printing.h" +#include "detection/terminalshell.h" #include diff --git a/src/modules/terminalfont.c b/src/modules/terminalfont.c index 1cdac5601..e08977c36 100644 --- a/src/modules/terminalfont.c +++ b/src/modules/terminalfont.c @@ -5,6 +5,7 @@ #include "common/settings.h" #include "common/processing.h" #include "detection/displayserver.h" +#include "detection/terminalshell.h" #define FF_TERMFONT_MODULE_NAME "Terminal Font" #define FF_TERMFONT_NUM_FORMAT_ARGS 5