mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 02:42:09 +02:00
Style: adds Cpp11BracedListStyle: Block
This commit is contained in:
@@ -55,6 +55,7 @@ BinPackParameters: false
|
||||
BinPackArguments: false
|
||||
AlignAfterOpenBracket: DontAlign
|
||||
BracedInitializerIndentWidth: 4
|
||||
Cpp11BracedListStyle: Block
|
||||
|
||||
ForEachMacros:
|
||||
- FF_LIST_FOR_EACH
|
||||
|
||||
@@ -92,8 +92,8 @@ static const char* smcCall(io_connect_t conn, uint32_t selector, SmcKeyData_t* i
|
||||
|
||||
// Provides key info, using a cache to dramatically improve the energy impact of smcFanControl
|
||||
static const char* smcGetKeyInfo(io_connect_t conn, const uint32_t key, SmcKeyData_keyInfo_t* key_info) {
|
||||
SmcKeyData_t inputStructure = {0};
|
||||
SmcKeyData_t outputStructure = {0};
|
||||
SmcKeyData_t inputStructure = { 0 };
|
||||
SmcKeyData_t outputStructure = { 0 };
|
||||
|
||||
inputStructure.key = key;
|
||||
inputStructure.data8 = kSmcCmdReadKeyInfo;
|
||||
@@ -108,8 +108,8 @@ static const char* smcGetKeyInfo(io_connect_t conn, const uint32_t key, SmcKeyDa
|
||||
}
|
||||
|
||||
static const char* smcReadSmcVal(io_connect_t conn, const UInt32Char_t key, SmcVal_t* val) {
|
||||
SmcKeyData_t inputStructure = {0};
|
||||
SmcKeyData_t outputStructure = {0};
|
||||
SmcKeyData_t inputStructure = { 0 };
|
||||
SmcKeyData_t outputStructure = { 0 };
|
||||
|
||||
inputStructure.key = smcStrtoul(key, 4, 16);
|
||||
strcpy(val->key, key);
|
||||
@@ -148,7 +148,7 @@ static const char* smcOpen(io_connect_t* conn) {
|
||||
}
|
||||
|
||||
static const char* smcReadValue(io_connect_t conn, const UInt32Char_t key, double* value) {
|
||||
SmcVal_t val = {0};
|
||||
SmcVal_t val = { 0 };
|
||||
const char* error = smcReadSmcVal(conn, key, &val);
|
||||
if (error != NULL) {
|
||||
return error;
|
||||
|
||||
@@ -26,7 +26,7 @@ typedef enum __attribute__((__packed__)) FFArgType {
|
||||
FF_ARG_TYPE_BUFFER,
|
||||
} FFArgType;
|
||||
|
||||
#define FF_ARG(variable, var_name) {_Generic((variable), \
|
||||
#define FF_ARG(variable, var_name) { _Generic((variable), \
|
||||
uint32_t: FF_ARG_TYPE_UINT, \
|
||||
uint64_t: FF_ARG_TYPE_UINT64, \
|
||||
uint16_t: FF_ARG_TYPE_UINT16, \
|
||||
@@ -41,4 +41,4 @@ typedef enum __attribute__((__packed__)) FFArgType {
|
||||
bool: FF_ARG_TYPE_BOOL, \
|
||||
FFArgBuffer: FF_ARG_TYPE_BUFFER), \
|
||||
_Generic((variable), char*: (variable), const char*: (variable), default: &(variable)), \
|
||||
(var_name)}
|
||||
(var_name) }
|
||||
|
||||
@@ -42,7 +42,7 @@ static void getExePath(FFPlatform* platform) {
|
||||
#elif defined(__FreeBSD__) || defined(__NetBSD__)
|
||||
size_t exePathLen = sizeof(exePath);
|
||||
if (sysctl(
|
||||
(int[]) {CTL_KERN,
|
||||
(int[]) { CTL_KERN,
|
||||
# ifdef __FreeBSD__
|
||||
KERN_PROC,
|
||||
KERN_PROC_PATHNAME,
|
||||
@@ -281,7 +281,7 @@ static void getSysinfo(FFPlatformSysinfo* info, const struct utsname* uts) {
|
||||
|
||||
#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);
|
||||
sysctl((int[]) { CTL_HW, HW_PAGESIZE }, 2, &info->pageSize, &length, NULL, 0);
|
||||
#else
|
||||
info->pageSize = (uint32_t) sysconf(_SC_PAGESIZE);
|
||||
#endif
|
||||
|
||||
@@ -149,7 +149,7 @@ static void getUserName(FFPlatform* platform) {
|
||||
alignas(TOKEN_USER) char buf[SECURITY_MAX_SID_SIZE + sizeof(TOKEN_USER)];
|
||||
if (NT_SUCCESS(NtQueryInformationToken(NtCurrentProcessToken(), TokenUser, buf, sizeof(buf), &size))) {
|
||||
TOKEN_USER* tokenUser = (TOKEN_USER*) buf;
|
||||
UNICODE_STRING sidString = {.Buffer = buffer, .Length = 0, .MaximumLength = sizeof(buffer)};
|
||||
UNICODE_STRING sidString = { .Buffer = buffer, .Length = 0, .MaximumLength = sizeof(buffer) };
|
||||
if (NT_SUCCESS(RtlConvertSidToUnicodeString(&sidString, tokenUser->User.Sid, FALSE))) {
|
||||
ffStrbufSetNWS(&platform->sid, sidString.Length / sizeof(wchar_t), sidString.Buffer);
|
||||
}
|
||||
|
||||
@@ -835,13 +835,13 @@ int ffStrbufAppendUtf32CodePoint(FFstrbuf* strbuf, uint32_t codepoint) {
|
||||
ffStrbufAppendC(strbuf, (char) codepoint);
|
||||
return 1;
|
||||
} else if (codepoint <= 0x7FF) {
|
||||
ffStrbufAppendNS(strbuf, 2, (char[]) {(char) (0xC0 | (codepoint >> 6)), (char) (0x80 | (codepoint & 0x3F))});
|
||||
ffStrbufAppendNS(strbuf, 2, (char[]) { (char) (0xC0 | (codepoint >> 6)), (char) (0x80 | (codepoint & 0x3F)) });
|
||||
return 2;
|
||||
} else if (codepoint <= 0xFFFF) {
|
||||
ffStrbufAppendNS(strbuf, 3, (char[]) {(char) (0xE0 | (codepoint >> 12)), (char) (0x80 | ((codepoint >> 6) & 0x3F)), (char) (0x80 | (codepoint & 0x3F))});
|
||||
ffStrbufAppendNS(strbuf, 3, (char[]) { (char) (0xE0 | (codepoint >> 12)), (char) (0x80 | ((codepoint >> 6) & 0x3F)), (char) (0x80 | (codepoint & 0x3F)) });
|
||||
return 3;
|
||||
} else if (codepoint <= 0x10FFFF) {
|
||||
ffStrbufAppendNS(strbuf, 4, (char[]) {(char) (0xF0 | (codepoint >> 18)), (char) (0x80 | ((codepoint >> 12) & 0x3F)), (char) (0x80 | ((codepoint >> 6) & 0x3F)), (char) (0x80 | (codepoint & 0x3F))});
|
||||
ffStrbufAppendNS(strbuf, 4, (char[]) { (char) (0xF0 | (codepoint >> 18)), (char) (0x80 | ((codepoint >> 12) & 0x3F)), (char) (0x80 | ((codepoint >> 6) & 0x3F)), (char) (0x80 | (codepoint & 0x3F)) });
|
||||
return 4;
|
||||
}
|
||||
|
||||
|
||||
@@ -118,7 +118,7 @@ bool ffEdidIsValid(const uint8_t edid[128], uint32_t length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
static const uint8_t edidHeader[] = {0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00};
|
||||
static const uint8_t edidHeader[] = { 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00 };
|
||||
if (memcmp(edid, edidHeader, sizeof(edidHeader)) != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ void ffStart(void) {
|
||||
if (instance.config.display.noBuffer) {
|
||||
setvbuf(stdout, NULL, _IONBF, 0);
|
||||
}
|
||||
struct sigaction action = {.sa_handler = exitSignalHandler};
|
||||
struct sigaction action = { .sa_handler = exitSignalHandler };
|
||||
sigaction(SIGINT, &action, NULL);
|
||||
sigaction(SIGTERM, &action, NULL);
|
||||
sigaction(SIGQUIT, &action, NULL);
|
||||
|
||||
@@ -164,7 +164,7 @@ const char* ffGetTerminalResponse(const char* request, int nParams, const char*
|
||||
|
||||
// Give the terminal some time to respond
|
||||
#ifndef __APPLE__
|
||||
if (poll(&(struct pollfd) {.fd = ftty, .events = POLLIN}, 1, FF_IO_TERM_RESP_WAIT_MS) <= 0) {
|
||||
if (poll(&(struct pollfd) { .fd = ftty, .events = POLLIN }, 1, FF_IO_TERM_RESP_WAIT_MS) <= 0) {
|
||||
return "poll(/dev/tty) timeout or failed";
|
||||
}
|
||||
#else
|
||||
@@ -174,7 +174,7 @@ const char* ffGetTerminalResponse(const char* request, int nParams, const char*
|
||||
fd_set rd;
|
||||
FD_ZERO(&rd);
|
||||
FD_SET(ftty, &rd);
|
||||
if (select(ftty + 1, &rd, NULL, NULL, &(struct timeval) {.tv_sec = FF_IO_TERM_RESP_WAIT_MS / 1000, .tv_usec = (FF_IO_TERM_RESP_WAIT_MS % 1000) * 1000}) <= 0) {
|
||||
if (select(ftty + 1, &rd, NULL, NULL, &(struct timeval) { .tv_sec = FF_IO_TERM_RESP_WAIT_MS / 1000, .tv_usec = (FF_IO_TERM_RESP_WAIT_MS % 1000) * 1000 }) <= 0) {
|
||||
return "select(/dev/tty) timeout or failed";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ static bool createSubfolders(wchar_t* fileName) {
|
||||
// Rooted path on current drive: \foo\bar
|
||||
else if (ptr[0] == L'\\') {
|
||||
UNICODE_STRING* dosPath = &ffGetPeb()->ProcessParameters->CurrentDirectory.DosPath;
|
||||
wchar_t driveRoot[] = {dosPath->Buffer[0], L':', L'\\', L'\0'};
|
||||
wchar_t driveRoot[] = { dosPath->Buffer[0], L':', L'\\', L'\0' };
|
||||
hRoot = CreateFileW(
|
||||
driveRoot,
|
||||
FILE_LIST_DIRECTORY | FILE_TRAVERSE | SYNCHRONIZE,
|
||||
@@ -409,7 +409,7 @@ const char* ffGetTerminalResponse(const char* request, int nParams, const char*
|
||||
}
|
||||
|
||||
while (true) {
|
||||
if (NtWaitForSingleObject(hInput, FALSE, &(LARGE_INTEGER) {.QuadPart = (int64_t) FF_IO_TERM_RESP_WAIT_MS * -10000}) != STATUS_WAIT_0) {
|
||||
if (NtWaitForSingleObject(hInput, FALSE, &(LARGE_INTEGER) { .QuadPart = (int64_t) FF_IO_TERM_RESP_WAIT_MS * -10000 }) != STATUS_WAIT_0) {
|
||||
SetConsoleMode(hInput, inputMode);
|
||||
return "NtWaitForSingleObject() failed or timeout";
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ bool ffNetifGetDefaultRouteImplV4(FFNetifDefaultRouteResult* result) {
|
||||
}
|
||||
|
||||
{
|
||||
struct timeval timeout = {1, 0};
|
||||
struct timeval timeout = { 1, 0 };
|
||||
setsockopt(pfRoute, SOL_SOCKET, SO_RCVTIMEO, (char*) &timeout, sizeof(timeout));
|
||||
setsockopt(pfRoute, SOL_SOCKET, SO_SNDTIMEO, (char*) &timeout, sizeof(timeout));
|
||||
}
|
||||
@@ -138,7 +138,7 @@ bool ffNetifGetDefaultRouteImplV6(FFNetifDefaultRouteResult* result) {
|
||||
}
|
||||
|
||||
{
|
||||
struct timeval timeout = {1, 0};
|
||||
struct timeval timeout = { 1, 0 };
|
||||
setsockopt(pfRoute, SOL_SOCKET, SO_RCVTIMEO, (char*) &timeout, sizeof(timeout));
|
||||
setsockopt(pfRoute, SOL_SOCKET, SO_SNDTIMEO, (char*) &timeout, sizeof(timeout));
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ get_rt_address(struct rt_msghdr* rtm, int desired) {
|
||||
}
|
||||
|
||||
bool ffNetifGetDefaultRouteImplV4(FFNetifDefaultRouteResult* result) {
|
||||
int mib[6] = {CTL_NET, PF_ROUTE, 0, AF_INET, NET_RT_FLAGS, RTF_GATEWAY};
|
||||
int mib[6] = { CTL_NET, PF_ROUTE, 0, AF_INET, NET_RT_FLAGS, RTF_GATEWAY };
|
||||
size_t needed;
|
||||
|
||||
if (sysctl(mib, 6, NULL, &needed, NULL, 0) < 0 || needed == 0) {
|
||||
@@ -84,7 +84,7 @@ bool ffNetifGetDefaultRouteImplV4(FFNetifDefaultRouteResult* result) {
|
||||
}
|
||||
|
||||
bool ffNetifGetDefaultRouteImplV6(FFNetifDefaultRouteResult* result) {
|
||||
int mib[6] = {CTL_NET, PF_ROUTE, 0, AF_INET6, NET_RT_FLAGS, RTF_GATEWAY};
|
||||
int mib[6] = { CTL_NET, PF_ROUTE, 0, AF_INET6, NET_RT_FLAGS, RTF_GATEWAY };
|
||||
size_t needed;
|
||||
|
||||
if (sysctl(mib, 6, NULL, &needed, NULL, 0) < 0 || needed == 0) {
|
||||
|
||||
@@ -177,7 +177,7 @@ bool ffNetifGetDefaultRouteImplV4(FFNetifDefaultRouteResult* result) {
|
||||
uint32_t rta_data = *(uint32_t*) RTA_DATA(rta);
|
||||
switch (rta->rta_type) {
|
||||
case RTA_DST:
|
||||
FF_DEBUG("Unexpected RTA_DST: %s (len=%u)", inet_ntoa((struct in_addr) {.s_addr = rta_data}), rtm->rtm_dst_len);
|
||||
FF_DEBUG("Unexpected RTA_DST: %s (len=%u)", inet_ntoa((struct in_addr) { .s_addr = rta_data }), rtm->rtm_dst_len);
|
||||
goto next;
|
||||
case RTA_OIF:
|
||||
entry.ifindex = rta_data;
|
||||
|
||||
@@ -378,8 +378,7 @@ const char* ffNetworkingRecvHttpResponse(FFNetworkingState* state, FFstrbuf* buf
|
||||
{
|
||||
int pollRes = poll(&(struct pollfd) {
|
||||
.fd = state->sockfd,
|
||||
.events = POLLIN
|
||||
},
|
||||
.events = POLLIN },
|
||||
1,
|
||||
timeout > 0 ? (int) timeout : -1);
|
||||
if (pollRes == 0) {
|
||||
|
||||
@@ -169,7 +169,7 @@ const char* ffProcessReadOutput(FFProcessHandle* handle, FFstrbuf* buffer) {
|
||||
|
||||
for (;;) {
|
||||
if (timeout >= 0) {
|
||||
struct pollfd pollfd = {childPipeFd, POLLIN, 0};
|
||||
struct pollfd pollfd = { childPipeFd, POLLIN, 0 };
|
||||
int pollret = poll(&pollfd, 1, timeout);
|
||||
if (pollret == 0) {
|
||||
kill(childPid, SIGTERM);
|
||||
@@ -277,7 +277,7 @@ void ffProcessGetInfoLinux(pid_t pid, FFstrbuf* processName, FFstrbuf* exe, cons
|
||||
#elif defined(__APPLE__)
|
||||
|
||||
size_t len = 0;
|
||||
int mibs[] = {CTL_KERN, KERN_PROCARGS2, pid};
|
||||
int mibs[] = { CTL_KERN, KERN_PROCARGS2, pid };
|
||||
if (sysctl(mibs, ARRAY_SIZE(mibs), NULL, &len, NULL, 0) == 0) { // try get arg0
|
||||
// don't know why if don't let len longer, proArgs2 and len will change during the following sysctl() in old MacOS version.
|
||||
len++;
|
||||
@@ -340,7 +340,7 @@ void ffProcessGetInfoLinux(pid_t pid, FFstrbuf* processName, FFstrbuf* exe, cons
|
||||
|
||||
static_assert(ARG_MAX > PATH_MAX, "");
|
||||
|
||||
if (exePath && sysctl((int[]) {CTL_KERN,
|
||||
if (exePath && sysctl((int[]) { CTL_KERN,
|
||||
# if __FreeBSD__
|
||||
KERN_PROC,
|
||||
KERN_PROC_PATHNAME,
|
||||
@@ -360,7 +360,7 @@ void ffProcessGetInfoLinux(pid_t pid, FFstrbuf* processName, FFstrbuf* exe, cons
|
||||
|
||||
size = ARG_MAX;
|
||||
if (sysctl(
|
||||
(int[]) {CTL_KERN,
|
||||
(int[]) { CTL_KERN,
|
||||
# if __FreeBSD__
|
||||
KERN_PROC,
|
||||
KERN_PROC_ARGS,
|
||||
@@ -542,7 +542,7 @@ const char* ffProcessGetBasicInfoLinux(pid_t pid, FFstrbuf* name, pid_t* ppid, i
|
||||
struct kinfo_proc proc;
|
||||
size_t size = sizeof(proc);
|
||||
if (sysctl(
|
||||
(int[]) {CTL_KERN, KERN_PROC, KERN_PROC_PID, pid}, 4, &proc, &size, NULL, 0)) {
|
||||
(int[]) { CTL_KERN, KERN_PROC, KERN_PROC_PID, pid }, 4, &proc, &size, NULL, 0)) {
|
||||
return "sysctl(KERN_PROC_PID) failed";
|
||||
}
|
||||
|
||||
@@ -568,7 +568,7 @@ const char* ffProcessGetBasicInfoLinux(pid_t pid, FFstrbuf* name, pid_t* ppid, i
|
||||
struct kinfo_proc proc;
|
||||
size_t size = sizeof(proc);
|
||||
if (sysctl(
|
||||
(int[]) {CTL_KERN, KERN_PROC, KERN_PROC_PID, pid}, 4, &proc, &size, NULL, 0)) {
|
||||
(int[]) { CTL_KERN, KERN_PROC, KERN_PROC_PID, pid }, 4, &proc, &size, NULL, 0)) {
|
||||
return "sysctl(KERN_PROC_PID) failed";
|
||||
}
|
||||
|
||||
@@ -594,7 +594,7 @@ const char* ffProcessGetBasicInfoLinux(pid_t pid, FFstrbuf* name, pid_t* ppid, i
|
||||
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) {
|
||||
(int[]) { CTL_KERN, KERN_PROC2, KERN_PROC_PID, pid, sizeof(proc), 1 }, 6, &proc, &size, NULL, 0) != 0) {
|
||||
return "sysctl(KERN_PROC_PID) failed";
|
||||
}
|
||||
|
||||
|
||||
@@ -141,7 +141,7 @@ static void terminateChildProcess(HANDLE hProcess, HANDLE hChildPipeRead, HANDLE
|
||||
IO_STATUS_BLOCK cancelIosb = {};
|
||||
if (NT_SUCCESS(NtCancelIoFileEx(hChildPipeRead, piosb, &cancelIosb))) {
|
||||
if (hReadEvent) {
|
||||
NtWaitForSingleObject(hReadEvent, FALSE, &(LARGE_INTEGER) {.QuadPart = -100000}); // wait for cancellation to complete
|
||||
NtWaitForSingleObject(hReadEvent, FALSE, &(LARGE_INTEGER) { .QuadPart = -100000 }); // wait for cancellation to complete
|
||||
}
|
||||
}
|
||||
NtTerminateProcess(hProcess, 1);
|
||||
@@ -177,7 +177,7 @@ const char* ffProcessReadOutput(FFProcessHandle* handle, FFstrbuf* buffer) {
|
||||
NULL,
|
||||
NULL);
|
||||
if (status == STATUS_PENDING) {
|
||||
switch (NtWaitForSingleObject(hReadEvent, FALSE, &(LARGE_INTEGER) {.QuadPart = (int64_t) timeout * -10000})) {
|
||||
switch (NtWaitForSingleObject(hReadEvent, FALSE, &(LARGE_INTEGER) { .QuadPart = (int64_t) timeout * -10000 })) {
|
||||
case STATUS_WAIT_0:
|
||||
status = iosb.Status;
|
||||
break;
|
||||
@@ -228,7 +228,7 @@ bool ffProcessGetInfoWindows(uint32_t pid, uint32_t* ppid, FFstrbuf* pname, FFst
|
||||
if (!NT_SUCCESS(NtOpenProcess(&hProcess, PROCESS_QUERY_LIMITED_INFORMATION, &(OBJECT_ATTRIBUTES) {
|
||||
.Length = sizeof(OBJECT_ATTRIBUTES),
|
||||
},
|
||||
&(CLIENT_ID) {.UniqueProcess = (HANDLE) (uintptr_t) pid}))) {
|
||||
&(CLIENT_ID) { .UniqueProcess = (HANDLE) (uintptr_t) pid }))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,11 +22,11 @@ static FFvariant getGVariantValue(GVariant* variant, FFvarianttype type, const G
|
||||
if (variant == NULL) {
|
||||
result = FF_VARIANT_NULL;
|
||||
} else if (type == FF_VARIANT_TYPE_STRING) {
|
||||
result = (FFvariant) {.strValue = variantGetters->ffg_variant_dup_string(variant, NULL)}; // Dup string, so that variant itself can be freed
|
||||
result = (FFvariant) { .strValue = variantGetters->ffg_variant_dup_string(variant, NULL) }; // Dup string, so that variant itself can be freed
|
||||
} else if (type == FF_VARIANT_TYPE_BOOL) {
|
||||
result = (FFvariant) {.boolValue = (bool) variantGetters->ffg_variant_get_boolean(variant), .boolValueSet = true};
|
||||
result = (FFvariant) { .boolValue = (bool) variantGetters->ffg_variant_get_boolean(variant), .boolValueSet = true };
|
||||
} else if (type == FF_VARIANT_TYPE_INT) {
|
||||
result = (FFvariant) {.intValue = variantGetters->ffg_variant_get_int32(variant)};
|
||||
result = (FFvariant) { .intValue = variantGetters->ffg_variant_get_int32(variant) };
|
||||
} else {
|
||||
result = FF_VARIANT_NULL;
|
||||
}
|
||||
@@ -223,7 +223,7 @@ FFvariant ffSettingsGetXFConf(const char* channelName, const char* propertyName,
|
||||
int32_t value;
|
||||
if (ffDBusGetInt(&dbus, &rootIterator, &value)) {
|
||||
dbus.lib->ffdbus_message_unref(reply);
|
||||
return (FFvariant) {.intValue = value};
|
||||
return (FFvariant) { .intValue = value };
|
||||
}
|
||||
return FF_VARIANT_NULL;
|
||||
}
|
||||
@@ -232,7 +232,7 @@ FFvariant ffSettingsGetXFConf(const char* channelName, const char* propertyName,
|
||||
FFstrbuf value = ffStrbufCreate();
|
||||
if (ffDBusGetString(&dbus, &rootIterator, &value)) {
|
||||
dbus.lib->ffdbus_message_unref(reply);
|
||||
return (FFvariant) {.strValue = value.chars}; // Leaks value.chars
|
||||
return (FFvariant) { .strValue = value.chars }; // Leaks value.chars
|
||||
}
|
||||
return FF_VARIANT_NULL;
|
||||
}
|
||||
@@ -241,7 +241,7 @@ FFvariant ffSettingsGetXFConf(const char* channelName, const char* propertyName,
|
||||
bool value;
|
||||
if (ffDBusGetBool(&dbus, &rootIterator, &value)) {
|
||||
dbus.lib->ffdbus_message_unref(reply);
|
||||
return (FFvariant) {.boolValue = value, .boolValueSet = true};
|
||||
return (FFvariant) { .boolValue = value, .boolValueSet = true };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -295,7 +295,7 @@ FFvariant ffSettingsGetXFConfFirstMatch(const char* channelName, const char* pro
|
||||
int32_t value;
|
||||
if (ffDBusGetInt(&dbus, &dictIterator, &value)) {
|
||||
dbus.lib->ffdbus_message_unref(reply);
|
||||
return (FFvariant) {.intValue = value};
|
||||
return (FFvariant) { .intValue = value };
|
||||
}
|
||||
return FF_VARIANT_NULL;
|
||||
}
|
||||
@@ -304,7 +304,7 @@ FFvariant ffSettingsGetXFConfFirstMatch(const char* channelName, const char* pro
|
||||
FFstrbuf value = ffStrbufCreate();
|
||||
if (ffDBusGetString(&dbus, &dictIterator, &value)) {
|
||||
dbus.lib->ffdbus_message_unref(reply);
|
||||
return (FFvariant) {.strValue = value.chars}; // Leaks value.chars
|
||||
return (FFvariant) { .strValue = value.chars }; // Leaks value.chars
|
||||
}
|
||||
return FF_VARIANT_NULL;
|
||||
}
|
||||
@@ -313,7 +313,7 @@ FFvariant ffSettingsGetXFConfFirstMatch(const char* channelName, const char* pro
|
||||
bool value;
|
||||
if (ffDBusGetBool(&dbus, &dictIterator, &value)) {
|
||||
dbus.lib->ffdbus_message_unref(reply);
|
||||
return (FFvariant) {.boolValue = value, .boolValueSet = true};
|
||||
return (FFvariant) { .boolValue = value, .boolValueSet = true };
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,16 +27,16 @@ void ffSizeAppendNum(uint64_t bytes, FFstrbuf* result) {
|
||||
const FFOptionsDisplay* options = &instance.config.display;
|
||||
switch (options->sizeBinaryPrefix) {
|
||||
case FF_SIZE_BINARY_PREFIX_TYPE_IEC:
|
||||
appendNum(result, bytes, 1024, (const char*[]) {"B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB", NULL});
|
||||
appendNum(result, bytes, 1024, (const char*[]) { "B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB", NULL });
|
||||
break;
|
||||
case FF_SIZE_BINARY_PREFIX_TYPE_SI:
|
||||
appendNum(result, bytes, 1000, (const char*[]) {"B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB", NULL});
|
||||
appendNum(result, bytes, 1000, (const char*[]) { "B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB", NULL });
|
||||
break;
|
||||
case FF_SIZE_BINARY_PREFIX_TYPE_JEDEC:
|
||||
appendNum(result, bytes, 1024, (const char*[]) {"B", "KB", "MB", "GB", "TB", NULL});
|
||||
appendNum(result, bytes, 1024, (const char*[]) { "B", "KB", "MB", "GB", "TB", NULL });
|
||||
break;
|
||||
default:
|
||||
appendNum(result, bytes, 1024, (const char*[]) {"B", NULL});
|
||||
appendNum(result, bytes, 1024, (const char*[]) { "B", NULL });
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,13 +5,13 @@
|
||||
#ifdef __OpenBSD__
|
||||
const char* ffSysctlGetString(int mib1, int mib2, FFstrbuf* result) {
|
||||
size_t neededLength;
|
||||
if (sysctl((int[]) {mib1, mib2}, 2, NULL, &neededLength, NULL, 0) != 0 || neededLength == 1) { // neededLength is 1 for empty strings, because of the null terminator
|
||||
if (sysctl((int[]) { mib1, mib2 }, 2, NULL, &neededLength, NULL, 0) != 0 || neededLength == 1) { // neededLength is 1 for empty strings, because of the null terminator
|
||||
return "sysctlbyname() failed";
|
||||
}
|
||||
|
||||
ffStrbufEnsureFree(result, (uint32_t) neededLength - 1);
|
||||
|
||||
if (sysctl((int[]) {mib1, mib2}, 2, result->chars + result->length, &neededLength, NULL, 0) == 0) {
|
||||
if (sysctl((int[]) { mib1, mib2 }, 2, result->chars + result->length, &neededLength, NULL, 0) == 0) {
|
||||
result->length += (uint32_t) neededLength - 1;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ const char* ffSysctlGetString(int mib1, int mib2, FFstrbuf* result) {
|
||||
int ffSysctlGetInt(int mib1, int mib2, int defaultValue) {
|
||||
int result;
|
||||
size_t neededLength = sizeof(result);
|
||||
if (sysctl((int[]) {mib1, mib2}, 2, &result, &neededLength, NULL, 0) != 0) {
|
||||
if (sysctl((int[]) { mib1, mib2 }, 2, &result, &neededLength, NULL, 0) != 0) {
|
||||
return defaultValue;
|
||||
}
|
||||
return result;
|
||||
@@ -32,7 +32,7 @@ int ffSysctlGetInt(int mib1, int mib2, int defaultValue) {
|
||||
int64_t ffSysctlGetInt64(int mib1, int mib2, int64_t defaultValue) {
|
||||
int64_t result;
|
||||
size_t neededLength = sizeof(result);
|
||||
if (sysctl((int[]) {mib1, mib2}, 2, &result, &neededLength, NULL, 0) != 0) {
|
||||
if (sysctl((int[]) { mib1, mib2 }, 2, &result, &neededLength, NULL, 0) != 0) {
|
||||
return defaultValue;
|
||||
}
|
||||
return result;
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ typedef struct FFModuleFormatArgList {
|
||||
uint32_t count;
|
||||
} FFModuleFormatArgList;
|
||||
|
||||
#define FF_FORMAT_ARG_LIST(list) {.args = list, .count = sizeof(list) / sizeof(FFModuleFormatArg)}
|
||||
#define FF_FORMAT_ARG_LIST(list) { .args = list, .count = sizeof(list) / sizeof(FFModuleFormatArg) }
|
||||
|
||||
// Must be the first field of FFModuleOptions
|
||||
typedef struct FFModuleBaseInfo {
|
||||
|
||||
@@ -15,7 +15,7 @@ typedef struct FFColorRangeConfig {
|
||||
uint8_t yellow;
|
||||
} FFColorRangeConfig;
|
||||
|
||||
#define FF_VERSION_INIT ((FFVersion) {0})
|
||||
#define FF_VERSION_INIT ((FFVersion) { 0 })
|
||||
|
||||
void ffParseSemver(FFstrbuf* buffer, const FFstrbuf* major, const FFstrbuf* minor, const FFstrbuf* patch);
|
||||
void ffParseGTK(FFstrbuf* buffer, const FFstrbuf* gtk2, const FFstrbuf* gtk3, const FFstrbuf* gtk4);
|
||||
|
||||
@@ -19,15 +19,15 @@ static inline bool ffParsePropLine(const char* line, const char* start, FFstrbuf
|
||||
}
|
||||
|
||||
static inline bool ffParsePropFile(const char* filename, const char* start, FFstrbuf* buffer) {
|
||||
return ffParsePropFileValues(filename, 1, (FFpropquery[]) {{start, buffer}});
|
||||
return ffParsePropFileValues(filename, 1, (FFpropquery[]) { { start, buffer } });
|
||||
}
|
||||
|
||||
static inline bool ffParsePropFileHome(const char* relativeFile, const char* start, FFstrbuf* buffer) {
|
||||
return ffParsePropFileHomeValues(relativeFile, 1, (FFpropquery[]) {{start, buffer}});
|
||||
return ffParsePropFileHomeValues(relativeFile, 1, (FFpropquery[]) { { start, buffer } });
|
||||
}
|
||||
|
||||
static inline bool ffParsePropFileList(const FFlist* list, const char* relativeFile, const char* start, FFstrbuf* buffer) {
|
||||
return ffParsePropFileListValues(list, relativeFile, 1, (FFpropquery[]) {{start, buffer}});
|
||||
return ffParsePropFileListValues(list, relativeFile, 1, (FFpropquery[]) { { start, buffer } });
|
||||
}
|
||||
|
||||
static inline bool ffParsePropFileConfigValues(const char* relativeFile, uint32_t numQueries, FFpropquery* queries) {
|
||||
@@ -35,7 +35,7 @@ static inline bool ffParsePropFileConfigValues(const char* relativeFile, uint32_
|
||||
}
|
||||
|
||||
static inline bool ffParsePropFileConfig(const char* relativeFile, const char* start, FFstrbuf* buffer) {
|
||||
return ffParsePropFileConfigValues(relativeFile, 1, (FFpropquery[]) {{start, buffer}});
|
||||
return ffParsePropFileConfigValues(relativeFile, 1, (FFpropquery[]) { { start, buffer } });
|
||||
}
|
||||
|
||||
static inline bool ffParsePropFileDataValues(const char* relativeFile, uint32_t numQueries, FFpropquery* queries) {
|
||||
@@ -43,5 +43,5 @@ static inline bool ffParsePropFileDataValues(const char* relativeFile, uint32_t
|
||||
}
|
||||
|
||||
static inline bool ffParsePropFileData(const char* relativeFile, const char* start, FFstrbuf* buffer) {
|
||||
return ffParsePropFileDataValues(relativeFile, 1, (FFpropquery[]) {{start, buffer}});
|
||||
return ffParsePropFileDataValues(relativeFile, 1, (FFpropquery[]) { { start, buffer } });
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ typedef union FFvariant {
|
||||
};
|
||||
} FFvariant;
|
||||
|
||||
#define FF_VARIANT_NULL ((FFvariant) {.strValue = NULL})
|
||||
#define FF_VARIANT_NULL ((FFvariant) { .strValue = NULL })
|
||||
|
||||
FFvariant ffSettingsGetDConf(const char* key, FFvarianttype type);
|
||||
FFvariant ffSettingsGetGSettings(const char* schemaName, const char* path, const char* key, FFvarianttype type);
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@ static inline void ffThreadDetach(FFThreadType thread) {
|
||||
NtClose(thread);
|
||||
}
|
||||
static inline bool ffThreadJoin(FFThreadType thread, uint32_t timeout) {
|
||||
if (NtWaitForSingleObject(thread, FALSE, timeout == 0 ? NULL : &(LARGE_INTEGER) {.QuadPart = (int64_t) timeout * -10000}) != STATUS_WAIT_0) {
|
||||
if (NtWaitForSingleObject(thread, FALSE, timeout == 0 ? NULL : &(LARGE_INTEGER) { .QuadPart = (int64_t) timeout * -10000 }) != STATUS_WAIT_0) {
|
||||
TerminateThread(thread, (DWORD) -1);
|
||||
NtClose(thread);
|
||||
return false;
|
||||
|
||||
+1
-1
@@ -58,7 +58,7 @@ static inline bool ffTimeSleep(uint32_t msec) {
|
||||
interval.QuadPart = -(int64_t) msec * 10000; // Relative time in 100-nanosecond intervals
|
||||
return NT_SUCCESS(NtDelayExecution(TRUE, &interval));
|
||||
#else
|
||||
return nanosleep(&(struct timespec) {msec / 1000, (long) (msec % 1000) * 1000000}, NULL) == 0;
|
||||
return nanosleep(&(struct timespec) { msec / 1000, (long) (msec % 1000) * 1000000 }, NULL) == 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ struct FFBaseVariant : TVariant {
|
||||
if (this->vt == VT_LPWSTR) {
|
||||
return this->bstrVal;
|
||||
} else {
|
||||
return {this->bstrVal, SysStringLen(this->bstrVal)};
|
||||
return { this->bstrVal, SysStringLen(this->bstrVal) };
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ static inline void wrapYyjsonFree(yyjson_doc** doc) {
|
||||
static const char* parseTermuxApi(FFBatteryOptions* options, FFlist* results) {
|
||||
FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate();
|
||||
|
||||
if (ffProcessAppendStdOut(&buffer, (char* const[]) {FF_TERMUX_API_PATH, FF_TERMUX_API_PARAM, NULL})) {
|
||||
if (ffProcessAppendStdOut(&buffer, (char* const[]) { FF_TERMUX_API_PATH, FF_TERMUX_API_PARAM, NULL })) {
|
||||
return "Starting `" FF_TERMUX_API_PATH " " FF_TERMUX_API_PARAM "` failed";
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ static const char* detectWithCmApi(FFBatteryOptions* options, FFlist* results) {
|
||||
continue;
|
||||
}
|
||||
|
||||
BATTERY_QUERY_INFORMATION bqi = {.InformationLevel = BatteryInformation};
|
||||
BATTERY_QUERY_INFORMATION bqi = { .InformationLevel = BatteryInformation };
|
||||
|
||||
DWORD dwWait = 0;
|
||||
DWORD dwOut;
|
||||
@@ -47,7 +47,7 @@ static const char* detectWithCmApi(FFBatteryOptions* options, FFlist* results) {
|
||||
continue;
|
||||
}
|
||||
|
||||
BATTERY_INFORMATION bi = {0};
|
||||
BATTERY_INFORMATION bi = { 0 };
|
||||
if (!DeviceIoControl(hBattery, IOCTL_BATTERY_QUERY_INFORMATION, &bqi, sizeof(bqi), &bi, sizeof(bi), &dwOut, NULL)) {
|
||||
continue;
|
||||
}
|
||||
@@ -131,7 +131,7 @@ static const char* detectWithCmApi(FFBatteryOptions* options, FFlist* results) {
|
||||
|
||||
{
|
||||
BATTERY_STATUS bs;
|
||||
BATTERY_WAIT_STATUS bws = {.BatteryTag = bqi.BatteryTag};
|
||||
BATTERY_WAIT_STATUS bws = { .BatteryTag = bqi.BatteryTag };
|
||||
if (DeviceIoControl(hBattery, IOCTL_BATTERY_QUERY_STATUS, &bws, sizeof(bws), &bs, sizeof(bs), &dwOut, NULL) && bs.Capacity != BATTERY_UNKNOWN_CAPACITY && bi.FullChargedCapacity != 0) {
|
||||
battery->capacity = bs.Capacity * 100.0 / bi.FullChargedCapacity;
|
||||
} else {
|
||||
|
||||
@@ -20,8 +20,7 @@ const char* ffDetectBluetooth(FFBluetoothOptions* options, FFlist* devices /* FF
|
||||
.fReturnConnected = TRUE,
|
||||
.fReturnRemembered = options->showDisconnected,
|
||||
.fReturnAuthenticated = options->showDisconnected,
|
||||
.dwSize = sizeof(BLUETOOTH_DEVICE_SEARCH_PARAMS)
|
||||
},
|
||||
.dwSize = sizeof(BLUETOOTH_DEVICE_SEARCH_PARAMS) },
|
||||
&btdi);
|
||||
if (!hFind) {
|
||||
if (GetLastError() == ERROR_NO_MORE_ITEMS) {
|
||||
|
||||
@@ -25,7 +25,7 @@ extern "C" const char* ffBluetoothDetectBattery(FFlist* devices) {
|
||||
return "Failed to get GetDeviceProperties method";
|
||||
}
|
||||
|
||||
FFWmiVariant devicePropertyKeys({L"{104EA319-6EE2-4701-BD47-8DDBF425BBE5} 2", L"DEVPKEY_Bluetooth_DeviceAddress"});
|
||||
FFWmiVariant devicePropertyKeys({ L"{104EA319-6EE2-4701-BD47-8DDBF425BBE5} 2", L"DEVPKEY_Bluetooth_DeviceAddress" });
|
||||
if (FAILED(pInParams->Put(L"devicePropertyKeys", 0, &devicePropertyKeys, CIM_FLAG_ARRAY | CIM_STRING))) {
|
||||
return "Failed to put devicePropertyKeys";
|
||||
}
|
||||
|
||||
@@ -60,8 +60,7 @@ const char* ffDetectBluetoothRadio(FFlist* devices /* FFBluetoothRadioResult */)
|
||||
|
||||
HANDLE hRadio = NULL;
|
||||
HBLUETOOTH_DEVICE_FIND hFind = ffBluetoothFindFirstRadio(&(BLUETOOTH_FIND_RADIO_PARAMS) {
|
||||
.dwSize = sizeof(BLUETOOTH_FIND_RADIO_PARAMS)
|
||||
},
|
||||
.dwSize = sizeof(BLUETOOTH_FIND_RADIO_PARAMS) },
|
||||
&hRadio);
|
||||
if (!hFind) {
|
||||
if (GetLastError() == ERROR_NO_MORE_ITEMS) {
|
||||
@@ -81,7 +80,7 @@ const char* ffDetectBluetoothRadio(FFlist* devices /* FFBluetoothRadioResult */)
|
||||
FFBluetoothRadioResult* device = ffListAdd(devices);
|
||||
ffStrbufInitS(&device->name, blri.localInfo.name);
|
||||
|
||||
BLUETOOTH_ADDRESS_STRUCT addr = {.ullLong = blri.localInfo.address};
|
||||
BLUETOOTH_ADDRESS_STRUCT addr = { .ullLong = blri.localInfo.address };
|
||||
ffStrbufInitF(&device->address, "%02X:%02X:%02X:%02X:%02X:%02X", addr.rgBytes[5], addr.rgBytes[4], addr.rgBytes[3], addr.rgBytes[2], addr.rgBytes[1], addr.rgBytes[0]);
|
||||
|
||||
device->lmpVersion = blri.radioInfo.lmpVersion;
|
||||
|
||||
@@ -16,7 +16,7 @@ typedef uint16_t efi_char;
|
||||
#endif
|
||||
|
||||
#ifndef EFI_GLOBAL_VARIABLE
|
||||
# define EFI_GLOBAL_VARIABLE {0x8be4df61, 0x93ca, 0x11d2, 0xaa, 0x0d, {0x00, 0xe0, 0x98, 0x03, 0x2b, 0x8c}}
|
||||
# define EFI_GLOBAL_VARIABLE { 0x8be4df61, 0x93ca, 0x11d2, 0xaa, 0x0d, { 0x00, 0xe0, 0x98, 0x03, 0x2b, 0x8c } }
|
||||
#endif
|
||||
|
||||
const char* ffDetectBootmgr(FFBootmgrResult* result) {
|
||||
@@ -32,7 +32,7 @@ const char* ffDetectBootmgr(FFBootmgrResult* result) {
|
||||
};
|
||||
|
||||
ioc.datasize = sizeof(buffer);
|
||||
ioc.name = (efi_char[]) {'B', 'o', 'o', 't', 'C', 'u', 'r', 'r', 'e', 'n', 't', '\0'};
|
||||
ioc.name = (efi_char[]) { 'B', 'o', 'o', 't', 'C', 'u', 'r', 'r', 'e', 'n', 't', '\0' };
|
||||
ioc.namesize = sizeof("BootCurrent") * 2;
|
||||
if (ioctl(efifd, EFIIOC_VAR_GET, &ioc) < 0 || ioc.datasize != 2) {
|
||||
return "ioctl(EFIIOC_VAR_GET, BootCurrent) failed";
|
||||
@@ -43,7 +43,7 @@ const char* ffDetectBootmgr(FFBootmgrResult* result) {
|
||||
unsigned char hex[5];
|
||||
snprintf((char*) hex, sizeof(hex), "%04X", result->order);
|
||||
ioc.datasize = sizeof(buffer);
|
||||
ioc.name = (efi_char[]) {'B', 'o', 'o', 't', hex[0], hex[1], hex[2], hex[3], '\0'};
|
||||
ioc.name = (efi_char[]) { 'B', 'o', 'o', 't', hex[0], hex[1], hex[2], hex[3], '\0' };
|
||||
ioc.namesize = sizeof("Boot####") * 2;
|
||||
if (ioctl(efifd, EFIIOC_VAR_GET, &ioc) < 0 || ioc.datasize == sizeof(buffer)) {
|
||||
return "ioctl(EFIIOC_VAR_GET, Boot####) failed";
|
||||
@@ -51,7 +51,7 @@ const char* ffDetectBootmgr(FFBootmgrResult* result) {
|
||||
|
||||
ffEfiFillLoadOption((FFEfiLoadOption*) buffer, result);
|
||||
|
||||
ioc.name = (efi_char[]) {'S', 'e', 'c', 'u', 'r', 'e', 'B', 'o', 'o', 't', '\0'};
|
||||
ioc.name = (efi_char[]) { 'S', 'e', 'c', 'u', 'r', 'e', 'B', 'o', 'o', 't', '\0' };
|
||||
ioc.namesize = sizeof("SecureBoot") * 2;
|
||||
ioc.datasize = sizeof(buffer);
|
||||
if (ioctl(efifd, EFIIOC_VAR_GET, &ioc) == 0 && ioc.datasize == 1) {
|
||||
|
||||
@@ -15,8 +15,7 @@ const char* enablePrivilege(const wchar_t* privilege) {
|
||||
TOKEN_PRIVILEGES tp = {
|
||||
.PrivilegeCount = 1,
|
||||
.Privileges = {
|
||||
(LUID_AND_ATTRIBUTES) {.Attributes = SE_PRIVILEGE_ENABLED}
|
||||
},
|
||||
(LUID_AND_ATTRIBUTES) { .Attributes = SE_PRIVILEGE_ENABLED } },
|
||||
};
|
||||
if (!LookupPrivilegeValueW(NULL, privilege, &tp.Privileges[0].Luid)) {
|
||||
return "LookupPrivilegeValue() failed";
|
||||
|
||||
@@ -85,7 +85,7 @@ static const char* detectWithDdcci(FF_MAYBE_UNUSED const FFDisplayServerResult*
|
||||
}
|
||||
|
||||
{
|
||||
uint8_t i2cIn[4] = {0x82, 0x01, 0x10 /* luminance */};
|
||||
uint8_t i2cIn[4] = { 0x82, 0x01, 0x10 /* luminance */ };
|
||||
i2cIn[3] = 0x6e ^ i2cIn[0] ^ i2cIn[1] ^ i2cIn[2];
|
||||
|
||||
for (uint32_t i = 0; i < 2; ++i) {
|
||||
@@ -185,7 +185,7 @@ static const char* detectWithDdcci(const FFDisplayServerResult* displayServer, F
|
||||
continue;
|
||||
}
|
||||
|
||||
uint8_t i2cIn[] = {0x51, 0x82, 0x01, 0x10 /* luminance */, 0};
|
||||
uint8_t i2cIn[] = { 0x51, 0x82, 0x01, 0x10 /* luminance */, 0 };
|
||||
i2cIn[4] = 0x6E ^ i2cIn[0] ^ i2cIn[1] ^ i2cIn[2] ^ i2cIn[3];
|
||||
|
||||
IOI2CRequest request = {
|
||||
|
||||
@@ -16,7 +16,7 @@ static inline void wrapYyjsonFree(yyjson_doc** doc) {
|
||||
const char* ffDetectCamera(FF_MAYBE_UNUSED FFlist* result) {
|
||||
FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate();
|
||||
|
||||
if (ffProcessAppendStdOut(&buffer, (char* const[]) {FF_TERMUX_API_PATH, FF_TERMUX_API_PARAM, NULL})) {
|
||||
if (ffProcessAppendStdOut(&buffer, (char* const[]) { FF_TERMUX_API_PATH, FF_TERMUX_API_PARAM, NULL })) {
|
||||
return "Starting `" FF_TERMUX_API_PATH " " FF_TERMUX_API_PARAM "` failed";
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ const char* ffDetectCamera(FFlist* result) {
|
||||
continue;
|
||||
}
|
||||
|
||||
struct v4l2_format fmt = {.type = V4L2_BUF_TYPE_VIDEO_CAPTURE};
|
||||
struct v4l2_format fmt = { .type = V4L2_BUF_TYPE_VIDEO_CAPTURE };
|
||||
if (ioctl(fd, VIDIOC_G_FMT, &fmt) < 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -21,9 +21,8 @@ static const char* spawnProcess(FFCommandOptions* options, FFProcessHandle* hand
|
||||
options->shell.chars,
|
||||
options->param.chars,
|
||||
options->text.chars,
|
||||
NULL
|
||||
}
|
||||
: (char* const[]) {options->shell.chars, options->text.chars, NULL},
|
||||
NULL }
|
||||
: (char* const[]) { options->shell.chars, options->text.chars, NULL },
|
||||
options->useStdErr,
|
||||
handle);
|
||||
}
|
||||
|
||||
@@ -291,7 +291,7 @@ void ffCPUDetectByCpuid(FFCPUResult* cpu) {
|
||||
// #include <arm/cpu_capabilities_public.h> // Not available in macOS 14-
|
||||
|
||||
void ffCPUDetectByCpuid(FFCPUResult* cpu) {
|
||||
uint64_t caps[2] = {0}; // 80-bit capability mask, split into two 64-bit values
|
||||
uint64_t caps[2] = { 0 }; // 80-bit capability mask, split into two 64-bit values
|
||||
size_t size = sizeof(caps);
|
||||
|
||||
if (sysctlbyname("hw.optional.arm.caps", caps, &size, NULL, 0) != 0) {
|
||||
|
||||
@@ -92,7 +92,7 @@ static const char* detectFrequency(FFCPUResult* cpu) {
|
||||
if (cpu->frequencyBase == 0) {
|
||||
unsigned current = 0;
|
||||
size_t size = sizeof(current);
|
||||
if (sysctl((int[]) {CTL_HW, HW_CPU_FREQ}, 2, ¤t, &size, NULL, 0) == 0) {
|
||||
if (sysctl((int[]) { CTL_HW, HW_CPU_FREQ }, 2, ¤t, &size, NULL, 0) == 0) {
|
||||
cpu->frequencyBase = (uint32_t) (current / 1000 / 1000);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <sys/sensors.h>
|
||||
|
||||
static const char* detectCPUTemp(const FFCPUOptions* options, FFCPUResult* cpu) {
|
||||
int mib[5] = {CTL_HW, HW_SENSORS, 0, SENSOR_TEMP, 0};
|
||||
int mib[5] = { CTL_HW, HW_SENSORS, 0, SENSOR_TEMP, 0 };
|
||||
|
||||
for (mib[2] = 0; mib[2] < 1024; mib[2]++) {
|
||||
struct sensordev sensordev;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <kstat.h>
|
||||
|
||||
static const char* detectCPUTempByKstat(const FFCPUOptions* options, kstat_ctl_t* kc, FFCPUResult* cpu) {
|
||||
const char* possibleModules[] = {"temperature", "cpu_temp", "acpi_thermal", NULL};
|
||||
const char* possibleModules[] = { "temperature", "cpu_temp", "acpi_thermal", NULL };
|
||||
|
||||
if (options->tempSensor.length > 0) {
|
||||
possibleModules[0] = options->tempSensor.chars;
|
||||
@@ -36,7 +36,7 @@ static const char* detectCPUTempByKstat(const FFCPUOptions* options, kstat_ctl_t
|
||||
|
||||
static const char* detectCPUTempByIpmiTool(FFCPUResult* cpu) {
|
||||
FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate();
|
||||
const char* error = ffProcessAppendStdOut(&buffer, (char* const[]) {"ipmitool", "-c", "sdr", "list", NULL});
|
||||
const char* error = ffProcessAppendStdOut(&buffer, (char* const[]) { "ipmitool", "-c", "sdr", "list", NULL });
|
||||
|
||||
if (error) {
|
||||
return error;
|
||||
|
||||
@@ -24,7 +24,7 @@ const char* detectThermalTemp(const FFCPUOptions* options, double* result) {
|
||||
.Identifier = {
|
||||
// Thermal Zone Information
|
||||
// HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Perflib\_V2Providers\{383487a6-3676-4870-a4e7-d45b30c35629}\{52bc5412-dac2-449c-8bc2-96443888fe6b}
|
||||
.CounterSetGuid = {0x52bc5412, 0xdac2, 0x449c, {0x8b, 0xc2, 0x96, 0x44, 0x38, 0x88, 0xfe, 0x6b}},
|
||||
.CounterSetGuid = { 0x52bc5412, 0xdac2, 0x449c, { 0x8b, 0xc2, 0x96, 0x44, 0x38, 0x88, 0xfe, 0x6b } },
|
||||
.Size = sizeof(querySpec),
|
||||
.CounterId = PERF_WILDCARD_COUNTER,
|
||||
.InstanceId = PERF_WILDCARD_COUNTER,
|
||||
|
||||
@@ -14,9 +14,9 @@ const char* ffGetCpuUsageInfo(FFlist* cpuTimes) {
|
||||
size_t neededLength = 0;
|
||||
#if __OpenBSD__ || __NetBSD__
|
||||
# ifdef KERN_CPTIME
|
||||
int ctls[] = {CTL_KERN, KERN_CPTIME};
|
||||
int ctls[] = { CTL_KERN, KERN_CPTIME };
|
||||
# else
|
||||
int ctls[] = {CTL_KERN, KERN_CP_TIME};
|
||||
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";
|
||||
|
||||
@@ -49,7 +49,7 @@ static const char* getInfoByPerflib(FFlist* cpuTimes) {
|
||||
.Identifier = {
|
||||
// Processor Information GUID
|
||||
// HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Perflib\_V2Providers\{383487a6-3676-4870-a4e7-d45b30c35629}\{b4fc721a-0378-476f-89ba-a5a79f810b36}
|
||||
.CounterSetGuid = {0xb4fc721a, 0x0378, 0x476f, {0x89, 0xba, 0xa5, 0xa7, 0x9f, 0x81, 0x0b, 0x36}},
|
||||
.CounterSetGuid = { 0xb4fc721a, 0x0378, 0x476f, { 0x89, 0xba, 0xa5, 0xa7, 0x9f, 0x81, 0x0b, 0x36 } },
|
||||
.Size = sizeof(querySpec),
|
||||
.CounterId = PERF_WILDCARD_COUNTER, // https://learn.microsoft.com/en-us/windows/win32/perfctrs/using-the-perflib-functions-to-consume-counter-data
|
||||
.InstanceId = PERF_WILDCARD_COUNTER,
|
||||
|
||||
@@ -30,7 +30,7 @@ static bool detectCursorGTK(FFCursorResult* result) {
|
||||
}
|
||||
|
||||
static void detectCursorFromConfigFile(const char* relativeFilePath, const char* themeStart, const char* themeDefault, const char* sizeStart, const char* sizeDefault, FFCursorResult* result) {
|
||||
if (ffParsePropFileConfigValues(relativeFilePath, 2, (FFpropquery[]) {{themeStart, &result->theme}, {sizeStart, &result->size}})) {
|
||||
if (ffParsePropFileConfigValues(relativeFilePath, 2, (FFpropquery[]) { { themeStart, &result->theme }, { sizeStart, &result->size } })) {
|
||||
if (result->theme.length == 0) {
|
||||
ffStrbufAppendS(&result->theme, themeDefault);
|
||||
}
|
||||
@@ -46,7 +46,7 @@ static void detectCursorFromConfigFile(const char* relativeFilePath, const char*
|
||||
}
|
||||
|
||||
static bool detectCursorFromXResources(FFCursorResult* result) {
|
||||
ffParsePropFileHomeValues(".Xresources", 2, (FFpropquery[]) {{"Xcursor.theme :", &result->theme}, {"Xcursor.size :", &result->size}});
|
||||
ffParsePropFileHomeValues(".Xresources", 2, (FFpropquery[]) { { "Xcursor.theme :", &result->theme }, { "Xcursor.size :", &result->size } });
|
||||
|
||||
return result->theme.length > 0;
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ static void getKDE(FFstrbuf* result, FF_MAYBE_UNUSED FFDEOptions* options) {
|
||||
}
|
||||
|
||||
if (result->length == 0) {
|
||||
if (ffProcessAppendStdOut(result, (char* const[]) {"plasmashell", "--version", NULL}) == NULL) { // plasmashell 5.27.5
|
||||
if (ffProcessAppendStdOut(result, (char* const[]) { "plasmashell", "--version", NULL }) == NULL) { // plasmashell 5.27.5
|
||||
ffStrbufSubstrAfterLastC(result, ' ');
|
||||
}
|
||||
}
|
||||
@@ -74,7 +74,7 @@ static void getGnome(FFstrbuf* result, FF_MAYBE_UNUSED FFDEOptions* options) {
|
||||
getGnomeByDbus(result);
|
||||
|
||||
if (result->length == 0) {
|
||||
if (ffProcessAppendStdOut(result, (char* const[]) {"gnome-shell", "--version", NULL}) == NULL) { // GNOME Shell 44.1
|
||||
if (ffProcessAppendStdOut(result, (char* const[]) { "gnome-shell", "--version", NULL }) == NULL) { // GNOME Shell 44.1
|
||||
ffStrbufSubstrAfterLastC(result, ' ');
|
||||
}
|
||||
}
|
||||
@@ -88,7 +88,7 @@ static void getCinnamon(FFstrbuf* result, FF_MAYBE_UNUSED FFDEOptions* options)
|
||||
}
|
||||
|
||||
if (result->length == 0) {
|
||||
if (ffProcessAppendStdOut(result, (char* const[]) {"cinnamon", "--version", NULL}) == NULL) { // Cinnamon 6.2.2
|
||||
if (ffProcessAppendStdOut(result, (char* const[]) { "cinnamon", "--version", NULL }) == NULL) { // Cinnamon 6.2.2
|
||||
ffStrbufSubstrAfterLastC(result, ' ');
|
||||
}
|
||||
}
|
||||
@@ -99,12 +99,12 @@ static void getMate(FFstrbuf* result, FF_MAYBE_UNUSED FFDEOptions* options) {
|
||||
FF_STRBUF_AUTO_DESTROY minor = ffStrbufCreate();
|
||||
FF_STRBUF_AUTO_DESTROY micro = ffStrbufCreate();
|
||||
|
||||
ffParsePropFileDataValues("mate-about/mate-version.xml", 3, (FFpropquery[]) {{"<platform>", &major}, {"<minor>", &minor}, {"<micro>", µ}});
|
||||
ffParsePropFileDataValues("mate-about/mate-version.xml", 3, (FFpropquery[]) { { "<platform>", &major }, { "<minor>", &minor }, { "<micro>", µ } });
|
||||
|
||||
ffParseSemver(result, &major, &minor, µ);
|
||||
|
||||
if (result->length == 0) {
|
||||
ffProcessAppendStdOut(result, (char* const[]) {"mate-session", "--version", NULL});
|
||||
ffProcessAppendStdOut(result, (char* const[]) { "mate-session", "--version", NULL });
|
||||
|
||||
ffStrbufSubstrAfterFirstC(result, ' ');
|
||||
ffStrbufTrim(result, ' ');
|
||||
@@ -129,7 +129,7 @@ static void getXFCE4(FFstrbuf* result, FF_MAYBE_UNUSED FFDEOptions* options) {
|
||||
|
||||
if (result->length == 0) {
|
||||
// This is somewhat slow
|
||||
ffProcessAppendStdOut(result, (char* const[]) {"xfce4-session", "--version", NULL});
|
||||
ffProcessAppendStdOut(result, (char* const[]) { "xfce4-session", "--version", NULL });
|
||||
|
||||
ffStrbufSubstrBeforeFirstC(result, ')');
|
||||
ffStrbufSubstrAfterLastC(result, ' ');
|
||||
@@ -149,7 +149,7 @@ static void getLXQt(FFstrbuf* result, FF_MAYBE_UNUSED FFDEOptions* options) {
|
||||
|
||||
if (result->length == 0) {
|
||||
// This is really, really, really slow. Thank you, LXQt developers
|
||||
ffProcessAppendStdOut(result, (char* const[]) {"lxqt-session", "-v", NULL});
|
||||
ffProcessAppendStdOut(result, (char* const[]) { "lxqt-session", "-v", NULL });
|
||||
|
||||
result->length = 0; // don't set '\0' byte
|
||||
ffParsePropLines(result->chars, "liblxqt", result);
|
||||
@@ -192,7 +192,7 @@ static const char* getTrinity(FFstrbuf* result, FF_MAYBE_UNUSED FFDEOptions* opt
|
||||
}
|
||||
|
||||
ffStrbufClear(&path);
|
||||
if (ffProcessAppendStdOut(&path, (char* const[]) {"tde-config", "--version", NULL}) == NULL) {
|
||||
if (ffProcessAppendStdOut(&path, (char* const[]) { "tde-config", "--version", NULL }) == NULL) {
|
||||
ffParsePropLines(path.chars, "TDE: ", result);
|
||||
return NULL;
|
||||
}
|
||||
@@ -201,7 +201,7 @@ static const char* getTrinity(FFstrbuf* result, FF_MAYBE_UNUSED FFDEOptions* opt
|
||||
}
|
||||
|
||||
static const char* getCosmic(FFstrbuf* result, FF_MAYBE_UNUSED FFDEOptions* options) {
|
||||
if (ffProcessAppendStdOut(result, (char* const[]) {"cosmic-comp", "--version", NULL}) == NULL) {
|
||||
if (ffProcessAppendStdOut(result, (char* const[]) { "cosmic-comp", "--version", NULL }) == NULL) {
|
||||
// cosmic-comp 0.1.0 (git commit fa88002ba41d2edec25dd7ffdee9719fbb928fc0)
|
||||
ffStrbufSubstrAfterFirstC(result, ' ');
|
||||
ffStrbufSubstrBeforeFirstC(result, ' ');
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include <sys/sysctl.h>
|
||||
|
||||
const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options) {
|
||||
int mib[] = {CTL_HW, HW_IOSTATS, sizeof(struct io_sysctl)};
|
||||
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";
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include <sys/sysctl.h>
|
||||
|
||||
const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options) {
|
||||
int mib[] = {CTL_HW, HW_DISKSTATS};
|
||||
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";
|
||||
|
||||
@@ -35,12 +35,12 @@ static const struct wl_interface* kde_output_device_v2_types[] = {
|
||||
};
|
||||
|
||||
static const struct wl_message kde_output_device_registry_v2_requests[] = {
|
||||
{"stop", "21", kde_output_device_v2_types + 0},
|
||||
{ "stop", "21", kde_output_device_v2_types + 0 },
|
||||
};
|
||||
|
||||
static const struct wl_message kde_output_device_registry_v2_events[] = {
|
||||
{"finished", "21", kde_output_device_v2_types + 0},
|
||||
{"output", "21n", kde_output_device_v2_types + 8},
|
||||
{ "finished", "21", kde_output_device_v2_types + 0 },
|
||||
{ "output", "21n", kde_output_device_v2_types + 8 },
|
||||
};
|
||||
|
||||
WL_EXPORT const struct wl_interface kde_output_device_registry_v2_interface = {
|
||||
@@ -53,47 +53,47 @@ WL_EXPORT const struct wl_interface kde_output_device_registry_v2_interface = {
|
||||
};
|
||||
|
||||
static const struct wl_message kde_output_device_v2_requests[] = {
|
||||
{"release", "21", kde_output_device_v2_types + 0},
|
||||
{ "release", "21", kde_output_device_v2_types + 0 },
|
||||
};
|
||||
|
||||
static const struct wl_message kde_output_device_v2_events[] = {
|
||||
{"geometry", "iiiiissi", kde_output_device_v2_types + 0},
|
||||
{"current_mode", "o", kde_output_device_v2_types + 9},
|
||||
{"mode", "n", kde_output_device_v2_types + 10},
|
||||
{"done", "", kde_output_device_v2_types + 0},
|
||||
{"scale", "f", kde_output_device_v2_types + 0},
|
||||
{"edid", "s", kde_output_device_v2_types + 0},
|
||||
{"enabled", "i", kde_output_device_v2_types + 0},
|
||||
{"uuid", "s", kde_output_device_v2_types + 0},
|
||||
{"serial_number", "s", kde_output_device_v2_types + 0},
|
||||
{"eisa_id", "s", kde_output_device_v2_types + 0},
|
||||
{"capabilities", "u", kde_output_device_v2_types + 0},
|
||||
{"overscan", "u", kde_output_device_v2_types + 0},
|
||||
{"vrr_policy", "u", kde_output_device_v2_types + 0},
|
||||
{"rgb_range", "u", kde_output_device_v2_types + 0},
|
||||
{"name", "2s", kde_output_device_v2_types + 0},
|
||||
{"high_dynamic_range", "3u", kde_output_device_v2_types + 0},
|
||||
{"sdr_brightness", "3u", kde_output_device_v2_types + 0},
|
||||
{"wide_color_gamut", "3u", kde_output_device_v2_types + 0},
|
||||
{"auto_rotate_policy", "4u", kde_output_device_v2_types + 0},
|
||||
{"icc_profile_path", "5s", kde_output_device_v2_types + 0},
|
||||
{"brightness_metadata", "6uuu", kde_output_device_v2_types + 0},
|
||||
{"brightness_overrides", "6iii", kde_output_device_v2_types + 0},
|
||||
{"sdr_gamut_wideness", "6u", kde_output_device_v2_types + 0},
|
||||
{"color_profile_source", "7u", kde_output_device_v2_types + 0},
|
||||
{"brightness", "8u", kde_output_device_v2_types + 0},
|
||||
{"color_power_tradeoff", "10u", kde_output_device_v2_types + 0},
|
||||
{"dimming", "11u", kde_output_device_v2_types + 0},
|
||||
{"replication_source", "13s", kde_output_device_v2_types + 0},
|
||||
{"ddc_ci_allowed", "14u", kde_output_device_v2_types + 0},
|
||||
{"max_bits_per_color", "15u", kde_output_device_v2_types + 0},
|
||||
{"max_bits_per_color_range", "15uu", kde_output_device_v2_types + 0},
|
||||
{"automatic_max_bits_per_color_limit", "15u", kde_output_device_v2_types + 0},
|
||||
{"edr_policy", "16u", kde_output_device_v2_types + 0},
|
||||
{"sharpness", "17u", kde_output_device_v2_types + 0},
|
||||
{"priority", "18u", kde_output_device_v2_types + 0},
|
||||
{"auto_brightness", "20u", kde_output_device_v2_types + 0},
|
||||
{"removed", "21", kde_output_device_v2_types + 0},
|
||||
{ "geometry", "iiiiissi", kde_output_device_v2_types + 0 },
|
||||
{ "current_mode", "o", kde_output_device_v2_types + 9 },
|
||||
{ "mode", "n", kde_output_device_v2_types + 10 },
|
||||
{ "done", "", kde_output_device_v2_types + 0 },
|
||||
{ "scale", "f", kde_output_device_v2_types + 0 },
|
||||
{ "edid", "s", kde_output_device_v2_types + 0 },
|
||||
{ "enabled", "i", kde_output_device_v2_types + 0 },
|
||||
{ "uuid", "s", kde_output_device_v2_types + 0 },
|
||||
{ "serial_number", "s", kde_output_device_v2_types + 0 },
|
||||
{ "eisa_id", "s", kde_output_device_v2_types + 0 },
|
||||
{ "capabilities", "u", kde_output_device_v2_types + 0 },
|
||||
{ "overscan", "u", kde_output_device_v2_types + 0 },
|
||||
{ "vrr_policy", "u", kde_output_device_v2_types + 0 },
|
||||
{ "rgb_range", "u", kde_output_device_v2_types + 0 },
|
||||
{ "name", "2s", kde_output_device_v2_types + 0 },
|
||||
{ "high_dynamic_range", "3u", kde_output_device_v2_types + 0 },
|
||||
{ "sdr_brightness", "3u", kde_output_device_v2_types + 0 },
|
||||
{ "wide_color_gamut", "3u", kde_output_device_v2_types + 0 },
|
||||
{ "auto_rotate_policy", "4u", kde_output_device_v2_types + 0 },
|
||||
{ "icc_profile_path", "5s", kde_output_device_v2_types + 0 },
|
||||
{ "brightness_metadata", "6uuu", kde_output_device_v2_types + 0 },
|
||||
{ "brightness_overrides", "6iii", kde_output_device_v2_types + 0 },
|
||||
{ "sdr_gamut_wideness", "6u", kde_output_device_v2_types + 0 },
|
||||
{ "color_profile_source", "7u", kde_output_device_v2_types + 0 },
|
||||
{ "brightness", "8u", kde_output_device_v2_types + 0 },
|
||||
{ "color_power_tradeoff", "10u", kde_output_device_v2_types + 0 },
|
||||
{ "dimming", "11u", kde_output_device_v2_types + 0 },
|
||||
{ "replication_source", "13s", kde_output_device_v2_types + 0 },
|
||||
{ "ddc_ci_allowed", "14u", kde_output_device_v2_types + 0 },
|
||||
{ "max_bits_per_color", "15u", kde_output_device_v2_types + 0 },
|
||||
{ "max_bits_per_color_range", "15uu", kde_output_device_v2_types + 0 },
|
||||
{ "automatic_max_bits_per_color_limit", "15u", kde_output_device_v2_types + 0 },
|
||||
{ "edr_policy", "16u", kde_output_device_v2_types + 0 },
|
||||
{ "sharpness", "17u", kde_output_device_v2_types + 0 },
|
||||
{ "priority", "18u", kde_output_device_v2_types + 0 },
|
||||
{ "auto_brightness", "20u", kde_output_device_v2_types + 0 },
|
||||
{ "removed", "21", kde_output_device_v2_types + 0 },
|
||||
};
|
||||
|
||||
WL_EXPORT const struct wl_interface kde_output_device_v2_interface = {
|
||||
@@ -106,11 +106,11 @@ WL_EXPORT const struct wl_interface kde_output_device_v2_interface = {
|
||||
};
|
||||
|
||||
static const struct wl_message kde_output_device_mode_v2_events[] = {
|
||||
{"size", "ii", kde_output_device_v2_types + 0},
|
||||
{"refresh", "i", kde_output_device_v2_types + 0},
|
||||
{"preferred", "", kde_output_device_v2_types + 0},
|
||||
{"removed", "", kde_output_device_v2_types + 0},
|
||||
{"flags", "19u", kde_output_device_v2_types + 0},
|
||||
{ "size", "ii", kde_output_device_v2_types + 0 },
|
||||
{ "refresh", "i", kde_output_device_v2_types + 0 },
|
||||
{ "preferred", "", kde_output_device_v2_types + 0 },
|
||||
{ "removed", "", kde_output_device_v2_types + 0 },
|
||||
{ "flags", "19u", kde_output_device_v2_types + 0 },
|
||||
};
|
||||
|
||||
WL_EXPORT const struct wl_interface kde_output_device_mode_v2_interface = {
|
||||
|
||||
@@ -17,12 +17,12 @@ static const struct wl_interface* kde_output_order_v1_types[] = {
|
||||
};
|
||||
|
||||
static const struct wl_message kde_output_order_v1_requests[] = {
|
||||
{"destroy", "", kde_output_order_v1_types + 0},
|
||||
{ "destroy", "", kde_output_order_v1_types + 0 },
|
||||
};
|
||||
|
||||
static const struct wl_message kde_output_order_v1_events[] = {
|
||||
{"output", "s", kde_output_order_v1_types + 0},
|
||||
{"done", "", kde_output_order_v1_types + 0},
|
||||
{ "output", "s", kde_output_order_v1_types + 0 },
|
||||
{ "done", "", kde_output_order_v1_types + 0 },
|
||||
};
|
||||
|
||||
WL_EXPORT const struct wl_interface kde_output_order_v1_interface = {
|
||||
|
||||
@@ -45,7 +45,7 @@ static void waylandKdeModeListener(void* data, FF_MAYBE_UNUSED struct kde_output
|
||||
}
|
||||
|
||||
WaylandKdeMode* newMode = ffListAdd((FFlist*) wldata->internal);
|
||||
*newMode = (WaylandKdeMode) {.pMode = mode};
|
||||
*newMode = (WaylandKdeMode) { .pMode = mode };
|
||||
|
||||
// Strangely, the listener is called only in this function, but not in `waylandKdeCurrentModeListener`
|
||||
wldata->parent->ffwl_proxy_add_listener((struct wl_proxy*) mode, (void (**)(void)) &modeListener, newMode);
|
||||
|
||||
@@ -49,7 +49,7 @@ static bool waylandDetectWM(int fd, FFDisplayServerResult* result) {
|
||||
size_t size = 4096;
|
||||
ffStrbufEnsureFixedLengthFree(&result->wmProcessName, (uint32_t) size);
|
||||
|
||||
if (sysctl((int[]) {CTL_KERN, KERN_PROC, KERN_PROC_ARGS, ucred.cr_pid}, 4, result->wmProcessName.chars, &size, NULL, 0) != 0) {
|
||||
if (sysctl((int[]) { CTL_KERN, KERN_PROC, KERN_PROC_ARGS, ucred.cr_pid }, 4, result->wmProcessName.chars, &size, NULL, 0) != 0) {
|
||||
return false;
|
||||
}
|
||||
result->wmProcessName.length = (uint32_t) size - 1;
|
||||
|
||||
+39
-39
@@ -63,14 +63,14 @@ static const struct wl_interface* wlr_output_management_unstable_v1_types[] = {
|
||||
};
|
||||
|
||||
static const struct wl_message zwlr_output_manager_v1_requests[] = {
|
||||
{"create_configuration", "nu", wlr_output_management_unstable_v1_types + 3},
|
||||
{"stop", "", wlr_output_management_unstable_v1_types + 0},
|
||||
{ "create_configuration", "nu", wlr_output_management_unstable_v1_types + 3 },
|
||||
{ "stop", "", wlr_output_management_unstable_v1_types + 0 },
|
||||
};
|
||||
|
||||
static const struct wl_message zwlr_output_manager_v1_events[] = {
|
||||
{"head", "n", wlr_output_management_unstable_v1_types + 5},
|
||||
{"done", "u", wlr_output_management_unstable_v1_types + 0},
|
||||
{"finished", "", wlr_output_management_unstable_v1_types + 0},
|
||||
{ "head", "n", wlr_output_management_unstable_v1_types + 5 },
|
||||
{ "done", "u", wlr_output_management_unstable_v1_types + 0 },
|
||||
{ "finished", "", wlr_output_management_unstable_v1_types + 0 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface zwlr_output_manager_v1_interface = {
|
||||
@@ -83,24 +83,24 @@ WL_PRIVATE const struct wl_interface zwlr_output_manager_v1_interface = {
|
||||
};
|
||||
|
||||
static const struct wl_message zwlr_output_head_v1_requests[] = {
|
||||
{"release", "3", wlr_output_management_unstable_v1_types + 0},
|
||||
{ "release", "3", wlr_output_management_unstable_v1_types + 0 },
|
||||
};
|
||||
|
||||
static const struct wl_message zwlr_output_head_v1_events[] = {
|
||||
{"name", "s", wlr_output_management_unstable_v1_types + 0},
|
||||
{"description", "s", wlr_output_management_unstable_v1_types + 0},
|
||||
{"physical_size", "ii", wlr_output_management_unstable_v1_types + 0},
|
||||
{"mode", "n", wlr_output_management_unstable_v1_types + 6},
|
||||
{"enabled", "i", wlr_output_management_unstable_v1_types + 0},
|
||||
{"current_mode", "o", wlr_output_management_unstable_v1_types + 7},
|
||||
{"position", "ii", wlr_output_management_unstable_v1_types + 0},
|
||||
{"transform", "i", wlr_output_management_unstable_v1_types + 0},
|
||||
{"scale", "f", wlr_output_management_unstable_v1_types + 0},
|
||||
{"finished", "", wlr_output_management_unstable_v1_types + 0},
|
||||
{"make", "2s", wlr_output_management_unstable_v1_types + 0},
|
||||
{"model", "2s", wlr_output_management_unstable_v1_types + 0},
|
||||
{"serial_number", "2s", wlr_output_management_unstable_v1_types + 0},
|
||||
{"adaptive_sync", "4u", wlr_output_management_unstable_v1_types + 0},
|
||||
{ "name", "s", wlr_output_management_unstable_v1_types + 0 },
|
||||
{ "description", "s", wlr_output_management_unstable_v1_types + 0 },
|
||||
{ "physical_size", "ii", wlr_output_management_unstable_v1_types + 0 },
|
||||
{ "mode", "n", wlr_output_management_unstable_v1_types + 6 },
|
||||
{ "enabled", "i", wlr_output_management_unstable_v1_types + 0 },
|
||||
{ "current_mode", "o", wlr_output_management_unstable_v1_types + 7 },
|
||||
{ "position", "ii", wlr_output_management_unstable_v1_types + 0 },
|
||||
{ "transform", "i", wlr_output_management_unstable_v1_types + 0 },
|
||||
{ "scale", "f", wlr_output_management_unstable_v1_types + 0 },
|
||||
{ "finished", "", wlr_output_management_unstable_v1_types + 0 },
|
||||
{ "make", "2s", wlr_output_management_unstable_v1_types + 0 },
|
||||
{ "model", "2s", wlr_output_management_unstable_v1_types + 0 },
|
||||
{ "serial_number", "2s", wlr_output_management_unstable_v1_types + 0 },
|
||||
{ "adaptive_sync", "4u", wlr_output_management_unstable_v1_types + 0 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface zwlr_output_head_v1_interface = {
|
||||
@@ -113,14 +113,14 @@ WL_PRIVATE const struct wl_interface zwlr_output_head_v1_interface = {
|
||||
};
|
||||
|
||||
static const struct wl_message zwlr_output_mode_v1_requests[] = {
|
||||
{"release", "3", wlr_output_management_unstable_v1_types + 0},
|
||||
{ "release", "3", wlr_output_management_unstable_v1_types + 0 },
|
||||
};
|
||||
|
||||
static const struct wl_message zwlr_output_mode_v1_events[] = {
|
||||
{"size", "ii", wlr_output_management_unstable_v1_types + 0},
|
||||
{"refresh", "i", wlr_output_management_unstable_v1_types + 0},
|
||||
{"preferred", "", wlr_output_management_unstable_v1_types + 0},
|
||||
{"finished", "", wlr_output_management_unstable_v1_types + 0},
|
||||
{ "size", "ii", wlr_output_management_unstable_v1_types + 0 },
|
||||
{ "refresh", "i", wlr_output_management_unstable_v1_types + 0 },
|
||||
{ "preferred", "", wlr_output_management_unstable_v1_types + 0 },
|
||||
{ "finished", "", wlr_output_management_unstable_v1_types + 0 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface zwlr_output_mode_v1_interface = {
|
||||
@@ -133,17 +133,17 @@ WL_PRIVATE const struct wl_interface zwlr_output_mode_v1_interface = {
|
||||
};
|
||||
|
||||
static const struct wl_message zwlr_output_configuration_v1_requests[] = {
|
||||
{"enable_head", "no", wlr_output_management_unstable_v1_types + 8},
|
||||
{"disable_head", "o", wlr_output_management_unstable_v1_types + 10},
|
||||
{"apply", "", wlr_output_management_unstable_v1_types + 0},
|
||||
{"test", "", wlr_output_management_unstable_v1_types + 0},
|
||||
{"destroy", "", wlr_output_management_unstable_v1_types + 0},
|
||||
{ "enable_head", "no", wlr_output_management_unstable_v1_types + 8 },
|
||||
{ "disable_head", "o", wlr_output_management_unstable_v1_types + 10 },
|
||||
{ "apply", "", wlr_output_management_unstable_v1_types + 0 },
|
||||
{ "test", "", wlr_output_management_unstable_v1_types + 0 },
|
||||
{ "destroy", "", wlr_output_management_unstable_v1_types + 0 },
|
||||
};
|
||||
|
||||
static const struct wl_message zwlr_output_configuration_v1_events[] = {
|
||||
{"succeeded", "", wlr_output_management_unstable_v1_types + 0},
|
||||
{"failed", "", wlr_output_management_unstable_v1_types + 0},
|
||||
{"cancelled", "", wlr_output_management_unstable_v1_types + 0},
|
||||
{ "succeeded", "", wlr_output_management_unstable_v1_types + 0 },
|
||||
{ "failed", "", wlr_output_management_unstable_v1_types + 0 },
|
||||
{ "cancelled", "", wlr_output_management_unstable_v1_types + 0 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface zwlr_output_configuration_v1_interface = {
|
||||
@@ -156,12 +156,12 @@ WL_PRIVATE const struct wl_interface zwlr_output_configuration_v1_interface = {
|
||||
};
|
||||
|
||||
static const struct wl_message zwlr_output_configuration_head_v1_requests[] = {
|
||||
{"set_mode", "o", wlr_output_management_unstable_v1_types + 11},
|
||||
{"set_custom_mode", "iii", wlr_output_management_unstable_v1_types + 0},
|
||||
{"set_position", "ii", wlr_output_management_unstable_v1_types + 0},
|
||||
{"set_transform", "i", wlr_output_management_unstable_v1_types + 0},
|
||||
{"set_scale", "f", wlr_output_management_unstable_v1_types + 0},
|
||||
{"set_adaptive_sync", "4u", wlr_output_management_unstable_v1_types + 0},
|
||||
{ "set_mode", "o", wlr_output_management_unstable_v1_types + 11 },
|
||||
{ "set_custom_mode", "iii", wlr_output_management_unstable_v1_types + 0 },
|
||||
{ "set_position", "ii", wlr_output_management_unstable_v1_types + 0 },
|
||||
{ "set_transform", "i", wlr_output_management_unstable_v1_types + 0 },
|
||||
{ "set_scale", "f", wlr_output_management_unstable_v1_types + 0 },
|
||||
{ "set_adaptive_sync", "4u", wlr_output_management_unstable_v1_types + 0 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface zwlr_output_configuration_head_v1_interface = {
|
||||
|
||||
@@ -39,8 +39,8 @@ static const struct wl_interface* xdg_output_unstable_v1_types[] = {
|
||||
};
|
||||
|
||||
static const struct wl_message zxdg_output_manager_v1_requests[] = {
|
||||
{"destroy", "", xdg_output_unstable_v1_types + 0},
|
||||
{"get_xdg_output", "no", xdg_output_unstable_v1_types + 2},
|
||||
{ "destroy", "", xdg_output_unstable_v1_types + 0 },
|
||||
{ "get_xdg_output", "no", xdg_output_unstable_v1_types + 2 },
|
||||
};
|
||||
|
||||
WL_EXPORT const struct wl_interface zxdg_output_manager_v1_interface = {
|
||||
@@ -53,15 +53,15 @@ WL_EXPORT const struct wl_interface zxdg_output_manager_v1_interface = {
|
||||
};
|
||||
|
||||
static const struct wl_message zxdg_output_v1_requests[] = {
|
||||
{"destroy", "", xdg_output_unstable_v1_types + 0},
|
||||
{ "destroy", "", xdg_output_unstable_v1_types + 0 },
|
||||
};
|
||||
|
||||
static const struct wl_message zxdg_output_v1_events[] = {
|
||||
{"logical_position", "ii", xdg_output_unstable_v1_types + 0},
|
||||
{"logical_size", "ii", xdg_output_unstable_v1_types + 0},
|
||||
{"done", "", xdg_output_unstable_v1_types + 0},
|
||||
{"name", "2s", xdg_output_unstable_v1_types + 0},
|
||||
{"description", "2s", xdg_output_unstable_v1_types + 0},
|
||||
{ "logical_position", "ii", xdg_output_unstable_v1_types + 0 },
|
||||
{ "logical_size", "ii", xdg_output_unstable_v1_types + 0 },
|
||||
{ "done", "", xdg_output_unstable_v1_types + 0 },
|
||||
{ "name", "2s", xdg_output_unstable_v1_types + 0 },
|
||||
{ "description", "2s", xdg_output_unstable_v1_types + 0 },
|
||||
};
|
||||
|
||||
WL_EXPORT const struct wl_interface zxdg_output_v1_interface = {
|
||||
|
||||
@@ -51,7 +51,7 @@ static void waylandZwlrModeListener(void* data, FF_MAYBE_UNUSED struct zwlr_outp
|
||||
}
|
||||
|
||||
WaylandZwlrMode* newMode = ffListAdd((FFlist*) wldata->internal);
|
||||
*newMode = (WaylandZwlrMode) {.pMode = mode};
|
||||
*newMode = (WaylandZwlrMode) { .pMode = mode };
|
||||
|
||||
// Strangely, the listener is called only in this function, but not in `waylandZwlrCurrentModeListener`
|
||||
wldata->parent->ffwl_proxy_add_listener((struct wl_proxy*) mode, (void (**)(void)) &modeListener, newMode);
|
||||
|
||||
@@ -277,7 +277,7 @@ static const char* getFromProcesses(FFDisplayServerResult* result) {
|
||||
# define ki_comm kp_comm
|
||||
# endif
|
||||
|
||||
int request[] = {CTL_KERN, KERN_PROC, KERN_PROC_UID, (int) userId};
|
||||
int request[] = { CTL_KERN, KERN_PROC, KERN_PROC_UID, (int) userId };
|
||||
size_t length = 0;
|
||||
|
||||
if (sysctl(request, ARRAY_SIZE(request), NULL, &length, NULL, 0) != 0) {
|
||||
@@ -420,7 +420,7 @@ static const char* getFromProcesses(FFDisplayServerResult* result) {
|
||||
}
|
||||
}
|
||||
#elif __NetBSD__
|
||||
int request[] = {CTL_KERN, KERN_PROC2, KERN_PROC_UID, (int) userId, sizeof(struct kinfo_proc2), INT_MAX};
|
||||
int request[] = { CTL_KERN, KERN_PROC2, KERN_PROC_UID, (int) userId, sizeof(struct kinfo_proc2), INT_MAX };
|
||||
|
||||
size_t size = 0;
|
||||
if (sysctl(request, ARRAY_SIZE(request), NULL, &size, NULL, 0) != 0) {
|
||||
|
||||
@@ -11,7 +11,7 @@ const char* ffDetectFontImpl(FFFontResult* result);
|
||||
}
|
||||
|
||||
static void generateString(FFFontResult* font) {
|
||||
const char* types[] = {"Plain", "Menu", "Bold", "Mono"};
|
||||
const char* types[] = { "Plain", "Menu", "Bold", "Mono" };
|
||||
for (uint32_t i = 0; i < ARRAY_SIZE(types); ++i) {
|
||||
if (i == 0 || !ffStrbufEqual(&font->fonts[i - 1], &font->fonts[i])) {
|
||||
if (i > 0) {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include <windows.h>
|
||||
|
||||
static void generateString(FFFontResult* font) {
|
||||
const char* types[] = {"Caption", "Menu", "Message", "Status"};
|
||||
const char* types[] = { "Caption", "Menu", "Message", "Status" };
|
||||
for (uint32_t i = 0; i < ARRAY_SIZE(types); ++i) {
|
||||
if (i == 0 || !ffStrbufEqual(&font->fonts[i - 1], &font->fonts[i])) {
|
||||
if (i > 0) {
|
||||
@@ -28,10 +28,10 @@ const char* ffDetectFontImpl(FFFontResult* result) {
|
||||
|
||||
LOGFONTW fonts[4];
|
||||
FFArgBuffer fontBuffers[4] = {
|
||||
{.data = &fonts[0], .length = sizeof(fonts[0])},
|
||||
{.data = &fonts[1], .length = sizeof(fonts[1])},
|
||||
{.data = &fonts[2], .length = sizeof(fonts[2])},
|
||||
{.data = &fonts[3], .length = sizeof(fonts[3])},
|
||||
{ .data = &fonts[0], .length = sizeof(fonts[0]) },
|
||||
{ .data = &fonts[1], .length = sizeof(fonts[1]) },
|
||||
{ .data = &fonts[2], .length = sizeof(fonts[2]) },
|
||||
{ .data = &fonts[3], .length = sizeof(fonts[3]) },
|
||||
};
|
||||
|
||||
if (!ffRegReadValues(hKey, 4, (FFRegValueArg[]) {
|
||||
|
||||
@@ -33,9 +33,9 @@ const char* ffDetectGamepad(FFlist* devices /* List of FFGamepadDevice */) {
|
||||
return "IOHIDManagerOpen() failed";
|
||||
}
|
||||
|
||||
CFDictionaryRef FF_CFTYPE_AUTO_RELEASE matching1 = CFDictionaryCreate(kCFAllocatorDefault, (const void**) (CFStringRef[]) {CFSTR(kIOHIDDeviceUsagePageKey), CFSTR(kIOHIDDeviceUsageKey)}, (const void**) (CFNumberRef[]) {ffCfCreateInt(kHIDPage_GenericDesktop), ffCfCreateInt(kHIDUsage_GD_Joystick)}, 2, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
|
||||
CFDictionaryRef FF_CFTYPE_AUTO_RELEASE matching2 = CFDictionaryCreate(kCFAllocatorDefault, (const void**) (CFStringRef[]) {CFSTR(kIOHIDDeviceUsagePageKey), CFSTR(kIOHIDDeviceUsageKey)}, (const void**) (CFNumberRef[]) {ffCfCreateInt(kHIDPage_GenericDesktop), ffCfCreateInt(kHIDUsage_GD_GamePad)}, 2, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
|
||||
CFArrayRef FF_CFTYPE_AUTO_RELEASE matchings = CFArrayCreate(kCFAllocatorDefault, (const void**) (CFTypeRef[]) {matching1, matching2}, 2, &kCFTypeArrayCallBacks);
|
||||
CFDictionaryRef FF_CFTYPE_AUTO_RELEASE matching1 = CFDictionaryCreate(kCFAllocatorDefault, (const void**) (CFStringRef[]) { CFSTR(kIOHIDDeviceUsagePageKey), CFSTR(kIOHIDDeviceUsageKey) }, (const void**) (CFNumberRef[]) { ffCfCreateInt(kHIDPage_GenericDesktop), ffCfCreateInt(kHIDUsage_GD_Joystick) }, 2, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
|
||||
CFDictionaryRef FF_CFTYPE_AUTO_RELEASE matching2 = CFDictionaryCreate(kCFAllocatorDefault, (const void**) (CFStringRef[]) { CFSTR(kIOHIDDeviceUsagePageKey), CFSTR(kIOHIDDeviceUsageKey) }, (const void**) (CFNumberRef[]) { ffCfCreateInt(kHIDPage_GenericDesktop), ffCfCreateInt(kHIDUsage_GD_GamePad) }, 2, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
|
||||
CFArrayRef FF_CFTYPE_AUTO_RELEASE matchings = CFArrayCreate(kCFAllocatorDefault, (const void**) (CFTypeRef[]) { matching1, matching2 }, 2, &kCFTypeArrayCallBacks);
|
||||
IOHIDManagerSetDeviceMatchingMultiple(manager, matchings);
|
||||
|
||||
CFSetRef FF_CFTYPE_AUTO_RELEASE set = IOHIDManagerCopyDevices(manager);
|
||||
|
||||
@@ -101,7 +101,7 @@ const char* detectByOpenGL(FFlist* gpus) {
|
||||
gpu->coreCount = FF_GPU_CORE_COUNT_UNSET;
|
||||
gpu->frequency = FF_GPU_FREQUENCY_UNSET;
|
||||
gpu->coreUsage = FF_GPU_CORE_USAGE_UNSET;
|
||||
gpu->dedicated = gpu->shared = (FFGPUMemory) {0, 0};
|
||||
gpu->dedicated = gpu->shared = (FFGPUMemory) { 0, 0 };
|
||||
gpu->deviceId = 0;
|
||||
|
||||
FF_DEBUG("OpenGL reported renderer='%s', vendor='%s', version='%s'",
|
||||
|
||||
@@ -255,7 +255,7 @@ const char* ffDetectAmdGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverResu
|
||||
FF_DEBUG("Using Overdrive8 API (odVersion=%d)", odVersion);
|
||||
|
||||
if (result.frequency) {
|
||||
ADLOD8CurrentSetting currentSetting = {.count = OD8_COUNT};
|
||||
ADLOD8CurrentSetting currentSetting = { .count = OD8_COUNT };
|
||||
int status = adlData.ffADL2_Overdrive8_Current_Setting_Get(adlData.apiHandle, device->iAdapterIndex, ¤tSetting);
|
||||
FF_DEBUG("ADL2_Overdrive8_Current_Setting_Get returned %s (%d)", ffAdlStatusToString(status), status);
|
||||
if (status == ADL_OK) {
|
||||
|
||||
@@ -168,7 +168,7 @@ const char* ffDrmDetectAmdgpu(const FFGPUOptions* options, FFGPUResult* gpu, con
|
||||
const char* ffDrmDetectI915(FFGPUResult* gpu, int fd) {
|
||||
{
|
||||
int value;
|
||||
drm_i915_getparam_t getparam = {.param = I915_PARAM_EU_TOTAL, .value = &value};
|
||||
drm_i915_getparam_t getparam = { .param = I915_PARAM_EU_TOTAL, .value = &value };
|
||||
if (ioctl(fd, DRM_IOCTL_I915_GETPARAM, &getparam) >= 0) {
|
||||
gpu->coreCount = value;
|
||||
}
|
||||
|
||||
@@ -193,7 +193,7 @@ const char* ffDetectIntelGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverRe
|
||||
uint32_t sensorCount = ARRAY_SIZE(sensors);
|
||||
if (igclData.ffctlEnumTemperatureSensors(device, &sensorCount, sensors) == CTL_RESULT_SUCCESS && sensorCount > 0) {
|
||||
for (uint32_t iSensor = 0; iSensor < sensorCount; iSensor++) {
|
||||
ctl_temp_properties_t props = {.Size = sizeof(props)};
|
||||
ctl_temp_properties_t props = { .Size = sizeof(props) };
|
||||
// The official sample code does not set Version
|
||||
// https://github.com/intel/drivers.gpu.control-library/blob/1bbacbf3814f2fd0d2b930cdf42fad83f3628db9/Samples/Telemetry_Samples/Sample_TelemetryAPP.cpp#L256
|
||||
if (igclData.ffctlTemperatureGetProperties(sensors[iSensor], &props) == CTL_RESULT_SUCCESS) {
|
||||
@@ -211,7 +211,7 @@ const char* ffDetectIntelGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverRe
|
||||
uint32_t domainCount = ARRAY_SIZE(domains);
|
||||
if (igclData.ffctlEnumFrequencyDomains(device, &domainCount, domains) == CTL_RESULT_SUCCESS && domainCount > 0) {
|
||||
double maxValue = 0;
|
||||
ctl_freq_properties_t props = {.Size = sizeof(props), .Version = 0};
|
||||
ctl_freq_properties_t props = { .Size = sizeof(props), .Version = 0 };
|
||||
for (uint32_t iDomain = 0; iDomain < domainCount; iDomain++) {
|
||||
if (igclData.ffctlFrequencyGetProperties(domains[iDomain], &props) == CTL_RESULT_SUCCESS) {
|
||||
if (props.type == CTL_FREQ_DOMAIN_GPU && props.max > maxValue) {
|
||||
|
||||
@@ -253,7 +253,7 @@ const char* ffDetectNvidiaGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverR
|
||||
}
|
||||
|
||||
if (result.memory) {
|
||||
nvmlMemory_v2_t memory = {.version = nvmlMemory_v2};
|
||||
nvmlMemory_v2_t memory = { .version = nvmlMemory_v2 };
|
||||
if (nvmlData.ffnvmlDeviceGetMemoryInfo_v2(device, &memory) == NVML_SUCCESS) {
|
||||
result.memory->total = memory.used + memory.free;
|
||||
result.memory->used = memory.used;
|
||||
|
||||
@@ -286,7 +286,7 @@ const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist*
|
||||
|
||||
if (gpu->type == FF_GPU_TYPE_UNKNOWN && adapterLuid > 0) {
|
||||
FF_DEBUG("Trying to determine GPU type using D3DKMT APIs");
|
||||
D3DKMT_OPENADAPTERFROMLUID openAdapterFromLuid = {.AdapterLuid = *(LUID*) &adapterLuid};
|
||||
D3DKMT_OPENADAPTERFROMLUID openAdapterFromLuid = { .AdapterLuid = *(LUID*) &adapterLuid };
|
||||
if (NT_SUCCESS(D3DKMTOpenAdapterFromLuid(&openAdapterFromLuid))) {
|
||||
FF_DEBUG("Successfully opened adapter from LUID");
|
||||
|
||||
@@ -332,7 +332,7 @@ const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist*
|
||||
D3DKMT_QUERYSTATISTICS queryStatistics = {
|
||||
.Type = D3DKMT_QUERYSTATISTICS_NODE2, // Windows 11 (22H2) and later
|
||||
.AdapterLuid = *(LUID*) &adapterLuid,
|
||||
.QueryNode2 = {.PhysicalAdapterIndex = 0, .NodeOrdinal = (UINT16) nodeIdx},
|
||||
.QueryNode2 = { .PhysicalAdapterIndex = 0, .NodeOrdinal = (UINT16) nodeIdx },
|
||||
};
|
||||
if (NT_SUCCESS(D3DKMTQueryStatistics(&queryStatistics))) {
|
||||
gpu->frequency = (uint32_t) (queryStatistics.QueryResult.NodeInformation.NodePerfData.MaxFrequency / 1000 / 1000);
|
||||
@@ -344,7 +344,7 @@ const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist*
|
||||
}
|
||||
}
|
||||
|
||||
D3DKMT_CLOSEADAPTER closeAdapter = {.hAdapter = openAdapterFromLuid.hAdapter};
|
||||
D3DKMT_CLOSEADAPTER closeAdapter = { .hAdapter = openAdapterFromLuid.hAdapter };
|
||||
(void) D3DKMTCloseAdapter(&closeAdapter);
|
||||
openAdapterFromLuid.hAdapter = (D3DKMT_HANDLE) {};
|
||||
FF_DEBUG("Closed adapter handle");
|
||||
@@ -357,7 +357,7 @@ const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist*
|
||||
D3DKMT_QUERYSTATISTICS queryStatistics = {
|
||||
.Type = D3DKMT_QUERYSTATISTICS_PHYSICAL_ADAPTER, // Windows 10 (1803) and later
|
||||
.AdapterLuid = *(LUID*) &adapterLuid,
|
||||
.QueryPhysAdapter = {.PhysicalAdapterIndex = 0},
|
||||
.QueryPhysAdapter = { .PhysicalAdapterIndex = 0 },
|
||||
};
|
||||
if (NT_SUCCESS(D3DKMTQueryStatistics(&queryStatistics)) &&
|
||||
queryStatistics.QueryResult.PhysAdapterInformation.AdapterPerfData.Temperature != 0) {
|
||||
|
||||
@@ -55,7 +55,7 @@ extern "C" const char* ffGPUDetectTypeWithDXCore(LUID adapterLuid, FFGPUResult*
|
||||
return "Failed to get adapter by LUID";
|
||||
}
|
||||
|
||||
on_scope_exit releaseAdapter{[adapter] { adapter->Release(); }};
|
||||
on_scope_exit releaseAdapter{ [adapter] { adapter->Release(); } };
|
||||
|
||||
bool isIntegrated = false;
|
||||
hr = adapter->GetProperty(DXCoreAdapterProperty::IsIntegrated, sizeof(isIntegrated), &isIntegrated);
|
||||
|
||||
@@ -91,7 +91,7 @@ const char* ffGPUDetectWsl2(const FFGPUOptions* options, FFlist* gpus) {
|
||||
|
||||
const char* vendorStr = NULL;
|
||||
|
||||
D3DKMT_QUERY_DEVICE_IDS deviceIds = {.PhysicalAdapterIndex = 0};
|
||||
D3DKMT_QUERY_DEVICE_IDS deviceIds = { .PhysicalAdapterIndex = 0 };
|
||||
if (NT_SUCCESS(D3DKMTQueryAdapterInfo(dxg, &(D3DKMT_QUERYADAPTERINFO) {
|
||||
.hAdapter = adapter->hAdapter,
|
||||
.Type = KMTQAITYPE_PHYSICALADAPTERDEVICEIDS,
|
||||
@@ -274,7 +274,7 @@ const char* ffGPUDetectWsl2(const FFGPUOptions* options, FFlist* gpus) {
|
||||
D3DKMT_QUERYSTATISTICS queryStatistics = {
|
||||
.Type = D3DKMT_QUERYSTATISTICS_NODE2,
|
||||
.AdapterLuid = adapter->AdapterLuid,
|
||||
.QueryNode2 = {.PhysicalAdapterIndex = 0, .NodeOrdinal = (UINT16) nodeIdx},
|
||||
.QueryNode2 = { .PhysicalAdapterIndex = 0, .NodeOrdinal = (UINT16) nodeIdx },
|
||||
};
|
||||
if (NT_SUCCESS(D3DKMTQueryStatistics(dxg, &queryStatistics))) {
|
||||
gpu->frequency = (uint32_t) (queryStatistics.QueryResult.NodeInformation.NodePerfData.MaxFrequency / 1000 / 1000);
|
||||
@@ -290,7 +290,7 @@ const char* ffGPUDetectWsl2(const FFGPUOptions* options, FFlist* gpus) {
|
||||
D3DKMT_QUERYSTATISTICS queryStatistics = {
|
||||
.Type = D3DKMT_QUERYSTATISTICS_PHYSICAL_ADAPTER,
|
||||
.AdapterLuid = adapter->AdapterLuid,
|
||||
.QueryPhysAdapter = {.PhysicalAdapterIndex = 0},
|
||||
.QueryPhysAdapter = { .PhysicalAdapterIndex = 0 },
|
||||
};
|
||||
if (NT_SUCCESS(D3DKMTQueryStatistics(dxg, &queryStatistics)) &&
|
||||
queryStatistics.QueryResult.PhysAdapterInformation.AdapterPerfData.Temperature != 0) {
|
||||
@@ -325,7 +325,7 @@ const char* ffGPUDetectWsl2(const FFGPUOptions* options, FFlist* gpus) {
|
||||
(unsigned) gpu->type,
|
||||
(unsigned long) gpu->deviceId);
|
||||
|
||||
if (NT_SUCCESS(D3DKMTCloseAdapter(dxg, &(D3DKMT_CLOSEADAPTER) {.hAdapter = adapter->hAdapter}))) {
|
||||
if (NT_SUCCESS(D3DKMTCloseAdapter(dxg, &(D3DKMT_CLOSEADAPTER) { .hAdapter = adapter->hAdapter }))) {
|
||||
FF_DEBUG("Closed adapter #%u successfully", i);
|
||||
} else {
|
||||
FF_DEBUG("Failed to close adapter #%u: %s", i, strerror(errno));
|
||||
|
||||
@@ -100,7 +100,7 @@ static void detectGTKFromSettings(FFGTKResult* result) {
|
||||
}
|
||||
|
||||
static void detectGTKFromConfigFile(const char* filename, FFGTKResult* result) {
|
||||
ffParsePropFileValues(filename, 5, (FFpropquery[]) {{"gtk-theme-name =", &result->theme}, {"gtk-icon-theme-name =", &result->icons}, {"gtk-font-name =", &result->font}, {"gtk-cursor-theme-name =", &result->cursor}, {"gtk-cursor-theme-size =", &result->cursorSize}});
|
||||
ffParsePropFileValues(filename, 5, (FFpropquery[]) { { "gtk-theme-name =", &result->theme }, { "gtk-icon-theme-name =", &result->icons }, { "gtk-font-name =", &result->font }, { "gtk-cursor-theme-name =", &result->cursor }, { "gtk-cursor-theme-size =", &result->cursorSize } });
|
||||
}
|
||||
|
||||
static void detectGTKFromConfigDir(FFstrbuf* configDir, const char* version, FFGTKResult* result) {
|
||||
|
||||
@@ -127,7 +127,7 @@ static void detectPlasma(FFQtResult* result) {
|
||||
}
|
||||
|
||||
static void detectLXQt(FFQtResult* result) {
|
||||
ffParsePropFileConfigValues("lxqt/lxqt.conf", 3, (FFpropquery[]) {{"style = ", &result->widgetStyle}, {"icon_theme = ", &result->icons}, {"font = ", &result->font}});
|
||||
ffParsePropFileConfigValues("lxqt/lxqt.conf", 3, (FFpropquery[]) { { "style = ", &result->widgetStyle }, { "icon_theme = ", &result->icons }, { "font = ", &result->font } });
|
||||
|
||||
ffParsePropFileConfig("pcmanfm-qt/lxqt/settings.conf", "Wallpaper=", &result->wallpaper);
|
||||
}
|
||||
@@ -140,7 +140,7 @@ static void detectQtCt(char qver, FFQtResult* result) {
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY font = ffStrbufCreate();
|
||||
|
||||
ffParsePropFileConfigValues(file, 3, (FFpropquery[]) {{"style=", &result->widgetStyle}, {"icon_theme=", &result->icons}, {"general=", &font}});
|
||||
ffParsePropFileConfigValues(file, 3, (FFpropquery[]) { { "style=", &result->widgetStyle }, { "icon_theme=", &result->icons }, { "general=", &font } });
|
||||
|
||||
if (ffStrbufStartsWithC(&font, '@')) {
|
||||
// See QVariant notes on https://doc.qt.io/qt-5/qsettings.html and
|
||||
@@ -153,7 +153,7 @@ static void detectQtCt(char qver, FFQtResult* result) {
|
||||
|
||||
while (*p) {
|
||||
if (p[0] == '\\' && p[1] == 'x' && isxdigit(p[2]) && isxdigit(p[3]) && isxdigit(p[4]) && isxdigit(p[5])) {
|
||||
uint32_t codepoint = (uint32_t) strtoul((char[]) {p[2], p[3], p[4], p[5], '\0'}, NULL, 16);
|
||||
uint32_t codepoint = (uint32_t) strtoul((char[]) { p[2], p[3], p[4], p[5], '\0' }, NULL, 16);
|
||||
ffStrbufAppendUtf32CodePoint(&result->font, codepoint);
|
||||
p += 6;
|
||||
} else {
|
||||
@@ -168,7 +168,7 @@ static void detectQtCt(char qver, FFQtResult* result) {
|
||||
|
||||
static void detectKvantum(FFQtResult* result) {
|
||||
ffParsePropFileConfigValues("Kvantum/kvantum.kvconfig", 1, (FFpropquery[]) {
|
||||
{"theme=", &result->widgetStyle},
|
||||
{ "theme=", &result->widgetStyle },
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ const char* ffDetectKeyboard(FFlist* devices /* List of FFKeyboardDevice */) {
|
||||
return "IOHIDManagerOpen() failed";
|
||||
}
|
||||
|
||||
CFDictionaryRef FF_CFTYPE_AUTO_RELEASE matching1 = CFDictionaryCreate(kCFAllocatorDefault, (const void**) (CFStringRef[]) {CFSTR(kIOHIDDeviceUsagePageKey), CFSTR(kIOHIDDeviceUsageKey)}, (const void**) (CFNumberRef[]) {ffCfCreateInt(kHIDPage_GenericDesktop), ffCfCreateInt(kHIDUsage_GD_Keyboard)}, 2, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
|
||||
CFDictionaryRef FF_CFTYPE_AUTO_RELEASE matching1 = CFDictionaryCreate(kCFAllocatorDefault, (const void**) (CFStringRef[]) { CFSTR(kIOHIDDeviceUsagePageKey), CFSTR(kIOHIDDeviceUsageKey) }, (const void**) (CFNumberRef[]) { ffCfCreateInt(kHIDPage_GenericDesktop), ffCfCreateInt(kHIDUsage_GD_Keyboard) }, 2, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
|
||||
IOHIDManagerSetDeviceMatching(manager, matching1);
|
||||
|
||||
CFSetRef FF_CFTYPE_AUTO_RELEASE set = IOHIDManagerCopyDevices(manager);
|
||||
|
||||
@@ -10,9 +10,9 @@
|
||||
#define FF_SYSTEMD_USERS_PATH "/run/systemd/users/"
|
||||
|
||||
static const char* getGdmVersion(FFstrbuf* version) {
|
||||
const char* error = ffProcessAppendStdOut(version, (char* const[]) {"gdm", "--version", NULL});
|
||||
const char* error = ffProcessAppendStdOut(version, (char* const[]) { "gdm", "--version", NULL });
|
||||
if (error || version->length == 0) {
|
||||
error = ffProcessAppendStdOut(version, (char* const[]) {"gdm3", "--version", NULL});
|
||||
error = ffProcessAppendStdOut(version, (char* const[]) { "gdm3", "--version", NULL });
|
||||
if (error || version->length == 0) {
|
||||
return "Failed to get GDM version";
|
||||
}
|
||||
@@ -24,7 +24,7 @@ static const char* getGdmVersion(FFstrbuf* version) {
|
||||
}
|
||||
|
||||
static const char* getSshdVersion(FFstrbuf* version) {
|
||||
const char* error = ffProcessAppendStdErr(version, (char* const[]) {"sshd", "-V", NULL});
|
||||
const char* error = ffProcessAppendStdErr(version, (char* const[]) { "sshd", "-V", NULL });
|
||||
if (error) {
|
||||
return error;
|
||||
}
|
||||
@@ -87,7 +87,7 @@ static const char* getSddmVersion(FF_MAYBE_UNUSED FFstrbuf* version) {
|
||||
#endif
|
||||
|
||||
static const char* getXfwmVersion(FFstrbuf* version) {
|
||||
const char* error = ffProcessAppendStdOut(version, (char* const[]) {"xfwm4", "--version", NULL});
|
||||
const char* error = ffProcessAppendStdOut(version, (char* const[]) { "xfwm4", "--version", NULL });
|
||||
if (error) {
|
||||
return error;
|
||||
}
|
||||
@@ -100,7 +100,7 @@ static const char* getXfwmVersion(FFstrbuf* version) {
|
||||
}
|
||||
|
||||
static const char* getLightdmVersion(FFstrbuf* version) {
|
||||
const char* error = ffProcessAppendStdErr(version, (char* const[]) {"lightdm", "--version", NULL});
|
||||
const char* error = ffProcessAppendStdErr(version, (char* const[]) { "lightdm", "--version", NULL });
|
||||
if (error) {
|
||||
return error;
|
||||
}
|
||||
@@ -124,7 +124,7 @@ const char* ffDetectLM(FFLMResult* result) {
|
||||
// This is actually buggy, and assumes current user is using DE
|
||||
// `sd_pid_get_session` can be a better option, but we need to find a pid to use
|
||||
if (!ffParsePropFileValues(path.chars, 1, (FFpropquery[]) {
|
||||
{"DISPLAY=", &sessionId},
|
||||
{ "DISPLAY=", &sessionId },
|
||||
})) {
|
||||
return "Failed to get $XDG_SESSION_ID";
|
||||
}
|
||||
@@ -135,8 +135,8 @@ const char* ffDetectLM(FFLMResult* result) {
|
||||
|
||||
// WARNING: This is private data. Do not parse
|
||||
if (!ffParsePropFileValues(path.chars, 2, (FFpropquery[]) {
|
||||
{"SERVICE=", &result->service},
|
||||
{"TYPE=", &result->type},
|
||||
{ "SERVICE=", &result->service },
|
||||
{ "TYPE=", &result->type },
|
||||
})) {
|
||||
return "Failed to parse " FF_SYSTEMD_SESSIONS_PATH "$XDG_SESSION_ID";
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
const char* ffDetectLoadavg(double result[3]) {
|
||||
struct loadavg load;
|
||||
size_t size = sizeof(load);
|
||||
if (sysctl((int[]) {CTL_VM, VM_LOADAVG}, 2, &load, &size, NULL, 0) < 0) {
|
||||
if (sysctl((int[]) { CTL_VM, VM_LOADAVG }, 2, &load, &size, NULL, 0) < 0) {
|
||||
return "sysctl({CTL_VM, VM_LOADAVG}) failed";
|
||||
}
|
||||
for (int i = 0; i < 3; i++) {
|
||||
|
||||
@@ -46,7 +46,7 @@ static inline void kstatFreeWrap(kstat_ctl_t** pkc) {
|
||||
}
|
||||
#endif
|
||||
|
||||
#define FF_LOCALIP_NIFLAG(name) {IFF_##name, #name}
|
||||
#define FF_LOCALIP_NIFLAG(name) { IFF_##name, #name }
|
||||
|
||||
static const FFLocalIpNIFlag niFlagOptions[] = {
|
||||
FF_LOCALIP_NIFLAG(UP),
|
||||
@@ -567,7 +567,7 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results) {
|
||||
|
||||
if (options->showType & FF_LOCALIP_TYPE_SPEED_BIT) {
|
||||
#ifdef __linux__
|
||||
struct ethtool_cmd edata = {.cmd = ETHTOOL_GSET};
|
||||
struct ethtool_cmd edata = { .cmd = ETHTOOL_GSET };
|
||||
ifr.ifr_data = (void*) &edata;
|
||||
if (ioctl(sockfd, SIOCETHTOOL, &ifr) == 0) {
|
||||
iface->speed = (edata.speed_hi << 16) | edata.speed;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include "common/debug.h"
|
||||
#include "localip.h"
|
||||
|
||||
#define FF_LOCALIP_NIFLAG(name) {IP_ADAPTER_##name, #name}
|
||||
#define FF_LOCALIP_NIFLAG(name) { IP_ADAPTER_##name, #name }
|
||||
|
||||
static const FFLocalIpNIFlag niFlagOptions[] = {
|
||||
FF_LOCALIP_NIFLAG(DDNS_ENABLED),
|
||||
|
||||
@@ -80,7 +80,7 @@ static bool parseMprisMetadata(FFDBusData* data, DBusMessageIter* rootIterator,
|
||||
if (i + 2 >= path.length) {
|
||||
break;
|
||||
}
|
||||
char str[] = {path.chars[i + 1], path.chars[i + 2], 0};
|
||||
char str[] = { path.chars[i + 1], path.chars[i + 2], 0 };
|
||||
char* end = NULL;
|
||||
const char decodedChar = (char) strtoul(str, &end, 16);
|
||||
if (end == &str[2]) {
|
||||
@@ -155,7 +155,7 @@ static bool getBusProperties(FFDBusData* data, const char* busName, FFMediaResul
|
||||
if (fileName[1] == 0 || fileName[2] == 0) {
|
||||
break;
|
||||
}
|
||||
char str[] = {fileName[1], fileName[2], 0};
|
||||
char str[] = { fileName[1], fileName[2], 0 };
|
||||
ffStrbufAppendC(&result->song, (char) strtoul(str, NULL, 16));
|
||||
fileName += 2;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ const char* ffDetectMemory(FFMemoryResult* ram) {
|
||||
return "Failed to read hw.memsize_usable";
|
||||
}
|
||||
#else
|
||||
if (sysctl((int[]) {CTL_HW, HW_MEMSIZE}, 2, &ram->bytesTotal, &length, NULL, 0) != 0) {
|
||||
if (sysctl((int[]) { CTL_HW, HW_MEMSIZE }, 2, &ram->bytesTotal, &length, NULL, 0) != 0) {
|
||||
return "Failed to read hw.memsize";
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
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, HW_PHYSMEM }, 2, &ram->bytesTotal, &length, NULL, 0)) {
|
||||
return "Failed to read hw.physmem";
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
const char* ffDetectMemory(FFMemoryResult* ram) {
|
||||
struct uvmexp_sysctl buf;
|
||||
size_t length = sizeof(buf);
|
||||
if (sysctl((int[]) {CTL_VM, VM_UVMEXP2}, 2, &buf, &length, NULL, 0) < 0) {
|
||||
if (sysctl((int[]) { CTL_VM, VM_UVMEXP2 }, 2, &buf, &length, NULL, 0) < 0) {
|
||||
return "sysctl(CTL_VM, VM_UVMEXP2) failed";
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
const char* ffDetectMemory(FFMemoryResult* ram) {
|
||||
struct uvmexp buf;
|
||||
size_t length = sizeof(buf);
|
||||
if (sysctl((int[]) {CTL_VM, VM_UVMEXP}, 2, &buf, &length, NULL, 0) < 0) {
|
||||
if (sysctl((int[]) { CTL_VM, VM_UVMEXP }, 2, &buf, &length, NULL, 0) < 0) {
|
||||
return "sysctl(CTL_VM, VM_UVMEXP) failed";
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ const char* ffDetectMouse(FFlist* devices /* List of FFMouseDevice */) {
|
||||
return "IOHIDManagerOpen() failed";
|
||||
}
|
||||
|
||||
CFDictionaryRef FF_CFTYPE_AUTO_RELEASE matching1 = CFDictionaryCreate(kCFAllocatorDefault, (const void**) (CFStringRef[]) {CFSTR(kIOHIDDeviceUsagePageKey), CFSTR(kIOHIDDeviceUsageKey)}, (const void**) (CFNumberRef[]) {ffCfCreateInt(kHIDPage_GenericDesktop), ffCfCreateInt(kHIDUsage_GD_Mouse)}, 2, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
|
||||
CFDictionaryRef FF_CFTYPE_AUTO_RELEASE matching1 = CFDictionaryCreate(kCFAllocatorDefault, (const void**) (CFStringRef[]) { CFSTR(kIOHIDDeviceUsagePageKey), CFSTR(kIOHIDDeviceUsageKey) }, (const void**) (CFNumberRef[]) { ffCfCreateInt(kHIDPage_GenericDesktop), ffCfCreateInt(kHIDUsage_GD_Mouse) }, 2, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
|
||||
IOHIDManagerSetDeviceMatching(manager, matching1);
|
||||
|
||||
CFSetRef FF_CFTYPE_AUTO_RELEASE set = IOHIDManagerCopyDevices(manager);
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include <sys/sysctl.h>
|
||||
|
||||
const char* ffNetIOGetIoCounters(FFlist* result, FFNetIOOptions* options) {
|
||||
int mib[] = {CTL_NET, PF_LINK, NETLINK_GENERIC, options->defaultRouteOnly ? IFMIB_IFDATA : IFMIB_IFALLDATA, options->defaultRouteOnly ? (int) ffNetifGetDefaultRouteV4()->ifIndex : 0, IFDATA_GENERAL};
|
||||
int mib[] = { CTL_NET, PF_LINK, NETLINK_GENERIC, options->defaultRouteOnly ? IFMIB_IFDATA : IFMIB_IFALLDATA, options->defaultRouteOnly ? (int) ffNetifGetDefaultRouteV4()->ifIndex : 0, IFDATA_GENERAL };
|
||||
|
||||
size_t bufSize = 0;
|
||||
if (sysctl(mib, ARRAY_SIZE(mib), NULL, &bufSize, 0, 0) < 0) {
|
||||
|
||||
@@ -14,12 +14,12 @@ const char* ffNetIOGetIoCounters(FFlist* result, FFNetIOOptions* options) {
|
||||
uint32_t defaultRouteIfIndex = ffNetifGetDefaultRouteV4()->ifIndex;
|
||||
|
||||
size_t bufSize = 0;
|
||||
if (sysctl((int[]) {CTL_NET, PF_ROUTE, 0, 0, NET_RT_IFLIST, (options->defaultRouteOnly ? (int) defaultRouteIfIndex : 0)}, 6, NULL, &bufSize, 0, 0) < 0) {
|
||||
if (sysctl((int[]) { CTL_NET, PF_ROUTE, 0, 0, NET_RT_IFLIST, (options->defaultRouteOnly ? (int) defaultRouteIfIndex : 0) }, 6, NULL, &bufSize, 0, 0) < 0) {
|
||||
return "sysctl({ CTL_NET, PF_ROUTE, 0, 0, NET_RT_IFLIST, ifIndex }, 6, NULL, &bufSize, 0, 0) failed";
|
||||
}
|
||||
|
||||
FF_AUTO_FREE struct if_msghdr* buf = (struct if_msghdr*) malloc(bufSize);
|
||||
if (sysctl((int[]) {CTL_NET, PF_ROUTE, 0, 0, NET_RT_IFLIST, (options->defaultRouteOnly ? (int) defaultRouteIfIndex : 0)}, 6, buf, &bufSize, 0, 0) < 0) {
|
||||
if (sysctl((int[]) { CTL_NET, PF_ROUTE, 0, 0, NET_RT_IFLIST, (options->defaultRouteOnly ? (int) defaultRouteIfIndex : 0) }, 6, buf, &bufSize, 0, 0) < 0) {
|
||||
return "sysctl({ CTL_NET, PF_ROUTE, 0, 0, NET_RT_IFLIST, ifIndex }, 6, buf, &bufSize, 0, 0) failed";
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ const char* ffNetIOGetIoCounters(FFlist* result, FFNetIOOptions* options) {
|
||||
continue;
|
||||
}
|
||||
|
||||
MIB_IF_ROW2 ifRow = {.InterfaceIndex = adapter->IfIndex};
|
||||
MIB_IF_ROW2 ifRow = { .InterfaceIndex = adapter->IfIndex };
|
||||
if (GetIfEntry2(&ifRow) == NO_ERROR) {
|
||||
FFNetIOResult* counters = (FFNetIOResult*) ffListAdd(result);
|
||||
*counters = (FFNetIOResult) {
|
||||
|
||||
@@ -98,7 +98,7 @@ static const char* glxHandleVisualInfo(FFOpenGLResult* result, GLXData* data) {
|
||||
}
|
||||
|
||||
static const char* glxHandleDisplay(FFOpenGLResult* result, GLXData* data) {
|
||||
data->visualInfo = data->ffglXChooseVisual(data->display, DefaultScreen(data->display), (int[]) {None});
|
||||
data->visualInfo = data->ffglXChooseVisual(data->display, DefaultScreen(data->display), (int[]) { None });
|
||||
if (data->visualInfo == NULL) {
|
||||
return "glXChooseVisual returned NULL";
|
||||
}
|
||||
|
||||
@@ -73,12 +73,12 @@ static const char* eglHandleContext(FFOpenGLResult* result, EGLData* data) {
|
||||
|
||||
static const char* eglHandleSurface(FFOpenGLResult* result, EGLData* data, bool gles) {
|
||||
FF_DEBUG("Creating EGL context (preferred API=%s, client version=%d)", gles ? "OpenGL ES" : "OpenGL", gles ? 2 : 1);
|
||||
data->context = data->ffeglCreateContext(data->display, data->config, EGL_NO_CONTEXT, (EGLint[]) {EGL_CONTEXT_CLIENT_VERSION, gles ? 2 : 1, // Try GLES 2.0+ first
|
||||
EGL_NONE});
|
||||
data->context = data->ffeglCreateContext(data->display, data->config, EGL_NO_CONTEXT, (EGLint[]) { EGL_CONTEXT_CLIENT_VERSION, gles ? 2 : 1, // Try GLES 2.0+ first
|
||||
EGL_NONE });
|
||||
if (data->context == EGL_NO_CONTEXT && gles) // Some ANGLE builds support GLES 1.1 only
|
||||
{
|
||||
FF_DEBUG("EGL context creation with GLES 2.x failed, retrying with default attributes (GLES 1.1 fallback)");
|
||||
data->context = data->ffeglCreateContext(data->display, data->config, EGL_NO_CONTEXT, (EGLint[]) {EGL_NONE});
|
||||
data->context = data->ffeglCreateContext(data->display, data->config, EGL_NO_CONTEXT, (EGLint[]) { EGL_NONE });
|
||||
}
|
||||
if (data->context == EGL_NO_CONTEXT) {
|
||||
FF_DEBUG("eglCreateContext() returned EGL_NO_CONTEXT");
|
||||
@@ -115,7 +115,7 @@ static const char* eglHandleDisplay(FFOpenGLResult* result, EGLData* data) {
|
||||
}
|
||||
|
||||
FF_DEBUG("Creating EGL pbuffer surface (%dx%d)", FF_OPENGL_BUFFER_WIDTH, FF_OPENGL_BUFFER_HEIGHT);
|
||||
data->surface = data->ffeglCreatePbufferSurface(data->display, data->config, (EGLint[]) {EGL_WIDTH, FF_OPENGL_BUFFER_WIDTH, EGL_HEIGHT, FF_OPENGL_BUFFER_HEIGHT, EGL_NONE});
|
||||
data->surface = data->ffeglCreatePbufferSurface(data->display, data->config, (EGLint[]) { EGL_WIDTH, FF_OPENGL_BUFFER_WIDTH, EGL_HEIGHT, FF_OPENGL_BUFFER_HEIGHT, EGL_NONE });
|
||||
|
||||
if (data->surface == EGL_NO_SURFACE) {
|
||||
FF_DEBUG("eglCreatePbufferSurface() returned EGL_NO_SURFACE");
|
||||
|
||||
+18
-18
@@ -13,26 +13,26 @@
|
||||
|
||||
static bool parseLsbRelease(const char* fileName, FFOSResult* result) {
|
||||
return ffParsePropFileValues(fileName, 4, (FFpropquery[]) {
|
||||
{"DISTRIB_ID =", &result->id},
|
||||
{"DISTRIB_DESCRIPTION =", &result->prettyName},
|
||||
{"DISTRIB_RELEASE =", &result->version},
|
||||
{"DISTRIB_CODENAME =", &result->codename},
|
||||
{ "DISTRIB_ID =", &result->id },
|
||||
{ "DISTRIB_DESCRIPTION =", &result->prettyName },
|
||||
{ "DISTRIB_RELEASE =", &result->version },
|
||||
{ "DISTRIB_CODENAME =", &result->codename },
|
||||
});
|
||||
}
|
||||
|
||||
static bool parseOsRelease(const char* fileName, FFOSResult* result) {
|
||||
return ffParsePropFileValues(fileName, 11, (FFpropquery[]) {
|
||||
{"PRETTY_NAME =", &result->prettyName},
|
||||
{"NAME =", &result->name},
|
||||
{"ID =", &result->id},
|
||||
{"ID_LIKE =", &result->idLike},
|
||||
{"VARIANT =", &result->variant},
|
||||
{"VARIANT_ID =", &result->variantID},
|
||||
{"VERSION =", &result->version},
|
||||
{"VERSION_ID =", &result->versionID},
|
||||
{"VERSION_CODENAME =", &result->codename},
|
||||
{"CODENAME =", &result->codename},
|
||||
{"BUILD_ID =", &result->buildID},
|
||||
{ "PRETTY_NAME =", &result->prettyName },
|
||||
{ "NAME =", &result->name },
|
||||
{ "ID =", &result->id },
|
||||
{ "ID_LIKE =", &result->idLike },
|
||||
{ "VARIANT =", &result->variant },
|
||||
{ "VARIANT_ID =", &result->variantID },
|
||||
{ "VERSION =", &result->version },
|
||||
{ "VERSION_ID =", &result->versionID },
|
||||
{ "VERSION_CODENAME =", &result->codename },
|
||||
{ "CODENAME =", &result->codename },
|
||||
{ "BUILD_ID =", &result->buildID },
|
||||
});
|
||||
}
|
||||
|
||||
@@ -228,9 +228,9 @@ FF_MAYBE_UNUSED static bool detectDebianDerived(FFOSResult* result) {
|
||||
FF_STRBUF_AUTO_DESTROY sub = ffStrbufCreate();
|
||||
FF_STRBUF_AUTO_DESTROY rc = ffStrbufCreate();
|
||||
if (ffParsePropFileValues("/boot/dietpi/.version", 3, (FFpropquery[]) {
|
||||
{"G_DIETPI_VERSION_CORE=", &core},
|
||||
{"G_DIETPI_VERSION_SUB=", &sub},
|
||||
{"G_DIETPI_VERSION_RC=", &rc},
|
||||
{ "G_DIETPI_VERSION_CORE=", &core },
|
||||
{ "G_DIETPI_VERSION_SUB=", &sub },
|
||||
{ "G_DIETPI_VERSION_RC=", &rc },
|
||||
})) {
|
||||
ffStrbufAppendF(&result->prettyName, " %s.%s.%s", core.chars, sub.chars, rc.chars);
|
||||
}
|
||||
|
||||
@@ -413,8 +413,8 @@ static uint32_t getPacmanPackages(FFstrbuf* baseDir) {
|
||||
ffStrbufAppendS(baseDir, "/etc/pacman.conf");
|
||||
|
||||
bool confFound = ffParsePropFileValues(baseDir->chars, 2, (FFpropquery[]) {
|
||||
{"DBPath =", &dbPath},
|
||||
{"RootDir =", &rootDir},
|
||||
{ "DBPath =", &dbPath },
|
||||
{ "RootDir =", &rootDir },
|
||||
});
|
||||
ffStrbufSubstrBefore(baseDir, baseDirLen);
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ static uint32_t getNixPackagesImpl(char* path) {
|
||||
FF_STRBUF_AUTO_DESTROY cacheHash = ffStrbufCreateA(64);
|
||||
uint32_t count = 0;
|
||||
|
||||
ffProcessAppendStdOut(&hash, (char* const[]) {"nix-store", "--query", "--hash", path, NULL});
|
||||
ffProcessAppendStdOut(&hash, (char* const[]) { "nix-store", "--query", "--hash", path, NULL });
|
||||
|
||||
if (checkNixCache(&cacheDir, &cacheHash, &count) && ffStrbufEqual(&hash, &cacheHash)) {
|
||||
return count;
|
||||
@@ -115,7 +115,7 @@ static uint32_t getNixPackagesImpl(char* path) {
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY output = ffStrbufCreateA(1024);
|
||||
|
||||
ffProcessAppendStdOut(&output, (char* const[]) {"nix-store", "--query", "--requisites", path, NULL});
|
||||
ffProcessAppendStdOut(&output, (char* const[]) { "nix-store", "--query", "--requisites", path, NULL });
|
||||
|
||||
uint32_t lineLength = 0;
|
||||
for (uint32_t i = 0; i < output.length; i++) {
|
||||
|
||||
@@ -71,7 +71,7 @@ const char* ffDetectPhysicalDisk(FFlist* result, FFPhysicalDiskOptions* options)
|
||||
if (rootNode == DI_NODE_NIL) {
|
||||
return "di_init() failed";
|
||||
}
|
||||
di_walk_minor(rootNode, DDI_NT_BLOCK, DI_WALK_CLDFIRST, &(struct FFWalkTreeBundle) {options, result}, (void*) walkDevTree);
|
||||
di_walk_minor(rootNode, DDI_NT_BLOCK, DI_WALK_CLDFIRST, &(struct FFWalkTreeBundle) { options, result }, (void*) walkDevTree);
|
||||
di_fini(rootNode);
|
||||
|
||||
return NULL;
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#endif
|
||||
|
||||
const char* ffDetectProcesses(uint32_t* result) {
|
||||
int request[] = {CTL_KERN, KERN_PROC, KERN_PROC_PROC};
|
||||
int request[] = { CTL_KERN, KERN_PROC, KERN_PROC_PROC };
|
||||
size_t length;
|
||||
|
||||
if (sysctl(request, ARRAY_SIZE(request), NULL, &length, NULL, 0) != 0) {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include <sys/sysctl.h>
|
||||
|
||||
const char* ffDetectProcesses(uint32_t* result) {
|
||||
int request[] = {CTL_KERN, KERN_PROC2, KERN_PROC_ALL, -1, sizeof(struct kinfo_proc2), 0};
|
||||
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) {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
#define FF_UNITIALIZED ((const char*) (uintptr_t) -1)
|
||||
static FFNetworkingState states[2];
|
||||
static const char* statuses[2] = {FF_UNITIALIZED, FF_UNITIALIZED};
|
||||
static const char* statuses[2] = { FF_UNITIALIZED, FF_UNITIALIZED };
|
||||
|
||||
void ffPreparePublicIp(FFPublicIPOptions* options) {
|
||||
FFNetworkingState* state = &states[options->ipv6];
|
||||
|
||||
@@ -11,13 +11,13 @@
|
||||
const char* ffDetectSound(FFlist* devices /* List of FFSoundDevice */) {
|
||||
AudioDeviceID mainDeviceId;
|
||||
UInt32 dataSize = sizeof(mainDeviceId);
|
||||
if (AudioObjectGetPropertyData(kAudioObjectSystemObject, &(AudioObjectPropertyAddress) {kAudioHardwarePropertyDefaultOutputDevice, kAudioObjectPropertyScopeOutput, kAudioObjectPropertyElementMain}, 0, NULL, &dataSize, &mainDeviceId) != kAudioHardwareNoError) {
|
||||
if (AudioObjectGetPropertyData(kAudioObjectSystemObject, &(AudioObjectPropertyAddress) { kAudioHardwarePropertyDefaultOutputDevice, kAudioObjectPropertyScopeOutput, kAudioObjectPropertyElementMain }, 0, NULL, &dataSize, &mainDeviceId) != kAudioHardwareNoError) {
|
||||
return "AudioObjectGetPropertyData(kAudioHardwarePropertyDefaultOutputDevice) failed";
|
||||
}
|
||||
|
||||
AudioObjectID deviceIds[32] = {};
|
||||
dataSize = sizeof(deviceIds);
|
||||
if (AudioObjectGetPropertyData(kAudioObjectSystemObject, &(AudioObjectPropertyAddress) {kAudioHardwarePropertyDevices, kAudioObjectPropertyScopeOutput, kAudioObjectPropertyElementMain}, 0, NULL, &dataSize, &deviceIds) != kAudioHardwareNoError) {
|
||||
if (AudioObjectGetPropertyData(kAudioObjectSystemObject, &(AudioObjectPropertyAddress) { kAudioHardwarePropertyDevices, kAudioObjectPropertyScopeOutput, kAudioObjectPropertyElementMain }, 0, NULL, &dataSize, &deviceIds) != kAudioHardwareNoError) {
|
||||
return "AudioObjectGetPropertyData(kAudioHardwarePropertyDevices) failed";
|
||||
}
|
||||
|
||||
@@ -25,16 +25,16 @@ const char* ffDetectSound(FFlist* devices /* List of FFSoundDevice */) {
|
||||
AudioDeviceID deviceId = deviceIds[index];
|
||||
|
||||
// Ignore input devices
|
||||
if (AudioObjectGetPropertyDataSize(deviceId, &(AudioObjectPropertyAddress) {kAudioDevicePropertyStreams, kAudioObjectPropertyScopeInput, kAudioObjectPropertyElementMain}, 0, NULL, &dataSize) == kAudioHardwareNoError && dataSize > 0) {
|
||||
if (AudioObjectGetPropertyDataSize(deviceId, &(AudioObjectPropertyAddress) { kAudioDevicePropertyStreams, kAudioObjectPropertyScopeInput, kAudioObjectPropertyElementMain }, 0, NULL, &dataSize) == kAudioHardwareNoError && dataSize > 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
uint32_t dataSource;
|
||||
dataSize = sizeof(dataSource);
|
||||
if (AudioObjectGetPropertyData(deviceId, &(AudioObjectPropertyAddress) {kAudioDevicePropertyDataSource, kAudioObjectPropertyScopeOutput, kAudioObjectPropertyElementMain}, 0, NULL, &dataSize, &dataSource) == kAudioHardwareNoError && dataSource == 'hdpn') {
|
||||
if (AudioObjectGetPropertyData(deviceId, &(AudioObjectPropertyAddress) { kAudioDevicePropertyDataSource, kAudioObjectPropertyScopeOutput, kAudioObjectPropertyElementMain }, 0, NULL, &dataSize, &dataSource) == kAudioHardwareNoError && dataSource == 'hdpn') {
|
||||
uint32_t connected;
|
||||
dataSize = sizeof(connected);
|
||||
if (AudioObjectGetPropertyData(deviceId, &(AudioObjectPropertyAddress) {kAudioDevicePropertyJackIsConnected, kAudioObjectPropertyScopeOutput, kAudioObjectPropertyElementMain}, 0, NULL, &dataSize, &connected) == kAudioHardwareNoError) {
|
||||
if (AudioObjectGetPropertyData(deviceId, &(AudioObjectPropertyAddress) { kAudioDevicePropertyJackIsConnected, kAudioObjectPropertyScopeOutput, kAudioObjectPropertyElementMain }, 0, NULL, &dataSize, &connected) == kAudioHardwareNoError) {
|
||||
if (!connected) {
|
||||
continue;
|
||||
}
|
||||
@@ -51,7 +51,7 @@ const char* ffDetectSound(FFlist* devices /* List of FFSoundDevice */) {
|
||||
|
||||
FF_CFTYPE_AUTO_RELEASE CFStringRef uid = NULL;
|
||||
dataSize = sizeof(uid);
|
||||
if (AudioObjectGetPropertyData(deviceId, &(AudioObjectPropertyAddress) {kAudioDevicePropertyDeviceUID, kAudioObjectPropertyScopeOutput, kAudioObjectPropertyElementMain}, 0, NULL, &dataSize, &uid) == kAudioHardwareNoError) {
|
||||
if (AudioObjectGetPropertyData(deviceId, &(AudioObjectPropertyAddress) { kAudioDevicePropertyDeviceUID, kAudioObjectPropertyScopeOutput, kAudioObjectPropertyElementMain }, 0, NULL, &dataSize, &uid) == kAudioHardwareNoError) {
|
||||
ffCfStrGetString(uid, &device->identifier);
|
||||
} else {
|
||||
ffStrbufAppendF(&device->identifier, "ID-%u", (unsigned) deviceId);
|
||||
@@ -59,7 +59,7 @@ const char* ffDetectSound(FFlist* devices /* List of FFSoundDevice */) {
|
||||
|
||||
FF_CFTYPE_AUTO_RELEASE CFStringRef name = NULL;
|
||||
dataSize = sizeof(name);
|
||||
if (AudioObjectGetPropertyData(deviceId, &(AudioObjectPropertyAddress) {kAudioObjectPropertyName, kAudioObjectPropertyScopeOutput, kAudioObjectPropertyElementMain}, 0, NULL, &dataSize, &name) == kAudioHardwareNoError) {
|
||||
if (AudioObjectGetPropertyData(deviceId, &(AudioObjectPropertyAddress) { kAudioObjectPropertyName, kAudioObjectPropertyScopeOutput, kAudioObjectPropertyElementMain }, 0, NULL, &dataSize, &name) == kAudioHardwareNoError) {
|
||||
ffCfStrGetString(name, &device->name);
|
||||
} else {
|
||||
ffStrbufSet(&device->name, &device->identifier);
|
||||
@@ -67,13 +67,13 @@ const char* ffDetectSound(FFlist* devices /* List of FFSoundDevice */) {
|
||||
|
||||
uint32_t muted;
|
||||
dataSize = sizeof(muted);
|
||||
if (AudioObjectGetPropertyData(deviceId, &(AudioObjectPropertyAddress) {kAudioDevicePropertyMute, kAudioObjectPropertyScopeOutput, kAudioObjectPropertyElementMain}, 0, NULL, &dataSize, &muted) != kAudioHardwareNoError) {
|
||||
if (AudioObjectGetPropertyData(deviceId, &(AudioObjectPropertyAddress) { kAudioDevicePropertyMute, kAudioObjectPropertyScopeOutput, kAudioObjectPropertyElementMain }, 0, NULL, &dataSize, &muted) != kAudioHardwareNoError) {
|
||||
muted = false; // Device may not support volume control
|
||||
}
|
||||
|
||||
uint32_t active;
|
||||
dataSize = sizeof(active);
|
||||
if (AudioObjectGetPropertyData(deviceId, &(AudioObjectPropertyAddress) {kAudioDevicePropertyDeviceIsAlive, kAudioObjectPropertyScopeOutput, kAudioObjectPropertyElementMain}, 0, NULL, &dataSize, &active) == kAudioHardwareNoError) {
|
||||
if (AudioObjectGetPropertyData(deviceId, &(AudioObjectPropertyAddress) { kAudioDevicePropertyDeviceIsAlive, kAudioObjectPropertyScopeOutput, kAudioObjectPropertyElementMain }, 0, NULL, &dataSize, &active) == kAudioHardwareNoError) {
|
||||
device->active = !!active;
|
||||
}
|
||||
|
||||
@@ -82,17 +82,17 @@ const char* ffDetectSound(FFlist* devices /* List of FFSoundDevice */) {
|
||||
} else {
|
||||
float volume;
|
||||
dataSize = sizeof(volume);
|
||||
if (AudioObjectGetPropertyData(deviceId, &(AudioObjectPropertyAddress) {kAudioDevicePropertyVolumeScalar, kAudioObjectPropertyScopeOutput, kAudioObjectPropertyElementMain}, 0, NULL, &dataSize, &volume) == kAudioHardwareNoError) {
|
||||
if (AudioObjectGetPropertyData(deviceId, &(AudioObjectPropertyAddress) { kAudioDevicePropertyVolumeScalar, kAudioObjectPropertyScopeOutput, kAudioObjectPropertyElementMain }, 0, NULL, &dataSize, &volume) == kAudioHardwareNoError) {
|
||||
device->volume = (uint8_t) (volume * 100 + 0.5);
|
||||
} else {
|
||||
// Try detecting volume from channels
|
||||
uint32_t channels[2];
|
||||
dataSize = sizeof(channels);
|
||||
if (AudioObjectGetPropertyData(deviceId, &(AudioObjectPropertyAddress) {kAudioDevicePropertyPreferredChannelsForStereo, kAudioObjectPropertyScopeOutput, kAudioObjectPropertyElementMain}, 0, NULL, &dataSize, channels) == kAudioHardwareNoError) {
|
||||
if (AudioObjectGetPropertyData(deviceId, &(AudioObjectPropertyAddress) { kAudioDevicePropertyPreferredChannelsForStereo, kAudioObjectPropertyScopeOutput, kAudioObjectPropertyElementMain }, 0, NULL, &dataSize, channels) == kAudioHardwareNoError) {
|
||||
dataSize = sizeof(volume);
|
||||
if (AudioObjectGetPropertyData(deviceId, &(AudioObjectPropertyAddress) {kAudioDevicePropertyVolumeScalar, kAudioObjectPropertyScopeOutput, channels[0]}, 0, NULL, &dataSize, &volume) == kAudioHardwareNoError) {
|
||||
if (AudioObjectGetPropertyData(deviceId, &(AudioObjectPropertyAddress) { kAudioDevicePropertyVolumeScalar, kAudioObjectPropertyScopeOutput, channels[0] }, 0, NULL, &dataSize, &volume) == kAudioHardwareNoError) {
|
||||
float temp;
|
||||
if (AudioObjectGetPropertyData(deviceId, &(AudioObjectPropertyAddress) {kAudioDevicePropertyVolumeScalar, kAudioObjectPropertyScopeOutput, channels[1]}, 0, NULL, &dataSize, &temp) == kAudioHardwareNoError) {
|
||||
if (AudioObjectGetPropertyData(deviceId, &(AudioObjectPropertyAddress) { kAudioDevicePropertyVolumeScalar, kAudioObjectPropertyScopeOutput, channels[1] }, 0, NULL, &dataSize, &temp) == kAudioHardwareNoError) {
|
||||
device->volume = (uint8_t) ((volume + temp) / 2 * 100 + 0.5);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ const char* ffDetectSound(FFlist* devices) {
|
||||
|
||||
char path[] = "/dev/mixer0";
|
||||
|
||||
struct oss_sysinfo info = {.nummixers = 9};
|
||||
struct oss_sysinfo info = { .nummixers = 9 };
|
||||
|
||||
for (int idev = 0; idev <= info.nummixers; ++idev) {
|
||||
path[strlen("/dev/mixer")] = (char) ('0' + idev);
|
||||
@@ -58,7 +58,7 @@ const char* ffDetectSound(FFlist* devices) {
|
||||
ioctl(fd, SOUND_MIXER_READ_MUTE, &mutemask);
|
||||
#endif
|
||||
|
||||
struct oss_card_info ci = {.card = idev};
|
||||
struct oss_card_info ci = { .card = idev };
|
||||
if (ioctl(fd, SNDCTL_CARDINFO, &ci) < 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ const char* ffDetectSound(FFlist* devices) {
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY sndstat = ffStrbufCreate();
|
||||
|
||||
struct oss_sysinfo info = {.nummixers = 9};
|
||||
struct oss_sysinfo info = { .nummixers = 9 };
|
||||
|
||||
// The implementation is very different from *BSD's. They call it OSS4
|
||||
for (int idev = 0; idev < info.nummixers; ++idev) {
|
||||
@@ -55,12 +55,12 @@ const char* ffDetectSound(FFlist* devices) {
|
||||
|
||||
int volume = -1;
|
||||
for (int iext = 0; iext < mi.nrext; ++iext) {
|
||||
struct oss_mixext me = {.dev = mi.dev, .ctrl = iext};
|
||||
struct oss_mixext me = { .dev = mi.dev, .ctrl = iext };
|
||||
if (ioctl(fd, SNDCTL_MIX_EXTINFO, &me) < 0) {
|
||||
continue;
|
||||
}
|
||||
if (me.flags & MIXF_PCMVOL) {
|
||||
struct oss_mixer_value mv = {.dev = mi.dev, .ctrl = iext, .timestamp = me.timestamp};
|
||||
struct oss_mixer_value mv = { .dev = mi.dev, .ctrl = iext, .timestamp = me.timestamp };
|
||||
if (ioctl(fd, SNDCTL_MIX_READ, &mv) >= 0) {
|
||||
mv.value -= me.minvalue;
|
||||
me.maxvalue -= me.minvalue;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
const char* ffDetectSwap(FFlist* result) {
|
||||
struct xsw_usage xsw;
|
||||
size_t size = sizeof(xsw);
|
||||
if (sysctl((int[]) {CTL_VM, VM_SWAPUSAGE}, 2, &xsw, &size, NULL, 0) != 0) {
|
||||
if (sysctl((int[]) { CTL_VM, VM_SWAPUSAGE }, 2, &xsw, &size, NULL, 0) != 0) {
|
||||
return "Failed to read vm.swapusage";
|
||||
}
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ static const char* detectByProcSwaps(FFlist* result) {
|
||||
ffStrbufInitA(&swap->name, nameLen);
|
||||
for (size_t i = 0; i < nameLen; ++i) {
|
||||
if (name[i] == '\\') {
|
||||
char octal[4] = {name[i + 1], name[i + 2], name[i + 3], '\0'};
|
||||
char octal[4] = { name[i + 1], name[i + 2], name[i + 3], '\0' };
|
||||
ffStrbufAppendC(&swap->name, (char) strtol(octal, NULL, 8));
|
||||
i += 3;
|
||||
} else {
|
||||
|
||||
@@ -18,8 +18,8 @@ static void detectAlacritty(FFTerminalFontResult* terminalFont) {
|
||||
|
||||
do {
|
||||
FFpropquery fontQueryToml[] = {
|
||||
{"normal =", &fontNormal},
|
||||
{"size =", &fontSize},
|
||||
{ "normal =", &fontNormal },
|
||||
{ "size =", &fontSize },
|
||||
};
|
||||
|
||||
// alacritty parses config files in this order
|
||||
@@ -143,7 +143,7 @@ FF_MAYBE_UNUSED static void detectTTY(FFTerminalFontResult* terminalFont) {
|
||||
|
||||
if (fontName.length == 0) {
|
||||
ffStrbufAppendS(&fontName, "VGA default kernel font ");
|
||||
ffProcessAppendStdOut(&fontName, (char* const[]) {"showconsolefont", "--info", NULL});
|
||||
ffProcessAppendStdOut(&fontName, (char* const[]) { "showconsolefont", "--info", NULL });
|
||||
|
||||
ffStrbufTrimRight(&fontName, ' ');
|
||||
}
|
||||
@@ -193,8 +193,8 @@ FF_MAYBE_UNUSED static bool detectKitty(const FFstrbuf* exe, FFTerminalFontResul
|
||||
ffParsePropLines(buf.chars, "font_size: ", &fontSize);
|
||||
} else {
|
||||
FFpropquery fontQuery[] = {
|
||||
{"font_family ", &fontName},
|
||||
{"font_size ", &fontSize},
|
||||
{ "font_family ", &fontName },
|
||||
{ "font_size ", &fontSize },
|
||||
};
|
||||
|
||||
ffParsePropFileConfigValues("kitty/kitty.conf", 2, fontQuery);
|
||||
@@ -223,7 +223,7 @@ static bool detectWezterm(const FFstrbuf* exe, FFTerminalFontResult* result) {
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY fontName = ffStrbufCreate();
|
||||
|
||||
ffStrbufSetS(&result->error, ffProcessAppendStdOut(&fontName, (char* const[]) {cli.chars, "ls-fonts", "--text", "a", NULL}));
|
||||
ffStrbufSetS(&result->error, ffProcessAppendStdOut(&fontName, (char* const[]) { cli.chars, "ls-fonts", "--text", "a", NULL }));
|
||||
if (result->error.length) {
|
||||
return false;
|
||||
}
|
||||
@@ -247,8 +247,8 @@ static bool detectTabby(FFTerminalFontResult* result) {
|
||||
FF_STRBUF_AUTO_DESTROY fontSize = ffStrbufCreate();
|
||||
|
||||
FFpropquery fontQuery[] = {
|
||||
{"font: ", &fontName},
|
||||
{"fontSize: ", &fontSize},
|
||||
{ "font: ", &fontName },
|
||||
{ "fontSize: ", &fontSize },
|
||||
};
|
||||
|
||||
if (!ffParsePropFileConfigValues("tabby/config.yaml", 2, fontQuery)) {
|
||||
@@ -269,7 +269,7 @@ static bool detectTabby(FFTerminalFontResult* result) {
|
||||
|
||||
static bool detectContour(const FFstrbuf* exe, FFTerminalFontResult* result) {
|
||||
FF_STRBUF_AUTO_DESTROY buf = ffStrbufCreate();
|
||||
if (ffProcessAppendStdOut(&buf, (char* const[]) {exe->chars, "font-locator", NULL})) {
|
||||
if (ffProcessAppendStdOut(&buf, (char* const[]) { exe->chars, "font-locator", NULL })) {
|
||||
ffStrbufAppendS(&result->error, "`contour font-locator` failed");
|
||||
return false;
|
||||
}
|
||||
@@ -297,8 +297,8 @@ static bool detectRio(FFTerminalFontResult* terminalFont) {
|
||||
FF_STRBUF_AUTO_DESTROY fontSize = ffStrbufCreate();
|
||||
|
||||
FFpropquery fontQueryToml[] = {
|
||||
{"family =", &fontName},
|
||||
{"size =", &fontSize},
|
||||
{ "family =", &fontName },
|
||||
{ "size =", &fontSize },
|
||||
};
|
||||
|
||||
ffParsePropFileConfigValues("rio/config.toml", 2, fontQueryToml);
|
||||
|
||||
@@ -137,14 +137,14 @@ static void detectXFCETerminal(FFTerminalFontResult* terminalFont) {
|
||||
FF_STRBUF_AUTO_DESTROY fontName = ffStrbufCreate();
|
||||
|
||||
const char* path = "xfce4/xfconf/xfce-perchannel-xml/xfce4-terminal.xml";
|
||||
bool configFound = ffParsePropFileConfigValues(path, 2, (FFpropquery[]) {{"<property name=\"font-use-system\" type=\"bool\" value=\"", &useSysFont}, {"<property name=\"font-name\" type=\"string\" value=\"", &fontName}});
|
||||
bool configFound = ffParsePropFileConfigValues(path, 2, (FFpropquery[]) { { "<property name=\"font-use-system\" type=\"bool\" value=\"", &useSysFont }, { "<property name=\"font-name\" type=\"string\" value=\"", &fontName } });
|
||||
|
||||
if (configFound) {
|
||||
ffStrbufSubstrBeforeLastC(&useSysFont, '"');
|
||||
ffStrbufSubstrBeforeLastC(&fontName, '"');
|
||||
} else {
|
||||
path = "xfce4/terminal/terminalrc";
|
||||
configFound = ffParsePropFileConfigValues(path, 2, (FFpropquery[]) {{"FontUseSystem = ", &useSysFont}, {"FontName = ", &fontName}});
|
||||
configFound = ffParsePropFileConfigValues(path, 2, (FFpropquery[]) { { "FontUseSystem = ", &useSysFont }, { "FontName = ", &fontName } });
|
||||
}
|
||||
|
||||
if (configFound && (useSysFont.length == 0 || ffStrbufIgnCaseEqualS(&useSysFont, "false"))) {
|
||||
@@ -239,8 +239,8 @@ static void detectQTerminal(FFTerminalFontResult* terminalFont) {
|
||||
FF_STRBUF_AUTO_DESTROY fontSize = ffStrbufCreate();
|
||||
|
||||
ffParsePropFileConfigValues("qterminal.org/qterminal.ini", 2, (FFpropquery[]) {
|
||||
{"fontFamily=", &fontName},
|
||||
{"fontSize=", &fontSize},
|
||||
{ "fontFamily=", &fontName },
|
||||
{ "fontSize=", &fontSize },
|
||||
});
|
||||
|
||||
if (fontName.length == 0) {
|
||||
@@ -257,14 +257,14 @@ static void detectXterm(FFTerminalFontResult* terminalFont) {
|
||||
FF_STRBUF_AUTO_DESTROY fontSize = ffStrbufCreate();
|
||||
|
||||
ffParsePropFileHomeValues(".Xresources", 2, (FFpropquery[]) {
|
||||
{"xterm*faceName:", &fontName},
|
||||
{"xterm*faceSize:", &fontSize},
|
||||
{ "xterm*faceName:", &fontName },
|
||||
{ "xterm*faceSize:", &fontSize },
|
||||
});
|
||||
|
||||
if (fontName.length == 0) {
|
||||
ffParsePropFileHomeValues(".Xresources", 2, (FFpropquery[]) {
|
||||
{"xterm.vt100.faceName:", &fontName},
|
||||
{"xterm.vt100.faceSize:", &fontSize},
|
||||
{ "xterm.vt100.faceName:", &fontName },
|
||||
{ "xterm.vt100.faceSize:", &fontSize },
|
||||
});
|
||||
}
|
||||
|
||||
@@ -365,8 +365,8 @@ static void detectTerminator(FFTerminalFontResult* result) {
|
||||
FF_STRBUF_AUTO_DESTROY fontName = ffStrbufCreate();
|
||||
|
||||
if (!ffParsePropFileConfigValues("terminator/config", 2, (FFpropquery[]) {
|
||||
{"use_system_font =", &useSystemFont},
|
||||
{"font =", &fontName},
|
||||
{ "use_system_font =", &useSystemFont },
|
||||
{ "font =", &fontName },
|
||||
}) ||
|
||||
ffStrbufIgnCaseEqualS(&useSystemFont, "True")) {
|
||||
FF_AUTO_FREE const char* fontName = getSystemMonospaceFont();
|
||||
@@ -389,8 +389,8 @@ static void detectWestonTerminal(FFTerminalFontResult* terminalFont) {
|
||||
FF_STRBUF_AUTO_DESTROY font = ffStrbufCreate();
|
||||
FF_STRBUF_AUTO_DESTROY size = ffStrbufCreate();
|
||||
ffParsePropFileConfigValues("weston.ini", 2, (FFpropquery[]) {
|
||||
{"font=", &font},
|
||||
{"font-size=", &size},
|
||||
{ "font=", &font },
|
||||
{ "font-size=", &size },
|
||||
});
|
||||
if (!font.length) {
|
||||
ffStrbufSetStatic(&font, "DejaVu Sans Mono");
|
||||
@@ -405,10 +405,10 @@ static void detectUrxvt(FFTerminalFontResult* terminalFont) {
|
||||
FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate();
|
||||
|
||||
if (!(ffParsePropFileHomeValues(".Xresources", 1, (FFpropquery[]) {
|
||||
{"URxvt.font:", &buffer},
|
||||
{ "URxvt.font:", &buffer },
|
||||
}) ||
|
||||
ffParsePropFileHomeValues(".Xdefaults", 1, (FFpropquery[]) {
|
||||
{"URxvt.font:", &buffer},
|
||||
{ "URxvt.font:", &buffer },
|
||||
}))) {
|
||||
ffStrbufAppendS(&terminalFont->error, "Could not find URxvt.font in .Xresources or .Xdefaults");
|
||||
return;
|
||||
@@ -470,8 +470,8 @@ static void detectHaikuTerminal(FFTerminalFontResult* terminalFont) {
|
||||
FF_STRBUF_AUTO_DESTROY font = ffStrbufCreate();
|
||||
FF_STRBUF_AUTO_DESTROY size = ffStrbufCreate();
|
||||
ffParsePropFileConfigValues("Terminal/Default", 2, (FFpropquery[]) {
|
||||
{"\"Half Font Family\" , ", &font},
|
||||
{"\"Half Font Size\" , ", &size},
|
||||
{ "\"Half Font Family\" , ", &font },
|
||||
{ "\"Half Font Size\" , ", &size },
|
||||
});
|
||||
if (!font.length) {
|
||||
ffStrbufSetStatic(&font, "Noto Sans Mono");
|
||||
|
||||
@@ -137,7 +137,7 @@ static void detectFromWindowsTerminal(const FFstrbuf* terminalExe, FFTerminalFon
|
||||
}
|
||||
|
||||
if (!error && json.length == 0) {
|
||||
error = ffProcessAppendStdOut(&json, (char* const[]) {"cmd.exe", "/c",
|
||||
error = ffProcessAppendStdOut(&json, (char* const[]) { "cmd.exe", "/c",
|
||||
// print the file content directly, so we don't need to handle the difference of Windows and POSIX path
|
||||
"if exist %LOCALAPPDATA%\\Packages\\Microsoft.WindowsTerminal_8wekyb3d8bbwe\\LocalState\\settings.json "
|
||||
"( type %LOCALAPPDATA%\\Packages\\Microsoft.WindowsTerminal_8wekyb3d8bbwe\\LocalState\\settings.json ) "
|
||||
@@ -146,7 +146,7 @@ static void detectFromWindowsTerminal(const FFstrbuf* terminalExe, FFTerminalFon
|
||||
"else if exist \"%LOCALAPPDATA%\\Microsoft\\Windows Terminal\\settings.json\" "
|
||||
"( type %LOCALAPPDATA%\\Microsoft\\Windows Terminal\\settings.json ) "
|
||||
"else ( call )",
|
||||
NULL});
|
||||
NULL });
|
||||
}
|
||||
|
||||
if (error) {
|
||||
@@ -176,8 +176,8 @@ static void detectMintty(FFTerminalFontResult* terminalFont) {
|
||||
FF_STRBUF_AUTO_DESTROY fontName = ffStrbufCreate();
|
||||
FF_STRBUF_AUTO_DESTROY fontSize = ffStrbufCreate();
|
||||
|
||||
if (!ffParsePropFileConfigValues("mintty/config", 2, (FFpropquery[]) {{"Font=", &fontName}, {"FontHeight=", &fontSize}})) {
|
||||
ffParsePropFileConfigValues(".minttyrc", 2, (FFpropquery[]) {{"Font=", &fontName}, {"FontHeight=", &fontSize}});
|
||||
if (!ffParsePropFileConfigValues("mintty/config", 2, (FFpropquery[]) { { "Font=", &fontName }, { "FontHeight=", &fontSize } })) {
|
||||
ffParsePropFileConfigValues(".minttyrc", 2, (FFpropquery[]) { { "Font=", &fontName }, { "FontHeight=", &fontSize } });
|
||||
}
|
||||
if (fontName.length == 0) {
|
||||
ffStrbufAppendS(&fontName, "Lucida Console");
|
||||
@@ -190,7 +190,7 @@ static void detectMintty(FFTerminalFontResult* terminalFont) {
|
||||
}
|
||||
|
||||
static void detectConhost(FFTerminalFontResult* terminalFont) {
|
||||
CONSOLE_FONT_INFOEX cfi = {.cbSize = sizeof(cfi)};
|
||||
CONSOLE_FONT_INFOEX cfi = { .cbSize = sizeof(cfi) };
|
||||
if (!GetCurrentConsoleFontEx(GetStdHandle(STD_OUTPUT_HANDLE), FALSE, &cfi)) {
|
||||
ffStrbufAppendS(&terminalFont->error, "GetCurrentConsoleFontEx() failed");
|
||||
return;
|
||||
@@ -210,12 +210,12 @@ static void detectConEmu(FFTerminalFontResult* terminalFont) {
|
||||
FF_STRBUF_AUTO_DESTROY fontName = ffStrbufCreate();
|
||||
FF_STRBUF_AUTO_DESTROY fontSize = ffStrbufCreate();
|
||||
|
||||
const char* paths[] = {"ConEmuDir", "ConEmuBaseDir", "APPDATA"};
|
||||
const char* paths[] = { "ConEmuDir", "ConEmuBaseDir", "APPDATA" };
|
||||
for (uint32_t i = 0; i < ARRAY_SIZE(paths); ++i) {
|
||||
ffStrbufSetS(&path, getenv(paths[i]));
|
||||
if (path.length > 0) {
|
||||
ffStrbufAppendS(&path, "/ConEmu.xml");
|
||||
if (ffParsePropFileValues(path.chars, 2, (FFpropquery[]) {{"<value name=\"FontName\" type=\"string\" data=\"", &fontName}, {"<value name=\"FontSize\" type=\"ulong\" data=\"", &fontSize}})) {
|
||||
if (ffParsePropFileValues(path.chars, 2, (FFpropquery[]) { { "<value name=\"FontName\" type=\"string\" data=\"", &fontName }, { "<value name=\"FontSize\" type=\"ulong\" data=\"", &fontSize } })) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -249,7 +249,7 @@ static void detectWarp(FFTerminalFontResult* terminalFont) {
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY fontName = ffStrbufCreate();
|
||||
FF_STRBUF_AUTO_DESTROY fontSize = ffStrbufCreate();
|
||||
if (ffRegReadValues(key, 2, (FFRegValueArg[]) {FF_ARG(fontName, L"FontName"), FF_ARG(fontSize, L"FontSize")}, &terminalFont->error)) {
|
||||
if (ffRegReadValues(key, 2, (FFRegValueArg[]) { FF_ARG(fontName, L"FontName"), FF_ARG(fontSize, L"FontSize") }, &terminalFont->error)) {
|
||||
ffStrbufTrim(&fontName, '"');
|
||||
ffStrbufAppendS(&fontSize, "px");
|
||||
} else {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user