doing sth

This commit is contained in:
2026-05-05 17:49:37 +02:00
parent 6c8739ecd5
commit 110c012587
4 changed files with 81 additions and 0 deletions

8
src/cpu.c Normal file
View File

@@ -0,0 +1,8 @@
#include "cpu.h"
#include <stdio.h>
void cpu_detect(struct cpu_sensors_t* t, const char* pci_dev) {
char path[128];
snprintf(path, sizeof(path), "/sys/bus/pci/devices/%s/hwmon", pci_dev);
}

37
src/utils.c Normal file
View File

@@ -0,0 +1,37 @@
#include <fcntl.h>
#include <stdint.h>
#include <stdlib.h>
#include <unistd.h>
#include "log.h"
#include <glob.h>
#include "utils.h"
inline bool file_exists(const char* path) {
return access(path, F_OK) == 0;
}
int get_hwmon_dir(char* path) {
glob_t g;
if (glob(path, 0, NULL, &g) == 0) {
}
}
/* read n bytes from path into buffer */
inline ssize_t read_file(const char* path, char* buffer, const ssize_t n) {
const int fd = open(path, O_RDONLY | O_CLOEXEC);
if (fd < 0) {
applog(LOG_ERR, "Error reading %s", path);
return 0;
}
const ssize_t len = read(fd, buffer, n);
if (len >= 0) buffer[len] = '\0';
close(fd);
return len;
}
inline void _fRN_u64(const char* path, char* buf, uint64_t* result, const uint16_t divider) {
read_file(path, buf, 24); // wont ever be longer than 24 chars right? potential bug
*result = strtoull(buf, NULL, 10) / divider;
}