Skip to content

Commit 4dc52ac

Browse files
authored
v4.0.0
v4.0.0
2 parents 47ab846 + 9e8c55a commit 4dc52ac

File tree

12 files changed

+321
-218
lines changed

12 files changed

+321
-218
lines changed

src/cpu/cpu_info.c

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
* Copyright 2024 Andrew Kushyk
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*/
10+
11+
#include "cpu_info.h"
12+
13+
void print_cpu_info(void) {
14+
FILE *cpu_file;
15+
16+
printf(" ____________\n");
17+
printf("|\n");
18+
printf("| CPU Info:\n");
19+
printf("|____________\n");
20+
printf("|\n");
21+
22+
cpu_file = fopen("/proc/cpuinfo", "r");
23+
if (cpu_file) {
24+
char line[128];
25+
int lines = 0;
26+
while (fgets(line, sizeof(line), cpu_file) && lines < 19) {
27+
printf("| %s", line);
28+
lines++;
29+
}
30+
fclose(cpu_file);
31+
printf("|____________\n\n");
32+
} else {
33+
printf("Error opening /proc/cpuinfo\n");
34+
}
35+
}
36+
37+
void print_full_cpu_info(void) {
38+
FILE *cpu_file;
39+
40+
printf(" ____________\n");
41+
printf("|\n");
42+
printf("| Full CPU Info:\n");
43+
printf("|____________\n");
44+
printf("|\n");
45+
46+
cpu_file = fopen("/proc/cpuinfo", "r");
47+
if (cpu_file) {
48+
char line[128];
49+
while (fgets(line, sizeof(line), cpu_file)) {
50+
printf("| %s", line);
51+
}
52+
fclose(cpu_file);
53+
printf("|____________\n\n");
54+
} else {
55+
printf("Error opening /proc/cpuinfo\n");
56+
}
57+
}
58+

src/cpu/cpu_info.h

+6-47
Original file line numberDiff line numberDiff line change
@@ -8,51 +8,10 @@
88
* http://www.apache.org/licenses/LICENSE-2.0
99
*/
1010

11-
#include <stdio.h>
12-
13-
void print_cpu_info(void) {
14-
FILE *cpu_file;
15-
16-
printf(" ____________\n");
17-
printf("|\n");
18-
printf("| CPU Info:\n");
19-
printf("|____________\n");
20-
printf("|\n");
21-
22-
cpu_file = fopen("/proc/cpuinfo", "r");
23-
if (cpu_file) {
24-
char line[128];
25-
int lines = 0;
26-
while (fgets(line, sizeof(line), cpu_file) && lines < 19) {
27-
printf("| %s", line);
28-
lines++;
29-
}
30-
fclose(cpu_file);
31-
printf("|____________\n\n");
32-
} else {
33-
printf("Error opening /proc/cpuinfo\n");
34-
}
35-
}
36-
37-
void print_full_cpu_info(void) {
38-
FILE *cpu_file;
39-
40-
printf(" ____________\n");
41-
printf("|\n");
42-
printf("| Full CPU Info:\n");
43-
printf("|____________\n");
44-
printf("|\n");
45-
46-
cpu_file = fopen("/proc/cpuinfo", "r");
47-
if (cpu_file) {
48-
char line[128];
49-
while (fgets(line, sizeof(line), cpu_file)) {
50-
printf("| %s", line);
51-
}
52-
fclose(cpu_file);
53-
printf("|____________\n\n");
54-
} else {
55-
printf("Error opening /proc/cpuinfo\n");
56-
}
57-
}
11+
#ifndef CPU_INFO_H_SENTRY
12+
#define CPU_INFO_H_SENTRY
13+
#include <stdio.h>
5814

15+
void print_cpu_info(void);
16+
void print_full_cpu_info(void);
17+
#endif

src/hlp/hlp_info.c

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
/*
2+
* Copyright 2024 Andrew Kushyk
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*/
10+
11+
#include "hlp_info.h"
12+
13+
void print_banner(void){
14+
printf("\n \
15+
____ _\n \
16+
/ ___| _ __ _ _ _ __ (_)_ __\n \
17+
\\___ \\| '_ \\| | | | '_ \\| \\ \\/ /\n \
18+
___) | |_) | |_| | | | | |> <\n \
19+
|____/| .__/ \\__, |_| |_|_/_/\\_\\\n \
20+
|_| |___/\n\n");
21+
}
22+
23+
void print_logo(void) {
24+
printf("MMMMMMMMMMMMMMMMMMMMMMMMMMMMMWNK0OkxxdddddxkkO0KNWMMMMMMMMMMMMMMMMMMMMMMMMMMMMM\n\
25+
MMMMMMMMMMMMMMMMMMMMMMMWXKOxdoc:;,,''''''''',,;:codxOKXWMMMMMMMMMMMMMMMMMMMMMMM\n\
26+
MMMMMMMMMMMMMMMMMMMWKOdl;,'',;:clooooddddoooollc:;''',:ldOKWMMMMMMMMMMMMMMMMMMM\n\
27+
MMMMMMMMMMMMMMMMN0dc,.',:loxkOOOOOOOOOOOOOOOOOOOOkxdoc;'..,cd0NMMMMMMMMMMMMMMMM\n\
28+
MMMMMMMMMMMMMW0d:'.':oxOOOOOkkxdollcc::::ccclodxkkOOO0Okoc,..':d0WMMMMMMMMMMMMM\n");
29+
printf("MMMMMMMMMMWXkl'.':okOOOOkxoc;'...''.........'...',:ldkOOO0Oxl,..,lkNWMMMMMMMMMM\n\
30+
MMMMMMMMMXk:..,lxOOOOxo:'. ......,;:lllc:;'....'. ...;lxkOOOOd:...:kNMMMMMMMMM\n\
31+
MMMMMMMNO:..,okOkOkd:. .' .;cc:::;'......,:loxO0o..;. .,lxOkOOxc...:OWMMMMMMM\n\
32+
MMMMMWKo'.'lkOkOkl' .,c. .. ..';cclodddxdooodOO;.;c.. .:dOkkOx:..'oKMMMMMM\n\
33+
MMMMWO;..:xOkkko' ..,l, . .','..',;clx0x..cl,.. .:xOkkOd,..;OWMMMM\n");
34+
printf("MMMNx'..lOkkkx; ..';lc. ...',;cldk; 'oc,,... .ckkkOk:..,xNMMM\n\
35+
MMNd'.'dOxkkl. ..',;lo' ..',;co:. :oc;;'.. ,dkxkOl..'dNMM\n\
36+
MWx'.'dkxkk:. ..,::ccc, ...';:lkk, .:cc:::,'. .okxxOl..'xWM\n\
37+
WO, .okxkk: .',,,;;,'. ......';:codk0xc::;;;,,,'. .lkxxkc..,OW\n\
38+
K:..ckxxk: ...,clcc:,.. ...',,;;:cclooooddxkOO00Oko:'... .okdxx; .cK\n");
39+
printf("x. ,dxdkl. .','.. .......'''''',,,;;;:::cclllllcc:;,'..',,'. 'dxdxo. .x\n\
40+
:..cxdxd' ..';:::;. ..........''''...'''.... '::c:,'.. :xddx; .:\n\
41+
' 'odoxl. ...',;co' ..,,'. .',;'. .co:;,''... 'odoxl. '\n\
42+
. ,ddox; ...',;co, .. .ck0K0d;. .'lOKKOo,. '..co:;,'.... .ldldo' .\n\
43+
. ;dood, ...',;:oc.'' ':oOKXKkc;. ;l:'.,:d0KX0xc;..,.'ol:;,''... cdloo' .\n");
44+
printf(". ;dood, ...',,;co;.. .;cloolc:,..lkk: .:cloolc:'....co:;,,'.... :dloo' .\n\
45+
. ,oold; ...',;;:lo; ..'''''. .oO0l. ..'','''. .loc:;,,'.... .cocol. .\n\
46+
. .lococ. ...',;:lll;. .o00o.......';o: 'cloc:;,'... .llcoc. .\n\
47+
; .:ocll' ..,:c:,'',c;... .,'..,;::cldOx'.c:'.';:c:;'.. ,lcco; :\n\
48+
d. 'lc:l:. .',,'.':oxdc' . .',;:::cloxk: .;oxdl;..',,'. .cl:lc. .d\n");
49+
printf("K; .:l::l, '.. ,okdc'. . 'cloc::clxkc. .,lxko, ..'. ;c::l, :K\n\
50+
Wk' .cc;:c' ....,xx,. .. .,;llccldx: .;kk;.... ,c;;c:. 'kW\n\
51+
MNd. .cc,;c' .'..:l;. ...',:cooc. .:dl...'. ,c;,c:. .dNM\n\
52+
MMNo. .::,;:;. .'..'c:. ..,;::cc:;. .:l,..,. .,:,,::. .oNMM\n\
53+
MMMNd. .;:,'::. .'..,:'. ...... .'::..''. .;;',:;. .dNMMM\n");
54+
printf("MMMMNx' .,:,',:,. .....;,. .,:'..'. .;;'';:'. 'kWMMMM\n\
55+
MMMMMW0:. .;;'.,;,. .',. .,,. .. .,;,.';,. .c0WMMMMM\n\
56+
MMMMMMMNx,. .;;'.,;,.. .'. .,. .',;'.';,. .,xNMMMMMMM\n\
57+
MMMMMMMMWXd,. .,,,..,;,'. ... ... .',,,..,,,. .,dXMMMMMMMMM\n\
58+
MMMMMMMMMMWXd;. .',,'..,,,,'.. ...'',,'..',,.. .;xXWMMMMMMMMMM\n");
59+
printf("MMMMMMMMMMMMMNOl'. ..'''...',,,,''''''''''''''',,,''..''''.. .'lONMMMMMMMMMMMMM\n\
60+
MMMMMMMMMMMMMMMWXkl,. ......'''...'''''''''......''..... .,lkXWMMMMMMMMMMMMMMM\n\
61+
MMMMMMMMMMMMMMMMMMWN0dc,.. ........................ ..,cd0NWMMMMMMMMMMMMMMMMMM\n\
62+
MMMMMMMMMMMMMMMMMMMMMMWNKOdl:,'... ...',:ldOKNWMMMMMMMMMMMMMMMMMMMMMM\n\
63+
MMMMMMMMMMMMMMMMMMMMMMMMMMMMWNKOkdlc:::::::cldkOKNWMMMMMMMMMMMMMMMMMMMMMMMMMMMM\n");
64+
}
65+
66+
void print_err_info(void) {
67+
printf("Use spynix -h or spynix --help to display all valid options\n");
68+
}
69+
70+
void print_hlp_info(void) {
71+
print_banner();
72+
printf("Spynix is a commandline tool for gathering info about hardware.\n\n\
73+
\t\tInfo:\n\
74+
\t\t\t-h or --help \t\t- show this menu\n\
75+
\t\t\t-v or --version \t- show version\n\
76+
\t\t\t-b or --banner \t\t- show ASCII banner\n\
77+
\t\t\t-l or --logo \t\t- show ASCII logo\n\n");
78+
printf("\t\tOptions:\n\
79+
\t\t\t-a or --all \t- show summary info about system, cpu, ram and rom\n\
80+
\t\t\t-sys \t\t- show system info\n\
81+
\t\t\t-cpu \t\t- show short Central Processing Unit info\n\
82+
\t\t\t-ram \t\t- show Random Access Memory info\n\
83+
\t\t\t-rom \t\t- show Read Only Memory info\n\
84+
\t\t\t-net \t\t- show network info\n\n\
85+
\t\tAdvanced:\n\
86+
\t\t-cpu -f or -cpu --full \t- show full Central Processing Unit info\n");
87+
}
88+
89+
void print_ver_info(void) {
90+
print_banner();
91+
printf("spynix v3.0.0\n\nFor more info visit: https://github.com/git-user-cpp/spynix\n");
92+
}

src/hlp/hlp_info.h

+9-80
Original file line numberDiff line numberDiff line change
@@ -8,85 +8,14 @@
88
* http://www.apache.org/licenses/LICENSE-2.0
99
*/
1010

11-
#include <stdio.h>
11+
#ifndef HLP_INFO_H_SENTRY
12+
#define HLP_INFO_H_SENTRY
13+
#include <stdio.h>
1214

13-
void print_banner(void){
14-
printf("\n \
15-
____ _\n \
16-
/ ___| _ __ _ _ _ __ (_)_ __\n \
17-
\\___ \\| '_ \\| | | | '_ \\| \\ \\/ /\n \
18-
___) | |_) | |_| | | | | |> <\n \
19-
|____/| .__/ \\__, |_| |_|_/_/\\_\\\n \
20-
|_| |___/\n\n");
21-
}
15+
void print_banner(void);
16+
void print_logo(void);
17+
void print_err_info(void);
18+
void print_hlp_info(void);
19+
void print_ver_info(void);
20+
#endif
2221

23-
void print_logo(void) {
24-
printf("MMMMMMMMMMMMMMMMMMMMMMMMMMMMMWNK0OkxxdddddxkkO0KNWMMMMMMMMMMMMMMMMMMMMMMMMMMMMM\n\
25-
MMMMMMMMMMMMMMMMMMMMMMMWXKOxdoc:;,,''''''''',,;:codxOKXWMMMMMMMMMMMMMMMMMMMMMMM\n\
26-
MMMMMMMMMMMMMMMMMMMWKOdl;,'',;:clooooddddoooollc:;''',:ldOKWMMMMMMMMMMMMMMMMMMM\n\
27-
MMMMMMMMMMMMMMMMN0dc,.',:loxkOOOOOOOOOOOOOOOOOOOOkxdoc;'..,cd0NMMMMMMMMMMMMMMMM\n\
28-
MMMMMMMMMMMMMW0d:'.':oxOOOOOkkxdollcc::::ccclodxkkOOO0Okoc,..':d0WMMMMMMMMMMMMM\n");
29-
printf("MMMMMMMMMMWXkl'.':okOOOOkxoc;'...''.........'...',:ldkOOO0Oxl,..,lkNWMMMMMMMMMM\n\
30-
MMMMMMMMMXk:..,lxOOOOxo:'. ......,;:lllc:;'....'. ...;lxkOOOOd:...:kNMMMMMMMMM\n\
31-
MMMMMMMNO:..,okOkOkd:. .' .;cc:::;'......,:loxO0o..;. .,lxOkOOxc...:OWMMMMMMM\n\
32-
MMMMMWKo'.'lkOkOkl' .,c. .. ..';cclodddxdooodOO;.;c.. .:dOkkOx:..'oKMMMMMM\n\
33-
MMMMWO;..:xOkkko' ..,l, . .','..',;clx0x..cl,.. .:xOkkOd,..;OWMMMM\n");
34-
printf("MMMNx'..lOkkkx; ..';lc. ...',;cldk; 'oc,,... .ckkkOk:..,xNMMM\n\
35-
MMNd'.'dOxkkl. ..',;lo' ..',;co:. :oc;;'.. ,dkxkOl..'dNMM\n\
36-
MWx'.'dkxkk:. ..,::ccc, ...';:lkk, .:cc:::,'. .okxxOl..'xWM\n\
37-
WO, .okxkk: .',,,;;,'. ......';:codk0xc::;;;,,,'. .lkxxkc..,OW\n\
38-
K:..ckxxk: ...,clcc:,.. ...',,;;:cclooooddxkOO00Oko:'... .okdxx; .cK\n");
39-
printf("x. ,dxdkl. .','.. .......'''''',,,;;;:::cclllllcc:;,'..',,'. 'dxdxo. .x\n\
40-
:..cxdxd' ..';:::;. ..........''''...'''.... '::c:,'.. :xddx; .:\n\
41-
' 'odoxl. ...',;co' ..,,'. .',;'. .co:;,''... 'odoxl. '\n\
42-
. ,ddox; ...',;co, .. .ck0K0d;. .'lOKKOo,. '..co:;,'.... .ldldo' .\n\
43-
. ;dood, ...',;:oc.'' ':oOKXKkc;. ;l:'.,:d0KX0xc;..,.'ol:;,''... cdloo' .\n");
44-
printf(". ;dood, ...',,;co;.. .;cloolc:,..lkk: .:cloolc:'....co:;,,'.... :dloo' .\n\
45-
. ,oold; ...',;;:lo; ..'''''. .oO0l. ..'','''. .loc:;,,'.... .cocol. .\n\
46-
. .lococ. ...',;:lll;. .o00o.......';o: 'cloc:;,'... .llcoc. .\n\
47-
; .:ocll' ..,:c:,'',c;... .,'..,;::cldOx'.c:'.';:c:;'.. ,lcco; :\n\
48-
d. 'lc:l:. .',,'.':oxdc' . .',;:::cloxk: .;oxdl;..',,'. .cl:lc. .d\n");
49-
printf("K; .:l::l, '.. ,okdc'. . 'cloc::clxkc. .,lxko, ..'. ;c::l, :K\n\
50-
Wk' .cc;:c' ....,xx,. .. .,;llccldx: .;kk;.... ,c;;c:. 'kW\n\
51-
MNd. .cc,;c' .'..:l;. ...',:cooc. .:dl...'. ,c;,c:. .dNM\n\
52-
MMNo. .::,;:;. .'..'c:. ..,;::cc:;. .:l,..,. .,:,,::. .oNMM\n\
53-
MMMNd. .;:,'::. .'..,:'. ...... .'::..''. .;;',:;. .dNMMM\n");
54-
printf("MMMMNx' .,:,',:,. .....;,. .,:'..'. .;;'';:'. 'kWMMMM\n\
55-
MMMMMW0:. .;;'.,;,. .',. .,,. .. .,;,.';,. .c0WMMMMM\n\
56-
MMMMMMMNx,. .;;'.,;,.. .'. .,. .',;'.';,. .,xNMMMMMMM\n\
57-
MMMMMMMMWXd,. .,,,..,;,'. ... ... .',,,..,,,. .,dXMMMMMMMMM\n\
58-
MMMMMMMMMMWXd;. .',,'..,,,,'.. ...'',,'..',,.. .;xXWMMMMMMMMMM\n");
59-
printf("MMMMMMMMMMMMMNOl'. ..'''...',,,,''''''''''''''',,,''..''''.. .'lONMMMMMMMMMMMMM\n\
60-
MMMMMMMMMMMMMMMWXkl,. ......'''...'''''''''......''..... .,lkXWMMMMMMMMMMMMMMM\n\
61-
MMMMMMMMMMMMMMMMMMWN0dc,.. ........................ ..,cd0NWMMMMMMMMMMMMMMMMMM\n\
62-
MMMMMMMMMMMMMMMMMMMMMMWNKOdl:,'... ...',:ldOKNWMMMMMMMMMMMMMMMMMMMMMM\n\
63-
MMMMMMMMMMMMMMMMMMMMMMMMMMMMWNKOkdlc:::::::cldkOKNWMMMMMMMMMMMMMMMMMMMMMMMMMMMM\n");
64-
}
65-
66-
void print_err_info(void) {
67-
printf("Use spynix -h or spynix --help to display all valid options\n");
68-
}
69-
70-
void print_hlp_info(void) {
71-
print_banner();
72-
printf("Spynix is a commandline tool for gathering info about hardware.\n\n\
73-
\t\tInfo:\n\
74-
\t\t\t-h or --help \t\t- show this menu\n\
75-
\t\t\t-v or --version \t- show version\n\
76-
\t\t\t-b or --banner \t\t- show ASCII banner\n\
77-
\t\t\t-l or --logo \t\t- show ASCII logo\n\n");
78-
printf("\t\tOptions:\n\
79-
\t\t\t-a or --all \t- show summary info about system, cpu, ram and rom\n\
80-
\t\t\t-sys \t\t- show system info\n\
81-
\t\t\t-cpu \t\t- show short Central Processing Unit info\n\
82-
\t\t\t-ram \t\t- show Random Access Memory info\n\
83-
\t\t\t-rom \t\t- show Read Only Memory info\n\
84-
\t\t\t-net \t\t- show network info\n\n\
85-
\t\tAdvanced:\n\
86-
\t\t-cpu -f or -cpu --full \t- show full Central Processing Unit info\n");
87-
}
88-
89-
void print_ver_info(void) {
90-
print_banner();
91-
printf("spynix v3.0.0\n\nFor more info visit: https://github.com/git-user-cpp/spynix\n");
92-
}

src/net/net_info.c

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright 2024 Andrew Kushyk
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*/
10+
11+
#include "net_info.h"
12+
13+
void print_net_info(char *hostname){
14+
struct hostent *host = gethostbyname(hostname);
15+
struct ifaddrs *ifaddr, *ifa;
16+
int i;
17+
18+
if(host == NULL){
19+
perror("gethostbyname");
20+
exit(1);
21+
} else {
22+
printf("Host Name: %s\n", host->h_name);
23+
printf("IP Address: ");
24+
for(i = 0; host->h_addr_list[i] != NULL; i++){
25+
printf("%s ", inet_ntoa(*(struct in_addr *)host->h_addr_list[i]));
26+
}
27+
printf("\n");
28+
}
29+
30+
if(getifaddrs(&ifaddr) == -1) {
31+
perror("getifaddrs");
32+
exit(1);
33+
}
34+
for(ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next){
35+
if(ifa->ifa_addr != NULL && ifa->ifa_addr->sa_family == AF_INET){
36+
printf("Interface: %s\n", ifa->ifa_name);
37+
printf("Address: %s\n", inet_ntoa(((struct sockaddr_in*)ifa->ifa_addr)->sin_addr));
38+
printf("Netmask: %s\n", inet_ntoa(((struct sockaddr_in*)ifa->ifa_netmask)->sin_addr));
39+
}
40+
}
41+
42+
freeifaddrs(ifaddr);
43+
}

0 commit comments

Comments
 (0)