[refactor] created a new types header, seperated the structs from the lib.c

This commit is contained in:
Abdellah El Morabit 2025-10-13 14:13:10 +02:00
parent 0ffd6627ed
commit e0a44b9c2b
4 changed files with 87 additions and 68 deletions

View File

@ -6,37 +6,13 @@
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include <sys/types.h> #include <sys/types.h>
#include "types.h"
#define MAXC 1024 #define MAXC 1024
#define MAXC_CHAR 256 #define MAXC_CHAR 256
#define CONVERT_BYTES_TO_GIGABYTES 107374182 #define CONVERT_BYTES_TO_GIGABYTES 107374182
#define D 1073741824 #define D 1073741824
typedef struct {
int frequency;
int temperature;
char* name;
int threads;
} cpu_s;
typedef struct {
unsigned long total;
unsigned long available;
} ram_s;
typedef struct {
long long size;
short name;
} disk_s;
typedef struct {
char* name;
char* hostname;
char* os_version;
} device_s;
void cpu_name(); void cpu_name();
void cpu_threads(); void cpu_threads();
void cpu_temperature(); void cpu_temperature();
@ -254,6 +230,12 @@ void cpu_frequency(){
return; return;
} }
void cpu_temperature(cpu_s cpu)
{
cpu.temperature = 0;
return;
}
void mem_size() { void mem_size() {
int64_t size; int64_t size;
size_t len = sizeof(size); size_t len = sizeof(size);

View File

@ -3,19 +3,23 @@
#ifdef __APPLE__ #ifdef __APPLE__
void get_device_info();
void disk_size();
void size();
void av_size();
void ram_info();
void cpu_frequency();
void cpu_name(); void cpu_name();
void cpu_threads(); void cpu_threads();
void cpu_temperature(); void cpu_temperature();
void cpu_frequency(); void cpu_frequency();
void disk_size();
void size();
void av_size();
void ram_info();
void mem_size(); void mem_size();
void mem_av_size(); void mem_av_size();
void get_device_info();
void get_os_version();
#endif #endif
#endif #endif

View File

@ -9,6 +9,7 @@ void *gather_cpu_information();
void *gather_ram_information(); void *gather_ram_information();
void *gather_disk_information(); void *gather_disk_information();
void *gather_device_information(); void *gather_device_information();
void get_c_version();
/* /*
cJSON convert_to_json() { cJSON convert_to_json() {
@ -50,11 +51,8 @@ void handler(char *url) {
*/ */
void get_c_version()
{
#ifdef __APPLE__
int main(int argc, char** argv) {
#if __STDC_VERSION__ #if __STDC_VERSION__
printf("C standard version: %ld\n", __STDC_VERSION__); printf("C standard version: %ld\n", __STDC_VERSION__);
@ -62,7 +60,12 @@ int main(int argc, char** argv) {
printf("C standard not defined\n"); printf("C standard not defined\n");
#endif #endif
// handler("api.nsrddyn.com");
}
#ifdef __APPLE__
int main(int argc, char** argv) {
return 0; return 0;
} }
@ -75,6 +78,7 @@ int main(int argc, char** argv) {
return 0; return 0;
} }
#endif #endif

29
source/types.h Normal file
View File

@ -0,0 +1,29 @@
#ifndef TYPES_H
#define TYPES_H
typedef struct {
char* name;
int frequency;
int temperature;
int threads;
} cpu_s;
typedef struct {
unsigned long total;
unsigned long available;
} ram_s;
typedef struct {
long long size;
short name;
} disk_s;
typedef struct {
char* name;
char* hostname;
char* os_version;
} device_s;
#endif