diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2023-04-23 17:55:16 -0400 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2023-04-23 17:55:16 -0400 |
commit | 1f0c894080e0a3d62694a056456e378e36eb12a1 (patch) | |
tree | 7abd3928808aa9f03a4dd17dd3eb5ecde7607d18 /common.h | |
parent | 0ec45301dc4d1a61cc1d9bd2906cd010c88f81c0 (diff) | |
download | whatami-1f0c894080e0a3d62694a056456e378e36eb12a1.tar.gz |
Refactor
Split linux, darwin, and x86 into separate modules
Diffstat (limited to 'common.h')
-rw-r--r-- | common.h | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/common.h b/common.h new file mode 100644 index 0000000..b936a62 --- /dev/null +++ b/common.h @@ -0,0 +1,55 @@ +#ifndef WHATAMI_COMMON_H +#define WHATAMI_COMMON_H + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <sys/utsname.h> +#include <cpuid.h> +#include <ctype.h> +#include <dirent.h> +#include <limits.h> + +#if defined(__x86_64__) || defined(__i386__) +#include "x86.h" +#endif + +#if defined(__linux__) +#elif defined(__APPLE__) +#include <sys/types.h> +#include <sys/sysctl.h> +#endif + +union regs_t { + struct { + unsigned int eax; + unsigned int ebx; + unsigned int ecx; + unsigned int edx; + } gpr; + unsigned int bytes[15]; +}; + +struct Block_Device { + char path[PATH_MAX]; + char model[254]; + size_t size; +}; + +unsigned int CPUID(unsigned int leaf, union regs_t *reg); +int is_cpu_hyperthreaded(); +int is_cpu_virtual(); +char *get_sys_product(); +unsigned int get_cpu_count(); +char *get_cpu_manufacturer(); +char *get_cpu_vendor(); + + +size_t rstrip(char *s); +int get_sys_os_dist(char **name, char **version); +ssize_t get_sys_memory(); +char *get_sys_dmi_product(); +struct Block_Device **get_block_devices(size_t *total); + +#endif //WHATAMI_COMMON_H |