mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2025-02-20 11:43:27 +08:00
Host: support freebsd
This commit is contained in:
parent
3ee15d0401
commit
895d151e2e
@ -331,12 +331,8 @@ endif()
|
||||
|
||||
if(LINUX OR BSD)
|
||||
list(APPEND LIBFASTFETCH_SRC
|
||||
src/detection/host/host_linux.c
|
||||
src/detection/bios/bios_linux.c
|
||||
src/detection/board/board_linux.c
|
||||
src/detection/os/os_linux.c
|
||||
src/detection/gpu/gpu_linux.c
|
||||
src/detection/battery/battery_linux.c
|
||||
src/detection/displayserver/linux/displayserver_linux.c
|
||||
src/detection/displayserver/linux/wayland.c
|
||||
src/detection/displayserver/linux/xcb.c
|
||||
@ -351,6 +347,15 @@ if(LINUX OR BSD)
|
||||
)
|
||||
endif()
|
||||
|
||||
if(LINUX)
|
||||
list(APPEND LIBFASTFETCH_SRC
|
||||
src/detection/host/host_linux.c
|
||||
src/detection/bios/bios_linux.c
|
||||
src/detection/board/board_linux.c
|
||||
src/detection/battery/battery_linux.c
|
||||
)
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
list(APPEND LIBFASTFETCH_SRC
|
||||
src/common/processing_windows.c
|
||||
@ -421,6 +426,11 @@ if(BSD)
|
||||
src/detection/cpuUsage/cpuUsage_bsd.c
|
||||
src/detection/memory/memory_bsd.c
|
||||
src/detection/swap/swap_bsd.c
|
||||
src/detection/host/host_bsd.c
|
||||
|
||||
src/detection/battery/battery_nosupport.c
|
||||
src/detection/bios/bios_nosupport.c
|
||||
src/detection/board/board_nosupport.c
|
||||
)
|
||||
endif()
|
||||
|
||||
|
@ -2,11 +2,11 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
void ffSysctlGetString(const char* propName, FFstrbuf* result)
|
||||
const char* ffSysctlGetString(const char* propName, FFstrbuf* result)
|
||||
{
|
||||
size_t neededLength;
|
||||
if(sysctlbyname(propName, NULL, &neededLength, NULL, 0) != 0 || neededLength == 1) //neededLength is 1 for empty strings, because of the null terminator
|
||||
return;
|
||||
return "sysctlbyname() failed";
|
||||
|
||||
ffStrbufEnsureFree(result, (uint32_t) neededLength - 1);
|
||||
|
||||
@ -14,6 +14,8 @@ void ffSysctlGetString(const char* propName, FFstrbuf* result)
|
||||
result->length += (uint32_t) neededLength - 1;
|
||||
|
||||
result->chars[result->length] = '\0';
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int ffSysctlGetInt(const char* propName, int defaultValue)
|
||||
|
@ -4,12 +4,14 @@
|
||||
#define FF_INCLUDED_common_sysctl
|
||||
|
||||
#include "fastfetch.h"
|
||||
#include "util/FFcheckmacros.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/sysctl.h>
|
||||
|
||||
void ffSysctlGetString(const char* propName, FFstrbuf* result);
|
||||
int ffSysctlGetInt(const char* propName, int defaultValue);
|
||||
int64_t ffSysctlGetInt64(const char* propName, int64_t defaultValue);
|
||||
void* ffSysctlGetData(int* request, u_int requestLength, size_t* resultLength);
|
||||
const char* ffSysctlGetString(const char* propName, FFstrbuf* result);
|
||||
FF_C_NODISCARD int ffSysctlGetInt(const char* propName, int defaultValue);
|
||||
FF_C_NODISCARD int64_t ffSysctlGetInt64(const char* propName, int64_t defaultValue);
|
||||
FF_C_NODISCARD void* ffSysctlGetData(int* request, u_int requestLength, size_t* resultLength);
|
||||
|
||||
#endif
|
||||
|
19
src/detection/host/host_bsd.c
Normal file
19
src/detection/host/host_bsd.c
Normal file
@ -0,0 +1,19 @@
|
||||
#include "host.h"
|
||||
#include "common/sysctl.h"
|
||||
|
||||
void ffDetectHostImpl(FFHostResult* host)
|
||||
{
|
||||
ffStrbufInit(&host->error);
|
||||
|
||||
ffStrbufInit(&host->productName);
|
||||
ffStrbufInit(&host->productFamily);
|
||||
ffStrbufInit(&host->productVersion);
|
||||
ffStrbufInit(&host->productSku);
|
||||
|
||||
ffStrbufInit(&host->sysVendor);
|
||||
ffStrbufInit(&host->chassisType);
|
||||
ffStrbufInit(&host->chassisVendor);
|
||||
ffStrbufInit(&host->chassisVersion);
|
||||
|
||||
ffStrbufAppendS(&host->error, ffSysctlGetString("hw.fdt.model", &host->productName));
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user