Skip to content

Commit

Permalink
v4.0.0
Browse files Browse the repository at this point in the history
v4.0.0
  • Loading branch information
git-user-cpp authored Jan 16, 2024
2 parents 47ab846 + 9e8c55a commit 4dc52ac
Show file tree
Hide file tree
Showing 12 changed files with 321 additions and 218 deletions.
58 changes: 58 additions & 0 deletions src/cpu/cpu_info.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Copyright 2024 Andrew Kushyk
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*/

#include "cpu_info.h"

void print_cpu_info(void) {
FILE *cpu_file;

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

cpu_file = fopen("/proc/cpuinfo", "r");
if (cpu_file) {
char line[128];
int lines = 0;
while (fgets(line, sizeof(line), cpu_file) && lines < 19) {
printf("| %s", line);
lines++;
}
fclose(cpu_file);
printf("|____________\n\n");
} else {
printf("Error opening /proc/cpuinfo\n");
}
}

void print_full_cpu_info(void) {
FILE *cpu_file;

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

cpu_file = fopen("/proc/cpuinfo", "r");
if (cpu_file) {
char line[128];
while (fgets(line, sizeof(line), cpu_file)) {
printf("| %s", line);
}
fclose(cpu_file);
printf("|____________\n\n");
} else {
printf("Error opening /proc/cpuinfo\n");
}
}

53 changes: 6 additions & 47 deletions src/cpu/cpu_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,51 +8,10 @@
* http://www.apache.org/licenses/LICENSE-2.0
*/

#include <stdio.h>

void print_cpu_info(void) {
FILE *cpu_file;

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

cpu_file = fopen("/proc/cpuinfo", "r");
if (cpu_file) {
char line[128];
int lines = 0;
while (fgets(line, sizeof(line), cpu_file) && lines < 19) {
printf("| %s", line);
lines++;
}
fclose(cpu_file);
printf("|____________\n\n");
} else {
printf("Error opening /proc/cpuinfo\n");
}
}

void print_full_cpu_info(void) {
FILE *cpu_file;

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

cpu_file = fopen("/proc/cpuinfo", "r");
if (cpu_file) {
char line[128];
while (fgets(line, sizeof(line), cpu_file)) {
printf("| %s", line);
}
fclose(cpu_file);
printf("|____________\n\n");
} else {
printf("Error opening /proc/cpuinfo\n");
}
}
#ifndef CPU_INFO_H_SENTRY
#define CPU_INFO_H_SENTRY
#include <stdio.h>

void print_cpu_info(void);
void print_full_cpu_info(void);
#endif
92 changes: 92 additions & 0 deletions src/hlp/hlp_info.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/*
* Copyright 2024 Andrew Kushyk
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*/

#include "hlp_info.h"

void print_banner(void){
printf("\n \
____ _\n \
/ ___| _ __ _ _ _ __ (_)_ __\n \
\\___ \\| '_ \\| | | | '_ \\| \\ \\/ /\n \
___) | |_) | |_| | | | | |> <\n \
|____/| .__/ \\__, |_| |_|_/_/\\_\\\n \
|_| |___/\n\n");
}

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_banner();
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_banner();
printf("spynix v3.0.0\n\nFor more info visit: https://github.com/git-user-cpp/spynix\n");
}
89 changes: 9 additions & 80 deletions src/hlp/hlp_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,85 +8,14 @@
* http://www.apache.org/licenses/LICENSE-2.0
*/

#include <stdio.h>
#ifndef HLP_INFO_H_SENTRY
#define HLP_INFO_H_SENTRY
#include <stdio.h>

void print_banner(void){
printf("\n \
____ _\n \
/ ___| _ __ _ _ _ __ (_)_ __\n \
\\___ \\| '_ \\| | | | '_ \\| \\ \\/ /\n \
___) | |_) | |_| | | | | |> <\n \
|____/| .__/ \\__, |_| |_|_/_/\\_\\\n \
|_| |___/\n\n");
}
void print_banner(void);
void print_logo(void);
void print_err_info(void);
void print_hlp_info(void);
void print_ver_info(void);
#endif

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_banner();
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_banner();
printf("spynix v3.0.0\n\nFor more info visit: https://github.com/git-user-cpp/spynix\n");
}
43 changes: 43 additions & 0 deletions src/net/net_info.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright 2024 Andrew Kushyk
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*/

#include "net_info.h"

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(i = 0; host->h_addr_list[i] != NULL; i++){
printf("%s ", inet_ntoa(*(struct in_addr *)host->h_addr_list[i]));
}
printf("\n");
}

if(getifaddrs(&ifaddr) == -1) {
perror("getifaddrs");
exit(1);
}
for(ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next){
if(ifa->ifa_addr != NULL && ifa->ifa_addr->sa_family == AF_INET){
printf("Interface: %s\n", ifa->ifa_name);
printf("Address: %s\n", inet_ntoa(((struct sockaddr_in*)ifa->ifa_addr)->sin_addr));
printf("Netmask: %s\n", inet_ntoa(((struct sockaddr_in*)ifa->ifa_netmask)->sin_addr));
}
}

freeifaddrs(ifaddr);
}
Loading

0 comments on commit 4dc52ac

Please sign in to comment.