Inital Commit

This commit is contained in:
netbenixcn 2020-06-02 11:23:12 +02:00
commit cc95ff1c3a
22 changed files with 1166 additions and 0 deletions

15
utils/logger.c Normal file
View file

@ -0,0 +1,15 @@
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "logger.h"
void logger(char message[255]){
FILE *log_file;
time_t t = time(NULL);
struct tm tm = *localtime(&t);
log_file = fopen("output.log", "a");
fprintf(log_file, "[%d-%02d-%02d %02d:%02d:%02d] ", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
fprintf(log_file, "%s\n", message);
fclose(log_file);
}

6
utils/logger.h Normal file
View file

@ -0,0 +1,6 @@
#ifndef _LOGGER_H_
#define _LOGGER_H_
//Allows the user to log something
void logger(char message[255]);
#endif

58
utils/os_info.c Normal file
View file

@ -0,0 +1,58 @@
#ifdef _WIN32 || _WIN64
#include <windows.h>
#endif
#ifdef linux
#endif
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <malloc.h>
#include <string.h>
#include "os_info.h"
#include "logger.h"
char* getOS(){
char *os;
os = malloc(sizeof (char) * 20);
#ifdef _WIN32 || _WIN64
strcpy(os, "Windows");
#endif
#ifdef linux
strcpy(os, "Linux");
#endif
return os;
}
char* getArch(){
char *arch;
arch = malloc(sizeof(char) * 20);
#ifdef __amd64
strcpy(arch, "64-Bit");
#else
strcpy(arch, "32-Bit");
#endif
return arch;
}
void print_Specs(){
printf("OS: %s\n", getOS());
printf("Architecture: %s\n", getArch());
free(NULL);
}
void log_Specs(){
char buffer[1024];
logger("[INFO] System Information:");
snprintf(buffer, sizeof(buffer), "[INFO] OS: %s", getOS());
logger(buffer);
snprintf(buffer, sizeof(buffer), "[INFO] Architecture: %s", getArch());
logger(buffer);
free(NULL);
}

9
utils/os_info.h Normal file
View file

@ -0,0 +1,9 @@
#ifndef _OS_INFO_H_
#define _OS_INFO_H_
char* getOS();
char* getArch();
void print_Specs();
void log_Specs();
#endif