[refactor] created a new types header, seperated the structs from the lib.c
This commit is contained in:
parent
0ffd6627ed
commit
e0a44b9c2b
32
source/lib.c
32
source/lib.c
@ -6,37 +6,13 @@
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include "types.h"
|
||||
|
||||
#define MAXC 1024
|
||||
#define MAXC_CHAR 256
|
||||
#define CONVERT_BYTES_TO_GIGABYTES 107374182
|
||||
#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_threads();
|
||||
void cpu_temperature();
|
||||
@ -254,6 +230,12 @@ void cpu_frequency(){
|
||||
return;
|
||||
}
|
||||
|
||||
void cpu_temperature(cpu_s cpu)
|
||||
{
|
||||
cpu.temperature = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
void mem_size() {
|
||||
int64_t size;
|
||||
size_t len = sizeof(size);
|
||||
|
||||
16
source/lib.h
16
source/lib.h
@ -3,19 +3,23 @@
|
||||
|
||||
#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_threads();
|
||||
void cpu_temperature();
|
||||
void cpu_frequency();
|
||||
|
||||
void disk_size();
|
||||
void size();
|
||||
|
||||
void av_size();
|
||||
void ram_info();
|
||||
|
||||
void mem_size();
|
||||
void mem_av_size();
|
||||
|
||||
void get_device_info();
|
||||
void get_os_version();
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
@ -9,6 +9,7 @@ void *gather_cpu_information();
|
||||
void *gather_ram_information();
|
||||
void *gather_disk_information();
|
||||
void *gather_device_information();
|
||||
void get_c_version();
|
||||
|
||||
/*
|
||||
cJSON convert_to_json() {
|
||||
@ -50,11 +51,8 @@ void handler(char *url) {
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifdef __APPLE__
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
void get_c_version()
|
||||
{
|
||||
|
||||
#if __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");
|
||||
#endif
|
||||
|
||||
// handler("api.nsrddyn.com");
|
||||
|
||||
}
|
||||
|
||||
#ifdef __APPLE__
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -75,6 +78,7 @@ int main(int argc, char** argv) {
|
||||
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
29
source/types.h
Normal file
29
source/types.h
Normal 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
|
||||
Loading…
Reference in New Issue
Block a user