mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-11-03 11:44:18 +01:00
Chore: run clang-format
```bash find . -type f \( -name "*.c" -o -name "*.h" -o -name "*.cpp" -o -name "*.hpp" \) ! -path "src/3rdparty/*" -print0 | xargs -0 clang-format -i ```
This commit is contained in:
@@ -2,22 +2,22 @@
|
||||
|
||||
#include <sys/sysctl.h>
|
||||
#ifdef __FreeBSD__
|
||||
#include <sys/types.h>
|
||||
#include <sys/user.h>
|
||||
# include <sys/types.h>
|
||||
# include <sys/user.h>
|
||||
#endif
|
||||
|
||||
#ifndef KERN_PROC_PROC
|
||||
#define KERN_PROC_PROC KERN_PROC_ALL // Apple
|
||||
# define KERN_PROC_PROC KERN_PROC_ALL // Apple
|
||||
#endif
|
||||
|
||||
const char* ffDetectProcesses(uint32_t* result)
|
||||
{
|
||||
const char* ffDetectProcesses(uint32_t* result) {
|
||||
int request[] = {CTL_KERN, KERN_PROC, KERN_PROC_PROC};
|
||||
size_t length;
|
||||
|
||||
if(sysctl(request, ARRAY_SIZE(request), NULL, &length, NULL, 0) != 0)
|
||||
if (sysctl(request, ARRAY_SIZE(request), NULL, &length, NULL, 0) != 0) {
|
||||
return "sysctl({CTL_KERN, KERN_PROC, KERN_PROC_PROC}) failed";
|
||||
}
|
||||
|
||||
*result = (uint32_t)(length / sizeof(struct kinfo_proc));
|
||||
*result = (uint32_t) (length / sizeof(struct kinfo_proc));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
|
||||
#include <OS.h>
|
||||
|
||||
const char* ffDetectProcesses(uint32_t* result)
|
||||
{
|
||||
const char* ffDetectProcesses(uint32_t* result) {
|
||||
system_info info;
|
||||
if (get_system_info(&info) != B_OK)
|
||||
if (get_system_info(&info) != B_OK) {
|
||||
return "Error getting system info";
|
||||
}
|
||||
|
||||
*result = info.used_teams;
|
||||
|
||||
|
||||
@@ -3,22 +3,21 @@
|
||||
#include "common/io.h"
|
||||
#include "common/stringUtils.h"
|
||||
|
||||
const char* ffDetectProcesses(uint32_t* result)
|
||||
{
|
||||
const char* ffDetectProcesses(uint32_t* result) {
|
||||
FF_AUTO_CLOSE_DIR DIR* dir = opendir("/proc");
|
||||
if(dir == NULL)
|
||||
if (dir == NULL) {
|
||||
return "opendir(\"/proc\") failed";
|
||||
}
|
||||
|
||||
uint32_t num = 0;
|
||||
|
||||
struct dirent* entry;
|
||||
while ((entry = readdir(dir)) != NULL)
|
||||
{
|
||||
while ((entry = readdir(dir)) != NULL) {
|
||||
if (
|
||||
#ifdef _DIRENT_HAVE_D_TYPE
|
||||
(entry->d_type == DT_DIR || entry->d_type == DT_UNKNOWN) &&
|
||||
#endif
|
||||
ffCharIsDigit(entry->d_name[0]))
|
||||
#ifdef _DIRENT_HAVE_D_TYPE
|
||||
(entry->d_type == DT_DIR || entry->d_type == DT_UNKNOWN) &&
|
||||
#endif
|
||||
ffCharIsDigit(entry->d_name[0]))
|
||||
++num;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
|
||||
#include <sys/sysctl.h>
|
||||
|
||||
const char* ffDetectProcesses(uint32_t* result)
|
||||
{
|
||||
const char* ffDetectProcesses(uint32_t* result) {
|
||||
int request[] = {CTL_KERN, KERN_PROC2, KERN_PROC_ALL, -1, sizeof(struct kinfo_proc2), 0};
|
||||
size_t length = 0;
|
||||
|
||||
if(sysctl(request, ARRAY_SIZE(request), NULL, &length, NULL, 0) != 0)
|
||||
if (sysctl(request, ARRAY_SIZE(request), NULL, &length, NULL, 0) != 0) {
|
||||
return "sysctl({CTL_KERN, KERN_PROC2, KERN_PROC_ALL}) failed";
|
||||
}
|
||||
|
||||
*result = (uint32_t)(length / sizeof(struct kinfo_proc2));
|
||||
*result = (uint32_t) (length / sizeof(struct kinfo_proc2));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#include "processes.h"
|
||||
|
||||
const char* ffDetectProcesses(uint32_t* result)
|
||||
{
|
||||
const char* ffDetectProcesses(uint32_t* result) {
|
||||
return "Not supported on this platform";
|
||||
}
|
||||
|
||||
@@ -4,11 +4,12 @@
|
||||
#include <sys/sysctl.h>
|
||||
#include <kvm.h>
|
||||
|
||||
const char* ffDetectProcesses(uint32_t* result)
|
||||
{
|
||||
const char* ffDetectProcesses(uint32_t* result) {
|
||||
kvm_t* kd = kvm_open(NULL, NULL, NULL, KVM_NO_FILES, NULL);
|
||||
const void* ret = kvm_getprocs(kd, KERN_PROC_ALL, 0, 1, result);
|
||||
kvm_close(kd);
|
||||
if (!ret) return "kvm_getprocs() failed";
|
||||
if (!ret) {
|
||||
return "kvm_getprocs() failed";
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -4,32 +4,31 @@
|
||||
#include <ntstatus.h>
|
||||
#include <winternl.h>
|
||||
|
||||
const char* ffDetectProcesses(uint32_t* result)
|
||||
{
|
||||
const char* ffDetectProcesses(uint32_t* result) {
|
||||
SYSTEM_PROCESS_INFORMATION* FF_AUTO_FREE pstart = NULL;
|
||||
|
||||
// Multiple attempts in case processes change while
|
||||
// we are in the middle of querying them.
|
||||
ULONG size = 0;
|
||||
for (int attempts = 0;; ++attempts)
|
||||
{
|
||||
if (size)
|
||||
{
|
||||
pstart = (SYSTEM_PROCESS_INFORMATION*)realloc(pstart, size);
|
||||
for (int attempts = 0;; ++attempts) {
|
||||
if (size) {
|
||||
pstart = (SYSTEM_PROCESS_INFORMATION*) realloc(pstart, size);
|
||||
assert(pstart);
|
||||
}
|
||||
NTSTATUS status = NtQuerySystemInformation(SystemProcessInformation, pstart, size, &size);
|
||||
if(NT_SUCCESS(status))
|
||||
if (NT_SUCCESS(status)) {
|
||||
break;
|
||||
else if(status == STATUS_INFO_LENGTH_MISMATCH && attempts < 4)
|
||||
} else if (status == STATUS_INFO_LENGTH_MISMATCH && attempts < 4) {
|
||||
size += sizeof(SYSTEM_PROCESS_INFORMATION) * 5;
|
||||
else
|
||||
} else {
|
||||
return "NtQuerySystemInformation(SystemProcessInformation) failed";
|
||||
}
|
||||
}
|
||||
|
||||
*result = 1; //Init with 1 because we test for ptr->NextEntryOffset
|
||||
for (SYSTEM_PROCESS_INFORMATION* ptr = pstart; ptr->NextEntryOffset; ptr = (SYSTEM_PROCESS_INFORMATION*)((uint8_t*)ptr + ptr->NextEntryOffset))
|
||||
*result = 1; // Init with 1 because we test for ptr->NextEntryOffset
|
||||
for (SYSTEM_PROCESS_INFORMATION* ptr = pstart; ptr->NextEntryOffset; ptr = (SYSTEM_PROCESS_INFORMATION*) ((uint8_t*) ptr + ptr->NextEntryOffset)) {
|
||||
++*result;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user