mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 02:42:09 +02:00
Chore: IndentPPDirectives: BeforeHash [ci skip]
This commit is contained in:
@@ -11,15 +11,15 @@
|
||||
#include <assert.h>
|
||||
|
||||
#ifdef FF_USE_SYSTEM_YYJSON
|
||||
# include <yyjson.h>
|
||||
#include <yyjson.h>
|
||||
#else
|
||||
# include "3rdparty/yyjson/yyjson.h"
|
||||
#include "3rdparty/yyjson/yyjson.h"
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
// #include <shlwapi.h>
|
||||
__stdcall char* StrStrIA(const char* lpFirst, const char* lpSrch);
|
||||
# define strcasestr StrStrIA
|
||||
#define strcasestr StrStrIA
|
||||
#endif
|
||||
|
||||
#define FASTFETCH_STRBUF_DEFAULT_ALLOC 32
|
||||
|
||||
@@ -3,14 +3,14 @@
|
||||
#include <assert.h>
|
||||
|
||||
#ifdef __has_builtin
|
||||
# if !__cplusplus && FF_SUPPORTS_COUNT_OF
|
||||
# define ARRAY_SIZE(x) _Countof(x)
|
||||
# elif __has_builtin(__is_array)
|
||||
# define ARRAY_SIZE(x) ({ static_assert(__is_array(__typeof__(x)), "Must be an array"); (uint32_t) (sizeof(x) / sizeof(*(x))); })
|
||||
# elif __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"); (uint32_t) (sizeof(x) / sizeof(*(x))); })
|
||||
# endif
|
||||
#if !__cplusplus && FF_SUPPORTS_COUNT_OF
|
||||
#define ARRAY_SIZE(x) _Countof(x)
|
||||
#elif __has_builtin(__is_array)
|
||||
#define ARRAY_SIZE(x) ({ static_assert(__is_array(__typeof__(x)), "Must be an array"); (uint32_t) (sizeof(x) / sizeof(*(x))); })
|
||||
#elif __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"); (uint32_t) (sizeof(x) / sizeof(*(x))); })
|
||||
#endif
|
||||
#endif
|
||||
#ifndef ARRAY_SIZE
|
||||
# define ARRAY_SIZE(x) ((uint32_t) (sizeof(x) / sizeof(*(x))))
|
||||
#define ARRAY_SIZE(x) ((uint32_t) (sizeof(x) / sizeof(*(x))))
|
||||
#endif
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# define __attribute__(x)
|
||||
#define __attribute__(x)
|
||||
#endif
|
||||
|
||||
#define FF_A_FALLTHROUGH __attribute__((__fallthrough__))
|
||||
|
||||
+4
-4
@@ -1,10 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef FF_HAVE_DBUS
|
||||
# include <dbus/dbus.h>
|
||||
#include <dbus/dbus.h>
|
||||
|
||||
# include "common/FFstrbuf.h"
|
||||
# include "common/library.h"
|
||||
#include "common/FFstrbuf.h"
|
||||
#include "common/library.h"
|
||||
|
||||
typedef struct FFDBusLibrary {
|
||||
FF_LIBRARY_SYMBOL(dbus_bus_get)
|
||||
@@ -41,6 +41,6 @@ static inline DBusMessage* ffDBusGetAllProperties(FFDBusData* dbus, const char*
|
||||
return ffDBusGetMethodReply(dbus, busName, objectPath, "org.freedesktop.DBus.Properties", "GetAll", interface, NULL);
|
||||
}
|
||||
|
||||
# define FF_DBUS_AUTO_DESTROY_DATA FF_A_CLEANUP(ffDBusDestroyData)
|
||||
#define FF_DBUS_AUTO_DESTROY_DATA FF_A_CLEANUP(ffDBusDestroyData)
|
||||
|
||||
#endif // FF_HAVE_DBUS
|
||||
|
||||
+2
-2
@@ -17,13 +17,13 @@ static inline const char* ffFindFileName(const char* file) {
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
# define FF_DEBUG_PRINT(file_, line_, format_, ...) \
|
||||
#define FF_DEBUG_PRINT(file_, line_, format_, ...) \
|
||||
do { \
|
||||
if (instance.config.display.debugMode) \
|
||||
fprintf(stderr, "[%s%4d, %s] " format_ "\n", ffFindFileName(file_), line_, ffTimeToTimeStr(ffTimeGetNow()), ##__VA_ARGS__); \
|
||||
} while (0)
|
||||
#else
|
||||
# define FF_DEBUG_PRINT(file_, line_, format_, ...) \
|
||||
#define FF_DEBUG_PRINT(file_, line_, format_, ...) \
|
||||
do { \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
@@ -12,17 +12,17 @@
|
||||
#include <paths.h>
|
||||
|
||||
#ifdef __APPLE__
|
||||
# include <mach-o/dyld.h>
|
||||
# include <sys/sysctl.h>
|
||||
#include <mach-o/dyld.h>
|
||||
#include <sys/sysctl.h>
|
||||
#elif defined(__FreeBSD__) || defined(__NetBSD__)
|
||||
# include <sys/sysctl.h>
|
||||
#include <sys/sysctl.h>
|
||||
#elif defined(__OpenBSD__)
|
||||
# include <sys/sysctl.h>
|
||||
# include <kvm.h>
|
||||
# include "common/path.h"
|
||||
#include <sys/sysctl.h>
|
||||
#include <kvm.h>
|
||||
#include "common/path.h"
|
||||
#elif defined(__HAIKU__)
|
||||
# include <image.h>
|
||||
# include <OS.h>
|
||||
#include <image.h>
|
||||
#include <OS.h>
|
||||
#endif
|
||||
|
||||
static void getExePath(FFPlatform* platform) {
|
||||
@@ -43,15 +43,15 @@ static void getExePath(FFPlatform* platform) {
|
||||
size_t exePathLen = sizeof(exePath);
|
||||
if (sysctl(
|
||||
(int[]) { CTL_KERN,
|
||||
# ifdef __FreeBSD__
|
||||
#ifdef __FreeBSD__
|
||||
KERN_PROC,
|
||||
KERN_PROC_PATHNAME,
|
||||
(pid_t) platform->pid
|
||||
# else
|
||||
#else
|
||||
KERN_PROC_ARGS,
|
||||
(pid_t) platform->pid,
|
||||
KERN_PROC_PATHNAME
|
||||
# endif
|
||||
#endif
|
||||
},
|
||||
4,
|
||||
exePath,
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
|
||||
#if defined(FF_HAVE_ELF) || defined(__sun) || (defined(__FreeBSD__) && !defined(__DragonFly__)) || defined(__OpenBSD__) || defined(__NetBSD__)
|
||||
|
||||
# include "common/io.h"
|
||||
# include "common/library.h"
|
||||
# include "common/stringUtils.h"
|
||||
#include "common/io.h"
|
||||
#include "common/library.h"
|
||||
#include "common/stringUtils.h"
|
||||
|
||||
# include <libelf.h> // #1254
|
||||
# include <fcntl.h>
|
||||
#include <libelf.h> // #1254
|
||||
#include <fcntl.h>
|
||||
|
||||
/**
|
||||
* Structure to hold dynamically loaded libelf function pointers
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
#ifdef FF_HAVE_DBUS
|
||||
|
||||
# include "common/thread.h"
|
||||
# include "common/stringUtils.h"
|
||||
#include "common/thread.h"
|
||||
#include "common/stringUtils.h"
|
||||
|
||||
static bool loadLibSymbols(FFDBusLibrary* lib) {
|
||||
FF_LIBRARY_LOAD(dbus, false, "libdbus-1" FF_LIBRARY_EXTENSION, 4);
|
||||
|
||||
@@ -11,10 +11,10 @@
|
||||
#include <unistd.h>
|
||||
#include <locale.h>
|
||||
#ifdef _WIN32
|
||||
# include <windows.h>
|
||||
# include "common/windows/unicode.h"
|
||||
#include <windows.h>
|
||||
#include "common/windows/unicode.h"
|
||||
#else
|
||||
# include <signal.h>
|
||||
#include <signal.h>
|
||||
#endif
|
||||
|
||||
FFinstance instance; // Global singleton
|
||||
|
||||
@@ -8,15 +8,15 @@
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#ifndef __APPLE__
|
||||
# include <poll.h>
|
||||
#include <poll.h>
|
||||
#else
|
||||
# include <sys/select.h>
|
||||
#include <sys/select.h>
|
||||
#endif
|
||||
|
||||
#if FF_HAVE_WORDEXP
|
||||
# include <wordexp.h>
|
||||
#include <wordexp.h>
|
||||
#else
|
||||
# include <glob.h>
|
||||
#include <glob.h>
|
||||
#endif
|
||||
|
||||
static void createSubfolders(const char* fileName) {
|
||||
@@ -112,12 +112,12 @@ bool ffPathExpandEnv(const char* in, FFstrbuf* out) {
|
||||
|
||||
glob_t gb;
|
||||
if (glob(in, GLOB_NOSORT
|
||||
# ifdef GLOB_TILDE
|
||||
#ifdef GLOB_TILDE
|
||||
| GLOB_TILDE
|
||||
# endif
|
||||
# ifdef GLOB_BRACE
|
||||
#endif
|
||||
#ifdef GLOB_BRACE
|
||||
| GLOB_BRACE
|
||||
# endif
|
||||
#endif
|
||||
,
|
||||
NULL,
|
||||
&gb) != 0)
|
||||
|
||||
+21
-21
@@ -2,35 +2,35 @@
|
||||
#include "common/library.h"
|
||||
|
||||
#if _WIN32
|
||||
# include "common/debug.h"
|
||||
# include "common/windows/nt.h"
|
||||
# include <errno.h>
|
||||
# include <ntstatus.h>
|
||||
#include "common/debug.h"
|
||||
#include "common/windows/nt.h"
|
||||
#include <errno.h>
|
||||
#include <ntstatus.h>
|
||||
#endif
|
||||
|
||||
#ifndef FF_DISABLE_DLOPEN
|
||||
|
||||
# include <stdarg.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
// Clang doesn't define __SANITIZE_ADDRESS__ but defines __has_feature(address_sanitizer)
|
||||
# if !defined(__SANITIZE_ADDRESS__) && defined(__has_feature)
|
||||
# if __has_feature(address_sanitizer)
|
||||
# define __SANITIZE_ADDRESS__
|
||||
# endif
|
||||
# endif
|
||||
// Clang doesn't define __SANITIZE_ADDRESS__ but defines __has_feature(address_sanitizer)
|
||||
#if !defined(__SANITIZE_ADDRESS__) && defined(__has_feature)
|
||||
#if __has_feature(address_sanitizer)
|
||||
#define __SANITIZE_ADDRESS__
|
||||
#endif
|
||||
#endif
|
||||
|
||||
# ifndef FF_DLOPEN_FLAGS
|
||||
# ifdef __SANITIZE_ADDRESS__
|
||||
# define FF_DLOPEN_FLAGS RTLD_LAZY | RTLD_NODELETE
|
||||
# else
|
||||
# define FF_DLOPEN_FLAGS RTLD_LAZY
|
||||
# endif
|
||||
# endif
|
||||
#ifndef FF_DLOPEN_FLAGS
|
||||
#ifdef __SANITIZE_ADDRESS__
|
||||
#define FF_DLOPEN_FLAGS RTLD_LAZY | RTLD_NODELETE
|
||||
#else
|
||||
#define FF_DLOPEN_FLAGS RTLD_LAZY
|
||||
#endif
|
||||
#endif
|
||||
|
||||
static void* libraryLoad(const char* path, int maxVersion) {
|
||||
void* result = dlopen(path, FF_DLOPEN_FLAGS);
|
||||
|
||||
# ifdef _WIN32
|
||||
#ifdef _WIN32
|
||||
|
||||
// libX.dll.1 never exists on Windows, while libX-1.dll may exist
|
||||
FF_UNUSED(maxVersion)
|
||||
@@ -48,7 +48,7 @@ static void* libraryLoad(const char* path, int maxVersion) {
|
||||
strcpy(mempcpy(absPath, instance.state.platform.exePath.chars, pathLen + 1), path);
|
||||
return dlopen(absPath, FF_DLOPEN_FLAGS);
|
||||
|
||||
# else
|
||||
#else
|
||||
|
||||
if (result != NULL || maxVersion < 0) {
|
||||
return result;
|
||||
@@ -70,7 +70,7 @@ static void* libraryLoad(const char* path, int maxVersion) {
|
||||
ffStrbufSubstrBefore(&pathbuf, originalLength);
|
||||
}
|
||||
|
||||
# endif
|
||||
#endif
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#include "common/netif.h"
|
||||
|
||||
#ifndef _WIN32
|
||||
# include <net/if.h>
|
||||
# include <netinet/in.h>
|
||||
#include <net/if.h>
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
|
||||
const FFNetifDefaultRouteResult* ffNetifGetDefaultRouteV4(void) {
|
||||
|
||||
@@ -11,13 +11,13 @@
|
||||
#define ROUNDUP2(a, n) ((a) > 0 ? (1 + (((a) - 1U) | ((n) - 1))) : (n))
|
||||
|
||||
#if __APPLE__
|
||||
// https://github.com/apple-oss-distributions/network_cmds/blob/8f38231438e6a4d16ef8015e97e12c2c05105644/rtsol.tproj/if.c#L243
|
||||
# define ROUNDUP(a) ROUNDUP2((a), sizeof(uint32_t))
|
||||
// https://github.com/apple-oss-distributions/network_cmds/blob/8f38231438e6a4d16ef8015e97e12c2c05105644/rtsol.tproj/if.c#L243
|
||||
#define ROUNDUP(a) ROUNDUP2((a), sizeof(uint32_t))
|
||||
#elif __sun
|
||||
// https://github.com/illumos/illumos-gate/blob/95b8c88950fa7b19af46bc63230137cf96b0bff7/usr/src/cmd/cmd-inet/usr.sbin/route.c#L339
|
||||
# define ROUNDUP(a) ROUNDUP2((a), sizeof(long))
|
||||
// https://github.com/illumos/illumos-gate/blob/95b8c88950fa7b19af46bc63230137cf96b0bff7/usr/src/cmd/cmd-inet/usr.sbin/route.c#L339
|
||||
#define ROUNDUP(a) ROUNDUP2((a), sizeof(long))
|
||||
#else
|
||||
# error unknown platform
|
||||
#error unknown platform
|
||||
#endif
|
||||
|
||||
static struct sockaddr*
|
||||
|
||||
@@ -12,19 +12,19 @@
|
||||
#define ROUNDUP2(a, n) ((a) > 0 ? (1 + (((a) - 1U) | ((n) - 1))) : (n))
|
||||
|
||||
#if __DragonFly__
|
||||
// https://github.com/DragonFlyBSD/DragonFlyBSD/blob/cf0aa2f1e47a3f0a6055fe427563cb3f3e627064/sys/net/route.h#L315C9-L315C19
|
||||
# define ROUNDUP(a) ROUNDUP2((a), sizeof(long))
|
||||
// https://github.com/DragonFlyBSD/DragonFlyBSD/blob/cf0aa2f1e47a3f0a6055fe427563cb3f3e627064/sys/net/route.h#L315C9-L315C19
|
||||
#define ROUNDUP(a) ROUNDUP2((a), sizeof(long))
|
||||
#elif __FreeBSD__
|
||||
// https://github.com/freebsd/freebsd-src/blob/e4c0ecba44b20ebb2e4d80978c2cb6d16b730cb9/sys/net/route.h#L368C9-L368C16
|
||||
# define ROUNDUP(a) ROUNDUP2((a), sizeof(long))
|
||||
// https://github.com/freebsd/freebsd-src/blob/e4c0ecba44b20ebb2e4d80978c2cb6d16b730cb9/sys/net/route.h#L368C9-L368C16
|
||||
#define ROUNDUP(a) ROUNDUP2((a), sizeof(long))
|
||||
#elif __NetBSD__
|
||||
// https://github.com/NetBSD/src/blob/29beb637d057520c0ed37ac2cde966f7cc0cadf4/sys/net/route.h#L330
|
||||
# define ROUNDUP(a) ROUNDUP2((a), sizeof(uint64_t))
|
||||
// https://github.com/NetBSD/src/blob/29beb637d057520c0ed37ac2cde966f7cc0cadf4/sys/net/route.h#L330
|
||||
#define ROUNDUP(a) ROUNDUP2((a), sizeof(uint64_t))
|
||||
#elif __OpenBSD__
|
||||
// https://github.com/openbsd/src/blob/ca647cfa4ec3ccb8360714bc0ebc32a394f7fb6a/regress/sys/netinet/bindconnect/bindconnect.c#L250
|
||||
# define ROUNDUP(a) ROUNDUP2((a), sizeof(long))
|
||||
// https://github.com/openbsd/src/blob/ca647cfa4ec3ccb8360714bc0ebc32a394f7fb6a/regress/sys/netinet/bindconnect/bindconnect.c#L250
|
||||
#define ROUNDUP(a) ROUNDUP2((a), sizeof(long))
|
||||
#else
|
||||
# error unknown platform
|
||||
#error unknown platform
|
||||
#endif
|
||||
|
||||
static struct sockaddr*
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include "common/debug.h"
|
||||
|
||||
#ifdef FF_HAVE_ZLIB
|
||||
# include <zlib.h>
|
||||
#include <zlib.h>
|
||||
|
||||
struct FFZlibLibrary {
|
||||
FF_LIBRARY_SYMBOL(inflateInit2_)
|
||||
@@ -19,11 +19,11 @@ const char* ffNetworkingLoadZlibLibrary(void) {
|
||||
if (!zlibData.inited) {
|
||||
zlibData.inited = true;
|
||||
FF_LIBRARY_LOAD_MESSAGE(zlib,
|
||||
# ifdef _WIN32
|
||||
#ifdef _WIN32
|
||||
"zlib1"
|
||||
# else
|
||||
#else
|
||||
"libz"
|
||||
# endif
|
||||
#endif
|
||||
FF_LIBRARY_EXTENSION,
|
||||
2)
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(zlib, zlibData, inflateInit2_)
|
||||
|
||||
@@ -20,56 +20,56 @@ static const char* tryNonThreadingFastPath(FFNetworkingState* state) {
|
||||
#if defined(TCP_FASTOPEN) || __APPLE__
|
||||
|
||||
if (!state->tfo) {
|
||||
# if __linux__ || __GNU__
|
||||
#if __linux__ || __GNU__
|
||||
// Linux doesn't support sendto() on unconnected sockets
|
||||
FF_DEBUG("TCP Fast Open disabled, skipping");
|
||||
return "TCP Fast Open disabled";
|
||||
# endif
|
||||
#endif
|
||||
} else {
|
||||
FF_DEBUG("Attempting to use TCP Fast Open to connect");
|
||||
|
||||
# ifndef __APPLE__ // On macOS, TCP_FASTOPEN doesn't seem to be needed
|
||||
#ifndef __APPLE__ // On macOS, TCP_FASTOPEN doesn't seem to be needed
|
||||
// Set TCP Fast Open
|
||||
int flag = 1;
|
||||
if (setsockopt(state->sockfd, IPPROTO_TCP,
|
||||
# ifdef __APPLE__
|
||||
#ifdef __APPLE__
|
||||
// https://github.com/rust-lang/libc/pull/3135
|
||||
0x218 // TCP_FASTOPEN_FORCE_ENABLE
|
||||
# else
|
||||
#else
|
||||
TCP_FASTOPEN
|
||||
# endif
|
||||
#endif
|
||||
,
|
||||
&flag,
|
||||
sizeof(flag)) != 0) {
|
||||
FF_DEBUG("Failed to set TCP_FASTOPEN option: %s", strerror(errno));
|
||||
return "setsockopt(TCP_FASTOPEN) failed";
|
||||
} else {
|
||||
# if __linux__ || __GNU__
|
||||
#if __linux__ || __GNU__
|
||||
FF_DEBUG("Successfully set TCP_FASTOPEN option, queue length: %d", flag);
|
||||
# elif defined(__APPLE__)
|
||||
#elif defined(__APPLE__)
|
||||
FF_DEBUG("Successfully set TCP_FASTOPEN_FORCE_ENABLE option");
|
||||
# else
|
||||
#else
|
||||
FF_DEBUG("Successfully set TCP_FASTOPEN option");
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
# ifndef __APPLE__
|
||||
#ifndef __APPLE__
|
||||
FF_DEBUG("Using sendto() + MSG_DONTWAIT to send %u bytes of data", state->command.length);
|
||||
ssize_t sent = sendto(state->sockfd,
|
||||
state->command.chars,
|
||||
state->command.length,
|
||||
# ifdef MSG_FASTOPEN
|
||||
#ifdef MSG_FASTOPEN
|
||||
MSG_FASTOPEN |
|
||||
# endif
|
||||
# ifdef MSG_NOSIGNAL
|
||||
#endif
|
||||
#ifdef MSG_NOSIGNAL
|
||||
MSG_NOSIGNAL |
|
||||
# endif
|
||||
#endif
|
||||
MSG_DONTWAIT,
|
||||
state->addr->ai_addr,
|
||||
state->addr->ai_addrlen);
|
||||
# else
|
||||
#else
|
||||
if (fcntl(state->sockfd, F_SETFL, O_NONBLOCK) == -1) {
|
||||
FF_DEBUG("fcntl(F_SETFL) failed: %s", strerror(errno));
|
||||
return "fcntl(F_SETFL) failed";
|
||||
@@ -97,20 +97,20 @@ static const char* tryNonThreadingFastPath(FFNetworkingState* state) {
|
||||
FF_DEBUG("fcntl(F_SETFL) failed: %s", strerror(errno));
|
||||
return "fcntl(F_SETFL) failed";
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
if (sent > 0 || (errno == EAGAIN || errno == EWOULDBLOCK
|
||||
# ifdef __APPLE__
|
||||
#ifdef __APPLE__
|
||||
// On macOS EINPROGRESS means the connection cannot be completed immediately
|
||||
// On Linux, it means the TFO cookie is not available locally
|
||||
|| errno == EINPROGRESS
|
||||
# endif
|
||||
#endif
|
||||
)) {
|
||||
FF_DEBUG(
|
||||
# ifdef __APPLE__
|
||||
#ifdef __APPLE__
|
||||
"connectx()"
|
||||
# else
|
||||
#else
|
||||
"sendto()"
|
||||
# endif
|
||||
#endif
|
||||
" %s (sent=%zd, %s)",
|
||||
errno == 0 ? "succeeded" : "was in progress",
|
||||
sent,
|
||||
@@ -122,18 +122,18 @@ static const char* tryNonThreadingFastPath(FFNetworkingState* state) {
|
||||
}
|
||||
|
||||
FF_DEBUG(
|
||||
# ifdef __APPLE__
|
||||
#ifdef __APPLE__
|
||||
"connectx()"
|
||||
# else
|
||||
#else
|
||||
"sendto()"
|
||||
# endif
|
||||
#endif
|
||||
" failed: %s",
|
||||
strerror(errno));
|
||||
# ifdef __APPLE__
|
||||
#ifdef __APPLE__
|
||||
return "connectx() failed";
|
||||
# else
|
||||
#else
|
||||
return "sendto() failed";
|
||||
# endif
|
||||
#endif
|
||||
#else
|
||||
FF_UNUSED(state);
|
||||
return "TFO support is not available";
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
#include <ctype.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
# pragma GCC diagnostic push
|
||||
# pragma GCC diagnostic ignored "-Wformat"
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wformat"
|
||||
#endif
|
||||
|
||||
void ffParseSemver(FFstrbuf* buffer, const FFstrbuf* major, const FFstrbuf* minor, const FFstrbuf* patch) {
|
||||
@@ -124,5 +124,5 @@ void ffParseGTK(FFstrbuf* buffer, const FFstrbuf* gtk2, const FFstrbuf* gtk3, co
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
# pragma GCC diagnostic pop
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
+15
-15
@@ -9,17 +9,17 @@ const char* ffFindExecutableInPath(const char* name, FFstrbuf* result) {
|
||||
return "$PATH not set";
|
||||
}
|
||||
|
||||
# ifdef _WIN32
|
||||
#ifdef _WIN32
|
||||
const bool appendExe = !ffStrEndsWithIgnCase(name, ".exe");
|
||||
# endif
|
||||
#endif
|
||||
|
||||
for (char* token = path; *token; path = token + 1) {
|
||||
token = strchr(path,
|
||||
# ifdef _WIN32
|
||||
#ifdef _WIN32
|
||||
';'
|
||||
# else
|
||||
#else
|
||||
':'
|
||||
# endif
|
||||
#endif
|
||||
);
|
||||
if (!token) {
|
||||
token = path + strlen(path);
|
||||
@@ -27,25 +27,25 @@ const char* ffFindExecutableInPath(const char* name, FFstrbuf* result) {
|
||||
|
||||
ffStrbufSetNS(result, (uint32_t) (token - path), path);
|
||||
ffStrbufEnsureEndsWithC(result,
|
||||
# ifdef _WIN32
|
||||
#ifdef _WIN32
|
||||
'\\'
|
||||
# else
|
||||
#else
|
||||
'/'
|
||||
# endif
|
||||
#endif
|
||||
);
|
||||
ffStrbufAppendS(result, name);
|
||||
# ifdef _WIN32
|
||||
#ifdef _WIN32
|
||||
if (appendExe) {
|
||||
ffStrbufAppendS(result, ".exe");
|
||||
}
|
||||
if (!ffPathExists(result->chars, FF_PATHTYPE_FILE)) {
|
||||
continue;
|
||||
}
|
||||
# else
|
||||
#else
|
||||
if (access(result->chars, X_OK) != 0) {
|
||||
continue;
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -53,10 +53,10 @@ const char* ffFindExecutableInPath(const char* name, FFstrbuf* result) {
|
||||
return "Executable not found";
|
||||
}
|
||||
#else
|
||||
# include <windows.h>
|
||||
# include <winioctl.h>
|
||||
# include <errno.h>
|
||||
# include <stdalign.h>
|
||||
#include <windows.h>
|
||||
#include <winioctl.h>
|
||||
#include <errno.h>
|
||||
#include <stdalign.h>
|
||||
|
||||
const char* ffFindExecutableInPath(const char* name, FFstrbuf* result) {
|
||||
char buffer[MAX_PATH + 1];
|
||||
|
||||
@@ -13,28 +13,28 @@
|
||||
#include <sys/wait.h>
|
||||
|
||||
#if !(__ANDROID__ || __OpenBSD__)
|
||||
# include <spawn.h>
|
||||
#include <spawn.h>
|
||||
#endif
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__APPLE__)
|
||||
# include <sys/types.h>
|
||||
# include <sys/user.h>
|
||||
# include <sys/sysctl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/user.h>
|
||||
#include <sys/sysctl.h>
|
||||
#endif
|
||||
#if defined(__APPLE__)
|
||||
# include <libproc.h>
|
||||
#include <libproc.h>
|
||||
#elif defined(__sun)
|
||||
# include <procfs.h>
|
||||
#include <procfs.h>
|
||||
#elif defined(__OpenBSD__)
|
||||
# include <sys/param.h>
|
||||
# include <sys/sysctl.h>
|
||||
# include <kvm.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <kvm.h>
|
||||
#elif defined(__NetBSD__)
|
||||
# include <sys/types.h>
|
||||
# include <sys/sysctl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/sysctl.h>
|
||||
#elif defined(__HAIKU__)
|
||||
# include <OS.h>
|
||||
# include <image.h>
|
||||
#include <OS.h>
|
||||
#include <image.h>
|
||||
#endif
|
||||
|
||||
#ifndef environ
|
||||
@@ -234,9 +234,9 @@ void ffProcessGetInfoLinux(pid_t pid, FFstrbuf* processName, FFstrbuf* exe, cons
|
||||
|
||||
// For interpreters, try to find the real script path in the arguments
|
||||
if (ffStrStartsWith(name, "python")
|
||||
# ifndef __ANDROID__
|
||||
#ifndef __ANDROID__
|
||||
|| ffStrEquals(name, "guile") // for shepherd
|
||||
# endif
|
||||
#endif
|
||||
) {
|
||||
// `cmdline` always ends with a trailing '\0', and ffReadFileBuffer appends another \0
|
||||
// So `exe->chars` is always double '\0' terminated
|
||||
@@ -341,15 +341,15 @@ void ffProcessGetInfoLinux(pid_t pid, FFstrbuf* processName, FFstrbuf* exe, cons
|
||||
static_assert(ARG_MAX > PATH_MAX, "");
|
||||
|
||||
if (exePath && sysctl((int[]) { CTL_KERN,
|
||||
# if __FreeBSD__
|
||||
#if __FreeBSD__
|
||||
KERN_PROC,
|
||||
KERN_PROC_PATHNAME,
|
||||
pid
|
||||
# else
|
||||
#else
|
||||
KERN_PROC_ARGS,
|
||||
pid,
|
||||
KERN_PROC_PATHNAME
|
||||
# endif
|
||||
#endif
|
||||
},
|
||||
4,
|
||||
args,
|
||||
@@ -361,15 +361,15 @@ void ffProcessGetInfoLinux(pid_t pid, FFstrbuf* processName, FFstrbuf* exe, cons
|
||||
size = ARG_MAX;
|
||||
if (sysctl(
|
||||
(int[]) { CTL_KERN,
|
||||
# if __FreeBSD__
|
||||
#if __FreeBSD__
|
||||
KERN_PROC,
|
||||
KERN_PROC_ARGS,
|
||||
pid
|
||||
# else
|
||||
#else
|
||||
KERN_PROC_ARGS,
|
||||
pid,
|
||||
KERN_PROC_ARGV,
|
||||
# endif
|
||||
#endif
|
||||
},
|
||||
4,
|
||||
args,
|
||||
@@ -476,9 +476,9 @@ const char* ffProcessGetBasicInfoLinux(pid_t pid, FFstrbuf* name, pid_t* ppid, i
|
||||
#if defined(__linux__) || defined(__GNU__)
|
||||
|
||||
char procFilePath[64];
|
||||
# if __linux__
|
||||
#if __linux__
|
||||
if (ppid || tty)
|
||||
# endif
|
||||
#endif
|
||||
{
|
||||
snprintf(procFilePath, sizeof(procFilePath), "/proc/%d/stat", (int) pid);
|
||||
char buf[PROC_FILE_BUFFSIZ];
|
||||
@@ -509,9 +509,9 @@ const char* ffProcessGetBasicInfoLinux(pid_t pid, FFstrbuf* name, pid_t* ppid, i
|
||||
pState = end + 2; // skip ") "
|
||||
}
|
||||
|
||||
# if !__linux__
|
||||
#if !__linux__
|
||||
if (ppid || tty)
|
||||
# endif
|
||||
#endif
|
||||
{
|
||||
int ppid_, tty_;
|
||||
if (sscanf(pState + 2, "%d %*d %*d %d", &ppid_, &tty_) < 2) {
|
||||
@@ -526,7 +526,7 @@ const char* ffProcessGetBasicInfoLinux(pid_t pid, FFstrbuf* name, pid_t* ppid, i
|
||||
}
|
||||
}
|
||||
}
|
||||
# if __linux__
|
||||
#if __linux__
|
||||
else {
|
||||
snprintf(procFilePath, sizeof(procFilePath), "/proc/%d/comm", (int) pid);
|
||||
ssize_t nRead = ffReadFileBuffer(procFilePath, name);
|
||||
@@ -535,7 +535,7 @@ const char* ffProcessGetBasicInfoLinux(pid_t pid, FFstrbuf* name, pid_t* ppid, i
|
||||
}
|
||||
ffStrbufTrimRightSpace(name);
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#elif defined(__APPLE__)
|
||||
|
||||
@@ -558,12 +558,12 @@ 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
|
||||
#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);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#ifdef _WIN32
|
||||
# include "common/windows/getline.h"
|
||||
#include "common/windows/getline.h"
|
||||
#endif
|
||||
|
||||
bool ffParsePropLinePointer(const char** line, const char* start, FFstrbuf* buffer) {
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#ifdef FF_HAVE_GIO
|
||||
# include <gio/gio.h>
|
||||
#include <gio/gio.h>
|
||||
|
||||
typedef struct GVariantGetters {
|
||||
FF_LIBRARY_SYMBOL(g_variant_dup_string)
|
||||
@@ -124,7 +124,7 @@ FFvariant ffSettingsGetGSettings(const char* schemaName, const char* path, const
|
||||
#endif // FF_HAVE_GIO
|
||||
|
||||
#ifdef FF_HAVE_DCONF
|
||||
# include <dconf.h>
|
||||
#include <dconf.h>
|
||||
|
||||
typedef struct DConfData {
|
||||
FF_LIBRARY_SYMBOL(dconf_client_read_full)
|
||||
@@ -200,7 +200,7 @@ FFvariant ffSettingsGetGnome(const char* dconfKey, const char* gsettingsSchemaNa
|
||||
}
|
||||
|
||||
#ifdef FF_HAVE_DBUS
|
||||
# include "common/dbus.h"
|
||||
#include "common/dbus.h"
|
||||
|
||||
FFvariant ffSettingsGetXFConf(const char* channelName, const char* propertyName, FFvarianttype type) {
|
||||
FF_DBUS_AUTO_DESTROY_DATA FFDBusData dbus = {};
|
||||
@@ -248,7 +248,7 @@ FFvariant ffSettingsGetXFConf(const char* channelName, const char* propertyName,
|
||||
return FF_VARIANT_NULL;
|
||||
}
|
||||
|
||||
# define FF_DBUS_ITER_CONTINUE(dbus, iterator) \
|
||||
#define FF_DBUS_ITER_CONTINUE(dbus, iterator) \
|
||||
{ \
|
||||
if (!(dbus).lib->ffdbus_message_iter_next(iterator)) \
|
||||
break; \
|
||||
@@ -334,7 +334,7 @@ FFvariant ffSettingsGetXFConfFirstMatch(const char* channelName, const char* pro
|
||||
#endif // FF_HAVE_DBUS
|
||||
|
||||
#ifdef FF_HAVE_SQLITE3
|
||||
# include <sqlite3.h>
|
||||
#include <sqlite3.h>
|
||||
|
||||
typedef struct SQLiteData {
|
||||
FF_LIBRARY_SYMBOL(sqlite3_open_v2)
|
||||
@@ -454,7 +454,7 @@ bool ffSettingsGetSQLite3String(const char* dbPath, const char* query, FFstrbuf*
|
||||
#endif // FF_HAVE_SQLITE3
|
||||
|
||||
#ifdef __ANDROID__
|
||||
# include <sys/system_properties.h>
|
||||
#include <sys/system_properties.h>
|
||||
bool ffSettingsGetAndroidProperty(const char* propName, FFstrbuf* result) {
|
||||
ffStrbufEnsureFree(result, PROP_VALUE_MAX);
|
||||
int len = __system_property_get(propName, result->chars + result->length);
|
||||
@@ -466,7 +466,7 @@ bool ffSettingsGetAndroidProperty(const char* propName, FFstrbuf* result) {
|
||||
return true;
|
||||
}
|
||||
#elif defined(__FreeBSD__)
|
||||
# include <kenv.h>
|
||||
#include <kenv.h>
|
||||
bool ffSettingsGetFreeBSDKenv(const char* propName, FFstrbuf* result) {
|
||||
// https://wiki.ghostbsd.org/index.php/Kenv
|
||||
ffStrbufEnsureFree(result, KENV_MVALLEN);
|
||||
|
||||
+41
-41
@@ -141,21 +141,21 @@ static bool parseSmbiosTable(const uint8_t* data, uint32_t length) {
|
||||
}
|
||||
|
||||
#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__sun) || defined(__HAIKU__) || defined(__OpenBSD__) || defined(__GNU__)
|
||||
# include <fcntl.h>
|
||||
# include <sys/stat.h>
|
||||
# include <sys/types.h>
|
||||
# include <sys/mman.h>
|
||||
# include <stddef.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/mman.h>
|
||||
#include <stddef.h>
|
||||
|
||||
# ifdef __linux__
|
||||
# include "common/properties.h"
|
||||
# elif defined(__FreeBSD__)
|
||||
# include "common/settings.h"
|
||||
# elif defined(__NetBSD__)
|
||||
# include "common/sysctl.h"
|
||||
# endif
|
||||
#ifdef __linux__
|
||||
#include "common/properties.h"
|
||||
#elif defined(__FreeBSD__)
|
||||
#include "common/settings.h"
|
||||
#elif defined(__NetBSD__)
|
||||
#include "common/sysctl.h"
|
||||
#endif
|
||||
|
||||
# ifdef __linux__
|
||||
#ifdef __linux__
|
||||
bool ffGetSmbiosValue(const char* devicesPath, const char* classPath, FFstrbuf* buffer) {
|
||||
// /sys/class/dmi/id/* are all pseudo-files with very small content
|
||||
// so reading the whole file at once is efficient
|
||||
@@ -186,10 +186,10 @@ bool ffGetSmbiosValue(const char* devicesPath, const char* classPath, FFstrbuf*
|
||||
ffStrbufClear(buffer);
|
||||
return false;
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
||||
static bool readPhysicalMemory(int fd, off_t address, size_t length, void* buffer) {
|
||||
# if !defined(__FreeBSD__) // Either causes kernel panic or returns EFAULT
|
||||
#if !defined(__FreeBSD__) // Either causes kernel panic or returns EFAULT
|
||||
// -1: unknown, 0: failed before (stop trying), 1: succeeded before
|
||||
static int preadState = -1;
|
||||
if (preadState != 0) {
|
||||
@@ -208,7 +208,7 @@ static bool readPhysicalMemory(int fd, off_t address, size_t length, void* buffe
|
||||
} else {
|
||||
FF_DEBUG("Skipping pread due to cached failure; using mmap");
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
||||
off_t alignedAddress = address & ~((off_t) instance.state.platform.sysinfo.pageSize - 1);
|
||||
size_t pageOffset = (size_t) (address - alignedAddress);
|
||||
@@ -270,11 +270,11 @@ typedef union FFSmbiosEntryPoint {
|
||||
|
||||
static bool fillTableBufferFallback(FFstrbuf* buffer) {
|
||||
const char* devMem =
|
||||
# if __HAIKU__
|
||||
#if __HAIKU__
|
||||
"/dev/misc/mem";
|
||||
# else
|
||||
#else
|
||||
"/dev/mem"; // kern.securelevel must be -1
|
||||
# endif
|
||||
#endif
|
||||
FF_DEBUG("Using physical memory searching implementation: %s", devMem);
|
||||
|
||||
uint32_t tableLength = 0;
|
||||
@@ -355,7 +355,7 @@ static bool fillTableBufferFallback(FFstrbuf* buffer) {
|
||||
return true;
|
||||
}
|
||||
|
||||
# ifdef __OpenBSD__
|
||||
#ifdef __OpenBSD__
|
||||
static bool detectSmbiosTableLength(const uint8_t* data, uint32_t bufferLength, uint32_t* tableLength) {
|
||||
const uint8_t* p = data;
|
||||
const uint8_t* end = data + bufferLength;
|
||||
@@ -500,26 +500,26 @@ static bool fillTableBufferPlatform(FFstrbuf* buffer) {
|
||||
ffStrbufClear(buffer);
|
||||
return false;
|
||||
}
|
||||
# else
|
||||
#else
|
||||
static bool fillTableBufferPlatform(FFstrbuf* buffer) {
|
||||
# if __HAIKU__ && __GNU__
|
||||
#if __HAIKU__ && __GNU__
|
||||
return false;
|
||||
# elif defined(__linux__)
|
||||
#elif defined(__linux__)
|
||||
FF_DEBUG("Using Linux implementation - trying /sys/firmware/dmi/tables/DMI");
|
||||
if (!ffAppendFileBuffer("/sys/firmware/dmi/tables/DMI", buffer))
|
||||
# else
|
||||
#else
|
||||
{
|
||||
# if !defined(__sun) && !defined(__NetBSD__)
|
||||
#if !defined(__sun) && !defined(__NetBSD__)
|
||||
FF_DEBUG("Using memory-mapped implementation");
|
||||
FF_STRBUF_AUTO_DESTROY strEntryAddress = ffStrbufCreate();
|
||||
# ifdef __FreeBSD__
|
||||
#ifdef __FreeBSD__
|
||||
FF_DEBUG("Using FreeBSD kenv implementation");
|
||||
if (!ffSettingsGetFreeBSDKenv("hint.smbios.0.mem", &strEntryAddress)) {
|
||||
FF_DEBUG("Failed to get SMBIOS address from FreeBSD kenv");
|
||||
return false; // non-UEFI systems
|
||||
}
|
||||
FF_DEBUG("Got SMBIOS address from kenv: %s", strEntryAddress.chars);
|
||||
# elif defined(__linux__)
|
||||
#elif defined(__linux__)
|
||||
{
|
||||
FF_DEBUG("Using Linux EFI systab implementation");
|
||||
FF_STRBUF_AUTO_DESTROY systab = ffStrbufCreate();
|
||||
@@ -534,7 +534,7 @@ static bool fillTableBufferPlatform(FFstrbuf* buffer) {
|
||||
}
|
||||
FF_DEBUG("Found SMBIOS entry in systab: %s", strEntryAddress.chars);
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
||||
off_t entryAddress = (off_t) strtol(strEntryAddress.chars, NULL, 16);
|
||||
if (entryAddress == 0) {
|
||||
@@ -558,14 +558,14 @@ static bool fillTableBufferPlatform(FFstrbuf* buffer) {
|
||||
return false;
|
||||
}
|
||||
FF_DEBUG("Successfully read SMBIOS entry point data");
|
||||
# else
|
||||
#else
|
||||
// Sun or NetBSD
|
||||
FF_DEBUG("Using %s specific implementation",
|
||||
# ifdef __NetBSD__
|
||||
#ifdef __NetBSD__
|
||||
"NetBSD"
|
||||
# else
|
||||
#else
|
||||
"SunOS"
|
||||
# endif
|
||||
#endif
|
||||
);
|
||||
|
||||
FF_AUTO_CLOSE_FD int fd = open("/dev/smbios", O_RDONLY | O_CLOEXEC);
|
||||
@@ -576,7 +576,7 @@ static bool fillTableBufferPlatform(FFstrbuf* buffer) {
|
||||
FF_DEBUG("/dev/smbios opened successfully with fd=%d", fd);
|
||||
|
||||
FFSmbiosEntryPoint entryPoint;
|
||||
# ifdef __NetBSD__
|
||||
#ifdef __NetBSD__
|
||||
off_t addr = (off_t) ffSysctlGetInt64("machdep.smbios", 0);
|
||||
if (addr == 0) {
|
||||
FF_DEBUG("Failed to get SMBIOS address from sysctl");
|
||||
@@ -589,15 +589,15 @@ static bool fillTableBufferPlatform(FFstrbuf* buffer) {
|
||||
return false;
|
||||
}
|
||||
FF_DEBUG("Successfully read SMBIOS entry point");
|
||||
# else
|
||||
#else
|
||||
FF_DEBUG("Reading SMBIOS entry point from /dev/smbios");
|
||||
if (ffReadFDData(fd, sizeof(entryPoint), &entryPoint) < 1) {
|
||||
FF_DEBUG("Failed to read SMBIOS entry point: %s", strerror(errno));
|
||||
return false;
|
||||
}
|
||||
FF_DEBUG("Successfully read SMBIOS entry point");
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
uint32_t tableLength = 0;
|
||||
off_t tableAddress = 0;
|
||||
@@ -649,11 +649,11 @@ static bool fillTableBufferPlatform(FFstrbuf* buffer) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
||||
const FFSmbiosHeaderTable* ffGetSmbiosHeaderTable() {
|
||||
static FFstrbuf buffer;
|
||||
@@ -684,9 +684,9 @@ const FFSmbiosHeaderTable* ffGetSmbiosHeaderTable() {
|
||||
return &smbiosTable;
|
||||
}
|
||||
#elif defined(_WIN32)
|
||||
# include "common/windows/nt.h"
|
||||
#include "common/windows/nt.h"
|
||||
|
||||
# pragma GCC diagnostic ignored "-Wmultichar"
|
||||
#pragma GCC diagnostic ignored "-Wmultichar"
|
||||
|
||||
typedef struct FFRawSmbiosData {
|
||||
uint8_t Used20CallingMethod;
|
||||
@@ -754,7 +754,7 @@ const FFSmbiosHeaderTable* ffGetSmbiosHeaderTable() {
|
||||
return &smbiosTable;
|
||||
}
|
||||
#elif defined(__APPLE__)
|
||||
# include "common/apple/cf_helpers.h"
|
||||
#include "common/apple/cf_helpers.h"
|
||||
|
||||
const FFSmbiosHeaderTable* ffGetSmbiosHeaderTable() {
|
||||
static CFDataRef smbiosDataBuffer;
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
char ffTimeInternalBuffer[64]; // Reduce memory usage and prevent redundant allocations
|
||||
|
||||
#ifdef _WIN32
|
||||
# pragma GCC diagnostic push
|
||||
# pragma GCC diagnostic ignored "-Wformat"
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wformat"
|
||||
#endif
|
||||
|
||||
const char* ffTimeToFullStr(uint64_t msec) {
|
||||
@@ -45,7 +45,7 @@ const char* ffTimeToTimeStr(uint64_t msec) {
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
# pragma GCC diagnostic pop
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
FFTimeGetAgeResult ffTimeGetAge(uint64_t birthMs, uint64_t nowMs) {
|
||||
|
||||
+24
-24
@@ -4,36 +4,36 @@
|
||||
#include "common/FFlist.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
# include <fileapi.h>
|
||||
# include <handleapi.h>
|
||||
# include <io.h>
|
||||
# include "common/windows/nt.h"
|
||||
#include <fileapi.h>
|
||||
#include <handleapi.h>
|
||||
#include <io.h>
|
||||
#include "common/windows/nt.h"
|
||||
typedef HANDLE FFNativeFD;
|
||||
# define FF_INVALID_FD INVALID_HANDLE_VALUE
|
||||
#define FF_INVALID_FD INVALID_HANDLE_VALUE
|
||||
#else
|
||||
# include <unistd.h>
|
||||
# include <dirent.h>
|
||||
# include <sys/stat.h>
|
||||
# include <errno.h>
|
||||
# include <limits.h>
|
||||
# include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <dirent.h>
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
#include <fcntl.h>
|
||||
typedef int FFNativeFD;
|
||||
# define FF_INVALID_FD (-1)
|
||||
// procfs's file can be changed between read calls such as /proc/meminfo and /proc/uptime.
|
||||
// one safe way to read correct data is reading the whole file in a single read syscall
|
||||
# define PROC_FILE_BUFFSIZ (32 * 1024)
|
||||
#define FF_INVALID_FD (-1)
|
||||
// procfs's file can be changed between read calls such as /proc/meminfo and /proc/uptime.
|
||||
// one safe way to read correct data is reading the whole file in a single read syscall
|
||||
#define PROC_FILE_BUFFSIZ (32 * 1024)
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
# ifndef O_CLOEXEC
|
||||
# define O_CLOEXEC 0
|
||||
# endif
|
||||
# ifndef O_RDONLY
|
||||
# define O_RDONLY 0
|
||||
# endif
|
||||
# ifndef O_DIRECTORY
|
||||
# define O_DIRECTORY 0200000
|
||||
# endif
|
||||
#ifndef O_CLOEXEC
|
||||
#define O_CLOEXEC 0
|
||||
#endif
|
||||
#ifndef O_RDONLY
|
||||
#define O_RDONLY 0
|
||||
#endif
|
||||
#ifndef O_DIRECTORY
|
||||
#define O_DIRECTORY 0200000
|
||||
#endif
|
||||
|
||||
// Only O_RDONLY is supported
|
||||
HANDLE openat(HANDLE dfd, const char* fileName, int oflag);
|
||||
|
||||
+36
-36
@@ -4,22 +4,22 @@
|
||||
|
||||
#ifndef FF_DISABLE_DLOPEN
|
||||
|
||||
# if defined(_WIN32)
|
||||
# define FF_DLOPEN_FLAGS 0
|
||||
#if defined(_WIN32)
|
||||
#define FF_DLOPEN_FLAGS 0
|
||||
FF_A_NODISCARD void* dlopen(const char* path, int mode);
|
||||
FF_A_NODISCARD void* dlsym(void* handle, const char* symbol);
|
||||
int dlclose(void* handle);
|
||||
# else
|
||||
# include <dlfcn.h>
|
||||
# endif
|
||||
#else
|
||||
#include <dlfcn.h>
|
||||
#endif
|
||||
|
||||
# ifdef _WIN32
|
||||
# define FF_LIBRARY_EXTENSION ".dll"
|
||||
# elif defined(__APPLE__)
|
||||
# define FF_LIBRARY_EXTENSION ".dylib"
|
||||
# else
|
||||
# define FF_LIBRARY_EXTENSION ".so"
|
||||
# endif
|
||||
#ifdef _WIN32
|
||||
#define FF_LIBRARY_EXTENSION ".dll"
|
||||
#elif defined(__APPLE__)
|
||||
#define FF_LIBRARY_EXTENSION ".dylib"
|
||||
#else
|
||||
#define FF_LIBRARY_EXTENSION ".so"
|
||||
#endif
|
||||
|
||||
static inline void ffLibraryUnload(void** handle) {
|
||||
assert(handle);
|
||||
@@ -28,78 +28,78 @@ static inline void ffLibraryUnload(void** handle) {
|
||||
}
|
||||
}
|
||||
|
||||
# if __cplusplus
|
||||
# define __auto_type auto
|
||||
# endif
|
||||
#if __cplusplus
|
||||
#define __auto_type auto
|
||||
#endif
|
||||
|
||||
# define FF_LIBRARY_SYMBOL(symbolName) \
|
||||
#define FF_LIBRARY_SYMBOL(symbolName) \
|
||||
__typeof__(&symbolName) ff##symbolName;
|
||||
|
||||
# define FF_LIBRARY_LOAD(libraryObjectName, returnValue, ...) \
|
||||
#define FF_LIBRARY_LOAD(libraryObjectName, returnValue, ...) \
|
||||
void* FF_A_CLEANUP(ffLibraryUnload) libraryObjectName = ffLibraryLoad(__VA_ARGS__, NULL); \
|
||||
if (libraryObjectName == NULL) \
|
||||
return returnValue;
|
||||
|
||||
# define FF_LIBRARY_LOAD_MESSAGE(libraryObjectName, libraryFileName, maxVersion, ...) \
|
||||
#define FF_LIBRARY_LOAD_MESSAGE(libraryObjectName, libraryFileName, maxVersion, ...) \
|
||||
FF_LIBRARY_LOAD(libraryObjectName, "dlopen(" libraryFileName ") failed", libraryFileName, maxVersion, ##__VA_ARGS__)
|
||||
|
||||
# define FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, symbolMapping, symbolName, returnValue) \
|
||||
#define FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, symbolMapping, symbolName, returnValue) \
|
||||
symbolMapping = (__typeof__(&symbolName)) dlsym(library, #symbolName); \
|
||||
if (symbolMapping == NULL) \
|
||||
return returnValue;
|
||||
|
||||
# define FF_LIBRARY_LOAD_SYMBOL(library, symbolName, returnValue) \
|
||||
#define FF_LIBRARY_LOAD_SYMBOL(library, symbolName, returnValue) \
|
||||
__auto_type FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, ff##symbolName, symbolName, returnValue);
|
||||
|
||||
# define FF_LIBRARY_LOAD_SYMBOL_LAZY(library, symbolName) \
|
||||
#define FF_LIBRARY_LOAD_SYMBOL_LAZY(library, symbolName) \
|
||||
__auto_type ff##symbolName = (__typeof__(&symbolName)) dlsym(library, #symbolName);
|
||||
|
||||
# define FF_LIBRARY_LOAD_SYMBOL_MESSAGE(library, symbolName) \
|
||||
#define FF_LIBRARY_LOAD_SYMBOL_MESSAGE(library, symbolName) \
|
||||
__auto_type FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, ff##symbolName, symbolName, "dlsym " #symbolName " failed");
|
||||
|
||||
# define FF_LIBRARY_LOAD_SYMBOL_VAR(library, varName, symbolName, returnValue) \
|
||||
#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) \
|
||||
#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_PTR(library, varName, symbolName, returnValue) \
|
||||
#define FF_LIBRARY_LOAD_SYMBOL_PTR(library, varName, symbolName, returnValue) \
|
||||
FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, (varName)->ff##symbolName, symbolName, returnValue);
|
||||
|
||||
void* ffLibraryLoad(const char* path, int maxVersion, ...);
|
||||
|
||||
#else
|
||||
|
||||
# define FF_LIBRARY_EXTENSION ""
|
||||
#define FF_LIBRARY_EXTENSION ""
|
||||
|
||||
# define FF_LIBRARY_SYMBOL(symbolName) \
|
||||
#define FF_LIBRARY_SYMBOL(symbolName) \
|
||||
__typeof__(&symbolName) ff##symbolName;
|
||||
|
||||
# define FF_LIBRARY_LOAD(libraryObjectName, returnValue, ...) \
|
||||
#define FF_LIBRARY_LOAD(libraryObjectName, returnValue, ...) \
|
||||
FF_A_UNUSED void* libraryObjectName = NULL; // Placeholder
|
||||
|
||||
# define FF_LIBRARY_LOAD_MESSAGE(libraryObjectName, libraryFileName, maxVersion, ...) \
|
||||
#define FF_LIBRARY_LOAD_MESSAGE(libraryObjectName, libraryFileName, maxVersion, ...) \
|
||||
FF_LIBRARY_LOAD(libraryObjectName, , libraryFileName, maxVersion, ##__VA_ARGS__)
|
||||
|
||||
# define FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, symbolMapping, symbolName, returnValue) \
|
||||
#define FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, symbolMapping, symbolName, returnValue) \
|
||||
symbolMapping = (__typeof__(&symbolName)) &symbolName;
|
||||
|
||||
# define FF_LIBRARY_LOAD_SYMBOL(library, symbolName, returnValue) \
|
||||
#define FF_LIBRARY_LOAD_SYMBOL(library, symbolName, returnValue) \
|
||||
FF_A_UNUSED __auto_type FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, ff##symbolName, symbolName, returnValue);
|
||||
|
||||
# define FF_LIBRARY_LOAD_SYMBOL_LAZY(library, symbolName) \
|
||||
#define FF_LIBRARY_LOAD_SYMBOL_LAZY(library, symbolName) \
|
||||
FF_A_UNUSED __auto_type ff##symbolName = (__typeof__(&symbolName)) &symbolName;
|
||||
|
||||
# define FF_LIBRARY_LOAD_SYMBOL_MESSAGE(library, symbolName) \
|
||||
#define FF_LIBRARY_LOAD_SYMBOL_MESSAGE(library, symbolName) \
|
||||
FF_A_UNUSED __auto_type FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, ff##symbolName, symbolName, "dlsym " #symbolName " failed");
|
||||
|
||||
# define FF_LIBRARY_LOAD_SYMBOL_VAR(library, varName, symbolName, returnValue) \
|
||||
#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) \
|
||||
#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_PTR(library, varName, symbolName, returnValue) \
|
||||
#define FF_LIBRARY_LOAD_SYMBOL_PTR(library, varName, symbolName, returnValue) \
|
||||
FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, (varName)->ff##symbolName, symbolName, returnValue);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -4,13 +4,13 @@
|
||||
#include <assert.h>
|
||||
|
||||
#if FF_HAVE_MALLOC_USABLE_SIZE || FF_HAVE_MSVC_MSIZE
|
||||
# if __has_include(<malloc.h>)
|
||||
# include <malloc.h>
|
||||
# else
|
||||
# include <malloc_np.h> // For DragonFly BSD
|
||||
# endif
|
||||
#if __has_include(<malloc.h>)
|
||||
#include <malloc.h>
|
||||
#else
|
||||
#include <malloc_np.h> // For DragonFly BSD
|
||||
#endif
|
||||
#elif FF_HAVE_MALLOC_SIZE
|
||||
# include <malloc/malloc.h>
|
||||
#include <malloc/malloc.h>
|
||||
#endif
|
||||
|
||||
static inline void ffWrapFree(const void* pPtr) {
|
||||
|
||||
+2
-2
@@ -3,8 +3,8 @@
|
||||
#include "fastfetch.h"
|
||||
|
||||
#ifndef _WIN32
|
||||
# include <net/if.h>
|
||||
# include <netinet/in.h>
|
||||
#include <net/if.h>
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
|
||||
typedef enum FF_A_PACKED FFNetifDefaultRouteResultStatus {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "common/FFstrbuf.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
# include <minwindef.h>
|
||||
#include <minwindef.h>
|
||||
#endif
|
||||
|
||||
struct addrinfo;
|
||||
@@ -17,9 +17,9 @@ typedef struct FFNetworkingState {
|
||||
int sockfd;
|
||||
struct addrinfo* addr;
|
||||
|
||||
# ifdef FF_HAVE_THREADS
|
||||
#ifdef FF_HAVE_THREADS
|
||||
FFThreadType thread;
|
||||
# endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
FFstrbuf command;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "common/FFstrbuf.h"
|
||||
|
||||
#ifndef _WIN32
|
||||
# include <sys/types.h> // pid_t
|
||||
#include <sys/types.h> // pid_t
|
||||
#endif
|
||||
|
||||
typedef struct FFProcessHandle {
|
||||
|
||||
+27
-27
@@ -3,12 +3,12 @@
|
||||
#include "fastfetch.h"
|
||||
|
||||
#ifdef FF_HAVE_THREADS
|
||||
# if defined(_WIN32)
|
||||
# include <winternl.h>
|
||||
# include <synchapi.h>
|
||||
# include <process.h>
|
||||
# include <processthreadsapi.h>
|
||||
# define FF_THREAD_MUTEX_INITIALIZER SRWLOCK_INIT
|
||||
#if defined(_WIN32)
|
||||
#include <winternl.h>
|
||||
#include <synchapi.h>
|
||||
#include <process.h>
|
||||
#include <processthreadsapi.h>
|
||||
#define FF_THREAD_MUTEX_INITIALIZER SRWLOCK_INIT
|
||||
typedef SRWLOCK FFThreadMutex;
|
||||
typedef HANDLE FFThreadType;
|
||||
static inline void ffThreadMutexLock(FFThreadMutex* mutex) {
|
||||
@@ -20,12 +20,12 @@ static inline void ffThreadMutexUnlock(FFThreadMutex* mutex) {
|
||||
static inline FFThreadType ffThreadCreate(unsigned(__stdcall* func)(void*), void* data) {
|
||||
return (FFThreadType) _beginthreadex(NULL, 0, func, data, 0, NULL);
|
||||
}
|
||||
# define FF_THREAD_ENTRY_DECL_WRAPPER(fn, paramType) \
|
||||
#define FF_THREAD_ENTRY_DECL_WRAPPER(fn, paramType) \
|
||||
static __stdcall unsigned fn##ThreadMain(void* data) { \
|
||||
fn((paramType) data); \
|
||||
return 0; \
|
||||
}
|
||||
# define FF_THREAD_ENTRY_DECL_WRAPPER_NOPARAM(fn) \
|
||||
#define FF_THREAD_ENTRY_DECL_WRAPPER_NOPARAM(fn) \
|
||||
static __stdcall unsigned fn##ThreadMain() { \
|
||||
fn(); \
|
||||
return 0; \
|
||||
@@ -42,16 +42,16 @@ static inline bool ffThreadJoin(FFThreadType thread, uint32_t timeout) {
|
||||
NtClose(thread);
|
||||
return true;
|
||||
}
|
||||
# else
|
||||
# include <pthread.h>
|
||||
# include <signal.h>
|
||||
# if FF_HAVE_PTHREAD_NP
|
||||
# include <pthread_np.h>
|
||||
# endif
|
||||
#else
|
||||
#include <pthread.h>
|
||||
#include <signal.h>
|
||||
#if FF_HAVE_PTHREAD_NP
|
||||
#include <pthread_np.h>
|
||||
#endif
|
||||
typedef pthread_t FFThreadType;
|
||||
# if __APPLE__
|
||||
# include <os/lock.h>
|
||||
# define FF_THREAD_MUTEX_INITIALIZER OS_UNFAIR_LOCK_INIT
|
||||
#if __APPLE__
|
||||
#include <os/lock.h>
|
||||
#define FF_THREAD_MUTEX_INITIALIZER OS_UNFAIR_LOCK_INIT
|
||||
typedef os_unfair_lock FFThreadMutex;
|
||||
static inline void ffThreadMutexLock(os_unfair_lock* mutex) {
|
||||
os_unfair_lock_lock(mutex);
|
||||
@@ -59,8 +59,8 @@ static inline void ffThreadMutexLock(os_unfair_lock* mutex) {
|
||||
static inline void ffThreadMutexUnlock(os_unfair_lock* mutex) {
|
||||
os_unfair_lock_unlock(mutex);
|
||||
}
|
||||
# else
|
||||
# define FF_THREAD_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
|
||||
#else
|
||||
#define FF_THREAD_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
|
||||
typedef pthread_mutex_t FFThreadMutex;
|
||||
static inline void ffThreadMutexLock(FFThreadMutex* mutex) {
|
||||
pthread_mutex_lock(mutex);
|
||||
@@ -68,18 +68,18 @@ static inline void ffThreadMutexLock(FFThreadMutex* mutex) {
|
||||
static inline void ffThreadMutexUnlock(FFThreadMutex* mutex) {
|
||||
pthread_mutex_unlock(mutex);
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
static inline FFThreadType ffThreadCreate(void* (*func)(void*), void* data) {
|
||||
FFThreadType newThread = 0;
|
||||
pthread_create(&newThread, NULL, func, data);
|
||||
return newThread;
|
||||
}
|
||||
# define FF_THREAD_ENTRY_DECL_WRAPPER(fn, paramType) \
|
||||
#define FF_THREAD_ENTRY_DECL_WRAPPER(fn, paramType) \
|
||||
static void* fn##ThreadMain(void* data) { \
|
||||
fn((paramType) data); \
|
||||
return NULL; \
|
||||
}
|
||||
# define FF_THREAD_ENTRY_DECL_WRAPPER_NOPARAM(fn) \
|
||||
#define FF_THREAD_ENTRY_DECL_WRAPPER_NOPARAM(fn) \
|
||||
static void* fn##ThreadMain() { \
|
||||
fn(); \
|
||||
return NULL; \
|
||||
@@ -88,7 +88,7 @@ static inline void ffThreadDetach(FFThreadType thread) {
|
||||
pthread_detach(thread);
|
||||
}
|
||||
static inline bool ffThreadJoin(FFThreadType thread, FF_A_UNUSED uint32_t timeout) {
|
||||
# if HAVE_TIMEDJOIN_NP
|
||||
#if HAVE_TIMEDJOIN_NP
|
||||
if (timeout > 0) {
|
||||
struct timespec ts;
|
||||
if (clock_gettime(CLOCK_REALTIME, &ts) == 0) {
|
||||
@@ -101,15 +101,15 @@ static inline bool ffThreadJoin(FFThreadType thread, FF_A_UNUSED uint32_t timeou
|
||||
return true;
|
||||
}
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
pthread_join(thread, NULL);
|
||||
return true;
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
#else // FF_HAVE_THREADS
|
||||
# define FF_THREAD_MUTEX_INITIALIZER 0
|
||||
#define FF_THREAD_MUTEX_INITIALIZER 0
|
||||
typedef char FFThreadMutex;
|
||||
static inline void ffThreadMutexLock(FF_A_UNUSED FFThreadMutex* mutex) {}
|
||||
static inline void ffThreadMutexUnlock(FF_A_UNUSED FFThreadMutex* mutex) {}
|
||||
# define FF_THREAD_ENTRY_DECL_WRAPPER(fn, paramType)
|
||||
#define FF_THREAD_ENTRY_DECL_WRAPPER(fn, paramType)
|
||||
#endif // FF_HAVE_THREADS
|
||||
|
||||
+4
-4
@@ -4,11 +4,11 @@
|
||||
#include <stdint.h>
|
||||
#include <time.h>
|
||||
#ifdef _WIN32
|
||||
# include <ntstatus.h>
|
||||
# include "common/windows/nt.h"
|
||||
# include <profileapi.h>
|
||||
#include <ntstatus.h>
|
||||
#include "common/windows/nt.h"
|
||||
#include <profileapi.h>
|
||||
#elif defined(__HAIKU__)
|
||||
# include <OS.h>
|
||||
#include <OS.h>
|
||||
#endif
|
||||
|
||||
#include "common/arrayUtils.h"
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef FF_HAVE_WCWIDTH
|
||||
# include <wchar.h>
|
||||
#include <wchar.h>
|
||||
|
||||
// Should be char32_t but it's not defined on macOS
|
||||
static_assert(sizeof(wchar_t) == sizeof(uint32_t), "wcwidth implementation requires wchar_t to be 32 bits");
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
# include <unknwn.h>
|
||||
#include <unknwn.h>
|
||||
|
||||
const char* ffInitCom(void);
|
||||
|
||||
@@ -13,9 +13,9 @@ static inline void ffReleaseComObject(void* ppUnknown) {
|
||||
}
|
||||
}
|
||||
|
||||
# define FF_AUTO_RELEASE_COM_OBJECT FF_A_CLEANUP(ffReleaseComObject)
|
||||
#define FF_AUTO_RELEASE_COM_OBJECT FF_A_CLEANUP(ffReleaseComObject)
|
||||
|
||||
#else
|
||||
// Win32 COM headers requires C++ compiler
|
||||
# error Must be included in C++ source file
|
||||
// Win32 COM headers requires C++ compiler
|
||||
#error Must be included in C++ source file
|
||||
#endif
|
||||
|
||||
@@ -63,7 +63,7 @@ typedef struct _PROCESS_DEVICEMAP_INFORMATION_EX {
|
||||
} PROCESS_DEVICEMAP_INFORMATION_EX, *PPROCESS_DEVICEMAP_INFORMATION_EX;
|
||||
|
||||
#ifndef NtCurrentProcess
|
||||
# define NtCurrentProcess() ((HANDLE) (LONG_PTR) - 1)
|
||||
#define NtCurrentProcess() ((HANDLE) (LONG_PTR) - 1)
|
||||
#endif
|
||||
|
||||
typedef struct _CURDIR {
|
||||
|
||||
@@ -5,14 +5,14 @@
|
||||
#include "common/io.h"
|
||||
|
||||
#ifndef HKEY_CURRENT_USER
|
||||
# define HKEY_CLASSES_ROOT ((HKEY) (ULONG_PTR) ((LONG) 0x80000000))
|
||||
# define HKEY_CURRENT_USER ((HKEY) (ULONG_PTR) ((LONG) 0x80000001))
|
||||
# define HKEY_LOCAL_MACHINE ((HKEY) (ULONG_PTR) ((LONG) 0x80000002))
|
||||
# define HKEY_USERS ((HKEY) (ULONG_PTR) ((LONG) 0x80000003))
|
||||
# define HKEY_PERFORMANCE_DATA ((HKEY) (ULONG_PTR) ((LONG) 0x80000004))
|
||||
# define HKEY_CURRENT_CONFIG ((HKEY) (ULONG_PTR) ((LONG) 0x80000005))
|
||||
# define HKEY_DYN_DATA ((HKEY) (ULONG_PTR) ((LONG) 0x80000006))
|
||||
# define HKEY_CURRENT_USER_LOCAL_SETTINGS ((HKEY) (ULONG_PTR) ((LONG) 0x80000007))
|
||||
#define HKEY_CLASSES_ROOT ((HKEY) (ULONG_PTR) ((LONG) 0x80000000))
|
||||
#define HKEY_CURRENT_USER ((HKEY) (ULONG_PTR) ((LONG) 0x80000001))
|
||||
#define HKEY_LOCAL_MACHINE ((HKEY) (ULONG_PTR) ((LONG) 0x80000002))
|
||||
#define HKEY_USERS ((HKEY) (ULONG_PTR) ((LONG) 0x80000003))
|
||||
#define HKEY_PERFORMANCE_DATA ((HKEY) (ULONG_PTR) ((LONG) 0x80000004))
|
||||
#define HKEY_CURRENT_CONFIG ((HKEY) (ULONG_PTR) ((LONG) 0x80000005))
|
||||
#define HKEY_DYN_DATA ((HKEY) (ULONG_PTR) ((LONG) 0x80000006))
|
||||
#define HKEY_CURRENT_USER_LOCAL_SETTINGS ((HKEY) (ULONG_PTR) ((LONG) 0x80000007))
|
||||
#endif
|
||||
|
||||
typedef struct FFRegValueArg {
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
#ifdef __cplusplus
|
||||
|
||||
extern "C" {
|
||||
# include "unicode.h"
|
||||
#include "unicode.h"
|
||||
}
|
||||
|
||||
# include <string_view>
|
||||
#include <string_view>
|
||||
|
||||
static inline void ffStrbufInitWSV(FFstrbuf* result, const std::wstring_view source) {
|
||||
return ffStrbufInitNWS(result, (uint32_t) source.size(), source.data());
|
||||
@@ -22,6 +22,6 @@ static inline void ffStrbufSetWSV(FFstrbuf* result, const std::wstring_view sour
|
||||
|
||||
#else
|
||||
|
||||
# error Must be included in C++ source file
|
||||
#error Must be included in C++ source file
|
||||
|
||||
#endif
|
||||
|
||||
@@ -3,13 +3,13 @@
|
||||
#ifdef __cplusplus
|
||||
|
||||
extern "C" {
|
||||
# include "fastfetch.h"
|
||||
#include "fastfetch.h"
|
||||
}
|
||||
|
||||
# include <initguid.h>
|
||||
# include <wbemidl.h>
|
||||
#include <initguid.h>
|
||||
#include <wbemidl.h>
|
||||
|
||||
# include "variant.hpp"
|
||||
#include "variant.hpp"
|
||||
|
||||
enum class FFWmiNamespace {
|
||||
CIMV2,
|
||||
@@ -92,6 +92,6 @@ struct FFWmiQuery {
|
||||
};
|
||||
|
||||
#else
|
||||
// Win32 COM headers requires C++ compiler
|
||||
# error Must be included in C++ source file
|
||||
// Win32 COM headers requires C++ compiler
|
||||
#error Must be included in C++ source file
|
||||
#endif //__cplusplus
|
||||
|
||||
Reference in New Issue
Block a user