mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-29 16:26:39 +01:00
Fastfetch: make it compile on SunOS
This commit is contained in:
+20
-2
@@ -204,7 +204,11 @@ bool ffSuppressIO(bool suppress)
|
||||
|
||||
void listFilesRecursively(uint32_t baseLength, FFstrbuf* folder, uint8_t indentation, const char* folderName, bool pretty)
|
||||
{
|
||||
DIR* dir = opendir(folder->chars);
|
||||
FF_AUTO_CLOSE_FD int dfd = open(folder->chars, O_RDONLY);
|
||||
if (dfd < 0)
|
||||
return;
|
||||
|
||||
DIR* dir = fdopendir(dfd);
|
||||
if(dir == NULL)
|
||||
return;
|
||||
|
||||
@@ -221,7 +225,21 @@ void listFilesRecursively(uint32_t baseLength, FFstrbuf* folder, uint8_t indenta
|
||||
|
||||
while((entry = readdir(dir)) != NULL)
|
||||
{
|
||||
if(entry->d_type == DT_DIR)
|
||||
bool isDir = false;
|
||||
#ifdef _DIRENT_HAVE_D_TYPE
|
||||
if(entry->d_type != DT_UNKNOWN && entry->d_type != DT_LNK)
|
||||
isDir = entry->d_type == DT_DIR;
|
||||
else
|
||||
#else
|
||||
{
|
||||
struct stat stbuf;
|
||||
if (fstatat(dfd, entry->d_name, &stbuf, 0) < 0)
|
||||
isDir = false;
|
||||
else
|
||||
isDir = S_ISDIR(stbuf.st_mode);
|
||||
}
|
||||
#endif
|
||||
if (isDir)
|
||||
{
|
||||
if(ffStrEquals(entry->d_name, ".") || ffStrEquals(entry->d_name, ".."))
|
||||
continue;
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
#include "bios.h"
|
||||
|
||||
const char* ffDetectBios(FFBiosResult* bios)
|
||||
{
|
||||
return "Not supported on this platform";
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
#include "camera.h"
|
||||
|
||||
const char* ffDetectCamera(FF_MAYBE_UNUSED FFlist* result)
|
||||
{
|
||||
return "Not support on this platform";
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
#include "cpu.h"
|
||||
|
||||
const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu)
|
||||
{
|
||||
return "Not supported on this platform";
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
#include "cpucache.h"
|
||||
#include "common/sysctl.h"
|
||||
|
||||
const char* ffDetectCPUCache(FF_MAYBE_UNUSED FFCPUCacheResult* result)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
#include "fastfetch.h"
|
||||
#include "detection/cpuusage/cpuusage.h"
|
||||
|
||||
const char* ffGetCpuUsageInfo(FFlist* cpuTimes)
|
||||
{
|
||||
return "Not support on this platform";
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
#include "disk.h"
|
||||
|
||||
const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks)
|
||||
{
|
||||
return "Not supported on this platform";
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
#include "diskio.h"
|
||||
|
||||
const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options)
|
||||
{
|
||||
return "Not supported on this platform";
|
||||
}
|
||||
@@ -302,7 +302,7 @@ static const char* getFromProcesses(FFDisplayServerResult* result)
|
||||
if(result->dePrettyName.length > 0 && result->wmPrettyName.length > 0)
|
||||
break;
|
||||
}
|
||||
#else
|
||||
#elif !defined(__sun)
|
||||
FF_AUTO_CLOSE_DIR DIR* procdir = opendir("/proc");
|
||||
if(procdir == NULL)
|
||||
return "opendir(\"/proc\") failed";
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
#include "host.h"
|
||||
|
||||
const char* ffDetectHost(FFHostResult* host)
|
||||
{
|
||||
return "Not supported on this platform";
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
#include "libc.h"
|
||||
|
||||
const char* ffDetectLibc(FFLibcResult* result)
|
||||
{
|
||||
result->name = "Unknown";
|
||||
result->version = NULL;
|
||||
return NULL;
|
||||
}
|
||||
@@ -162,6 +162,7 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results)
|
||||
|
||||
if (ifAddrStruct) freeifaddrs(ifAddrStruct);
|
||||
|
||||
#ifdef SIOCGIFMTU
|
||||
FF_AUTO_CLOSE_FD int sockfd = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
if (sockfd > 0)
|
||||
{
|
||||
@@ -173,6 +174,7 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results)
|
||||
iface->mtu = ifr.ifr_mtu;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
#include "memory.h"
|
||||
|
||||
const char* ffDetectMemory(FFMemoryResult* ram)
|
||||
{
|
||||
return "Not supported on this platform";
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
#include "netio.h"
|
||||
|
||||
const char* ffNetIOGetIoCounters(FFlist* result, FFNetIOOptions* options)
|
||||
{
|
||||
return "Not supported on this platform";
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
#include "os.h"
|
||||
#include "common/io/io.h"
|
||||
|
||||
void ffDetectOSImpl(FFOSResult* os)
|
||||
{
|
||||
if (!ffReadFileBuffer("/etc/release", &os->prettyName))
|
||||
return;
|
||||
|
||||
ffStrbufSubstrBeforeFirstC(&os->prettyName, '\n');
|
||||
ffStrbufSubstrBeforeLastC(&os->prettyName, '(');
|
||||
ffStrbufTrim(&os->prettyName, ' ');
|
||||
|
||||
// OpenIndiana Hipster 2024.04
|
||||
uint32_t idx = ffStrbufFirstIndexC(&os->prettyName, ' ');
|
||||
ffStrbufSetNS(&os->name, idx, os->prettyName.chars);
|
||||
uint32_t idx2 = ffStrbufNextIndexC(&os->prettyName, idx + 1, ' ');
|
||||
ffStrbufSetNS(&os->codename, idx2 - idx - 1, os->prettyName.chars + idx + 1);
|
||||
ffStrbufSetNS(&os->version, idx2 - idx - 1, os->prettyName.chars + idx2 + 1);
|
||||
ffStrbufSetStatic(&os->idLike, "sunos");
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
#include "packages.h"
|
||||
|
||||
void ffDetectPackagesImpl(FFPackagesResult* result, FFPackagesOptions* options)
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
#include "physicaldisk.h"
|
||||
|
||||
const char* ffDetectPhysicalDisk(FFlist* result, FFPhysicalDiskOptions* options)
|
||||
{
|
||||
return "Not supported on this platform";
|
||||
}
|
||||
@@ -14,7 +14,11 @@ const char* ffDetectProcesses(uint32_t* result)
|
||||
struct dirent* entry;
|
||||
while ((entry = readdir(dir)) != NULL)
|
||||
{
|
||||
if (entry->d_type == DT_DIR && ffCharIsDigit(entry->d_name[0]))
|
||||
if (
|
||||
#ifdef _DIRENT_HAVE_D_TYPE
|
||||
entry->d_type == DT_DIR &&
|
||||
#endif
|
||||
ffCharIsDigit(entry->d_name[0]))
|
||||
++num;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
#include "swap.h"
|
||||
|
||||
const char* ffDetectSwap(FFSwapResult* swap)
|
||||
{
|
||||
return "Not supported on this platform";
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "terminalsize.h"
|
||||
#include "common/io/io.h"
|
||||
|
||||
#include <sys/termios.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
#include "uptime.h"
|
||||
#include "common/time.h"
|
||||
#include <utmpx.h>
|
||||
|
||||
const char* ffDetectUptime(FFUptimeResult* result)
|
||||
{
|
||||
struct utmpx* ut;
|
||||
|
||||
setutxent();
|
||||
while (NULL != (ut = getutxent()))
|
||||
{
|
||||
if (ut->ut_type == BOOT_TIME)
|
||||
{
|
||||
result->bootTime = (uint64_t) ut->ut_tv.tv_sec * 1000 + (uint64_t) ut->ut_tv.tv_usec / 10000000;
|
||||
result->uptime = ffTimeGetNow() - result->bootTime;
|
||||
break;
|
||||
}
|
||||
}
|
||||
endutxent();
|
||||
return NULL;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
#include "wifi.h"
|
||||
|
||||
const char* ffDetectWifi(FFlist* result)
|
||||
{
|
||||
return "Not support on this platform";
|
||||
}
|
||||
@@ -22,7 +22,7 @@ const char* ffOptionsParseGeneralJsonConfig(FFOptionsGeneral* options, yyjson_va
|
||||
else if (ffStrEqualsIgnCase(key, "processingTimeout"))
|
||||
options->processingTimeout = (int32_t) yyjson_get_int(val);
|
||||
|
||||
#if defined(__linux__) || defined(__FreeBSD__)
|
||||
#if defined(__linux__) || defined(__FreeBSD__) || defined(__sun)
|
||||
else if (ffStrEqualsIgnCase(key, "escapeBedrock"))
|
||||
options->escapeBedrock = yyjson_get_bool(val);
|
||||
else if (ffStrEqualsIgnCase(key, "playerName"))
|
||||
|
||||
@@ -15,7 +15,7 @@ typedef struct FFOptionsGeneral
|
||||
int32_t processingTimeout;
|
||||
|
||||
// Module options that cannot be put in module option structure
|
||||
#if defined(__linux__) || defined(__FreeBSD__)
|
||||
#if defined(__linux__) || defined(__FreeBSD__) || defined(__sun)
|
||||
FFstrbuf playerName;
|
||||
bool escapeBedrock;
|
||||
FFDsForceDrmType dsForceDrm;
|
||||
|
||||
@@ -34,6 +34,8 @@ static void getExePath(FFPlatform* platform)
|
||||
exePathLen = 0;
|
||||
else
|
||||
exePathLen--; // remove terminating NUL
|
||||
#else
|
||||
int exePathLen = 0;
|
||||
#endif
|
||||
if (exePathLen > 0)
|
||||
{
|
||||
@@ -181,7 +183,7 @@ void ffPlatformInitImpl(FFPlatform* platform)
|
||||
struct passwd* pwd = getpwuid(getuid());
|
||||
|
||||
struct utsname uts;
|
||||
if(uname(&uts) != 0)
|
||||
if(uname(&uts) < 0)
|
||||
memset(&uts, 0, sizeof(uts));
|
||||
|
||||
getExePath(platform);
|
||||
|
||||
Reference in New Issue
Block a user