mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-29 16:26:39 +01:00
@@ -12,7 +12,6 @@ void ffPlatformInit(FFPlatform* platform)
|
||||
|
||||
ffStrbufInit(&platform->userName);
|
||||
ffStrbufInit(&platform->hostName);
|
||||
ffStrbufInit(&platform->domainName);
|
||||
ffStrbufInit(&platform->userShell);
|
||||
|
||||
ffStrbufInit(&platform->systemName);
|
||||
@@ -22,9 +21,6 @@ void ffPlatformInit(FFPlatform* platform)
|
||||
|
||||
ffPlatformInitImpl(platform);
|
||||
|
||||
if(platform->domainName.length == 0)
|
||||
ffStrbufAppend(&platform->domainName, &platform->hostName);
|
||||
|
||||
if(platform->systemName.length == 0)
|
||||
{
|
||||
#if defined(__linux__)
|
||||
@@ -59,7 +55,6 @@ void ffPlatformDestroy(FFPlatform* platform)
|
||||
|
||||
ffStrbufDestroy(&platform->userName);
|
||||
ffStrbufDestroy(&platform->hostName);
|
||||
ffStrbufDestroy(&platform->domainName);
|
||||
ffStrbufDestroy(&platform->userShell);
|
||||
|
||||
ffStrbufDestroy(&platform->systemArchitecture);
|
||||
|
||||
@@ -15,7 +15,6 @@ typedef struct FFPlatform {
|
||||
|
||||
FFstrbuf userName;
|
||||
FFstrbuf hostName;
|
||||
FFstrbuf domainName;
|
||||
FFstrbuf userShell;
|
||||
|
||||
FFstrbuf systemName;
|
||||
|
||||
@@ -141,38 +141,9 @@ static void getUserName(FFPlatform* platform, const struct passwd* pwd)
|
||||
|
||||
static void getHostName(FFPlatform* platform, const struct utsname* uts)
|
||||
{
|
||||
char hostname[256];
|
||||
if(gethostname(hostname, sizeof(hostname)) == 0)
|
||||
ffStrbufAppendS(&platform->hostName, hostname);
|
||||
|
||||
if(platform->hostName.length == 0)
|
||||
ffStrbufAppendS(&platform->hostName, uts->nodename);
|
||||
ffStrbufAppendS(&platform->hostName, uts->nodename);
|
||||
}
|
||||
|
||||
#ifdef __linux__
|
||||
#include <netdb.h>
|
||||
static void getDomainName(FFPlatform* platform)
|
||||
{
|
||||
struct addrinfo hints = {0};
|
||||
hints.ai_socktype = SOCK_STREAM;
|
||||
hints.ai_flags = AI_CANONNAME;
|
||||
|
||||
struct addrinfo* info = NULL;
|
||||
|
||||
if(getaddrinfo(platform->hostName.chars, "80", &hints, &info) != 0)
|
||||
return;
|
||||
|
||||
struct addrinfo* current = info;
|
||||
while(platform->domainName.length == 0 && current != NULL)
|
||||
{
|
||||
ffStrbufAppendS(&platform->domainName, current->ai_canonname);
|
||||
current = current->ai_next;
|
||||
}
|
||||
|
||||
freeaddrinfo(info);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void getUserShell(FFPlatform* platform, const struct passwd* pwd)
|
||||
{
|
||||
const char* shell = getenv("SHELL");
|
||||
@@ -198,11 +169,6 @@ void ffPlatformInitImpl(FFPlatform* platform)
|
||||
|
||||
getUserName(platform, pwd);
|
||||
getHostName(platform, &uts);
|
||||
|
||||
#ifdef __linux__
|
||||
getDomainName(platform);
|
||||
#endif
|
||||
|
||||
getUserShell(platform, pwd);
|
||||
|
||||
ffStrbufAppendS(&platform->systemName, uts.sysname);
|
||||
|
||||
@@ -130,12 +130,11 @@ static void getHostName(FFPlatform* platform)
|
||||
ffStrbufSetWS(&platform->hostName, buffer);
|
||||
}
|
||||
|
||||
static void getDomainName(FFPlatform* platform)
|
||||
static void getUserShell(FFPlatform* platform)
|
||||
{
|
||||
wchar_t buffer[128];
|
||||
DWORD len = sizeof(buffer) / sizeof(*buffer);
|
||||
if(GetComputerNameExW(ComputerNameDnsDomain, buffer, &len))
|
||||
ffStrbufSetWS(&platform->domainName, buffer);
|
||||
// Works in MSYS2
|
||||
ffStrbufAppendS(&platform->userShell, getenv("SHELL"));
|
||||
ffStrbufReplaceAllC(&platform->userShell, '\\', '/');
|
||||
}
|
||||
|
||||
static void getSystemName(FFPlatform* platform)
|
||||
@@ -233,7 +232,7 @@ void ffPlatformInitImpl(FFPlatform* platform)
|
||||
|
||||
getUserName(platform);
|
||||
getHostName(platform);
|
||||
getDomainName(platform);
|
||||
getUserShell(platform);
|
||||
|
||||
getSystemName(platform);
|
||||
getSystemReleaseAndVersion(platform);
|
||||
|
||||
Reference in New Issue
Block a user