diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7de15b0a58..7140fbd5ba 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -381,7 +381,7 @@ jobs: run: | uname -a sudo pkg update - sudo pkg install -y cmake git pkgconf binutils wayland vulkan-headers vulkan-loader libxcb libXrandr libX11 libdrm libelf glib dconf dbus sqlite3-tcl xfce4-conf egl libosmesa opencl ocl-icd v4l_compat py311-requests + sudo pkg install -y cmake git pkgconf binutils wayland vulkan-headers vulkan-loader libxcb libXrandr libX11 libdrm glib dconf dbus sqlite3-tcl xfce4-conf egl libosmesa opencl ocl-icd v4l_compat py311-requests chafa cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -DENABLE_EMBEDDED_PCIIDS=On . cmake --build . --target package --verbose -j4 ./fastfetch --list-features @@ -397,6 +397,41 @@ jobs: name: fastfetch-freebsd-amd64 path: ./fastfetch-*.* + dragonfly-amd64: + name: DragonFly-amd64 + runs-on: ubuntu-latest + permissions: + security-events: write + contents: read + steps: + - name: checkout repository + uses: actions/checkout@v4 + + - name: run VM + uses: vmactions/dragonflybsd-vm@v1 + with: + usesh: yes + prepare: | + uname -a + pkg update + pkg install -y cmake git pkgconf binutils wayland vulkan-headers vulkan-loader libxcb libXrandr libX11 libdrm glib dconf dbus sqlite3-tcl xfce4-conf egl libosmesa opencl ocl-icd v4l_compat py39-requests chafa libelf + + run: | + cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -DENABLE_EMBEDDED_PCIIDS=On . + cmake --build . --target package --verbose -j4 + ./fastfetch --list-features + time ./fastfetch -c presets/ci.jsonc --stat false + time ./fastfetch -c presets/ci.jsonc --format json + time ./flashfetch + ldd fastfetch + ctest + + - name: upload artifacts + uses: actions/upload-artifact@v4 + with: + name: fastfetch-dragonfly-amd64 + path: ./fastfetch-*.* + openbsd-amd64: name: OpenBSD-amd64 runs-on: ubuntu-latest @@ -417,8 +452,8 @@ jobs: version: '7.5' run: | uname -a - sudo pkg_add -r cmake git pkgconf wayland vulkan-headers vulkan-loader glib2 dconf dbus sqlite3 xfconf imagemagick chafa pulseaudio - cmake -DSET_TWEAK=Off -DBUILD_TESTS=On . + sudo pkg_add -r cmake git pkgconf wayland vulkan-headers vulkan-loader glib2 dconf dbus sqlite3 xfconf imagemagick chafa pulseaudio py3-requests + cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -DENABLE_EMBEDDED_PCIIDS=ON . cmake --build . --target package --verbose -j4 ./fastfetch --list-features time ./fastfetch -c presets/ci.jsonc --stat false @@ -433,6 +468,42 @@ jobs: name: fastfetch-openbsd-amd64 path: ./fastfetch-*.* + netbsd-amd64: + name: NetBSD-amd64 + runs-on: ubuntu-latest + permissions: + security-events: write + contents: read + steps: + - name: checkout repository + uses: actions/checkout@v4 + + - name: run VM + uses: cross-platform-actions/action@master + with: + operating_system: netbsd + architecture: x86-64 + cpu_count: 4 + shell: bash + version: '10.0' + run: | + uname -a + sudo pkgin -y install cmake git pkgconf wayland vulkan-headers dconf dbus sqlite3 ImageMagick pulseaudio opencl-headers ocl-icd py312-requests + cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -DENABLE_EMBEDDED_PCIIDS=ON . + cmake --build . --target package --verbose -j4 + ./fastfetch --list-features + time ./fastfetch -c presets/ci.jsonc --stat false + time ./fastfetch -c presets/ci.jsonc --format json + time ./flashfetch + ldd fastfetch + ctest + + - name: upload artifacts + uses: actions/upload-artifact@v4 + with: + name: fastfetch-netbsd-amd64 + path: ./fastfetch-*.* + windows-amd64: name: Windows-amd64 runs-on: windows-latest @@ -498,76 +569,6 @@ jobs: name: fastfetch-windows-amd64 path: ./fastfetch-windows-amd64.* - windows-i686: - name: Windows-i686 - runs-on: windows-latest - permissions: - security-events: write - contents: read - defaults: - run: - shell: msys2 {0} - steps: - - name: checkout repository - uses: actions/checkout@v4 - - - name: setup-msys2 - uses: msys2/setup-msys2@v2 - with: - msystem: MINGW32 - update: true - install: git p7zip mingw-w64-i686-cmake mingw-w64-i686-clang mingw-w64-i686-vulkan-loader mingw-w64-i686-vulkan-headers mingw-w64-i686-opencl-icd mingw-w64-i686-opencl-headers - - - name: print msys version - run: uname -a - - - name: Initialize CodeQL - uses: github/codeql-action/init@v3 - with: - languages: c, cpp - - - name: configure project - run: env PKG_CONFIG_PATH=/mingw32/lib/pkgconfig/:$PKG_CONFIG_PATH cmake -DSET_TWEAK=Off -DBUILD_TESTS=On . - - - name: build project - run: cmake --build . --verbose -j4 - - - name: perform CodeQL analysis - uses: github/codeql-action/analyze@v3 - - - name: copy necessary dlls - run: cp /mingw32/bin/{OpenCL,vulkan-1}.dll . - - - name: download amd_ags - run: curl -LO https://github.com/GPUOpen-LibrariesAndSDKs/AGS_SDK/raw/master/ags_lib/lib/amd_ags_x86.dll - - - name: run fastfetch - run: time ./fastfetch -c presets/ci.jsonc --stat false - - - name: run fastfetch --format json - run: time ./fastfetch -c presets/ci.jsonc --format json - - - name: run flashfetch - run: time ./flashfetch - - - name: print dependencies - run: ldd fastfetch - - - name: run tests - run: ctest - - - name: create zip archive - run: 7z a -tzip -mx9 -bd -y fastfetch-windows-i686.zip LICENSE *.dll fastfetch.exe flashfetch.exe presets - - - name: create 7z archive - run: 7z a -t7z -mx9 -bd -y fastfetch-windows-i686.7z LICENSE *.dll fastfetch.exe flashfetch.exe presets - - - name: upload artifacts - uses: actions/upload-artifact@v4 - with: - name: fastfetch-windows-i686 - path: ./fastfetch-windows-i686.* - release: if: github.event_name == 'push' && github.ref == 'refs/heads/master' && github.repository == 'fastfetch-cli/fastfetch' name: Release @@ -581,9 +582,10 @@ jobs: - macos-universal - freebsd-amd64 - openbsd-amd64 + - netbsd-amd64 + - dragonfly-amd64 - sunos-amd64 - windows-amd64 - - windows-i686 permissions: contents: write steps: diff --git a/.gitignore b/.gitignore index 2d69a508fc..35828e8701 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ tags fastfetch.kdev4 *.user *.user.* +*.swp diff --git a/CHANGELOG.md b/CHANGELOG.md index 556a6a8521..9a3c50f403 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,30 @@ +# 2.29.0 + +Changes: +* Due to [the upstream removal of MSYS2 CLANG32 environment](https://www.msys2.org/news/#2024-09-23-starting-to-drop-the-clang32-environment), we dropped fastfetch-windows-i686 support. v2.27.1 was the last version supporting it. + * Note: fastfetch built with MSVCRT has known bug that DateTime module doesn't work because of its bad support of [strftime](https://en.cppreference.com/w/c/chrono/strftime). Don't use it. + +Features: +* Port to NetBSD and DragonFly BSD + * Fastfetch now supports all major BSD variants +* Support DiskIO, NetIO, GPU and Users module on OpenBSD +* Report SD8E SOC name (CPU, Android) +* On Windows, try loading dlls from current exe path (Windows) + * Fix Media module when installed with winget + +Bugfixes: +* Fix the VIM version detection on Ubuntu (Editor, Linux) +* Improve performance of OS version detection on Proxmox (#1370, OS, Linux) + +Logo: +* Update OpenSuse Tumbleweed +* Add XCP-ng +* Add SummitOS +* Add Lilidog +* Update PikaOS +* Update OpenSUSE Leap +* Update aperture + # 2.28.0 Features: diff --git a/CMakeLists.txt b/CMakeLists.txt index 3a63bb64de..cc33bf5bec 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.12.0) # target_link_libraries with OBJECT libs & project homepage url project(fastfetch - VERSION 2.28.0 + VERSION 2.29.0 LANGUAGES C DESCRIPTION "Fast neofetch-like system information tool" HOMEPAGE_URL "https://github.com/fastfetch-cli/fastfetch" @@ -20,6 +20,11 @@ elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "FreeBSD") set(FreeBSD TRUE CACHE BOOL "..." FORCE) elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "OpenBSD") set(OpenBSD TRUE CACHE BOOL "..." FORCE) +elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "NetBSD") + set(NetBSD TRUE CACHE BOOL "..." FORCE) +elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "DragonFly") + set(FreeBSD TRUE CACHE BOOL "..." FORCE) + set(DragonFly TRUE CACHE BOOL "..." FORCE) elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "SunOS") set(SunOS TRUE CACHE BOOL "..." FORCE) elseif(NOT APPLE AND NOT WIN32) @@ -46,35 +51,36 @@ include(CheckIncludeFile) include(CMakeDependentOption) -cmake_dependent_option(ENABLE_VULKAN "Enable vulkan" ON "LINUX OR APPLE OR FreeBSD OR OpenBSD OR WIN32 OR ANDROID OR SunOS" OFF) -cmake_dependent_option(ENABLE_WAYLAND "Enable wayland-client" ON "LINUX OR FreeBSD OR OpenBSD" OFF) -cmake_dependent_option(ENABLE_XCB_RANDR "Enable xcb-randr" ON "LINUX OR FreeBSD OR OpenBSD OR SunOS" OFF) -cmake_dependent_option(ENABLE_XCB "Enable xcb" ON "LINUX OR FreeBSD OR OpenBSD OR SunOS" OFF) -cmake_dependent_option(ENABLE_XRANDR "Enable xrandr" ON "LINUX OR FreeBSD OR OpenBSD OR SunOS" OFF) -cmake_dependent_option(ENABLE_X11 "Enable x11" ON "LINUX OR FreeBSD OR OpenBSD OR SunOS" OFF) -cmake_dependent_option(ENABLE_DRM "Enable libdrm" ON "LINUX OR FreeBSD OR OpenBSD OR SunOS" OFF) +cmake_dependent_option(ENABLE_VULKAN "Enable vulkan" ON "LINUX OR APPLE OR FreeBSD OR OpenBSD OR NetBSD OR WIN32 OR ANDROID OR SunOS" OFF) +cmake_dependent_option(ENABLE_WAYLAND "Enable wayland-client" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD" OFF) +cmake_dependent_option(ENABLE_XCB_RANDR "Enable xcb-randr" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR SunOS" OFF) +cmake_dependent_option(ENABLE_XCB "Enable xcb" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR SunOS" OFF) +cmake_dependent_option(ENABLE_XRANDR "Enable xrandr" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR SunOS" OFF) +cmake_dependent_option(ENABLE_X11 "Enable x11" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR SunOS" OFF) +cmake_dependent_option(ENABLE_DRM "Enable libdrm" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR SunOS" OFF) cmake_dependent_option(ENABLE_DRM_AMDGPU "Enable libdrm_amdgpu" ON "LINUX" OFF) -cmake_dependent_option(ENABLE_GIO "Enable gio-2.0" ON "LINUX OR FreeBSD OR OpenBSD OR SunOS" OFF) -cmake_dependent_option(ENABLE_DCONF "Enable dconf" ON "LINUX OR FreeBSD OR OpenBSD OR SunOS" OFF) -cmake_dependent_option(ENABLE_DBUS "Enable dbus-1" ON "LINUX OR FreeBSD OR OpenBSD OR SunOS" OFF) -cmake_dependent_option(ENABLE_XFCONF "Enable libxfconf-0" ON "LINUX OR FreeBSD OR OpenBSD OR SunOS" OFF) -cmake_dependent_option(ENABLE_SQLITE3 "Enable sqlite3" ON "LINUX OR FreeBSD OR APPLE OR OpenBSD OR SunOS" OFF) +cmake_dependent_option(ENABLE_GIO "Enable gio-2.0" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR SunOS" OFF) +cmake_dependent_option(ENABLE_DCONF "Enable dconf" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR SunOS" OFF) +cmake_dependent_option(ENABLE_DBUS "Enable dbus-1" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR SunOS" OFF) +cmake_dependent_option(ENABLE_XFCONF "Enable libxfconf-0" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR SunOS" OFF) +cmake_dependent_option(ENABLE_SQLITE3 "Enable sqlite3" ON "LINUX OR FreeBSD OR APPLE OR OpenBSD OR NetBSD OR SunOS" OFF) cmake_dependent_option(ENABLE_RPM "Enable rpm" ON "LINUX" OFF) -cmake_dependent_option(ENABLE_IMAGEMAGICK7 "Enable imagemagick 7" ON "LINUX OR FreeBSD OR OpenBSD OR APPLE OR WIN32 OR SunOS" OFF) -cmake_dependent_option(ENABLE_IMAGEMAGICK6 "Enable imagemagick 6" ON "LINUX OR FreeBSD OR OpenBSD OR APPLE OR SunOS" OFF) +cmake_dependent_option(ENABLE_IMAGEMAGICK7 "Enable imagemagick 7" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR APPLE OR WIN32 OR SunOS" OFF) +cmake_dependent_option(ENABLE_IMAGEMAGICK6 "Enable imagemagick 6" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR APPLE OR SunOS" OFF) cmake_dependent_option(ENABLE_CHAFA "Enable chafa" ON "ENABLE_IMAGEMAGICK6 OR ENABLE_IMAGEMAGICK7" OFF) cmake_dependent_option(ENABLE_ZLIB "Enable zlib" ON "ENABLE_IMAGEMAGICK6 OR ENABLE_IMAGEMAGICK7" OFF) -cmake_dependent_option(ENABLE_EGL "Enable egl" ON "LINUX OR FreeBSD OR OpenBSD OR WIN32 OR SunOS" OFF) -cmake_dependent_option(ENABLE_GLX "Enable glx" ON "LINUX OR FreeBSD OR OpenBSD OR SunOS" OFF) -cmake_dependent_option(ENABLE_OSMESA "Enable osmesa" ON "LINUX OR FreeBSD OR OpenBSD OR SunOS" OFF) -cmake_dependent_option(ENABLE_OPENCL "Enable opencl" ON "LINUX OR FreeBSD OR OpenBSD OR WIN32 OR ANDROID OR SunOS" OFF) +cmake_dependent_option(ENABLE_EGL "Enable egl" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR WIN32 OR SunOS" OFF) +cmake_dependent_option(ENABLE_GLX "Enable glx" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR SunOS" OFF) +cmake_dependent_option(ENABLE_OSMESA "Enable osmesa" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR SunOS" OFF) +cmake_dependent_option(ENABLE_OPENCL "Enable opencl" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR WIN32 OR ANDROID OR SunOS" OFF) cmake_dependent_option(ENABLE_FREETYPE "Enable freetype" ON "ANDROID" OFF) -cmake_dependent_option(ENABLE_PULSE "Enable pulse" ON "LINUX OR OpenBSD OR SunOS" OFF) +cmake_dependent_option(ENABLE_PULSE "Enable pulse" ON "LINUX OR OpenBSD OR NetBSD OR SunOS" OFF) cmake_dependent_option(ENABLE_DDCUTIL "Enable ddcutil" ON "LINUX" OFF) cmake_dependent_option(ENABLE_DIRECTX_HEADERS "Enable DirectX headers for WSL" ON "LINUX" OFF) -cmake_dependent_option(ENABLE_ELF "Enable libelf" ON "LINUX OR ANDROID" OFF) +cmake_dependent_option(ENABLE_ELF "Enable libelf" ON "LINUX OR ANDROID OR DragonFly" OFF) cmake_dependent_option(ENABLE_THREADS "Enable multithreading" ON "Threads_FOUND" OFF) cmake_dependent_option(ENABLE_LIBZFS "Enable libzfs" ON "LINUX OR FreeBSD OR SunOS" OFF) +cmake_dependent_option(ENABLE_PCIACCESS "Enable libpciaccess" ON "NetBSD OR OpenBSD OR SunOS" OFF) option(ENABLE_SYSTEM_YYJSON "Use system provided (instead of fastfetch embedded) yyjson library" OFF) option(ENABLE_ASAN "Build fastfetch with ASAN (address sanitizer)" OFF) @@ -663,6 +669,88 @@ elseif(FreeBSD) src/util/platform/FFPlatform_unix.c src/util/binary_linux.c ) +elseif(NetBSD) + list(APPEND LIBFASTFETCH_SRC + src/common/dbus.c + src/common/io/io_unix.c + src/common/netif/netif_bsd.c + src/common/networking_linux.c + src/common/processing_linux.c + src/common/sysctl.c + src/detection/battery/battery_nosupport.c + src/detection/bios/bios_nbsd.c + src/detection/bluetooth/bluetooth_linux.c + src/detection/bluetoothradio/bluetoothradio_linux.c + src/detection/board/board_nbsd.c + src/detection/bootmgr/bootmgr_nosupport.c + src/detection/brightness/brightness_nosupport.c + src/detection/btrfs/btrfs_nosupport.c + src/detection/chassis/chassis_nbsd.c + src/detection/cpu/cpu_nbsd.c + src/detection/cpucache/cpucache_nosupport.c + src/detection/cpuusage/cpuusage_bsd.c + src/detection/cursor/cursor_linux.c + src/detection/disk/disk_bsd.c + src/detection/dns/dns_linux.c + src/detection/physicaldisk/physicaldisk_nosupport.c + src/detection/physicalmemory/physicalmemory_nosupport.c + src/detection/diskio/diskio_nbsd.c + src/detection/displayserver/linux/displayserver_linux.c + src/detection/displayserver/linux/drm.c + src/detection/displayserver/linux/wayland/wayland.c + src/detection/displayserver/linux/wayland/global-output.c + src/detection/displayserver/linux/wayland/zwlr-output.c + src/detection/displayserver/linux/wayland/kde-output.c + src/detection/displayserver/linux/wayland/wlr-output-management-unstable-v1-protocol.c + src/detection/displayserver/linux/wayland/kde-output-device-v2-protocol.c + src/detection/displayserver/linux/wayland/kde-output-order-v1-protocol.c + src/detection/displayserver/linux/wayland/xdg-output-unstable-v1-protocol.c + src/detection/displayserver/linux/wmde.c + src/detection/displayserver/linux/xcb.c + src/detection/displayserver/linux/xlib.c + src/detection/font/font_linux.c + src/detection/gpu/gpu_general.c + src/detection/gpu/gpu_pci.c + src/detection/gtk_qt/gtk.c + src/detection/host/host_nbsd.c + src/detection/lm/lm_linux.c + src/detection/icons/icons_linux.c + src/detection/initsystem/initsystem_linux.c + src/detection/keyboard/keyboard_nosupport.c + src/detection/libc/libc_nosupport.c + src/detection/loadavg/loadavg_bsd.c + src/detection/locale/locale_linux.c + src/detection/localip/localip_linux.c + src/detection/gamepad/gamepad_nosupport.c + src/detection/media/media_linux.c + src/detection/memory/memory_obsd.c + src/detection/mouse/mouse_nosupport.c + src/detection/netio/netio_bsd.c + src/detection/opengl/opengl_linux.c + src/detection/os/os_nbsd.c + src/detection/packages/packages_obsd.c + src/detection/poweradapter/poweradapter_nosupport.c + src/detection/processes/processes_nbsd.c + src/detection/gtk_qt/qt.c + src/detection/sound/sound_linux.c + src/detection/swap/swap_obsd.c + src/detection/terminalfont/terminalfont_linux.c + src/detection/terminalshell/terminalshell_linux.c + src/detection/terminalsize/terminalsize_linux.c + src/detection/theme/theme_linux.c + src/detection/tpm/tpm_nosupport.c + src/detection/uptime/uptime_bsd.c + src/detection/users/users_linux.c + src/detection/wallpaper/wallpaper_linux.c + src/detection/wifi/wifi_nosupport.c + src/detection/wm/wm_nosupport.c + src/detection/de/de_linux.c + src/detection/wmtheme/wmtheme_linux.c + src/detection/camera/camera_linux.c + src/detection/zpool/zpool_linux.c + src/util/platform/FFPlatform_unix.c + src/util/binary_linux.c + ) elseif(OpenBSD) list(APPEND LIBFASTFETCH_SRC src/common/dbus.c @@ -673,8 +761,8 @@ elseif(OpenBSD) src/common/sysctl.c src/detection/battery/battery_nosupport.c src/detection/bios/bios_nosupport.c - src/detection/bluetooth/bluetooth_nosupport.c - src/detection/bluetoothradio/bluetoothradio_nosupport.c + src/detection/bluetooth/bluetooth_linux.c + src/detection/bluetoothradio/bluetoothradio_linux.c src/detection/board/board_nosupport.c src/detection/bootmgr/bootmgr_nosupport.c src/detection/brightness/brightness_nosupport.c @@ -688,7 +776,7 @@ elseif(OpenBSD) src/detection/dns/dns_linux.c src/detection/physicaldisk/physicaldisk_nosupport.c src/detection/physicalmemory/physicalmemory_nosupport.c - src/detection/diskio/diskio_nosupport.c + src/detection/diskio/diskio_obsd.c src/detection/displayserver/linux/displayserver_linux.c src/detection/displayserver/linux/drm.c src/detection/displayserver/linux/wayland/wayland.c @@ -703,7 +791,8 @@ elseif(OpenBSD) src/detection/displayserver/linux/xcb.c src/detection/displayserver/linux/xlib.c src/detection/font/font_linux.c - src/detection/gpu/gpu_nosupport.c + src/detection/gpu/gpu_pci.c + src/detection/gpu/gpu_general.c src/detection/gtk_qt/gtk.c src/detection/host/host_obsd.c src/detection/lm/lm_nosupport.c @@ -718,7 +807,7 @@ elseif(OpenBSD) src/detection/media/media_linux.c src/detection/memory/memory_obsd.c src/detection/mouse/mouse_nosupport.c - src/detection/netio/netio_nosupport.c + src/detection/netio/netio_bsd.c src/detection/opengl/opengl_linux.c src/detection/os/os_obsd.c src/detection/packages/packages_obsd.c @@ -733,13 +822,13 @@ elseif(OpenBSD) src/detection/theme/theme_linux.c src/detection/tpm/tpm_nosupport.c src/detection/uptime/uptime_bsd.c - src/detection/users/users_nosupport.c + src/detection/users/users_obsd.c src/detection/wallpaper/wallpaper_linux.c src/detection/wifi/wifi_nosupport.c src/detection/wm/wm_nosupport.c src/detection/de/de_linux.c src/detection/wmtheme/wmtheme_linux.c - src/detection/camera/camera_nosupport.c + src/detection/camera/camera_linux.c src/detection/zpool/zpool_nosupport.c src/util/platform/FFPlatform_unix.c src/util/binary_linux.c @@ -1035,25 +1124,39 @@ if(APPLE AND EXISTS "/usr/bin/otool") endif() endif() if(FreeBSD AND EXISTS "/usr/local/bin/objdump") - execute_process(COMMAND /bin/sh -c "/usr/local/bin/objdump -T /lib/libc.so.* | grep 'FBSD_[^ )]*' -o | sort -Vru | head -1" + execute_process(COMMAND /bin/sh -c "/usr/local/bin/objdump -T /lib/libc.so.* | grep 'FBSD_[0-9][0-9]*\\.[0-9][0-9]*' -o | sort -Vru | head -1" OUTPUT_VARIABLE OBJDUMP_T_RESULT) if("${OBJDUMP_T_RESULT}" MATCHES "FBSD_([0-9]+\\.[0-9]+)") target_compile_definitions(libfastfetch PUBLIC FF_FBSD_VERSION="${CMAKE_MATCH_1}") endif() endif() +if(DragonFly AND EXISTS "/usr/local/bin/objdump") + execute_process(COMMAND /bin/sh -c "/usr/local/bin/objdump -T /lib/libc.so.* | grep 'DF[0-9][0-9]*\\.[0-9][0-9]*' -o | sort -Vru | head -1" + OUTPUT_VARIABLE OBJDUMP_T_RESULT) + if("${OBJDUMP_T_RESULT}" MATCHES "DF([0-9]+\\.[0-9]+)") + target_compile_definitions(libfastfetch PUBLIC FF_DF_VERSION="${CMAKE_MATCH_1}") + endif() +endif() if(LINUX) - target_compile_definitions(libfastfetch PUBLIC _GNU_SOURCE _XOPEN_SOURCE _ATFILE_SOURCE __STDC_WANT_LIB_EXT1__ _FILE_OFFSET_BITS=64) # "$<$:_FORTIFY_SOURCE=3>" + target_compile_definitions(libfastfetch PUBLIC _GNU_SOURCE _XOPEN_SOURCE _ATFILE_SOURCE __STDC_WANT_LIB_EXT1__ _FILE_OFFSET_BITS=64 _TIME_BITS=64) # "$<$:_FORTIFY_SOURCE=3>" elseif(ANDROID) target_compile_definitions(libfastfetch PUBLIC _GNU_SOURCE _XOPEN_SOURCE _FILE_OFFSET_BITS=64 "$<$:__BIONIC_FORTIFY>" "$<$:__BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED>") elseif(WIN32) - target_compile_definitions(libfastfetch PUBLIC _GNU_SOURCE WIN32_LEAN_AND_MEAN=1 _WIN32_WINNT=0x0A00) # "$<$:_FORTIFY_SOURCE=3>" + target_compile_definitions(libfastfetch PUBLIC _GNU_SOURCE WIN32_LEAN_AND_MEAN=1 _WIN32_WINNT=0x0A00 NOMINMAX) # "$<$:_FORTIFY_SOURCE=3>" elseif(APPLE) target_compile_definitions(libfastfetch PUBLIC _GNU_SOURCE _XOPEN_SOURCE __STDC_WANT_LIB_EXT1__ _FILE_OFFSET_BITS=64 _DARWIN_C_SOURCE) elseif(OpenBSD) target_compile_definitions(libfastfetch PUBLIC _XOPEN_SOURCE=700 _FILE_OFFSET_BITS=64 _BSD_SOURCE) + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-rpath,/usr/X11R6/lib") # detect x11 lib path automatically +elseif(DragonFly) + target_compile_definitions(libfastfetch PUBLIC __FreeBSD__) elseif(SunOS) target_compile_definitions(libfastfetch PUBLIC _GNU_SOURCE _XOPEN_SOURCE __STDC_WANT_LIB_EXT1__ _FILE_OFFSET_BITS=64 __EXTENSIONS__ _POSIX_C_SOURCE) +elseif(NetBSD) + target_compile_definitions(libfastfetch PUBLIC _GNU_SOURCE) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-char-subscripts") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-rpath,/usr/X11R7/lib -Wl,-rpath,/usr/pkg/lib") # ditto endif() if(HAVE_STATX) @@ -1199,7 +1302,7 @@ ff_lib_enable(EGL "egl" "EGL" ) -if(NOT OpenBSD) +if(NOT OpenBSD AND NOT NetBSD) ff_lib_enable(GLX "glx" "GLX" @@ -1238,6 +1341,10 @@ ff_lib_enable(DIRECTX_HEADERS "DirectX-Headers" "DirectX-Headers" ) +ff_lib_enable(PCIACCESS + "pciaccess" + "pciaccess" +) # The system is only usable on SunOS. We provide our local copy of it so it's always available. if(ENABLE_LIBZFS) if(BINARY_LINK_TYPE STREQUAL "dlopen") @@ -1323,13 +1430,25 @@ elseif(FreeBSD) target_link_libraries(libfastfetch PRIVATE "m" PRIVATE "usbhid" - PRIVATE "geom" ) + if(NOT DragonFly) + target_link_libraries(libfastfetch + PRIVATE "geom" + ) + else() + target_link_libraries(libfastfetch + PRIVATE "devstat" + ) + endif() elseif(OpenBSD) target_link_libraries(libfastfetch PRIVATE "m" PRIVATE "kvm" ) +elseif(NetBSD) + target_link_libraries(libfastfetch + PRIVATE "m" + ) elseif(SunOS) target_link_libraries(libfastfetch PRIVATE "m" @@ -1382,9 +1501,9 @@ if(WIN32) set(CMAKE_CXX_STANDARD 17) endif() if(FreeBSD) - set(CMAKE_REQUIRED_INCLUDES "/usr/local/include" "/usr/include") + set(CMAKE_REQUIRED_INCLUDES "/usr/local/include" "/usr/include") endif() -if(LINUX OR FreeBSD) +if(LINUX OR FreeBSD OR OpenBSD OR NetBSD) CHECK_INCLUDE_FILE("linux/videodev2.h" HAVE_LINUX_VIDEODEV2) if(HAVE_LINUX_VIDEODEV2) target_compile_definitions(libfastfetch PRIVATE FF_HAVE_LINUX_VIDEODEV2=1) diff --git a/debian/changelog b/debian/changelog index 42685d71b8..d7fed41259 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +fastfetch (2.28.0) jammy; urgency=medium + + * Update to 2.28.0 + + -- Carter Li Wed, 23 Oct 2024 10:18:59 +0800 + fastfetch (2.27.1) jammy; urgency=medium * Update to 2.27.1 diff --git a/debian/files b/debian/files index a5daf6ddf5..386b6ac11e 100644 --- a/debian/files +++ b/debian/files @@ -1 +1 @@ -fastfetch_2.27.1_source.buildinfo universe/utils optional +fastfetch_2.28.0_source.buildinfo universe/utils optional diff --git a/src/common/font.c b/src/common/font.c index 80a67144ca..13264f5771 100644 --- a/src/common/font.c +++ b/src/common/font.c @@ -51,7 +51,7 @@ static void fontInitPretty(FFfont* font) for(uint32_t i = 0; i < font->styles.length; i++) { - ffStrbufAppend(&font->pretty, ffListGet(&font->styles, i)); + ffStrbufAppend(&font->pretty, FF_LIST_GET(FFstrbuf, font->styles, i)); if(i < font->styles.length - 1) ffStrbufAppendS(&font->pretty, ", "); @@ -86,7 +86,7 @@ void ffFontInitQt(FFfont* font, const char* data) { do { - FFstrbuf* style = ffListAdd(&font->styles); + FFstrbuf* style = (FFstrbuf*) ffListAdd(&font->styles); ffStrbufInit(style); data = ffStrbufAppendSUntilC(style, data, ' '); if (data) data++; @@ -142,7 +142,7 @@ static void fontPangoParseWord(const char** data, FFfont* font, FFstrbuf* altern ) { if(alternativeBuffer == NULL) { - alternativeBuffer = ffListAdd(&font->styles); + alternativeBuffer = (FFstrbuf*) ffListAdd(&font->styles); ffStrbufInit(alternativeBuffer); } @@ -215,7 +215,7 @@ void ffFontDestroy(FFfont* font) ffStrbufDestroy(&font->name); ffStrbufDestroy(&font->size); - for(uint32_t i = 0; i < font->styles.length; i++) - ffStrbufDestroy(ffListGet(&font->styles, i)); + FF_LIST_FOR_EACH(FFstrbuf, str, font->styles) + ffStrbufDestroy(str); ffListDestroy(&font->styles); } diff --git a/src/common/format.c b/src/common/format.c index 1e8c927020..19564a3fb6 100644 --- a/src/common/format.c +++ b/src/common/format.c @@ -42,10 +42,10 @@ void ffFormatAppendFormatArg(FFstrbuf* buffer, const FFformatarg* formatarg) break; case FF_FORMAT_ARG_TYPE_LIST: { - const FFlist* list = formatarg->value; + const FFlist* list = (const FFlist*) formatarg->value; for(uint32_t i = 0; i < list->length; i++) { - ffStrbufAppend(buffer, ffListGet(list, i)); + ffStrbufAppend(buffer, FF_LIST_GET(FFstrbuf, *list, i)); if(i < list->length - 1) ffStrbufAppendS(buffer, ", "); } @@ -110,7 +110,7 @@ static inline bool formatArgSet(const FFformatarg* arg) (arg->type == FF_FORMAT_ARG_TYPE_DOUBLE && *(double*)arg->value > 0.0) || //Also is false for NaN (arg->type == FF_FORMAT_ARG_TYPE_INT && *(int*)arg->value > 0) || (arg->type == FF_FORMAT_ARG_TYPE_STRBUF && ((FFstrbuf*)arg->value)->length > 0) || - (arg->type == FF_FORMAT_ARG_TYPE_STRING && ffStrSet(arg->value)) || + (arg->type == FF_FORMAT_ARG_TYPE_STRING && ffStrSet((char*)arg->value)) || (arg->type == FF_FORMAT_ARG_TYPE_UINT8 && *(uint8_t*)arg->value > 0) || (arg->type == FF_FORMAT_ARG_TYPE_UINT16 && *(uint16_t*)arg->value > 0) || (arg->type == FF_FORMAT_ARG_TYPE_UINT && *(uint32_t*)arg->value > 0) || diff --git a/src/common/init.c b/src/common/init.c index 643f94a944..8f8dfea246 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -245,7 +245,7 @@ void ffListFeatures(void) #if FF_HAVE_DDCUTIL "libddcutil\n" #endif - #if FF_HAVE_ELF || __sun || __FreeBSD__ || __OpenBSD__ + #if FF_HAVE_ELF || __sun || (__FreeBSD__ && !__DragonFly__) || __OpenBSD__ || __NetBSD__ "libelf\n" #endif #if FF_HAVE_LIBZFS diff --git a/src/common/library.c b/src/common/library.c index 7bb30c14bf..27bac3b820 100644 --- a/src/common/library.c +++ b/src/common/library.c @@ -29,6 +29,17 @@ static void* libraryLoad(const char* path, int maxVersion) // libX.dll.1 never exists on Windows, while libX-1.dll may exist FF_UNUSED(maxVersion) + if(result != NULL) + return result; + + uint32_t pathLen = ffStrbufLastIndexC(&instance.state.platform.exePath, '/'); + if (pathLen == instance.state.platform.exePath.length) + return result; + + char absPath[MAX_PATH + 1]; + strcpy(mempcpy(absPath, instance.state.platform.exePath.chars, pathLen + 1), path); + return dlopen(absPath, FF_DLOPEN_FLAGS); + #else if(result != NULL || maxVersion < 0) diff --git a/src/common/library.h b/src/common/library.h index 1f9154bd21..849b89ee37 100644 --- a/src/common/library.h +++ b/src/common/library.h @@ -43,11 +43,6 @@ static inline void ffLibraryUnload(void** handle) if(symbolMapping == NULL) \ return returnValue; -#define FF_LIBRARY_LOAD_SYMBOL_ADDRESS2(library, symbolMapping, symbolName, alternateName, returnValue) \ - symbolMapping = dlsym(library, #symbolName); \ - if(symbolMapping == NULL && !(symbolMapping = (__typeof__(&symbolName)) dlsym(library, #alternateName))) \ - return returnValue; - #define FF_LIBRARY_LOAD_SYMBOL(library, symbolName, returnValue) \ __typeof__(&symbolName) FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, ff ## symbolName, symbolName, returnValue); @@ -57,18 +52,12 @@ static inline void ffLibraryUnload(void** handle) #define FF_LIBRARY_LOAD_SYMBOL_MESSAGE(library, symbolName) \ __typeof__(&symbolName) FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, ff ## symbolName, symbolName, "dlsym " #symbolName " failed"); -#define FF_LIBRARY_LOAD_SYMBOL_MESSAGE2(library, symbolName, alternateName) \ - __typeof__(&symbolName) FF_LIBRARY_LOAD_SYMBOL_ADDRESS2(library, ff ## symbolName, symbolName, alternateName, "dlsym " #symbolName " failed"); - #define FF_LIBRARY_LOAD_SYMBOL_VAR(library, varName, symbolName, returnValue) \ FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, (varName).ff ## symbolName, symbolName, returnValue); #define FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(library, varName, symbolName) \ FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, (varName).ff ## symbolName, symbolName, "dlsym " #symbolName " failed"); -#define FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE2(library, varName, symbolName, alternateName) \ - FF_LIBRARY_LOAD_SYMBOL_ADDRESS2(library, (varName).ff ## symbolName, symbolName, alternateName, "dlsym " #symbolName " failed"); - #define FF_LIBRARY_LOAD_SYMBOL_PTR(library, varName, symbolName, returnValue) \ FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, (varName)->ff ## symbolName, symbolName, returnValue); @@ -87,9 +76,6 @@ void* ffLibraryLoad(const char* path, int maxVersion, ...); #define FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, symbolMapping, symbolName, returnValue) \ symbolMapping = (__typeof__(&symbolName)) &symbolName -#define FF_LIBRARY_LOAD_SYMBOL_ADDRESS2(library, symbolMapping, symbolName, alternateName, returnValue) \ - symbolMapping = (__typeof__(&symbolName)) &symbolName - #define FF_LIBRARY_LOAD_SYMBOL(library, symbolName, returnValue) \ FF_MAYBE_UNUSED __typeof__(&symbolName) FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, ff ## symbolName, symbolName, returnValue); @@ -99,18 +85,12 @@ void* ffLibraryLoad(const char* path, int maxVersion, ...); #define FF_LIBRARY_LOAD_SYMBOL_MESSAGE(library, symbolName) \ FF_MAYBE_UNUSED __typeof__(&symbolName) FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, ff ## symbolName, symbolName, "dlsym " #symbolName " failed"); -#define FF_LIBRARY_LOAD_SYMBOL_MESSAGE2(library, symbolName, alternateName) \ - FF_MAYBE_UNUSED __typeof__(&symbolName) FF_LIBRARY_LOAD_SYMBOL_ADDRESS2(library, ff ## symbolName, symbolName, alternateName, "dlsym " #symbolName " failed"); - #define FF_LIBRARY_LOAD_SYMBOL_VAR(library, varName, symbolName, returnValue) \ FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, (varName).ff ## symbolName, symbolName, returnValue); #define FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(library, varName, symbolName) \ FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, (varName).ff ## symbolName, symbolName, "dlsym " #symbolName " failed"); -#define FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE2(library, varName, symbolName, alternateName) \ - FF_LIBRARY_LOAD_SYMBOL_ADDRESS2(library, (varName).ff ## symbolName, symbolName, alternateName, "dlsym " #symbolName " failed"); - #define FF_LIBRARY_LOAD_SYMBOL_PTR(library, varName, symbolName, returnValue) \ FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, (varName)->ff ## symbolName, symbolName, returnValue); diff --git a/src/common/modules.c b/src/common/modules.c index ce649cfc93..724c1aa493 100644 --- a/src/common/modules.c +++ b/src/common/modules.c @@ -5,65 +5,65 @@ static FFModuleBaseInfo* A[] = { }; static FFModuleBaseInfo* B[] = { - (void*) &instance.config.modules.battery, - (void*) &instance.config.modules.bios, - (void*) &instance.config.modules.bluetooth, - (void*) &instance.config.modules.bluetoothRadio, - (void*) &instance.config.modules.board, - (void*) &instance.config.modules.bootmgr, - (void*) &instance.config.modules.break_, - (void*) &instance.config.modules.brightness, - (void*) &instance.config.modules.btrfs, + (FFModuleBaseInfo*) &instance.config.modules.battery, + (FFModuleBaseInfo*) &instance.config.modules.bios, + (FFModuleBaseInfo*) &instance.config.modules.bluetooth, + (FFModuleBaseInfo*) &instance.config.modules.bluetoothRadio, + (FFModuleBaseInfo*) &instance.config.modules.board, + (FFModuleBaseInfo*) &instance.config.modules.bootmgr, + (FFModuleBaseInfo*) &instance.config.modules.break_, + (FFModuleBaseInfo*) &instance.config.modules.brightness, + (FFModuleBaseInfo*) &instance.config.modules.btrfs, NULL, }; static FFModuleBaseInfo* C[] = { - (void*) &instance.config.modules.camera, - (void*) &instance.config.modules.chassis, - (void*) &instance.config.modules.command, - (void*) &instance.config.modules.colors, - (void*) &instance.config.modules.cpu, - (void*) &instance.config.modules.cpuCache, - (void*) &instance.config.modules.cpuUsage, - (void*) &instance.config.modules.cursor, - (void*) &instance.config.modules.custom, + (FFModuleBaseInfo*) &instance.config.modules.camera, + (FFModuleBaseInfo*) &instance.config.modules.chassis, + (FFModuleBaseInfo*) &instance.config.modules.command, + (FFModuleBaseInfo*) &instance.config.modules.colors, + (FFModuleBaseInfo*) &instance.config.modules.cpu, + (FFModuleBaseInfo*) &instance.config.modules.cpuCache, + (FFModuleBaseInfo*) &instance.config.modules.cpuUsage, + (FFModuleBaseInfo*) &instance.config.modules.cursor, + (FFModuleBaseInfo*) &instance.config.modules.custom, NULL, }; static FFModuleBaseInfo* D[] = { - (void*) &instance.config.modules.dateTime, - (void*) &instance.config.modules.de, - (void*) &instance.config.modules.display, - (void*) &instance.config.modules.disk, - (void*) &instance.config.modules.diskIo, - (void*) &instance.config.modules.dns, + (FFModuleBaseInfo*) &instance.config.modules.dateTime, + (FFModuleBaseInfo*) &instance.config.modules.de, + (FFModuleBaseInfo*) &instance.config.modules.display, + (FFModuleBaseInfo*) &instance.config.modules.disk, + (FFModuleBaseInfo*) &instance.config.modules.diskIo, + (FFModuleBaseInfo*) &instance.config.modules.dns, NULL, }; static FFModuleBaseInfo* E[] = { - (void*) &instance.config.modules.editor, + (FFModuleBaseInfo*) &instance.config.modules.editor, NULL, }; static FFModuleBaseInfo* F[] = { - (void*) &instance.config.modules.font, + (FFModuleBaseInfo*) &instance.config.modules.font, NULL, }; static FFModuleBaseInfo* G[] = { - (void*) &instance.config.modules.gamepad, - (void*) &instance.config.modules.gpu, + (FFModuleBaseInfo*) &instance.config.modules.gamepad, + (FFModuleBaseInfo*) &instance.config.modules.gpu, NULL, }; static FFModuleBaseInfo* H[] = { - (void*) &instance.config.modules.host, + (FFModuleBaseInfo*) &instance.config.modules.host, NULL, }; static FFModuleBaseInfo* I[] = { - (void*) &instance.config.modules.icons, - (void*) &instance.config.modules.initSystem, + (FFModuleBaseInfo*) &instance.config.modules.icons, + (FFModuleBaseInfo*) &instance.config.modules.initSystem, NULL, }; @@ -72,47 +72,47 @@ static FFModuleBaseInfo* J[] = { }; static FFModuleBaseInfo* K[] = { - (void*) &instance.config.modules.kernel, - (void*) &instance.config.modules.keyboard, + (FFModuleBaseInfo*) &instance.config.modules.kernel, + (FFModuleBaseInfo*) &instance.config.modules.keyboard, NULL, }; static FFModuleBaseInfo* L[] = { - (void*) &instance.config.modules.lm, - (void*) &instance.config.modules.loadavg, - (void*) &instance.config.modules.locale, - (void*) &instance.config.modules.localIP, + (FFModuleBaseInfo*) &instance.config.modules.lm, + (FFModuleBaseInfo*) &instance.config.modules.loadavg, + (FFModuleBaseInfo*) &instance.config.modules.locale, + (FFModuleBaseInfo*) &instance.config.modules.localIP, NULL, }; static FFModuleBaseInfo* M[] = { - (void*) &instance.config.modules.media, - (void*) &instance.config.modules.memory, - (void*) &instance.config.modules.monitor, - (void*) &instance.config.modules.mouse, + (FFModuleBaseInfo*) &instance.config.modules.media, + (FFModuleBaseInfo*) &instance.config.modules.memory, + (FFModuleBaseInfo*) &instance.config.modules.monitor, + (FFModuleBaseInfo*) &instance.config.modules.mouse, NULL, }; static FFModuleBaseInfo* N[] = { - (void*) &instance.config.modules.netIo, + (FFModuleBaseInfo*) &instance.config.modules.netIo, NULL, }; static FFModuleBaseInfo* O[] = { - (void*) &instance.config.modules.openCL, - (void*) &instance.config.modules.openGL, - (void*) &instance.config.modules.os, + (FFModuleBaseInfo*) &instance.config.modules.openCL, + (FFModuleBaseInfo*) &instance.config.modules.openGL, + (FFModuleBaseInfo*) &instance.config.modules.os, NULL, }; static FFModuleBaseInfo* P[] = { - (void*) &instance.config.modules.packages, - (void*) &instance.config.modules.physicalDisk, - (void*) &instance.config.modules.physicalMemory, - (void*) &instance.config.modules.player, - (void*) &instance.config.modules.powerAdapter, - (void*) &instance.config.modules.processes, - (void*) &instance.config.modules.publicIP, + (FFModuleBaseInfo*) &instance.config.modules.packages, + (FFModuleBaseInfo*) &instance.config.modules.physicalDisk, + (FFModuleBaseInfo*) &instance.config.modules.physicalMemory, + (FFModuleBaseInfo*) &instance.config.modules.player, + (FFModuleBaseInfo*) &instance.config.modules.powerAdapter, + (FFModuleBaseInfo*) &instance.config.modules.processes, + (FFModuleBaseInfo*) &instance.config.modules.publicIP, NULL, }; @@ -125,42 +125,42 @@ static FFModuleBaseInfo* R[] = { }; static FFModuleBaseInfo* S[] = { - (void*) &instance.config.modules.separator, - (void*) &instance.config.modules.shell, - (void*) &instance.config.modules.sound, - (void*) &instance.config.modules.swap, + (FFModuleBaseInfo*) &instance.config.modules.separator, + (FFModuleBaseInfo*) &instance.config.modules.shell, + (FFModuleBaseInfo*) &instance.config.modules.sound, + (FFModuleBaseInfo*) &instance.config.modules.swap, NULL, }; static FFModuleBaseInfo* T[] = { - (void*) &instance.config.modules.terminal, - (void*) &instance.config.modules.terminalFont, - (void*) &instance.config.modules.terminalSize, - (void*) &instance.config.modules.terminalTheme, - (void*) &instance.config.modules.title, - (void*) &instance.config.modules.theme, - (void*) &instance.config.modules.tpm, + (FFModuleBaseInfo*) &instance.config.modules.terminal, + (FFModuleBaseInfo*) &instance.config.modules.terminalFont, + (FFModuleBaseInfo*) &instance.config.modules.terminalSize, + (FFModuleBaseInfo*) &instance.config.modules.terminalTheme, + (FFModuleBaseInfo*) &instance.config.modules.title, + (FFModuleBaseInfo*) &instance.config.modules.theme, + (FFModuleBaseInfo*) &instance.config.modules.tpm, NULL, }; static FFModuleBaseInfo* U[] = { - (void*) &instance.config.modules.uptime, - (void*) &instance.config.modules.users, + (FFModuleBaseInfo*) &instance.config.modules.uptime, + (FFModuleBaseInfo*) &instance.config.modules.users, NULL, }; static FFModuleBaseInfo* V[] = { - (void*) &instance.config.modules.version, - (void*) &instance.config.modules.vulkan, + (FFModuleBaseInfo*) &instance.config.modules.version, + (FFModuleBaseInfo*) &instance.config.modules.vulkan, NULL, }; static FFModuleBaseInfo* W[] = { - (void*) &instance.config.modules.wallpaper, - (void*) &instance.config.modules.weather, - (void*) &instance.config.modules.wm, - (void*) &instance.config.modules.wifi, - (void*) &instance.config.modules.wmTheme, + (FFModuleBaseInfo*) &instance.config.modules.wallpaper, + (FFModuleBaseInfo*) &instance.config.modules.weather, + (FFModuleBaseInfo*) &instance.config.modules.wm, + (FFModuleBaseInfo*) &instance.config.modules.wifi, + (FFModuleBaseInfo*) &instance.config.modules.wmTheme, NULL, }; @@ -173,7 +173,7 @@ static FFModuleBaseInfo* Y[] = { }; static FFModuleBaseInfo* Z[] = { - (void*) &instance.config.modules.zpool, + (FFModuleBaseInfo*) &instance.config.modules.zpool, NULL, }; diff --git a/src/common/netif/netif_bsd.c b/src/common/netif/netif_bsd.c index b01ef2040c..91a270905b 100644 --- a/src/common/netif/netif_bsd.c +++ b/src/common/netif/netif_bsd.c @@ -91,7 +91,11 @@ bool ffNetifGetDefaultRouteImpl(char iface[IF_NAMESIZE + 1], uint32_t* ifIndex) if (rtmsg.hdr.rtm_seq == 1 && rtmsg.hdr.rtm_pid == pid) { struct sockaddr_dl* sdl = (struct sockaddr_dl *)get_rt_address(&rtmsg.hdr, RTA_IFP); - if (sdl) + if (sdl + #ifndef __sun + && sdl->sdl_len + #endif + ) { assert(sdl->sdl_nlen <= IF_NAMESIZE); memcpy(iface, sdl->sdl_data, sdl->sdl_nlen); diff --git a/src/common/parsing.c b/src/common/parsing.c index 50f1a54aac..dce4cef025 100644 --- a/src/common/parsing.c +++ b/src/common/parsing.c @@ -72,7 +72,7 @@ static void parseSize(FFstrbuf* result, uint64_t bytes, uint32_t base, const cha } if(counter == 0) - ffStrbufAppendF(result, "%"PRIu64" %s", bytes, prefixes[0]); + ffStrbufAppendF(result, "%" PRIu64 " %s", bytes, prefixes[0]); else ffStrbufAppendF(result, "%.*f %s", instance.config.display.sizeNdigits, size, prefixes[counter]); } diff --git a/src/common/processing_linux.c b/src/common/processing_linux.c index 0e6a243ceb..fb5db62601 100644 --- a/src/common/processing_linux.c +++ b/src/common/processing_linux.c @@ -23,9 +23,12 @@ #elif defined(__sun) #include #elif defined(__OpenBSD__) -#include -#include -#include + #include + #include + #include +#elif defined(__NetBSD__) + #include + #include #endif enum { FF_PIPE_BUFSIZ = 8192 }; @@ -202,7 +205,7 @@ void ffProcessGetInfoLinux(pid_t pid, FFstrbuf* processName, FFstrbuf* exe, cons } } - #elif defined(__FreeBSD__) + #elif defined(__FreeBSD__) || defined(__NetBSD__) size_t size = ARG_MAX; FF_AUTO_FREE char* args = malloc(size); @@ -210,7 +213,13 @@ void ffProcessGetInfoLinux(pid_t pid, FFstrbuf* processName, FFstrbuf* exe, cons static_assert(ARG_MAX > PATH_MAX, ""); if(exePath && sysctl( - (int[]){CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, pid}, 4, + (int[]){CTL_KERN, + #if __FreeBSD__ + KERN_PROC, KERN_PROC_PATHNAME, pid + #else + KERN_PROC_ARGS, pid, KERN_PROC_PATHNAME + #endif + }, 4, args, &size, NULL, 0 ) == 0) @@ -218,7 +227,13 @@ void ffProcessGetInfoLinux(pid_t pid, FFstrbuf* processName, FFstrbuf* exe, cons size = ARG_MAX; if(sysctl( - (int[]){CTL_KERN, KERN_PROC, KERN_PROC_ARGS, pid}, 4, + (int[]){CTL_KERN, + #if __FreeBSD__ + KERN_PROC, KERN_PROC_ARGS, pid + #else + KERN_PROC_ARGS, pid, KERN_PROC_ARGV, + #endif + }, 4, args, &size, NULL, 0 ) == 0) @@ -352,6 +367,13 @@ const char* ffProcessGetBasicInfoLinux(pid_t pid, FFstrbuf* name, pid_t* ppid, i #elif defined(__FreeBSD__) + #ifdef __DragonFly__ + #define ki_comm kp_comm + #define ki_ppid kp_ppid + #define ki_tdev kp_tdev + #define ki_flag kp_flags + #endif + struct kinfo_proc proc; size_t size = sizeof(proc); if(sysctl( @@ -378,6 +400,34 @@ const char* ffProcessGetBasicInfoLinux(pid_t pid, FFstrbuf* name, pid_t* ppid, i *tty = -1; } + #elif defined(__NetBSD__) + + struct kinfo_proc2 proc; + size_t size = sizeof(proc); + if(sysctl( + (int[]){CTL_KERN, KERN_PROC2, KERN_PROC_PID, pid, sizeof(proc), 1}, 6, + &proc, &size, + NULL, 0 + ) != 0) + return "sysctl(KERN_PROC_PID) failed"; + + ffStrbufSetS(name, proc.p_comm); + if (ppid) + *ppid = (pid_t)proc.p_ppid; + if (tty) + { + if (proc.p_flag & P_CONTROLT) + { + const char* ttyName = devname(proc.p_tdev, S_IFCHR); + if (ffStrStartsWith(ttyName, "pts/")) + *tty = (int32_t) strtol(ttyName + strlen("pts/"), NULL, 10); + else + *tty = -1; + } + else + *tty = -1; + } + #elif defined(__sun) char path[128]; snprintf(path, sizeof(path), "/proc/%d/psinfo", (int) pid); diff --git a/src/detection/battery/battery_bsd.c b/src/detection/battery/battery_bsd.c index 228d6aa362..2997070cde 100644 --- a/src/detection/battery/battery_bsd.c +++ b/src/detection/battery/battery_bsd.c @@ -70,14 +70,26 @@ const char* ffDetectBattery(FF_MAYBE_UNUSED FFBatteryOptions* options, FFlist* r ffStrbufTrimRight(&battery->status, ','); } + #ifdef ACPIIO_BATT_GET_BIX battio.unit = i; if (ioctl(acpifd, ACPIIO_BATT_GET_BIX, &battio) >= 0) { ffStrbufAppendS(&battery->manufacturer, battio.bix.oeminfo); ffStrbufAppendS(&battery->modelName, battio.bix.model); ffStrbufAppendS(&battery->technology, battio.bix.type); + ffStrbufAppendS(&battery->serial, battio.bix.serial); battery->cycleCount = battio.bix.cycles; } + #elif defined(ACPIIO_BATT_GET_BIF) + battio.unit = i; + if (ioctl(acpifd, ACPIIO_BATT_GET_BIF, &battio) >= 0) + { + ffStrbufAppendS(&battery->manufacturer, battio.bif.oeminfo); + ffStrbufAppendS(&battery->modelName, battio.bif.model); + ffStrbufAppendS(&battery->technology, battio.bif.type); + ffStrbufAppendS(&battery->serial, battio.bif.serial); + } + #endif } return NULL; } diff --git a/src/detection/bios/bios_nbsd.c b/src/detection/bios/bios_nbsd.c new file mode 100644 index 0000000000..3330a74f4f --- /dev/null +++ b/src/detection/bios/bios_nbsd.c @@ -0,0 +1,15 @@ +#include "bios.h" +#include "common/sysctl.h" +#include "util/smbiosHelper.h" + +const char* ffDetectBios(FFBiosResult* bios) +{ + if (ffSysctlGetString("machdep.dmi.bios-date", &bios->date) == NULL) + ffCleanUpSmbiosValue(&bios->date); + if (ffSysctlGetString("machdep.dmi.bios-version", &bios->version) == NULL) + ffCleanUpSmbiosValue(&bios->version); + if (ffSysctlGetString("machdep.dmi.bios-vendor", &bios->vendor) == NULL) + ffCleanUpSmbiosValue(&bios->vendor); + ffSysctlGetString("machdep.bootmethod", &bios->type); + return NULL; +} diff --git a/src/detection/board/board_nbsd.c b/src/detection/board/board_nbsd.c new file mode 100644 index 0000000000..9557cc3398 --- /dev/null +++ b/src/detection/board/board_nbsd.c @@ -0,0 +1,15 @@ +#include "board.h" +#include "common/sysctl.h" +#include "util/smbiosHelper.h" + +const char* ffDetectBoard(FFBoardResult* board) +{ + if (ffSysctlGetString("machdep.dmi.board-product", &board->name) == NULL) + ffCleanUpSmbiosValue(&board->name); + if (ffSysctlGetString("machdep.dmi.board-version", &board->version) == NULL) + ffCleanUpSmbiosValue(&board->version); + if (ffSysctlGetString("machdep.dmi.board-vendor", &board->vendor) == NULL) + ffCleanUpSmbiosValue(&board->vendor); + + return NULL; +} diff --git a/src/detection/bootmgr/bootmgr.c b/src/detection/bootmgr/bootmgr.c index 9d4dfa8388..47c9a418a9 100644 --- a/src/detection/bootmgr/bootmgr.c +++ b/src/detection/bootmgr/bootmgr.c @@ -34,9 +34,9 @@ bool ffEfiFillLoadOption(const FFEfiLoadOption* efiOption, FFBootmgrResult* resu ffEfiUcs2ToUtf8(efiOption->Description, &result->name); for ( - ffEfiDevicePathProtocol* filePathList = (void*) &efiOption->Description[descLen + 1]; + ffEfiDevicePathProtocol* filePathList = (ffEfiDevicePathProtocol*) &efiOption->Description[descLen + 1]; filePathList->Type != 0x7F; // End of Hardware Device Path - filePathList = (void*) ((uint8_t*) filePathList + filePathList->Length)) + filePathList = (ffEfiDevicePathProtocol*) ((uint8_t*) filePathList + filePathList->Length)) { if (filePathList->Type == 4 && filePathList->SubType == 4) { diff --git a/src/detection/chassis/chassis_nbsd.c b/src/detection/chassis/chassis_nbsd.c new file mode 100644 index 0000000000..796c241a9d --- /dev/null +++ b/src/detection/chassis/chassis_nbsd.c @@ -0,0 +1,15 @@ +#include "chassis.h" +#include "common/sysctl.h" +#include "util/smbiosHelper.h" + +const char* ffDetectChassis(FFChassisResult* chassis) +{ + if (ffSysctlGetString("machdep.dmi.chassis-type", &chassis->type) == NULL) + ffCleanUpSmbiosValue(&chassis->type); + if (ffSysctlGetString("machdep.dmi.chassis-version", &chassis->version) == NULL) + ffCleanUpSmbiosValue(&chassis->version); + if (ffSysctlGetString("machdep.dmi.chassis-vendor", &chassis->vendor) == NULL) + ffCleanUpSmbiosValue(&chassis->vendor); + + return NULL; +} diff --git a/src/detection/cpu/cpu_bsd.c b/src/detection/cpu/cpu_bsd.c index 961cb8478a..7a5b72144c 100644 --- a/src/detection/cpu/cpu_bsd.c +++ b/src/detection/cpu/cpu_bsd.c @@ -25,7 +25,7 @@ static const char* detectThermalTemp(double* current) const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu) { - if (ffSysctlGetString("hw.model", &cpu->name)) + if (ffSysctlGetString("hw.model", &cpu->name) != NULL) return "sysctlbyname(hw.model) failed"; cpu->coresPhysical = (uint16_t) ffSysctlGetInt("hw.ncpu", 1); diff --git a/src/detection/cpu/cpu_linux.c b/src/detection/cpu/cpu_linux.c index 9533effd56..91c8ba46f6 100644 --- a/src/detection/cpu/cpu_linux.c +++ b/src/detection/cpu/cpu_linux.c @@ -89,7 +89,9 @@ static void detectQualcomm(FFCPUResult* cpu) { // https://en.wikipedia.org/wiki/List_of_Qualcomm_Snapdragon_systems_on_chips - if (ffStrbufEqualS(&cpu->name, "SM8635")) + if (ffStrbufEqualS(&cpu->name, "SM8750")) + ffStrbufSetStatic(&cpu->name, "Qualcomm Snapdragon 8 Elite [SM8750]"); + else if (ffStrbufEqualS(&cpu->name, "SM8635")) ffStrbufSetStatic(&cpu->name, "Qualcomm Snapdragon 8s Gen 3 [SM8635]"); else if (ffStrbufEqualS(&cpu->name, "SM8650-AC")) ffStrbufSetStatic(&cpu->name, "Qualcomm Snapdragon 8 Gen 3 for Galaxy [SM8650-AC]"); diff --git a/src/detection/cpu/cpu_nbsd.c b/src/detection/cpu/cpu_nbsd.c new file mode 100644 index 0000000000..0a78ed146b --- /dev/null +++ b/src/detection/cpu/cpu_nbsd.c @@ -0,0 +1,57 @@ +#include "cpu.h" +#include "common/sysctl.h" +#include + +static const char* detectCpuTemp(double* current) +{ + int temp = ffSysctlGetInt("dev.cpu.0.temperature", -999999); + if (temp == -999999) + return "ffSysctlGetInt(\"dev.cpu.0.temperature\") failed"; + + // In tenth of degrees Kelvin + *current = (double) temp / 10 - 273.15; + return NULL; +} + +static const char* detectThermalTemp(double* current) +{ + int temp = ffSysctlGetInt("hw.acpi.thermal.tz0.temperature", -999999); + if (temp == -999999) + return "ffSysctlGetInt(\"hw.acpi.thermal.tz0.temperature\") failed"; + + // In tenth of degrees Kelvin + *current = (double) temp / 10 - 273.15; + return NULL; +} + +const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu) +{ + if (ffSysctlGetString("machdep.cpu_brand", &cpu->name) != NULL) + { + if (ffSysctlGetString("machdep.dmi.processor-version", &cpu->name) != NULL) + return "sysctlbyname(machdep.cpu_brand) failed"; + } + + cpu->coresPhysical = (uint16_t) ffSysctlGetInt("hw.ncpu", 1); + cpu->coresLogical = cpu->coresPhysical; + cpu->coresOnline = (uint16_t) ffSysctlGetInt("hw.ncpuonline", cpu->coresLogical); + + ffCPUDetectSpeedByCpuid(cpu); + + { + struct clockinfo info; + size_t length = sizeof(info); + if (sysctl((int[]) {CTL_KERN, KERN_CLOCKRATE}, 2, &info, &length, NULL, 0) == 0) + cpu->frequencyBase = (uint32_t) info.hz / 1000; + } + + cpu->temperature = FF_CPU_TEMP_UNSET; + + if (options->temp) + { + if (detectCpuTemp(&cpu->temperature) != NULL) + detectThermalTemp(&cpu->temperature); + } + + return NULL; +} diff --git a/src/detection/cpuusage/cpuusage.c b/src/detection/cpuusage/cpuusage.c index f6cfd37ce9..d89c54919d 100644 --- a/src/detection/cpuusage/cpuusage.c +++ b/src/detection/cpuusage/cpuusage.c @@ -36,8 +36,8 @@ const char* ffGetCpuUsageResult(FFCPUUsageOptions* options, FFlist* result) for (uint32_t i = 0; i < cpuTimes1.length; ++i) { - FFCpuUsageInfo* cpuTime1 = ffListGet(&cpuTimes1, i); - FFCpuUsageInfo* cpuTime2 = ffListGet(&cpuTimes2, i); + FFCpuUsageInfo* cpuTime1 = FF_LIST_GET(FFCpuUsageInfo, cpuTimes1, i); + FFCpuUsageInfo* cpuTime2 = FF_LIST_GET(FFCpuUsageInfo, cpuTimes2, i); if (cpuTime2->totalAll <= cpuTime1->totalAll) { if (++retryCount <= 3) @@ -51,8 +51,8 @@ const char* ffGetCpuUsageResult(FFCPUUsageOptions* options, FFlist* result) for (uint32_t i = 0; i < cpuTimes1.length; ++i) { - FFCpuUsageInfo* cpuTime1 = ffListGet(&cpuTimes1, i); - FFCpuUsageInfo* cpuTime2 = ffListGet(&cpuTimes2, i); + FFCpuUsageInfo* cpuTime1 = FF_LIST_GET(FFCpuUsageInfo, cpuTimes1, i); + FFCpuUsageInfo* cpuTime2 = FF_LIST_GET(FFCpuUsageInfo, cpuTimes2, i); *(double*) ffListAdd(result) = (double)(cpuTime2->inUseAll - cpuTime1->inUseAll) / (double)(cpuTime2->totalAll - cpuTime1->totalAll) * 100; cpuTime1->inUseAll = cpuTime2->inUseAll; cpuTime1->totalAll = cpuTime2->totalAll; diff --git a/src/detection/cpuusage/cpuusage_bsd.c b/src/detection/cpuusage/cpuusage_bsd.c index a04c05b75d..5b9312d9e2 100644 --- a/src/detection/cpuusage/cpuusage_bsd.c +++ b/src/detection/cpuusage/cpuusage_bsd.c @@ -6,15 +6,19 @@ #include #include -#ifdef __OpenBSD__ +#if __OpenBSD__ || __NetBSD__ #include #endif const char* ffGetCpuUsageInfo(FFlist* cpuTimes) { size_t neededLength = 0; -#ifdef __OpenBSD__ - int ctls[] = {CTL_KERN, KERN_CPTIME}; +#if __OpenBSD__|| __NetBSD__ + #ifdef KERN_CPTIME + int ctls[] = {CTL_KERN, KERN_CPTIME}; + #else + int ctls[] = {CTL_KERN, KERN_CP_TIME}; + #endif if (sysctl(ctls, 2, NULL, &neededLength, NULL, 0) != 0) return "sysctl({CTL_KERN, KERN_CPTIME}, 2, NULL) failed"; #else @@ -27,7 +31,7 @@ const char* ffGetCpuUsageInfo(FFlist* cpuTimes) FF_AUTO_FREE uint64_t (*cpTimes)[CPUSTATES] = malloc(neededLength); -#ifdef __OpenBSD__ +#if __OpenBSD__ || __NetBSD__ if (sysctl(ctls, 2, cpTimes, &neededLength, NULL, 0) != 0) return "sysctl({CTL_KERN, KERN_CPTIME}, 2, NULL) failed"; #else diff --git a/src/detection/disk/disk_bsd.c b/src/detection/disk/disk_bsd.c index 4060669c33..957314f108 100644 --- a/src/detection/disk/disk_bsd.c +++ b/src/detection/disk/disk_bsd.c @@ -5,7 +5,17 @@ #include #include +#ifdef __NetBSD__ +#include +#include +#define getfsstat(...) getvfsstat(__VA_ARGS__) +#define statfs statvfs +#define f_flags f_flag +#define f_bsize f_frsize +#endif + #ifdef __FreeBSD__ +#if __has_include() #include static const char* detectFsLabel(struct statfs* fs, FFDisk* disk) @@ -42,6 +52,12 @@ static const char* detectFsLabel(struct statfs* fs, FFDisk* disk) return NULL; } +#else +static const char* detectFsLabel(struct statfs* fs, FFDisk* disk) +{ + return "Fastfetch was compiled without libgeom support"; +} +#endif static void detectFsInfo(struct statfs* fs, FFDisk* disk) { @@ -51,7 +67,7 @@ static void detectFsInfo(struct statfs* fs, FFDisk* disk) ? FF_DISK_VOLUME_TYPE_REGULAR_BIT : FF_DISK_VOLUME_TYPE_SUBVOLUME_BIT; } - else if(ffStrbufStartsWithS(&disk->mountpoint, "/boot") || ffStrbufStartsWithS(&disk->mountpoint, "/efi")) + else if(fs->f_flags & MNT_IGNORE) disk->type = FF_DISK_VOLUME_TYPE_HIDDEN_BIT; else if(!(fs->f_flags & MNT_LOCAL)) disk->type = FF_DISK_VOLUME_TYPE_EXTERNAL_BIT; @@ -95,7 +111,15 @@ void detectFsInfo(struct statfs* fs, FFDisk* disk) #else static void detectFsInfo(struct statfs* fs, FFDisk* disk) { - FF_UNUSED(fs, disk); + #ifdef MNT_IGNORE + if(fs->f_flags & MNT_IGNORE) + disk->type = FF_DISK_VOLUME_TYPE_HIDDEN_BIT; + else + #endif + if(!(fs->f_flags & MNT_LOCAL)) + disk->type = FF_DISK_VOLUME_TYPE_EXTERNAL_BIT; + else + disk->type = FF_DISK_VOLUME_TYPE_REGULAR_BIT; } #endif @@ -117,7 +141,7 @@ const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks) if(!ffDiskMatchMountpoint(options, fs->f_mntonname)) continue; } - else if(!ffStrStartsWith(fs->f_mntfromname, "/dev/") && !ffStrEquals(fs->f_fstypename, "zfs")) + else if(!ffStrEquals(fs->f_mntonname, "/") && !ffStrStartsWith(fs->f_mntfromname, "/dev/") && !ffStrEquals(fs->f_fstypename, "zfs")) continue; #ifdef __FreeBSD__ @@ -151,10 +175,11 @@ const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks) #ifdef __OpenBSD__ #define st_birthtimespec __st_birthtim #endif - + #ifndef __DragonFly__ struct stat st; if(stat(fs->f_mntonname, &st) == 0 && st.st_birthtimespec.tv_sec > 0) disk->createTime = (uint64_t)((st.st_birthtimespec.tv_sec * 1000) + (st.st_birthtimespec.tv_nsec / 1000000)); + #endif } return NULL; diff --git a/src/detection/disk/disk_linux.c b/src/detection/disk/disk_linux.c index 41600e7efe..4480d4d233 100644 --- a/src/detection/disk/disk_linux.c +++ b/src/detection/disk/disk_linux.c @@ -176,7 +176,7 @@ static bool isSubvolume(const FFlist* disks, FFDisk* currentDisk) FF_STRBUF_AUTO_DESTROY zpoolName = ffStrbufCreateNS(index, currentDisk->mountFrom.chars); for(uint32_t i = 0; i < disks->length - 1; i++) { - const FFDisk* otherDevice = ffListGet(disks, i); + const FFDisk* otherDevice = FF_LIST_GET(FFDisk, *disks, i); if(ffStrbufEqualS(&otherDevice->filesystem, "zfs") && ffStrbufStartsWith(&otherDevice->mountFrom, &zpoolName)) return true; } @@ -188,7 +188,7 @@ static bool isSubvolume(const FFlist* disks, FFDisk* currentDisk) //Filter all disks which device was already found. This catches BTRFS subvolumes. for(uint32_t i = 0; i < disks->length - 1; i++) { - const FFDisk* otherDevice = ffListGet(disks, i); + const FFDisk* otherDevice = FF_LIST_GET(FFDisk, *disks, i); if(ffStrbufEqual(¤tDisk->mountFrom, &otherDevice->mountFrom)) return true; diff --git a/src/detection/disk/disk_sunos.c b/src/detection/disk/disk_sunos.c index e2d6d714ea..af19d74d4e 100644 --- a/src/detection/disk/disk_sunos.c +++ b/src/detection/disk/disk_sunos.c @@ -48,7 +48,7 @@ static bool isSubvolume(const FFlist* disks, FFDisk* currentDisk) FF_STRBUF_AUTO_DESTROY zpoolName = ffStrbufCreateNS(index, currentDisk->mountFrom.chars); for(uint32_t i = 0; i < disks->length - 1; i++) { - const FFDisk* otherDevice = ffListGet(disks, i); + const FFDisk* otherDevice = FF_LIST_GET(FFDisk, *disks, i); if(ffStrbufEqualS(&otherDevice->filesystem, "zfs") && ffStrbufStartsWith(&otherDevice->mountFrom, &zpoolName)) return true; } @@ -60,7 +60,7 @@ static bool isSubvolume(const FFlist* disks, FFDisk* currentDisk) //Filter all disks which device was already found. This catches BTRFS subvolumes. for(uint32_t i = 0; i < disks->length - 1; i++) { - const FFDisk* otherDevice = ffListGet(disks, i); + const FFDisk* otherDevice = FF_LIST_GET(FFDisk, *disks, i); if(ffStrbufEqual(¤tDisk->mountFrom, &otherDevice->mountFrom)) return true; diff --git a/src/detection/diskio/diskio.c b/src/detection/diskio/diskio.c index 4c129d7941..1677c5cf28 100644 --- a/src/detection/diskio/diskio.c +++ b/src/detection/diskio/diskio.c @@ -56,8 +56,8 @@ const char* ffDetectDiskIO(FFlist* result, FFDiskIOOptions* options) for (uint32_t i = 0; i < result->length; ++i) { - FFDiskIOResult* icPrev = (FFDiskIOResult*)ffListGet(&ioCounters1, i); - FFDiskIOResult* icCurr = (FFDiskIOResult*)ffListGet(result, i); + FFDiskIOResult* icPrev = FF_LIST_GET(FFDiskIOResult, ioCounters1, i); + FFDiskIOResult* icCurr = FF_LIST_GET(FFDiskIOResult, *result, i); if (!ffStrbufEqual(&icPrev->devPath, &icCurr->devPath)) return "Physical disk device path changed"; diff --git a/src/detection/diskio/diskio_bsd.c b/src/detection/diskio/diskio_bsd.c index 08ecb47cf5..afb271a102 100644 --- a/src/detection/diskio/diskio_bsd.c +++ b/src/detection/diskio/diskio_bsd.c @@ -1,4 +1,7 @@ #include "diskio.h" + +#if __has_include() + #include "util/stringUtils.h" #include @@ -58,3 +61,49 @@ const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options) return NULL; } + +#else + +#include +#include + +const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options) +{ + if (checkversion() < 0) + return "checkversion() failed"; + + struct statinfo stats = { + .dinfo = (struct devinfo *)calloc(1, sizeof(struct devinfo)), + }; + if (getdevs(&stats) < 0) + return "getdevs() failed"; + + for (int i = 0; i < stats.dinfo->numdevs; i++) + { + struct devstat* current = &stats.dinfo->devices[i]; + if (current->device_type & DEVSTAT_TYPE_PASS) + continue; + + char deviceName[128]; + snprintf(deviceName, sizeof(deviceName), "%s%d", current->device_name, current->unit_number); + + if (options->namePrefix.length && strncmp(deviceName, options->namePrefix.chars, options->namePrefix.length) != 0) + continue; + + FFDiskIOResult* device = (FFDiskIOResult*) ffListAdd(result); + ffStrbufInitS(&device->name, deviceName); + ffStrbufInitF(&device->devPath, "/dev/%s", deviceName); + device->bytesRead = current->bytes_read; + device->readCount = current->num_reads; + device->bytesWritten = current->bytes_written; + device->writeCount = current->num_writes; + } + + if (stats.dinfo->mem_ptr) + free(stats.dinfo->mem_ptr); + free(stats.dinfo); + + return NULL; +} + +#endif diff --git a/src/detection/diskio/diskio_nbsd.c b/src/detection/diskio/diskio_nbsd.c new file mode 100644 index 0000000000..8d537045a7 --- /dev/null +++ b/src/detection/diskio/diskio_nbsd.c @@ -0,0 +1,38 @@ +#include "diskio.h" +#include "util/stringUtils.h" +#include "util/mallocHelper.h" + +#include +#include + +const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options) +{ + int mib[] = {CTL_HW, HW_IOSTATS, sizeof(struct io_sysctl)}; + size_t len; + if (sysctl(mib, ARRAY_SIZE(mib), NULL, &len, NULL, 0) < 0) + return "sysctl({HW_IOSTATS}, NULL) failed"; + uint32_t nDrive = (uint32_t) (len / sizeof(struct io_sysctl)); + + struct io_sysctl* stats = malloc(len); + + if (sysctl(mib, ARRAY_SIZE(mib), stats, &len, NULL, 0) < 0) + return "sysctl({HW_IOSTATS}, stats) failed"; + + for (uint32_t i = 0; i < nDrive; ++i) + { + struct io_sysctl* st = &stats[i]; + + if (options->namePrefix.length && strncmp(st->name, options->namePrefix.chars, options->namePrefix.length) != 0) + continue; + + FFDiskIOResult* device = (FFDiskIOResult*) ffListAdd(result); + ffStrbufInitF(&device->devPath, "/dev/%s", st->name); + ffStrbufInitS(&device->name, st->name); + device->bytesRead = st->rbytes; + device->readCount = st->rxfer; + device->bytesWritten = st->wbytes; + device->writeCount = st->wxfer; + } + + return NULL; +} diff --git a/src/detection/diskio/diskio_obsd.c b/src/detection/diskio/diskio_obsd.c new file mode 100644 index 0000000000..b00b733a22 --- /dev/null +++ b/src/detection/diskio/diskio_obsd.c @@ -0,0 +1,40 @@ +#include "diskio.h" +#include "util/stringUtils.h" +#include "util/mallocHelper.h" + +#include +#include + +const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options) +{ + int mib[] = {CTL_HW, HW_DISKSTATS}; + size_t len; + if (sysctl(mib, ARRAY_SIZE(mib), NULL, &len, NULL, 0) < 0) + return "sysctl({HW_DISKSTATS}, NULL) failed"; + uint32_t nDrive = (uint32_t) (len / sizeof(struct diskstats)); + + printf("C: %d\n", nDrive); + + struct diskstats* stats = malloc(len); + + if (sysctl(mib, ARRAY_SIZE(mib), stats, &len, NULL, 0) < 0) + return "sysctl({HW_DISKSTATS}, stats) failed"; + + for (uint32_t i = 0; i < nDrive; ++i) + { + struct diskstats* st = &stats[i]; + + if (options->namePrefix.length && strncmp(st->ds_name, options->namePrefix.chars, options->namePrefix.length) != 0) + continue; + + FFDiskIOResult* device = (FFDiskIOResult*) ffListAdd(result); + ffStrbufInitF(&device->devPath, "/dev/%s", st->ds_name); + ffStrbufInitS(&device->name, st->ds_name); + device->bytesRead = st->ds_rbytes; + device->readCount = st->ds_rxfer; + device->bytesWritten = st->ds_wbytes; + device->writeCount = st->ds_wxfer; + } + + return NULL; +} diff --git a/src/detection/diskio/diskio_sunos.c b/src/detection/diskio/diskio_sunos.c index 26a3350ffc..a6bb0b3115 100644 --- a/src/detection/diskio/diskio_sunos.c +++ b/src/detection/diskio/diskio_sunos.c @@ -27,12 +27,12 @@ const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options) continue; FFDiskIOResult* device = (FFDiskIOResult*) ffListAdd(result); - ffStrbufInitS(&device->devPath, ks->ks_name); + ffStrbufInit(&device->devPath); + ffStrbufInitS(&device->name, ks->ks_name); device->bytesRead = kio.nread; device->readCount = kio.reads; device->bytesWritten = kio.nwritten; device->writeCount = kio.writes; - ffStrbufInitS(&device->name, ks->ks_name); } return NULL; diff --git a/src/detection/displayserver/displayserver.c b/src/detection/displayserver/displayserver.c index 235c00dc2c..c2ba3e593a 100644 --- a/src/detection/displayserver/displayserver.c +++ b/src/detection/displayserver/displayserver.c @@ -19,7 +19,7 @@ FFDisplayResult* ffdsAppendDisplay( if(width == 0 || height == 0) return NULL; - FFDisplayResult* display = ffListAdd(&result->displays); + FFDisplayResult* display = (FFDisplayResult*) ffListAdd(&result->displays); display->width = width; display->height = height; display->refreshRate = refreshRate; diff --git a/src/detection/displayserver/linux/wayland/kde-output.c b/src/detection/displayserver/linux/wayland/kde-output.c index 1c4576dd4b..beac7b6355 100644 --- a/src/detection/displayserver/linux/wayland/kde-output.c +++ b/src/detection/displayserver/linux/wayland/kde-output.c @@ -113,7 +113,11 @@ static void waylandKdeNameListener(void* data, FF_MAYBE_UNUSED struct kde_output WaylandDisplay* display = data; display->type = ffdsGetDisplayType(name); // As display->id is used as an internal identifier, we don't need it to be NUL terminated + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wstringop-truncation" strncpy((char*) &display->id, name, sizeof(display->id)); + #pragma GCC diagnostic pop + ffStrbufAppendS(&display->name, name); } diff --git a/src/detection/displayserver/linux/wmde.c b/src/detection/displayserver/linux/wmde.c index 5502da78a2..aa1f0eafdf 100644 --- a/src/detection/displayserver/linux/wmde.c +++ b/src/detection/displayserver/linux/wmde.c @@ -257,6 +257,10 @@ static const char* getFromProcesses(FFDisplayServerResult* result) uint32_t userId = getuid(); #if __FreeBSD__ + #ifdef __DragonFly__ + #define ki_comm kp_comm + #endif + int request[] = {CTL_KERN, KERN_PROC, KERN_PROC_UID, (int) userId}; size_t length = 0; diff --git a/src/detection/editor/editor.c b/src/detection/editor/editor.c index 8a0e58cd6b..1566cfbb18 100644 --- a/src/detection/editor/editor.c +++ b/src/detection/editor/editor.c @@ -95,7 +95,7 @@ const char* ffDetectEditor(FFEditorResult* result) if (ffStrbufEqualS(&result->exe, "nvim")) ffBinaryExtractStrings(result->path.chars, extractNvimVersionFromBinary, &result->version, (uint32_t) strlen("NVIM v0.0.0")); - else if (ffStrbufEqualS(&result->exe, "vim")) + else if (ffStrbufEqualS(&result->exe, "vim") || ffStrbufStartsWithS(&result->exe, "vim.")) ffBinaryExtractStrings(result->path.chars, extractVimVersionFromBinary, &result->version, (uint32_t) strlen("VIM - Vi IMproved 0.0")); else if (ffStrbufEqualS(&result->exe, "nano")) ffBinaryExtractStrings(result->path.chars, extractNanoVersionFromBinary, &result->version, (uint32_t) strlen("GNU nano 0.0")); @@ -106,6 +106,7 @@ const char* ffDetectEditor(FFEditorResult* result) if ( ffStrbufEqualS(&result->exe, "nano") || ffStrbufEqualS(&result->exe, "vim") || + ffStrbufStartsWithS(&result->exe, "vim.") || // vim.basic/vim.tiny ffStrbufEqualS(&result->exe, "nvim") || ffStrbufEqualS(&result->exe, "micro") || ffStrbufEqualS(&result->exe, "emacs") || @@ -134,24 +135,14 @@ const char* ffDetectEditor(FFEditorResult* result) return NULL; ffStrbufSubstrBeforeFirstC(&result->version, '\n'); - for (uint32_t iStart = 0; iStart < result->version.length; ++iStart) - { - char c = result->version.chars[iStart]; - if (ffCharIsDigit(c)) - { - for (uint32_t iEnd = iStart + 1; iEnd < result->version.length; ++iEnd) - { - char c = result->version.chars[iEnd]; - if (isspace(c)) - { - ffStrbufSubstrBefore(&result->version, iEnd); - break; - } - } - if (iStart > 0) - ffStrbufSubstrAfter(&result->version, iStart - 1); - break; - } + const char* versionStart = strpbrk(result->version.chars, "0123456789"); + if (versionStart != NULL) { + const char* versionEnd = strpbrk(versionStart, " \t\v\f\r"); + if (versionEnd != NULL) + ffStrbufSubstrBefore(&result->version, (uint32_t)(versionEnd - result->version.chars)); + + if (versionStart != result->version.chars) + ffStrbufSubstrAfter(&result->version, (uint32_t)(versionStart - result->version.chars - 1)); } return NULL; diff --git a/src/detection/gamepad/gamepad_bsd.c b/src/detection/gamepad/gamepad_bsd.c index a84f4f42c7..fa68b46fc5 100644 --- a/src/detection/gamepad/gamepad_bsd.c +++ b/src/detection/gamepad/gamepad_bsd.c @@ -4,7 +4,12 @@ #include #include #include -#include + +#if __has_include() +#include // FreeBSD +#else +#include // DragonFly +#endif #define MAX_UHID_JOYS 64 diff --git a/src/detection/gpu/gpu.h b/src/detection/gpu/gpu.h index 3edd78fc16..5ccd33dd8e 100644 --- a/src/detection/gpu/gpu.h +++ b/src/detection/gpu/gpu.h @@ -48,6 +48,6 @@ const char* ffDetectGPUImpl(const FFGPUOptions* options, FFlist* gpus); const char* ffGetGPUVendorString(unsigned vendorId); -#if defined(__linux__) || defined(__FreeBSD__) || defined(__sun) +#if defined(__linux__) || defined(__FreeBSD__) || defined(__sun) || defined(__NetBSD__) || defined(__OpenBSD__) void ffGPUFillVendorAndName(uint8_t subclass, uint16_t vendor, uint16_t device, FFGPUResult* gpu); #endif diff --git a/src/detection/gpu/gpu_bsd.c b/src/detection/gpu/gpu_bsd.c index b64935df41..49218e13f4 100644 --- a/src/detection/gpu/gpu_bsd.c +++ b/src/detection/gpu/gpu_bsd.c @@ -2,12 +2,14 @@ #include "common/io/io.h" #include "common/properties.h" -#include "util/mallocHelper.h" -#include "util/stringUtils.h" -#include #include #include +#if __has_include() + #include // FreeBSD +#else + #include // DragonFly +#endif const char* ffDetectGPUImpl(const FFGPUOptions* options, FFlist* gpus) { diff --git a/src/detection/gpu/gpu_general.c b/src/detection/gpu/gpu_general.c new file mode 100644 index 0000000000..31d7bac3ec --- /dev/null +++ b/src/detection/gpu/gpu_general.c @@ -0,0 +1,68 @@ +#include "gpu.h" + +#ifdef FF_HAVE_PCIACCESS + +#include "common/properties.h" +#include "common/io/io.h" +#include "common/library.h" + +#include + +const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist* gpus) +{ + FF_LIBRARY_LOAD(pciaccess, "Failed to load libpciaccess" FF_LIBRARY_EXTENSION, "libpciaccess" FF_LIBRARY_EXTENSION, 0) + FF_LIBRARY_LOAD_SYMBOL_MESSAGE(pciaccess, pci_system_init) + FF_LIBRARY_LOAD_SYMBOL_MESSAGE(pciaccess, pci_slot_match_iterator_create) + FF_LIBRARY_LOAD_SYMBOL_MESSAGE(pciaccess, pci_device_next) + FF_LIBRARY_LOAD_SYMBOL_MESSAGE(pciaccess, pci_system_cleanup) + + { + // Requires root access + // Same behavior can be observed with `cp $(which scanpci) /tmp/ && /tmp/scanpci` + FF_SUPPRESS_IO(); + if (ffpci_system_init() < 0) + return "pci_system_init() failed"; + } + + struct pci_device_iterator* iter = ffpci_slot_match_iterator_create(NULL); + for (struct pci_device* dev = NULL; (dev = ffpci_device_next(iter)); ) + { + if (dev->device_class >> 16 != 0x03 /*PCI_BASE_CLASS_DISPLAY*/) + continue; + + FFGPUResult* gpu = (FFGPUResult*)ffListAdd(gpus); + ffStrbufInitStatic(&gpu->vendor, ffGetGPUVendorString(dev->vendor_id)); + ffStrbufInit(&gpu->name); + ffStrbufInit(&gpu->driver); + ffStrbufInit(&gpu->platformApi); + gpu->temperature = FF_GPU_TEMP_UNSET; + gpu->coreCount = FF_GPU_CORE_COUNT_UNSET; + gpu->type = FF_GPU_TYPE_UNKNOWN; + gpu->dedicated.total = gpu->dedicated.used = gpu->shared.total = gpu->shared.used = FF_GPU_VMEM_SIZE_UNSET; + gpu->deviceId = ((uint64_t) dev->domain << 6) | ((uint64_t) dev->bus << 4) | ((uint64_t) dev->dev << 2) | (uint64_t) dev->func; + gpu->frequency = FF_GPU_FREQUENCY_UNSET; + + if (gpu->vendor.chars == FF_GPU_VENDOR_NAME_AMD) + { + char query[32]; + snprintf(query, sizeof(query), "%X,\t%X,", (unsigned) dev->device_id, (unsigned) dev->revision); + ffParsePropFileData("libdrm/amdgpu.ids", query, &gpu->name); + } + + if (gpu->name.length == 0) + { + ffGPUFillVendorAndName((dev->device_class >> 8) & 8, dev->vendor_id, dev->device_id, gpu); + } + } + + ffpci_system_cleanup(); + return NULL; +} + +#else + +const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FF_MAYBE_UNUSED FFlist* gpus) +{ + return "Fastfetch was built without libpciaccess support"; +} +#endif diff --git a/src/detection/gpu/gpu_pci.c b/src/detection/gpu/gpu_pci.c index fe0f0c9399..2de51a2ca4 100644 --- a/src/detection/gpu/gpu_pci.c +++ b/src/detection/gpu/gpu_pci.c @@ -4,6 +4,9 @@ #include #ifdef __FreeBSD__ #include + #ifndef _PATH_LOCALBASE + #define _PATH_LOCALBASE "/usr/local" + #endif #endif #if FF_HAVE_EMBEDDED_PCIIDS @@ -41,6 +44,10 @@ static const FFstrbuf* loadPciIds() ffReadFileBuffer(FASTFETCH_TARGET_DIR_USR "/share/pciids/pci.ids", &pciids); #elif __sun ffReadFileBuffer(FASTFETCH_TARGET_DIR_ROOT "/usr/share/hwdata/pci.ids", &pciids); + #elif __OpenBSD__ + ffReadFileBuffer(FASTFETCH_TARGET_DIR_ROOT "/usr/local/share/pci.ids", &pciids); + #elif __NetBSD__ + ffReadFileBuffer(FASTFETCH_TARGET_DIR_ROOT "/usr/pkg/share/pciutils/pci.ids", &pciids); #endif #endif // FF_CUSTOM_PCI_IDS_PATH diff --git a/src/detection/host/host_nbsd.c b/src/detection/host/host_nbsd.c new file mode 100644 index 0000000000..947198cb6e --- /dev/null +++ b/src/detection/host/host_nbsd.c @@ -0,0 +1,17 @@ +#include "host.h" +#include "common/sysctl.h" +#include "util/smbiosHelper.h" + +const char* ffDetectHost(FFHostResult* host) +{ + const char* error = NULL; + if ((error = ffSysctlGetString("machdep.dmi.system-product", &host->name))) + return error; + ffCleanUpSmbiosValue(&host->name); + if (ffSysctlGetString("machdep.dmi.system-vendor", &host->vendor) == NULL) + ffCleanUpSmbiosValue(&host->vendor); + if (ffSysctlGetString("machdep.dmi.system-version", &host->version) == NULL) + ffCleanUpSmbiosValue(&host->version); + + return NULL; +} diff --git a/src/detection/keyboard/keyboard_bsd.c b/src/detection/keyboard/keyboard_bsd.c index 4f424ba70f..31dc3aa245 100644 --- a/src/detection/keyboard/keyboard_bsd.c +++ b/src/detection/keyboard/keyboard_bsd.c @@ -4,7 +4,12 @@ #include #include #include -#include + +#if __has_include() + #include // FreeBSD +#else + #include // DragonFly +#endif #define MAX_UHID_JOYS 64 diff --git a/src/detection/keyboard/keyboard_linux.c b/src/detection/keyboard/keyboard_linux.c index 8952ca674b..e2d482150f 100644 --- a/src/detection/keyboard/keyboard_linux.c +++ b/src/detection/keyboard/keyboard_linux.c @@ -31,9 +31,9 @@ const char* ffDetectKeyboard(FFlist* devices /* List of FFKeyboardDevice */) if (pend == eventid) continue; // Ignore duplicate entries - if (flags & (1 << index)) + if (flags & (1UL << index)) continue; - flags |= (1 << index); + flags |= (1UL << index); ffStrbufSetF(&path, "/sys/class/input/event%s/device/name", eventid); diff --git a/src/detection/libc/libc_bsd.c b/src/detection/libc/libc_bsd.c index 0b6ee49439..7c80e1181b 100644 --- a/src/detection/libc/libc_bsd.c +++ b/src/detection/libc/libc_bsd.c @@ -2,12 +2,20 @@ const char* ffDetectLibc(FFLibcResult* result) { - result->name = "FBSD"; + result->name = "Unknown"; + result->version = NULL; -#ifdef FF_FBSD_VERSION +#ifdef __DragonFly__ // We define `__FreeBSD__` on DragonFly BSD for simplification + result->name = "DF"; + #ifdef FF_DF_VERSION + result->version = FF_DF_VERSION; + #endif +#elif __FreeBSD__ + result->name = "FBSD"; + #ifdef FF_FBSD_VERSION result->version = FF_FBSD_VERSION; -#else - result->version = NULL; + #endif #endif + return NULL; } diff --git a/src/detection/loadavg/loadavg_bsd.c b/src/detection/loadavg/loadavg_bsd.c index 3a0b6bca57..ca7b17caf3 100644 --- a/src/detection/loadavg/loadavg_bsd.c +++ b/src/detection/loadavg/loadavg_bsd.c @@ -2,7 +2,7 @@ #include -#if __FreeBSD__ || __OpenBSD__ +#if __FreeBSD__ || __OpenBSD__ || __NetBSD__ #include #include #if __FreeBSD__ diff --git a/src/detection/localip/localip_linux.c b/src/detection/localip/localip_linux.c index adf5713da5..00e64b990b 100644 --- a/src/detection/localip/localip_linux.c +++ b/src/detection/localip/localip_linux.c @@ -18,7 +18,7 @@ #include #endif -#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__APPLE__) +#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__APPLE__) || defined(__NetBSD__) #include #include #else @@ -39,7 +39,7 @@ static const FFLocalIpNIFlag niFlagOptions[] = { { IFF_PROMISC, "PROMISC" }, { IFF_ALLMULTI, "ALLMULTI" }, { IFF_MULTICAST, "MULTICAST" }, -#if defined(__linux__) || defined(__APPLE__) || defined(__sun) +#ifdef IFF_NOTRAILERS { IFF_NOTRAILERS, "NOTRAILERS" }, #endif #ifdef __linux__ @@ -52,17 +52,17 @@ static const FFLocalIpNIFlag niFlagOptions[] = { { IFF_DORMANT, "DORMANT" }, { IFF_ECHO, "ECHO" }, #endif -#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__OpenBSD__) +#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__OpenBSD__) || defined(__NetBSD__) { IFF_OACTIVE, "OACTIVE" }, { IFF_SIMPLEX, "SIMPLEX" }, { IFF_LINK0, "LINK0" }, { IFF_LINK1, "LINK1" }, { IFF_LINK2, "LINK2" }, #endif -#if defined(__FreeBSD__) || defined(__APPLE__) +#ifdef IFF_ALTPHYS { IFF_ALTPHYS, "ALTPHYS" }, #endif -#ifdef __FreeBSD__ +#ifdef IFF_CANTCONFIG { IFF_CANTCONFIG, "CANTCONFIG" }, #endif // sentinel @@ -190,7 +190,7 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results) addNewIp(results, ifa->ifa_name, addressBuffer, AF_INET6, isDefaultRoute, flags, !(options->showType & FF_LOCALIP_TYPE_ALL_IPS_BIT)); } - #if __FreeBSD__ || __OpenBSD__ || __APPLE__ + #if __FreeBSD__ || __OpenBSD__ || __APPLE__ || __NetBSD__ else if (ifa->ifa_addr->sa_family == AF_LINK) { if (!(options->showType & FF_LOCALIP_TYPE_MAC_BIT)) @@ -246,7 +246,7 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results) ifr.ifr_data = (void*) &edata; if (ioctl(sockfd, SIOCETHTOOL, &ifr) == 0) iface->speed = (edata.speed_hi << 16) | edata.speed; // ethtool_cmd_speed is not available on Android - #elif __FreeBSD__ || __APPLE__ || __OpenBSD__ + #elif __FreeBSD__ || __APPLE__ || __OpenBSD__ || __NetBSD__ struct ifmediareq ifmr = {}; ffStrCopyN(ifmr.ifm_name, iface->name.chars, IFNAMSIZ); if (ioctl(sockfd, SIOCGIFMEDIA, &ifmr) == 0 && (IFM_TYPE(ifmr.ifm_active) & IFM_ETHER)) diff --git a/src/detection/memory/memory_bsd.c b/src/detection/memory/memory_bsd.c index 0db20527a2..587ca7f1f0 100644 --- a/src/detection/memory/memory_bsd.c +++ b/src/detection/memory/memory_bsd.c @@ -4,7 +4,13 @@ const char* ffDetectMemory(FFMemoryResult* ram) { size_t length = sizeof(ram->bytesTotal); - if (sysctl((int[]){ CTL_HW, HW_PHYSMEM }, 2, &ram->bytesTotal, &length, NULL, 0)) + if (sysctl((int[]){ CTL_HW, +#if __NetBSD__ + HW_PHYSMEM64 +#else + HW_PHYSMEM +#endif + }, 2, &ram->bytesTotal, &length, NULL, 0)) return "Failed to read hw.physmem"; // vm.stats.vm.* are int values diff --git a/src/detection/memory/memory_obsd.c b/src/detection/memory/memory_obsd.c index 9efc21ead9..3dda7656aa 100644 --- a/src/detection/memory/memory_obsd.c +++ b/src/detection/memory/memory_obsd.c @@ -3,6 +3,10 @@ #include +#if __NetBSD__ + #include +#endif + const char* ffDetectMemory(FFMemoryResult* ram) { struct uvmexp buf; diff --git a/src/detection/mouse/mouse_bsd.c b/src/detection/mouse/mouse_bsd.c index 6018d18931..cb99a47cf5 100644 --- a/src/detection/mouse/mouse_bsd.c +++ b/src/detection/mouse/mouse_bsd.c @@ -4,7 +4,12 @@ #include #include #include -#include + +#if __has_include() +#include // FreeBSD +#else +#include // DragonFly +#endif #define MAX_UHID_JOYS 64 diff --git a/src/detection/netio/netio.c b/src/detection/netio/netio.c index bcb64bca08..0c40843881 100644 --- a/src/detection/netio/netio.c +++ b/src/detection/netio/netio.c @@ -56,8 +56,8 @@ const char* ffDetectNetIO(FFlist* result, FFNetIOOptions* options) for (uint32_t i = 0; i < result->length; ++i) { - FFNetIOResult* icPrev = (FFNetIOResult*)ffListGet(&ioCounters1, i); - FFNetIOResult* icCurr = (FFNetIOResult*)ffListGet(result, i); + FFNetIOResult* icPrev = FF_LIST_GET(FFNetIOResult, ioCounters1, i); + FFNetIOResult* icCurr = FF_LIST_GET(FFNetIOResult, *result, i); if (!ffStrbufEqual(&icPrev->name, &icCurr->name)) return "Network interface name changed"; diff --git a/src/detection/netio/netio_bsd.c b/src/detection/netio/netio_bsd.c index 6bf9a8ce6e..5328949a95 100644 --- a/src/detection/netio/netio_bsd.c +++ b/src/detection/netio/netio_bsd.c @@ -48,7 +48,11 @@ const char* ffNetIOGetIoCounters(FFlist* result, FFNetIOOptions* options) .rxPackets = ifm->ifm_data.ifi_ipackets, .txErrors = ifm->ifm_data.ifi_oerrors, .rxErrors = ifm->ifm_data.ifi_ierrors, + #ifdef _IFI_OQDROPS + .txDrops = if2m->ifm_data.ifi_oqdrops, + #else .txDrops = 0, // unsupported + #endif .rxDrops = ifm->ifm_data.ifi_iqdrops, .defaultRoute = sdl->sdl_index == defaultRouteIfIndex, }; diff --git a/src/detection/opengl/opengl_linux.c b/src/detection/opengl/opengl_linux.c index 05a72bf25c..452d3e6bd4 100644 --- a/src/detection/opengl/opengl_linux.c +++ b/src/detection/opengl/opengl_linux.c @@ -120,7 +120,7 @@ static const char* detectByGlx(FFOpenGLResult* result) GLXData data; FF_LIBRARY_LOAD(glx, "dlopen glx failed", - #if !__OpenBSD__ + #if !__OpenBSD__ && !__NetBSD__ "libGLX" #else "libGL" diff --git a/src/detection/os/os_linux.c b/src/detection/os/os_linux.c index c7ede9b160..cab2cef8ae 100644 --- a/src/detection/os/os_linux.c +++ b/src/detection/os/os_linux.c @@ -46,7 +46,7 @@ static bool parseOsRelease(const char* fileName, FFOSResult* result) }); } -static void getUbuntuFlavour(FFOSResult* result) +FF_MAYBE_UNUSED static void getUbuntuFlavour(FFOSResult* result) { const char* xdgConfigDirs = getenv("XDG_CONFIG_DIRS"); if(!ffStrSet(xdgConfigDirs)) @@ -143,7 +143,7 @@ static void getUbuntuFlavour(FFOSResult* result) } } -static void getDebianVersion(FFOSResult* result) +FF_MAYBE_UNUSED static void getDebianVersion(FFOSResult* result) { FF_STRBUF_AUTO_DESTROY debianVersion = ffStrbufCreate(); ffAppendFileBuffer("/etc/debian_version", &debianVersion); @@ -153,7 +153,7 @@ static void getDebianVersion(FFOSResult* result) ffStrbufSet(&result->versionID, &debianVersion); } -static bool detectDebianDerived(FFOSResult* result) +FF_MAYBE_UNUSED static bool detectDebianDerived(FFOSResult* result) { if (ffStrbufStartsWithS(&result->prettyName, "Armbian ")) // Armbian 24.2.1 bookworm { @@ -179,6 +179,13 @@ static bool detectDebianDerived(FFOSResult* result) ffStrbufSetS(&result->idLike, "debian"); return true; } + else if (ffStrbufStartsWithS(&result->name, "Lilidog GNU/Linux")) + { + // https://github.com/fastfetch-cli/fastfetch/issues/1373 + ffStrbufSetS(&result->id, "lilidog"); + ffStrbufSetS(&result->idLike, "debian"); + return true; + } else if (access("/usr/bin/pveversion", X_OK) == 0) { ffStrbufSetS(&result->id, "pve"); @@ -186,13 +193,13 @@ static bool detectDebianDerived(FFOSResult* result) ffStrbufSetS(&result->name, "Proxmox VE"); ffStrbufClear(&result->versionID); if (ffProcessAppendStdOut(&result->versionID, (char* const[]) { - "/usr/bin/pveversion", + "/usr/bin/dpkg-query", + "--showformat=${version}", + "--show", + "pve-manager", NULL, - }) == NULL) // pve-manager/8.2.2/9355359cd7afbae4 (running kernel: 6.8.4-2-pve) - { - ffStrbufSubstrBeforeLastC(&result->versionID, '/'); - ffStrbufSubstrAfterFirstC(&result->versionID, '/'); - } + }) == NULL) // 8.2.2 + ffStrbufTrimRightSpace(&result->versionID); ffStrbufSetF(&result->prettyName, "Proxmox VE %s", result->versionID.chars); return true; } @@ -258,6 +265,7 @@ void ffDetectOSImpl(FFOSResult* os) { detectOS(os); + #ifdef __linux__ if(ffStrbufIgnCaseEqualS(&os->id, "ubuntu")) getUbuntuFlavour(os); else if(ffStrbufIgnCaseEqualS(&os->id, "debian")) @@ -265,4 +273,5 @@ void ffDetectOSImpl(FFOSResult* os) if (!detectDebianDerived(os)) getDebianVersion(os); } + #endif } diff --git a/src/detection/os/os_nbsd.c b/src/detection/os/os_nbsd.c new file mode 100644 index 0000000000..229df96d1f --- /dev/null +++ b/src/detection/os/os_nbsd.c @@ -0,0 +1,7 @@ +#include "os.h" + +void ffDetectOSImpl(FFOSResult* os) +{ + ffStrbufSetStatic(&os->name, "NetBSD"); + ffStrbufSet(&os->version, &instance.state.platform.sysinfo.release); +} diff --git a/src/detection/packages/packages_obsd.c b/src/detection/packages/packages_obsd.c index c7fadcbdff..79d383ed48 100644 --- a/src/detection/packages/packages_obsd.c +++ b/src/detection/packages/packages_obsd.c @@ -26,6 +26,12 @@ void ffDetectPackagesImpl(FFPackagesResult* result, FFPackagesOptions* options) { if (!(options->disabled & FF_PACKAGES_FLAG_PKG_BIT)) { - result->pkg = getNumElementsImpl(FASTFETCH_TARGET_DIR_ROOT "/var/db/pkg", DT_DIR); + result->pkg = getNumElementsImpl(FASTFETCH_TARGET_DIR_ROOT + #if __OpenBSD + "/var/db/pkg" + #else + "/usr/pkg/pkgdb" + #endif + , DT_DIR); } } diff --git a/src/detection/physicaldisk/physicaldisk_bsd.c b/src/detection/physicaldisk/physicaldisk_bsd.c index 99dbaf9cca..42918ff95a 100644 --- a/src/detection/physicaldisk/physicaldisk_bsd.c +++ b/src/detection/physicaldisk/physicaldisk_bsd.c @@ -1,4 +1,7 @@ #include "physicaldisk.h" + +#if __has_include() + #include "util/stringUtils.h" #include @@ -92,3 +95,9 @@ const char* ffDetectPhysicalDisk(FFlist* result, FFPhysicalDiskOptions* options) return NULL; } +#else +const char* ffDetectPhysicalDisk(FFlist* result, FFPhysicalDiskOptions* options) +{ + return "Fastfetch was compiled without libgeom support"; +} +#endif diff --git a/src/detection/processes/processes_nbsd.c b/src/detection/processes/processes_nbsd.c new file mode 100644 index 0000000000..cf16a04cd6 --- /dev/null +++ b/src/detection/processes/processes_nbsd.c @@ -0,0 +1,15 @@ +#include "processes.h" + +#include + +const char* ffDetectProcesses(uint32_t* result) +{ + int request[] = {CTL_KERN, KERN_PROC2, KERN_PROC_ALL, -1, sizeof(struct kinfo_proc2), 0}; + size_t length = 0; + + if(sysctl(request, ARRAY_SIZE(request), NULL, &length, NULL, 0) != 0) + return "sysctl({CTL_KERN, KERN_PROC2, KERN_PROC_ALL}) failed"; + + *result = (uint32_t)(length / sizeof(struct kinfo_proc2)); + return NULL; +} diff --git a/src/detection/processes/processes_nosupport.c b/src/detection/processes/processes_nosupport.c new file mode 100644 index 0000000000..e1774dd040 --- /dev/null +++ b/src/detection/processes/processes_nosupport.c @@ -0,0 +1,6 @@ +#include "processes.h" + +const char* ffDetectProcesses(uint32_t* result) +{ + return "Not supported on this platform"; +} diff --git a/src/detection/sound/sound_bsd.c b/src/detection/sound/sound_bsd.c index 3053c14d53..af601b5a53 100644 --- a/src/detection/sound/sound_bsd.c +++ b/src/detection/sound/sound_bsd.c @@ -10,6 +10,9 @@ const char* ffDetectSound(FFlist* devices) char path[] = "/dev/mixer0"; int defaultDev = ffSysctlGetInt("hw.snd.default_unit", -1); + if (defaultDev == -1) + return "sysctl(hw.snd.default_unit) failed"; + for (int idev = 0; idev <= 9; ++idev) { path[strlen("/dev/mixer")] = (char) ('0' + idev); @@ -23,8 +26,7 @@ const char* ffDetectSound(FFlist* devices) continue; uint32_t mutemask = 0; - if (ioctl(fd, SOUND_MIXER_READ_MUTE, &mutemask) < 0) - continue; + ioctl(fd, SOUND_MIXER_READ_MUTE, &mutemask); // doesn't seem to be available on DragonFly struct oss_card_info ci = { .card = idev }; if (ioctl(fd, SNDCTL_CARDINFO, &ci) < 0) diff --git a/src/detection/terminalshell/terminalshell.c b/src/detection/terminalshell/terminalshell.c index a68e33517c..b8f6e1159c 100644 --- a/src/detection/terminalshell/terminalshell.c +++ b/src/detection/terminalshell/terminalshell.c @@ -8,8 +8,13 @@ #include #ifdef __FreeBSD__ #include + #ifndef _PATH_LOCALBASE + #define _PATH_LOCALBASE "/usr/local" + #endif #elif __OpenBSD__ #define _PATH_LOCALBASE "/usr/local" +#elif __NetBSD__ + #define _PATH_LOCALBASE "/usr/pkg" #endif #ifdef _WIN32 @@ -121,7 +126,7 @@ static bool getShellVersionPwsh(FFstrbuf* exe, FFstrbuf* version) static bool getShellVersionKsh(FFstrbuf* exe, FFstrbuf* version) { -#if __OpenBSD__ +#if __OpenBSD__ || __NetBSD__ if(ffProcessAppendStdOut(version, (char* const[]) { exe->chars, "-c", @@ -575,7 +580,7 @@ static bool getTerminalVersionZed(FFstrbuf* exe, FFstrbuf* version) #ifndef _WIN32 static bool getTerminalVersionKitty(FFstrbuf* exe, FFstrbuf* version) { - #if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) + #if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) char buffer[1024] = {}; if ( #ifdef __linux__ @@ -678,7 +683,7 @@ bool fftsGetTerminalVersion(FFstrbuf* processName, FF_MAYBE_UNUSED FFstrbuf* exe #endif - #if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__sun) + #if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__sun) || defined(__NetBSD__) if(ffStrbufStartsWithIgnCaseS(processName, "gnome-terminal")) return getTerminalVersionGnome(exe, version); diff --git a/src/detection/terminalshell/terminalshell_linux.c b/src/detection/terminalshell/terminalshell_linux.c index c29d97742d..5d63236f83 100644 --- a/src/detection/terminalshell/terminalshell_linux.c +++ b/src/detection/terminalshell/terminalshell_linux.c @@ -236,7 +236,7 @@ static void getTerminalFromEnv(FFTerminalResult* result) } #endif - #if defined(__linux__) || defined(__FreeBSD__) + #if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) //Konsole else if( getenv("KONSOLE_VERSION") != NULL @@ -329,7 +329,7 @@ static void setTerminalInfoDetails(FFTerminalResult* result) else if(ffStrbufEqualS(&result->processName, "com.termux")) ffStrbufInitStatic(&result->prettyName, "Termux"); - #elif defined(__linux__) || defined(__FreeBSD__) + #elif defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) else if(ffStrbufStartsWithS(&result->processName, "gnome-terminal")) ffStrbufInitStatic(&result->prettyName, "GNOME Terminal"); diff --git a/src/detection/uptime/uptime_bsd.c b/src/detection/uptime/uptime_bsd.c index 47202544ae..446a95e254 100644 --- a/src/detection/uptime/uptime_bsd.c +++ b/src/detection/uptime/uptime_bsd.c @@ -6,7 +6,11 @@ const char* ffDetectUptime(FFUptimeResult* result) { + #if __NetBSD__ + struct timespec bootTime; + #else struct timeval bootTime; + #endif size_t bootTimeSize = sizeof(bootTime); if(sysctl( (int[]) {CTL_KERN, KERN_BOOTTIME}, 2, @@ -15,7 +19,11 @@ const char* ffDetectUptime(FFUptimeResult* result) ) != 0) return "sysctl({CTL_KERN, KERN_BOOTTIME}) failed"; + #if __NetBSD__ + result->bootTime = (uint64_t) bootTime.tv_sec * 1000 + (uint64_t) bootTime.tv_nsec / 10000000; + #else result->bootTime = (uint64_t) bootTime.tv_sec * 1000 + (uint64_t) bootTime.tv_usec / 1000; + #endif result->uptime = ffTimeGetNow() - result->bootTime; return NULL; diff --git a/src/detection/users/users_obsd.c b/src/detection/users/users_obsd.c new file mode 100644 index 0000000000..db7a894673 --- /dev/null +++ b/src/detection/users/users_obsd.c @@ -0,0 +1,36 @@ +#include "fastfetch.h" +#include "users.h" +#include "common/io/io.h" + +#include + +const char* ffDetectUsers(FF_MAYBE_UNUSED FFUsersOptions* options, FFlist* users) +{ + FF_AUTO_CLOSE_FILE FILE* fp = fopen(_PATH_UTMP, "r"); + if (!fp) return "fopen(_PATH_UTMP, r) failed"; + + struct utmp n; +next: + while (fread(&n, sizeof(n), 1, fp) == 1) + { + if (!n.ut_name[0]) continue; + + if (options->myselfOnly && !ffStrbufEqualS(&instance.state.platform.userName, n.ut_name)) + continue; + + FF_LIST_FOR_EACH(FFUserResult, user, *users) + { + if (ffStrbufEqualS(&user->name, n.ut_name)) + goto next; + } + + FFUserResult* user = (FFUserResult*) ffListAdd(users); + ffStrbufInitS(&user->name, n.ut_name); + ffStrbufInitS(&user->hostName, n.ut_host); + ffStrbufInitS(&user->sessionName, n.ut_line); + ffStrbufInit(&user->clientIp); + user->loginTime = (uint64_t) n.ut_time * 1000; + } + + return NULL; +} diff --git a/src/detection/version/version.c b/src/detection/version/version.c index 6e89c3b660..8b230eecbf 100644 --- a/src/detection/version/version.c +++ b/src/detection/version/version.c @@ -26,6 +26,8 @@ #define FF_SYSNAME "Android" #elif defined(__linux__) #define FF_SYSNAME "Linux" +#elif defined(__DragonFly__) // We define `__FreeBSD__` on DragonFly BSD for simplification + #define FF_SYSNAME "DragonFly" #elif defined(__FreeBSD__) #define FF_SYSNAME "FreeBSD" #elif defined(__APPLE__) diff --git a/src/detection/vulkan/vulkan.c b/src/detection/vulkan/vulkan.c index caa6e68d3f..3f26b747e6 100644 --- a/src/detection/vulkan/vulkan.c +++ b/src/detection/vulkan/vulkan.c @@ -48,10 +48,10 @@ static const char* detectVulkan(FFVulkanResult* result) "libvulkan"FF_LIBRARY_EXTENSION, 2 #endif ) - FF_LIBRARY_LOAD_SYMBOL_MESSAGE2(vulkan, vkGetInstanceProcAddr, vkGetInstanceProcAddr@8) - FF_LIBRARY_LOAD_SYMBOL_MESSAGE2(vulkan, vkCreateInstance, vkCreateInstance@12) - FF_LIBRARY_LOAD_SYMBOL_MESSAGE2(vulkan, vkDestroyInstance, vkDestroyInstance@8) - FF_LIBRARY_LOAD_SYMBOL_MESSAGE2(vulkan, vkEnumeratePhysicalDevices, vkEnumeratePhysicalDevices@12) + FF_LIBRARY_LOAD_SYMBOL_MESSAGE(vulkan, vkGetInstanceProcAddr) + FF_LIBRARY_LOAD_SYMBOL_MESSAGE(vulkan, vkCreateInstance) + FF_LIBRARY_LOAD_SYMBOL_MESSAGE(vulkan, vkDestroyInstance) + FF_LIBRARY_LOAD_SYMBOL_MESSAGE(vulkan, vkEnumeratePhysicalDevices) //Some drivers (nvdc) print messages to stdout //and that is the best way I found to disable that diff --git a/src/fastfetch.c b/src/fastfetch.c index 8be2ab211b..07acf68a51 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -370,7 +370,7 @@ static void generateConfigFile(bool force, const char* filePath) { if (!filePath) { - ffStrbufSet(&instance.state.genConfigPath, (FFstrbuf*) ffListGet(&instance.state.platform.configDirs, 0)); + ffStrbufSet(&instance.state.genConfigPath, FF_LIST_GET(FFstrbuf, instance.state.platform.configDirs, 0)); ffStrbufAppendS(&instance.state.genConfigPath, "fastfetch/config.jsonc"); } else diff --git a/src/fastfetch.h b/src/fastfetch.h index ae9d0657f6..a95ab7501b 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -27,11 +27,11 @@ #ifdef __has_builtin #if __has_builtin(__builtin_types_compatible_p) - #define ARRAY_SIZE(x) ({ static_assert(!__builtin_types_compatible_p(__typeof__(x), __typeof__(&*(x))), "Must not be a pointer"); sizeof(x) / sizeof(*(x)); }) + #define ARRAY_SIZE(x) ({ static_assert(!__builtin_types_compatible_p(__typeof__(x), __typeof__(&*(x))), "Must not be a pointer"); (uint32_t) (sizeof(x) / sizeof(*(x))); }) #endif #endif #ifndef ARRAY_SIZE - #define ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x))) + #define ARRAY_SIZE(x) ((uint32_t) (sizeof(x) / sizeof(*(x)))) #endif diff --git a/src/logo/ascii/aperture.txt b/src/logo/ascii/aperture.txt index 778779e1b1..59a9a77d01 100644 --- a/src/logo/ascii/aperture.txt +++ b/src/logo/ascii/aperture.txt @@ -1,20 +1,20 @@ .,-:;//;:=, - . :H@@@MM@M#H/.,+%;, - ,/X+ +M@@M@MM%=,-%HMMM@X/, - -+@MM; SM@@MH+-,;XMMMM@MMMM@+- - ;@M@@M- XM@X;. -+XXXXXHHH@M@M#@/. - ,%MM@@MH ,@%= .---=-=:=,. - =@#@@@MX., -%HXSS%%%:; - =-./@M@MS .;@MMMM@MM: - X@/ -SMM/ . +MM@@@MS -,@M@H: :@: . =X#@@@@- -,@@@MMX, . /H- ;@M@M= -.H@@@@M@+, %MM+..%#S. - /MMMM@MMH/. XM@MH; =; - /%+%SXHH@S= , .H@@@@MX, - .=--------. -%H.,@@@@@MX, - .%MM@@@HHHXXSSS%+- .:SMMX =M@@MM%. - =XMMM@MM@MM#H;,-+HMM@M+ /MMMX= - =%@M@M#@S-.=S@MM@@@M; %M%= - ,:+S+-,/H#MMMMMMM@= =, - =++%%%%+/:-. \ No newline at end of file + $8. $1:H@@@MM@M#H/.$2,+%;, + $8,/X+ $1+M@@M@MM%=,$2-%HMMM@X/, + $8-+@MM; $1$$M@@MH+-,$2;XMMMM@MMMM@+- + $8;@M@@M- $1XM@X;. $2-+XXXXXHHH@M@M#@/. + $8,%MM@@MH $1,@%= $2.---=-=:=,. + $8=@#@@@MX., $3-%HX$$$$%%%:; + $7=-$8./@M@M$$ $3.;@MMMM@MM: + $7X@/$8 -$$MM/ $3. +MM@@@M$$ +$7,@M@H:$8 :@: $4. $3=X#@@@@- +$7,@@@MMX,$8 . $4/H- $3;@M@M= +$7.H@@@@M@+, $4%MM+. $3%#$. + $7/MMMM@MMH/. $4XM@MH; $3=; + $7/%+%$$XHH@$$= $5, $4.H@@@@MX, + $6=----------. $5-%H.$4,@@@@@MX, + $6.%MM@@@HHHXX$$$$$$%+- $5.:$$MMX$4 =M@@MM%. + $6=XMMM@MM@MM#H;$5,-+HMM@M+$4 /MMMX= + $6=%@M@M#@$$-$5.=$@MM@@@M;$4 %M%= + $6,:+$$+-$5,/H#MMMMMMM@=$4 =, + $5=++%%%%+/:-. \ No newline at end of file diff --git a/src/logo/ascii/lilidog.txt b/src/logo/ascii/lilidog.txt new file mode 100644 index 0000000000..abc6c2f930 --- /dev/null +++ b/src/logo/ascii/lilidog.txt @@ -0,0 +1,16 @@ + +DDDL+ +LDDDDD+ + LD++++D+D+::::::+D + D+-::::=D+::::::::+LLDD+ + D=::::::=L=-::::::=LL++=+D + D-:::::=LDD=-::-=+L=-::::=D + L+--==+++===++LDD+:::::::-D + DL+++==:::::::::-+D-:::::::=D + D=:::::::::::::::::++:::::-+D +D+::::::::::::::::::+D++==+LD+ + D=:::::::::::::::::+LD+=--:-+D + L+=-::::::::::::::L+-::::::=D + DLL++-::::::::::-D:::::::-+D + DL+:::::::::+D=-:::-=+D + D=:::::::-D +LDLLD+ + L+--::-=D + +LDLDD+ \ No newline at end of file diff --git a/src/logo/ascii/opensuse_leap.txt b/src/logo/ascii/opensuse_leap.txt index e0d8cddc82..fa96b3f891 100644 --- a/src/logo/ascii/opensuse_leap.txt +++ b/src/logo/ascii/opensuse_leap.txt @@ -1,16 +1,18 @@ - .-++:. - ./oooooo/- - `:oooooooooooo:. - -+oooooooooooooooo+-` - ./oooooooooooooooooooooo/- - :oooooooooooooooooooooooooo: - ` `-+oooooooooooooooooooo/- ` - `:oo/- .:ooooooooooooooo+:` `-+oo/. -`/oooooo:. -/oooooooooo/. ./oooooo/. - `:+ooooo+-` `:+oooo+- `:oooooo+:` - .:oooooo/. .::` -+oooooo/. - -/oooooo:. ./oooooo+- - `:+ooooo+-:+oooooo:` - ./oooooooooo/. - -/oooo+:` - `:/. \ No newline at end of file + ==== + ====== + ==== ====+ + +==== +==== + +===+ ==== + ==== ==== ++=== +==== +==== +==== + ===== ==== + +===+ ===== +==+ ===== +===+ === +==== ==== ===== ===== + ==== ======= ==== + ==== === ==== + ====+ ==== + ==== ===== + ====== + == \ No newline at end of file diff --git a/src/logo/ascii/opensuse_leap_old.txt b/src/logo/ascii/opensuse_leap_old.txt new file mode 100644 index 0000000000..e0d8cddc82 --- /dev/null +++ b/src/logo/ascii/opensuse_leap_old.txt @@ -0,0 +1,16 @@ + .-++:. + ./oooooo/- + `:oooooooooooo:. + -+oooooooooooooooo+-` + ./oooooooooooooooooooooo/- + :oooooooooooooooooooooooooo: + ` `-+oooooooooooooooooooo/- ` + `:oo/- .:ooooooooooooooo+:` `-+oo/. +`/oooooo:. -/oooooooooo/. ./oooooo/. + `:+ooooo+-` `:+oooo+- `:oooooo+:` + .:oooooo/. .::` -+oooooo/. + -/oooooo:. ./oooooo+- + `:+ooooo+-:+oooooo:` + ./oooooooooo/. + -/oooo+:` + `:/. \ No newline at end of file diff --git a/src/logo/ascii/opensuse_tumbleweed.txt b/src/logo/ascii/opensuse_tumbleweed.txt index fefdeee4ad..bf857a76a7 100644 --- a/src/logo/ascii/opensuse_tumbleweed.txt +++ b/src/logo/ascii/opensuse_tumbleweed.txt @@ -1,13 +1,21 @@ - ...... - .,cdxxxoc,. .:kKMMMNWMMMNk:. - cKMMN0OOOKWMMXo. A ;0MWk:' ':OMMk. - ;WMK;' 'lKMMNM, :NMK' 'OMW; - cMW; WMMMN ,XMK' oMM. -.MMc ''^*~l. xMN: KM0 -'MM. .NMO oMM -.MM, .kMMl xMN - KM0 .kMM0' .dl>~,. .WMd - 'XM0. ,OMMK' OMMM7' .XMK - *WMO:. .;xNMMk' NNNMKl. .xWMx - ^ONMMNXMMMKx; V 'xNMWKkxllox0NMWk' - ''''' ':dOOXXKOxl' \ No newline at end of file + .,:looooooc;. + ,ool oo,;oo: + .lo' oo. oo: + oo. oo. oo: +:ol oo. 'oo +:oo .oo. .oo. +.oooooooooooooo. .oo. + ;oo. .oo. + oo, .oo. + .ooc,'..........:ooc.......... + .cooooooooooooooooooooooooool;. + .oo. .oo; + .oo. .oo. + .oo. oooooooooo:ooo. + .oo. .oo. col + oo' .oo col + coo .oo oo' + coc .oo lo, + .oo, .oo .:oo + .oooooc,,,:lol + ,clc' \ No newline at end of file diff --git a/src/logo/ascii/opensuse_tumbleweed_old.txt b/src/logo/ascii/opensuse_tumbleweed_old.txt new file mode 100644 index 0000000000..fefdeee4ad --- /dev/null +++ b/src/logo/ascii/opensuse_tumbleweed_old.txt @@ -0,0 +1,13 @@ + ...... + .,cdxxxoc,. .:kKMMMNWMMMNk:. + cKMMN0OOOKWMMXo. A ;0MWk:' ':OMMk. + ;WMK;' 'lKMMNM, :NMK' 'OMW; + cMW; WMMMN ,XMK' oMM. +.MMc ''^*~l. xMN: KM0 +'MM. .NMO oMM +.MM, .kMMl xMN + KM0 .kMM0' .dl>~,. .WMd + 'XM0. ,OMMK' OMMM7' .XMK + *WMO:. .;xNMMk' NNNMKl. .xWMx + ^ONMMNXMMMKx; V 'xNMWKkxllox0NMWk' + ''''' ':dOOXXKOxl' \ No newline at end of file diff --git a/src/logo/ascii/pikaos.txt b/src/logo/ascii/pikaos.txt index ea477a258f..ae19ee4616 100644 --- a/src/logo/ascii/pikaos.txt +++ b/src/logo/ascii/pikaos.txt @@ -1,28 +1,18 @@ - '',,, ,,,d, - ',, ,,' - ', ,. - ., ' - . . - ' . - .. oddddkdlc:;,.. .. - . ............lllc, . - . ....................: . - . . .................... - '. ..........'o........d0XX0. - ....lllllllcOOOcllllll............cxlxc...;okkkx. - ..................................';lc'...lo. - .'''''''''''''.....................,;,....... - ',,,,,,,,,,,,,,,,''...............dkkkd...... - ',,,,,,,,,,,,,,,,,,,'............;okkkd;.... - .,,,,,,,,,,,,,,,,,,,,,............;cll;..... - ,,,,,,,,,,,,,,,,,,,,'....................:d, - ,,,,,,,,,,,,,,,,,,,....................oxxx: - .,,,,,,,,,,,,,,,,,'..................oxxxxx. . - .,,,,,,,,,,,,,,'.......... ,oxxxxxxx . - .;,,,,,,,,,,,,'.. 'cxxxxxxxxx, - :dl:,'',,'.... .;lxxxxxxxxxd; - ,codol:;'. ...,;cldxxxxxxxxxoc. - .:cxxxxxdlccccc:ccldxxxxxxxxxxxxxx::. - .'::dxxxxxxxxxxxxxxxxxxxxxxxd::'. - ..,::cdxxxxxxxxxxxxxdc::,.. - ...,;:::::::;,... \ No newline at end of file + - + ---------------- + ------------------ + ------------------- + -- -----------=*-=----##### + -----------------------------####--=###### + ------------------------------++---+#### + =============----------------=+=----- + =================-----------####+---- + ==================----------*###=---- + ===================----------------- + ==================----------------- + =================---------------- + ===============------------:::: + ============-::::::::::::::: + =======--::::::::::::::: + .::::::::::::::::. + ::::::: \ No newline at end of file diff --git a/src/logo/ascii/summitos.txt b/src/logo/ascii/summitos.txt new file mode 100644 index 0000000000..ff875cb279 --- /dev/null +++ b/src/logo/ascii/summitos.txt @@ -0,0 +1,22 @@ + :~^ + ~5PPJ + :5555P7 + .Y55555P~ + ?P5555555^ + 7P55555555Y. + ~5555555555PJ$2 7YJ^ + $1^555555555555P7$2 7GGGP^ + $1.Y5555555555555P!$2 ~PPPPP5. + $1JP555555555555555^$2 ^PPPPPPGY + $17P5555555555555555Y$2^5PPPPPPPG? + $1~P55555555555555555$2^PPPPPPPPPPP! + $1^555555555555555555$2^PPPPPPPPPPPPP^ + $1.Y555555555555P$3G$1P55$2^PPPPPPPPPPPPPP5: + $1JP55555555555P$3GGG$1P$2^PPPPPPPPPPPPPPPGY + $17P555555555555$3GGGGG$2PPPPPPPPPPPPPPPPPG? + $1!P555555555555$3GGGGGGG$2PPPPPPPPPPPPPPPPPG! + $1^5555555555555$3PGGGGGGGG$2PPPPPPPPPPPPPPPPPP^ + $1:Y555555555555$3PGGGGGGGGGG$2PPPPPPPPPPPPPPPPP5: +$1.JP55555555555$3PGGGGGGGGGGGG$2PPPPPPPPPPPPPPPPGY. +$1?PPPPPPPPPPPP$3GGBBBBBBBBBBBBB$2GGGGGGGGGGGGGGGGGJ +$1^~~~~~~~~~~~$3!!!!!!!!!!!!!!!!!$2!!!!!!!!!!!!!!!!~ diff --git a/src/logo/ascii/xcp_ng.txt b/src/logo/ascii/xcp_ng.txt new file mode 100644 index 0000000000..4d33560b81 --- /dev/null +++ b/src/logo/ascii/xcp_ng.txt @@ -0,0 +1,15 @@ + ${c3}%${c4}# + ${c1}((((${c3}%%%%%${c4}&& + ${c1}#((((((((((${c4}&&&& + ${c1}(((((((((((${c2}#####${c4}&& + ${c1}(((((${c5}%.....${c2}%####### + ${c1}(((( ((((((${c5}%.......${c2}%####, + ${c1}%((((((& ((((((((${c5}%.....${c2}%#### + ${c1}((((((((((((((${c2}########### + ${c1}(((( (((((((${c2}########### + ${c1}( /((((${c2}########### + ${c6},,*..${c2}########## + ${c6},,,******${c2}## ###### + ${c6},,,*,,,, ${c2}## ###### +${c6}. .,,,, ${c2}### ## + ${c6}... \ No newline at end of file diff --git a/src/logo/builtin.c b/src/logo/builtin.c index 7ef6ce8fba..c20cbc9278 100644 --- a/src/logo/builtin.c +++ b/src/logo/builtin.c @@ -258,6 +258,13 @@ static const FFlogo A[] = { .lines = FASTFETCH_DATATEXT_LOGO_APERTURE, .colors = { FF_COLOR_FG_CYAN, + FF_COLOR_FG_CYAN, + FF_COLOR_FG_CYAN, + FF_COLOR_FG_CYAN, + FF_COLOR_FG_CYAN, + FF_COLOR_FG_CYAN, + FF_COLOR_FG_CYAN, + FF_COLOR_FG_CYAN, }, .colorKeys = FF_COLOR_FG_CYAN, .colorTitle = FF_COLOR_FG_WHITE, @@ -2382,6 +2389,16 @@ static const FFlogo L[] = { .colorKeys = FF_COLOR_FG_GREEN, .colorTitle = FF_COLOR_FG_YELLOW, }, + // Lilidog + { + .names = {"Lilidog"}, + .lines = FASTFETCH_DATATEXT_LOGO_LIBREELEC, + .colors = { + FF_COLOR_FG_BLUE, + }, + .colorKeys = FF_COLOR_FG_RED, + .colorTitle = FF_COLOR_FG_WHITE, + }, // Lingmo OS { .names = {"Lingmo", "lingmo", "LingmoOS", "lingmoos"}, @@ -3196,7 +3213,7 @@ static const FFlogo O[] = { }, // OpenSuseLeap { - .names = {"opensuse_leap", "open_suse_leap", "opensuse-leap", "open-suse-leap", "suse_leap", "suse-leap", "opensuseleap"}, + .names = {"opensuse_leap", "opensuse leap"}, .lines = FASTFETCH_DATATEXT_LOGO_OPENSUSE_LEAP, .colors = { FF_COLOR_FG_WHITE, @@ -3204,9 +3221,20 @@ static const FFlogo O[] = { .colorKeys = FF_COLOR_FG_GREEN, .colorTitle = FF_COLOR_FG_GREEN, }, + // OpenSuseLeapOld + { + .names = {"opensuse_leap_old", "opensuse leap_old"}, + .lines = FASTFETCH_DATATEXT_LOGO_OPENSUSE_LEAP_OLD, + .type = FF_LOGO_LINE_TYPE_ALTER_BIT, + .colors = { + FF_COLOR_FG_WHITE, + }, + .colorKeys = FF_COLOR_FG_GREEN, + .colorTitle = FF_COLOR_FG_GREEN, + }, // OpenSuseTumbleweed { - .names = {"opensuse_tumbleweed", "open_suse_tumbleweed", "opensuse-tumbleweed", "open-suse-tumbleweed", "suse_tumbleweed", "suse-tumbleweed", "opensusetumbleweed"}, + .names = {"opensuse-tumbleweed", "opensuse_tumbleweed"}, .lines = FASTFETCH_DATATEXT_LOGO_OPENSUSE_TUMBLEWEED, .colors = { FF_COLOR_FG_WHITE, @@ -3214,6 +3242,17 @@ static const FFlogo O[] = { .colorKeys = FF_COLOR_FG_GREEN, .colorTitle = FF_COLOR_FG_GREEN, }, + // OpenSuseTumbleweedOld + { + .names = {"opensuse-tumbleweed-old", "opensuse_tumbleweed-old"}, + .lines = FASTFETCH_DATATEXT_LOGO_OPENSUSE_TUMBLEWEED_OLD, + .type = FF_LOGO_LINE_TYPE_ALTER_BIT, + .colors = { + FF_COLOR_FG_WHITE, + }, + .colorKeys = FF_COLOR_FG_GREEN, + .colorTitle = FF_COLOR_FG_GREEN, + }, // openSUSESlowroll { .names = {"opensuse_slowroll", "opensuse-slowroll", "opensuse-tumbleweed-slowroll"}, @@ -4251,6 +4290,16 @@ static const FFlogo S[] = { FF_COLOR_FG_WHITE, }, }, + // SummitOS + { + .names = {"SummitOS"}, + .lines = FASTFETCH_DATATEXT_LOGO_SUMMITOS, + .colors = { + FF_COLOR_FG_RGB "143;191;80", + FF_COLOR_FG_RGB "160;205;102", + FF_COLOR_FG_RGB "181;225;102", + }, + }, // Suse { .names = {"suse", "suse-linux"}, @@ -4810,6 +4859,19 @@ static const FFlogo X[] = { FF_COLOR_FG_RED, } }, + // XCP-ng + { + .names = {"XCP-ng", "xenenterprise"}, + .lines = FASTFETCH_DATATEXT_LOGO_XCP_NG, + .colors = { + FF_COLOR_FG_RED, + FF_COLOR_FG_RED, + FF_COLOR_FG_BLACK, + FF_COLOR_FG_BLACK, + FF_COLOR_FG_BLUE, + FF_COLOR_FG_YELLOW, + } + }, // Xferience { .names = {"Xferience"}, diff --git a/src/modules/bluetooth/bluetooth.c b/src/modules/bluetooth/bluetooth.c index a6bca3bce3..b00ff013ca 100644 --- a/src/modules/bluetooth/bluetooth.c +++ b/src/modules/bluetooth/bluetooth.c @@ -74,7 +74,7 @@ void ffPrintBluetooth(FFBluetoothOptions* options) for(uint32_t i = 0; i < filtered.length; i++) { uint8_t index = (uint8_t) (filtered.length == 1 ? 0 : i + 1); - printDevice(options, *(FFBluetoothResult**)ffListGet(&filtered, i), index); + printDevice(options, *FF_LIST_GET(FFBluetoothResult*, filtered, i), index); } } diff --git a/src/modules/display/display.c b/src/modules/display/display.c index e845ff164b..98255ed467 100644 --- a/src/modules/display/display.c +++ b/src/modules/display/display.c @@ -75,7 +75,7 @@ void ffPrintDisplay(FFDisplayOptions* options) for(uint32_t i = 0; i < dsResult->displays.length; i++) { - FFDisplayResult* result = ffListGet(&dsResult->displays, i); + FFDisplayResult* result = FF_LIST_GET(FFDisplayResult, dsResult->displays, i); uint32_t moduleIndex = dsResult->displays.length == 1 ? 0 : i + 1; const char* displayType = result->type == FF_DISPLAY_TYPE_UNKNOWN ? NULL : result->type == FF_DISPLAY_TYPE_BUILTIN ? "built-in" : "external"; diff --git a/src/modules/gpu/gpu.c b/src/modules/gpu/gpu.c index 1d449d33a1..57a7b9a8a4 100644 --- a/src/modules/gpu/gpu.c +++ b/src/modules/gpu/gpu.c @@ -133,7 +133,7 @@ void ffPrintGPU(FFGPUOptions* options) } for(uint32_t i = 0; i < selectedGPUs.length; i++) - printGPUResult(options, selectedGPUs.length == 1 ? 0 : (uint8_t) (i + 1), * (const FFGPUResult**) ffListGet(&selectedGPUs, i)); + printGPUResult(options, selectedGPUs.length == 1 ? 0 : (uint8_t) (i + 1), *FF_LIST_GET(const FFGPUResult*, selectedGPUs, i)); if(selectedGPUs.length == 0) ffPrintError(FF_GPU_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "No GPUs found"); diff --git a/src/modules/localip/localip.c b/src/modules/localip/localip.c index a6bcd261ad..9e3f88e1b7 100644 --- a/src/modules/localip/localip.c +++ b/src/modules/localip/localip.c @@ -530,7 +530,7 @@ void ffInitLocalIpOptions(FFLocalIpOptions* options) ffOptionInitModuleArg(&options->moduleArgs, "󰩟"); options->showType = FF_LOCALIP_TYPE_IPV4_BIT | FF_LOCALIP_TYPE_PREFIX_LEN_BIT - #if !__ANDROID__ /*Permission denied*/ && !__OpenBSD__ /*Report invalid argument for some reason*/ + #if !__ANDROID__ /*Permission denied*/ && !__OpenBSD__ /*Report invalid argument for some reason*/ && !__DragonFly__ /*Doesn't work*/ | FF_LOCALIP_TYPE_DEFAULT_ROUTE_ONLY_BIT #endif ; diff --git a/src/modules/netio/netio.c b/src/modules/netio/netio.c index 89113c3756..6dd3e8a987 100644 --- a/src/modules/netio/netio.c +++ b/src/modules/netio/netio.c @@ -264,7 +264,7 @@ void ffInitNetIOOptions(FFNetIOOptions* options) ffStrbufInit(&options->namePrefix); options->defaultRouteOnly = - #ifdef __ANDROID__ + #if __ANDROID__ || __OpenBSD__ false #else true diff --git a/src/modules/poweradapter/poweradapter.c b/src/modules/poweradapter/poweradapter.c index 3445f7c35f..76745e6e13 100644 --- a/src/modules/poweradapter/poweradapter.c +++ b/src/modules/poweradapter/poweradapter.c @@ -25,7 +25,7 @@ void ffPrintPowerAdapter(FFPowerAdapterOptions* options) { for(uint8_t i = 0; i < (uint8_t) results.length; i++) { - FFPowerAdapterResult* result = ffListGet(&results, i); + FFPowerAdapterResult* result = FF_LIST_GET(FFPowerAdapterResult, results, i); if(options->moduleArgs.outputFormat.length == 0) { diff --git a/src/modules/users/users.c b/src/modules/users/users.c index 3c7db48e0c..7be21109bc 100644 --- a/src/modules/users/users.c +++ b/src/modules/users/users.c @@ -38,7 +38,7 @@ void ffPrintUsers(FFUsersOptions* options) { if(i > 0) ffStrbufAppendS(&result, ", "); - FFUserResult* user = (FFUserResult*)ffListGet(&users, i); + FFUserResult* user = FF_LIST_GET(FFUserResult, users, i); ffStrbufAppend(&result, &user->name); } ffStrbufPutTo(&result, stdout); @@ -47,7 +47,7 @@ void ffPrintUsers(FFUsersOptions* options) { for(uint32_t i = 0; i < users.length; ++i) { - FFUserResult* user = (FFUserResult*)ffListGet(&users, i); + FFUserResult* user = FF_LIST_GET(FFUserResult, users, i); ffPrintLogoAndKey(FF_USERS_MODULE_NAME, users.length == 1 ? 0 : (uint8_t) (i + 1), &options->moduleArgs, FF_PRINT_TYPE_DEFAULT); @@ -66,7 +66,7 @@ void ffPrintUsers(FFUsersOptions* options) { for(uint32_t i = 0; i < users.length; ++i) { - FFUserResult* user = (FFUserResult*)ffListGet(&users, i); + FFUserResult* user = FF_LIST_GET(FFUserResult, users, i); FF_PRINT_FORMAT_CHECKED(FF_USERS_MODULE_NAME, users.length == 1 ? 0 : (uint8_t) (i + 1), &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_USERS_NUM_FORMAT_ARGS, ((FFformatarg[]){ FF_FORMAT_ARG(user->name, "name"), diff --git a/src/modules/wifi/wifi.c b/src/modules/wifi/wifi.c index ace8340a18..d000c7e6bc 100644 --- a/src/modules/wifi/wifi.c +++ b/src/modules/wifi/wifi.c @@ -24,7 +24,7 @@ void ffPrintWifi(FFWifiOptions* options) for(uint32_t index = 0; index < result.length; ++index) { - FFWifiResult* item = (FFWifiResult*)ffListGet(&result, index); + FFWifiResult* item = FF_LIST_GET(FFWifiResult, result, index); uint8_t moduleIndex = result.length == 1 ? 0 : (uint8_t)(index + 1); if(options->moduleArgs.outputFormat.length == 0) diff --git a/src/options/general.c b/src/options/general.c index a29c21960a..6f088256fb 100644 --- a/src/options/general.c +++ b/src/options/general.c @@ -39,7 +39,7 @@ const char* ffOptionsParseGeneralJsonConfig(FFOptionsGeneral* options, yyjson_va else if (ffStrEqualsIgnCase(key, "detectVersion")) options->detectVersion = yyjson_get_bool(val); - #if defined(__linux__) || defined(__FreeBSD__) || defined(__sun) || defined(__OpenBSD__) + #if defined(__linux__) || defined(__FreeBSD__) || defined(__sun) || defined(__OpenBSD__) || defined(__NetBSD__) else if (ffStrEqualsIgnCase(key, "escapeBedrock")) options->escapeBedrock = yyjson_get_bool(val); else if (ffStrEqualsIgnCase(key, "playerName")) @@ -84,7 +84,7 @@ bool ffOptionsParseGeneralCommandLine(FFOptionsGeneral* options, const char* key else if(ffStrEqualsIgnCase(key, "--detect-version")) options->detectVersion = ffOptionParseBoolean(value); - #if defined(__linux__) || defined(__FreeBSD__) || defined(__sun) || defined(__OpenBSD__) + #if defined(__linux__) || defined(__FreeBSD__) || defined(__sun) || defined(__OpenBSD__) || defined(__NetBSD__) else if(ffStrEqualsIgnCase(key, "--escape-bedrock")) options->escapeBedrock = ffOptionParseBoolean(value); else if(ffStrEqualsIgnCase(key, "--player-name")) @@ -115,7 +115,7 @@ void ffOptionsInitGeneral(FFOptionsGeneral* options) options->multithreading = true; options->detectVersion = true; - #if defined(__linux__) || defined(__FreeBSD__) + #if defined(__linux__) || defined(__FreeBSD__) || defined(__sun) || defined(__OpenBSD__) || defined(__NetBSD__) options->escapeBedrock = true; ffStrbufInit(&options->playerName); options->dsForceDrm = FF_DS_FORCE_DRM_TYPE_FALSE; diff --git a/src/options/general.h b/src/options/general.h index 0a85df7672..f1f0f3ff82 100644 --- a/src/options/general.h +++ b/src/options/general.h @@ -16,7 +16,7 @@ typedef struct FFOptionsGeneral bool detectVersion; // Module options that cannot be put in module option structure - #if defined(__linux__) || defined(__FreeBSD__) || defined(__sun) || defined(__OpenBSD__) + #if defined(__linux__) || defined(__FreeBSD__) || defined(__sun) || defined(__OpenBSD__) || defined(__NetBSD__) FFstrbuf playerName; bool escapeBedrock; FFDsForceDrmType dsForceDrm; diff --git a/src/util/FFlist.c b/src/util/FFlist.c index 59f5a8b567..e640f507e7 100644 --- a/src/util/FFlist.c +++ b/src/util/FFlist.c @@ -3,14 +3,6 @@ #include #include -void ffListInitA(FFlist* list, uint32_t elementSize, uint32_t capacity) -{ - list->elementSize = elementSize; - list->capacity = capacity; - list->length = 0; - list->data = capacity == 0 ? NULL : malloc((size_t)list->capacity * list->elementSize); -} - void* ffListAdd(FFlist* list) { if(list->length == list->capacity) @@ -24,17 +16,6 @@ void* ffListAdd(FFlist* list) return ffListGet(list, list->length - 1); } -uint32_t ffListFirstIndexComp(const FFlist* list, void* compElement, bool(*compFunc)(const void*, const void*)) -{ - for(uint32_t i = 0; i < list->length; i++) - { - if(compFunc(ffListGet(list, i), compElement)) - return i; - } - - return list->length; -} - bool ffListShift(FFlist* list, void* result) { if(list->length == 0) diff --git a/src/util/FFlist.h b/src/util/FFlist.h index c3fd451e59..a4b2f64c45 100644 --- a/src/util/FFlist.h +++ b/src/util/FFlist.h @@ -17,12 +17,8 @@ typedef struct FFlist uint32_t capacity; } FFlist; -void ffListInitA(FFlist* list, uint32_t elementSize, uint32_t capacity); - void* ffListAdd(FFlist* list); -FF_C_NODISCARD uint32_t ffListFirstIndexComp(const FFlist* list, void* compElement, bool(*compFunc)(const void*, const void*)); - // Removes the first element, and copy its value to `*result` bool ffListShift(FFlist* list, void* result); // Removes the last element, and copy its value to `*result` @@ -37,6 +33,13 @@ static inline void ffListInit(FFlist* list, uint32_t elementSize) list->data = NULL; } +static inline void ffListInitA(FFlist* list, uint32_t elementSize, uint32_t capacity) +{ + ffListInit(list, elementSize); + list->capacity = capacity; + list->data = __builtin_expect(capacity == 0, 0) ? NULL : (char*) malloc((size_t)list->capacity * list->elementSize); +} + static inline FFlist ffListCreate(uint32_t elementSize) { FFlist result; @@ -50,6 +53,17 @@ static inline void* ffListGet(const FFlist* list, uint32_t index) return list->data + (index * list->elementSize); } +FF_C_NODISCARD static inline uint32_t ffListFirstIndexComp(const FFlist* list, void* compElement, bool(*compFunc)(const void*, const void*)) +{ + for(uint32_t i = 0; i < list->length; i++) + { + if(compFunc(ffListGet(list, i), compElement)) + return i; + } + + return list->length; +} + static inline bool ffListContains(const FFlist* list, void* compElement, bool(*compFunc)(const void*, const void*)) { return ffListFirstIndexComp(list, compElement, compFunc) != list->length; diff --git a/src/util/FFstrbuf.h b/src/util/FFstrbuf.h index fa4a9da876..c40f411e51 100644 --- a/src/util/FFstrbuf.h +++ b/src/util/FFstrbuf.h @@ -379,7 +379,7 @@ static inline FF_C_NODISCARD uint32_t ffStrbufFirstIndexS(const FFstrbuf* strbuf static inline FF_C_NODISCARD uint32_t ffStrbufLastIndexC(const FFstrbuf* strbuf, char c) { if(strbuf->length == 0) - return strbuf->length; + return 0; return ffStrbufPreviousIndexC(strbuf, strbuf->length - 1, c); } diff --git a/src/util/binary_linux.c b/src/util/binary_linux.c index b9c521ca9c..3b6ccca350 100644 --- a/src/util/binary_linux.c +++ b/src/util/binary_linux.c @@ -1,6 +1,6 @@ #include "binary.h" -#if defined(FF_HAVE_ELF) || defined(__sun) || defined(__FreeBSD__) || defined(__OpenBSD__) +#if defined(FF_HAVE_ELF) || defined(__sun) || (defined(__FreeBSD__) && !defined(__DragonFly__)) || defined(__OpenBSD__) || defined(__NetBSD__) #include "common/io/io.h" #include "common/library.h" diff --git a/src/util/platform/FFPlatform_unix.c b/src/util/platform/FFPlatform_unix.c index 9eaeae38a5..b0d0ac1bda 100644 --- a/src/util/platform/FFPlatform_unix.c +++ b/src/util/platform/FFPlatform_unix.c @@ -12,7 +12,7 @@ #ifdef __APPLE__ #include #include -#elif defined(__FreeBSD__) || defined(__OpenBSD__) +#elif defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) #include #endif @@ -24,10 +24,16 @@ static void getExePath(FFPlatform* platform) exePath[exePathLen] = '\0'; #elif defined(__APPLE__) int exePathLen = proc_pidpath((int) getpid(), exePath, sizeof(exePath)); - #elif defined(__FreeBSD__) + #elif defined(__FreeBSD__) || defined(__NetBSD__) size_t exePathLen = sizeof(exePath); if(sysctl( - (int[]){CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, (int) getpid()}, 4, + (int[]){CTL_KERN, + #ifdef __FreeBSD__ + KERN_PROC, KERN_PROC_PATHNAME, (int) getpid() + #else + KERN_PROC_ARGS, (int) getpid(), KERN_PROC_PATHNAME + #endif + }, 4, exePath, &exePathLen, NULL, 0 ) < 0) @@ -179,7 +185,7 @@ static void getSysinfo(FFPlatformSysinfo* info, const struct utsname* uts) ffStrbufAppendS(&info->architecture, uts->machine); ffStrbufInit(&info->displayVersion); - #if defined(__FreeBSD__) || defined(__APPLE__) || defined(__OpenBSD__) + #if defined(__FreeBSD__) || defined(__APPLE__) || defined(__OpenBSD__) || defined(__NetBSD__) size_t length = sizeof(info->pageSize); sysctl((int[]){ CTL_HW, HW_PAGESIZE }, 2, &info->pageSize, &length, NULL, 0); #else