Skip to content

v3.0.0 ANSI C #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added main
Binary file not shown.
13 changes: 8 additions & 5 deletions src/cpu/cpu_info.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
#include <stdio.h>
#include <dirent.h>

void print_cpu_info() {
void print_cpu_info(void) {
FILE *cpu_file;

printf(" ____________\n");
printf("|\n");
printf("| CPU Info:\n");
printf("|____________\n");
printf("|\n");

FILE *cpu_file = fopen("/proc/cpuinfo", "r");
cpu_file = fopen("/proc/cpuinfo", "r");
if (cpu_file) {
char line[128];
int lines = 0;
Expand All @@ -23,14 +24,16 @@ void print_cpu_info() {
}
}

void print_full_cpu_info() {
void print_full_cpu_info(void) {
FILE *cpu_file;

printf(" ____________\n");
printf("|\n");
printf("| Full CPU Info:\n");
printf("|____________\n");
printf("|\n");

FILE *cpu_file = fopen("/proc/cpuinfo", "r");
cpu_file = fopen("/proc/cpuinfo", "r");
if (cpu_file) {
char line[128];
while (fgets(line, sizeof(line), cpu_file)) {
Expand Down
82 changes: 63 additions & 19 deletions src/hlp/hlp_info.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <stdio.h>

void print_banner() {
void print_banner(void){
printf("\n \
____ _\n \
/ ___| _ __ _ _ _ __ (_)_ __\n \
Expand All @@ -10,29 +10,73 @@ void print_banner() {
|_| |___/\n\n");
}

void print_err_info() {
void print_logo(void) {
printf("MMMMMMMMMMMMMMMMMMMMMMMMMMMMMWNK0OkxxdddddxkkO0KNWMMMMMMMMMMMMMMMMMMMMMMMMMMMMM\n\
MMMMMMMMMMMMMMMMMMMMMMMWXKOxdoc:;,,''''''''',,;:codxOKXWMMMMMMMMMMMMMMMMMMMMMMM\n\
MMMMMMMMMMMMMMMMMMMWKOdl;,'',;:clooooddddoooollc:;''',:ldOKWMMMMMMMMMMMMMMMMMMM\n\
MMMMMMMMMMMMMMMMN0dc,.',:loxkOOOOOOOOOOOOOOOOOOOOkxdoc;'..,cd0NMMMMMMMMMMMMMMMM\n\
MMMMMMMMMMMMMW0d:'.':oxOOOOOkkxdollcc::::ccclodxkkOOO0Okoc,..':d0WMMMMMMMMMMMMM\n");
printf("MMMMMMMMMMWXkl'.':okOOOOkxoc;'...''.........'...',:ldkOOO0Oxl,..,lkNWMMMMMMMMMM\n\
MMMMMMMMMXk:..,lxOOOOxo:'. ......,;:lllc:;'....'. ...;lxkOOOOd:...:kNMMMMMMMMM\n\
MMMMMMMNO:..,okOkOkd:. .' .;cc:::;'......,:loxO0o..;. .,lxOkOOxc...:OWMMMMMMM\n\
MMMMMWKo'.'lkOkOkl' .,c. .. ..';cclodddxdooodOO;.;c.. .:dOkkOx:..'oKMMMMMM\n\
MMMMWO;..:xOkkko' ..,l, . .','..',;clx0x..cl,.. .:xOkkOd,..;OWMMMM\n");
printf("MMMNx'..lOkkkx; ..';lc. ...',;cldk; 'oc,,... .ckkkOk:..,xNMMM\n\
MMNd'.'dOxkkl. ..',;lo' ..',;co:. :oc;;'.. ,dkxkOl..'dNMM\n\
MWx'.'dkxkk:. ..,::ccc, ...';:lkk, .:cc:::,'. .okxxOl..'xWM\n\
WO, .okxkk: .',,,;;,'. ......';:codk0xc::;;;,,,'. .lkxxkc..,OW\n\
K:..ckxxk: ...,clcc:,.. ...',,;;:cclooooddxkOO00Oko:'... .okdxx; .cK\n");
printf("x. ,dxdkl. .','.. .......'''''',,,;;;:::cclllllcc:;,'..',,'. 'dxdxo. .x\n\
:..cxdxd' ..';:::;. ..........''''...'''.... '::c:,'.. :xddx; .:\n\
' 'odoxl. ...',;co' ..,,'. .',;'. .co:;,''... 'odoxl. '\n\
. ,ddox; ...',;co, .. .ck0K0d;. .'lOKKOo,. '..co:;,'.... .ldldo' .\n\
. ;dood, ...',;:oc.'' ':oOKXKkc;. ;l:'.,:d0KX0xc;..,.'ol:;,''... cdloo' .\n");
printf(". ;dood, ...',,;co;.. .;cloolc:,..lkk: .:cloolc:'....co:;,,'.... :dloo' .\n\
. ,oold; ...',;;:lo; ..'''''. .oO0l. ..'','''. .loc:;,,'.... .cocol. .\n\
. .lococ. ...',;:lll;. .o00o.......';o: 'cloc:;,'... .llcoc. .\n\
; .:ocll' ..,:c:,'',c;... .,'..,;::cldOx'.c:'.';:c:;'.. ,lcco; :\n\
d. 'lc:l:. .',,'.':oxdc' . .',;:::cloxk: .;oxdl;..',,'. .cl:lc. .d\n");
printf("K; .:l::l, '.. ,okdc'. . 'cloc::clxkc. .,lxko, ..'. ;c::l, :K\n\
Wk' .cc;:c' ....,xx,. .. .,;llccldx: .;kk;.... ,c;;c:. 'kW\n\
MNd. .cc,;c' .'..:l;. ...',:cooc. .:dl...'. ,c;,c:. .dNM\n\
MMNo. .::,;:;. .'..'c:. ..,;::cc:;. .:l,..,. .,:,,::. .oNMM\n\
MMMNd. .;:,'::. .'..,:'. ...... .'::..''. .;;',:;. .dNMMM\n");
printf("MMMMNx' .,:,',:,. .....;,. .,:'..'. .;;'';:'. 'kWMMMM\n\
MMMMMW0:. .;;'.,;,. .',. .,,. .. .,;,.';,. .c0WMMMMM\n\
MMMMMMMNx,. .;;'.,;,.. .'. .,. .',;'.';,. .,xNMMMMMMM\n\
MMMMMMMMWXd,. .,,,..,;,'. ... ... .',,,..,,,. .,dXMMMMMMMMM\n\
MMMMMMMMMMWXd;. .',,'..,,,,'.. ...'',,'..',,.. .;xXWMMMMMMMMMM\n");
printf("MMMMMMMMMMMMMNOl'. ..'''...',,,,''''''''''''''',,,''..''''.. .'lONMMMMMMMMMMMMM\n\
MMMMMMMMMMMMMMMWXkl,. ......'''...'''''''''......''..... .,lkXWMMMMMMMMMMMMMMM\n\
MMMMMMMMMMMMMMMMMMWN0dc,.. ........................ ..,cd0NWMMMMMMMMMMMMMMMMMM\n\
MMMMMMMMMMMMMMMMMMMMMMWNKOdl:,'... ...',:ldOKNWMMMMMMMMMMMMMMMMMMMMMM\n\
MMMMMMMMMMMMMMMMMMMMMMMMMMMMWNKOkdlc:::::::cldkOKNWMMMMMMMMMMMMMMMMMMMMMMMMMMMM\n");
}

void print_err_info(void) {
printf("Use spynix -h or spynix --help to display all valid options\n");
}

void print_hlp_info() {
void print_hlp_info(void) {
print_banner();
printf("Spynix is a commandline tool for gathering info about hardware.\n\n \
Info:\n\t \
-h or --help \t- show this menu\n\t \
-v or --version \t- show version\n\t \
-b or --banner \t- show ASCII banner\n\n \
Options:\n\t \
-a or --all \t- show summary info about system, cpu, ram and rom\n\t \
-sys \t\t- show system info\n\t \
-cpu \t\t- show short Central Processing Unit info\n\t \
-ram \t\t- show Random Access Memory info\n\t \
-rom \t\t- show Read Only Memory info\n\t \
-net \t\t- show network info\n\n \
Advanced:\n\t \
-cpu -f or -cpu --full \t- show full Central Processing Unit info\n");
printf("Spynix is a commandline tool for gathering info about hardware.\n\n\
\t\tInfo:\n\
\t\t\t-h or --help \t\t- show this menu\n\
\t\t\t-v or --version \t- show version\n\
\t\t\t-b or --banner \t\t- show ASCII banner\n\
\t\t\t-l or --logo \t\t- show ASCII logo\n\n");
printf("\t\tOptions:\n\
\t\t\t-a or --all \t- show summary info about system, cpu, ram and rom\n\
\t\t\t-sys \t\t- show system info\n\
\t\t\t-cpu \t\t- show short Central Processing Unit info\n\
\t\t\t-ram \t\t- show Random Access Memory info\n\
\t\t\t-rom \t\t- show Read Only Memory info\n\
\t\t\t-net \t\t- show network info\n\n\
\t\tAdvanced:\n\
\t\t-cpu -f or -cpu --full \t- show full Central Processing Unit info\n");
}

void print_ver_info() {
void print_ver_info(void) {
print_banner();
printf("spynix v2.1.0\n\nFor more info visit: https://github.com/git-user-cpp/spynix\n");
printf("spynix v3.0.0\n\nFor more info visit: https://github.com/git-user-cpp/spynix\n");
}
2 changes: 2 additions & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ int main(int argc, char **argv) {
print_ver_info();
} else if(strcmp(argv[1], "-b") == 0 || strcmp(argv[1], "--banner") == 0) {
print_banner();
} else if(strcmp(argv[1], "-l") == 0 || strcmp(argv[1], "--logo") == 0) {
print_logo();
} else {
print_err_info();
}
Expand Down
6 changes: 4 additions & 2 deletions src/net/net_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,21 @@

void print_net_info(char *hostname){
struct hostent *host = gethostbyname(hostname);
struct ifaddrs *ifaddr, *ifa;
int i;

if(host == NULL){
perror("gethostbyname");
exit(1);
} else {
printf("Host Name: %s\n", host->h_name);
printf("IP Address: ");
for(int i = 0; host->h_addr_list[i] != NULL; i++){
for(i = 0; host->h_addr_list[i] != NULL; i++){
printf("%s ", inet_ntoa(*(struct in_addr *)host->h_addr_list[i]));
}
printf("\n");
}

struct ifaddrs *ifaddr, *ifa;
if(getifaddrs(&ifaddr) == -1) {
perror("getifaddrs");
exit(1);
Expand Down
2 changes: 1 addition & 1 deletion src/ram/ram_info.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <stdio.h>
#include <sys/sysinfo.h>

void print_ram_info() {
void print_ram_info(void) {
struct sysinfo sys_info;
sysinfo(&sys_info);
printf(" ____________\n");
Expand Down
5 changes: 3 additions & 2 deletions src/rom/rom_info.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
#include <stdio.h>
#include <sys/statvfs.h>

void print_rom_info() {
void print_rom_info(void) {
struct statvfs fs_info;

printf(" ____________\n");
printf("|\n");
printf("| ROM Info:\n");
printf("|____________\n");
printf("|\n");
struct statvfs fs_info;
if (statvfs("/", &fs_info) == 0) {
printf("| Total Disk Space: %ld MiB\n", fs_info.f_blocks * fs_info.f_bsize
/ 1024 / 1024);
Expand Down
2 changes: 1 addition & 1 deletion src/sys/sys_info.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <stdio.h>
#include <sys/utsname.h>

void print_sys_info() {
void print_sys_info(void) {
struct utsname sys_info;
uname(&sys_info);
printf(" ____________\n");
Expand Down