Skip to content

Commit e04f22b

Browse files
committed
added various options
1 parent 19bb86e commit e04f22b

File tree

5 files changed

+83
-5
lines changed

5 files changed

+83
-5
lines changed

main

16.3 KB
Binary file not shown.

src/cpu/cpu_info.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,24 @@ void print_cpu_info() {
2222
printf("Error opening /proc/cpuinfo\n");
2323
}
2424
}
25+
26+
void print_full_cpu_info() {
27+
printf(" ____________\n");
28+
printf("|\n");
29+
printf("| Full CPU Info:\n");
30+
printf("|____________\n");
31+
printf("|\n");
32+
33+
FILE *cpu_file = fopen("/proc/cpuinfo", "r");
34+
if (cpu_file) {
35+
char line[128];
36+
while (fgets(line, sizeof(line), cpu_file)) {
37+
printf("| %s", line);
38+
}
39+
fclose(cpu_file);
40+
printf("|____________\n\n");
41+
} else {
42+
printf("Error opening /proc/cpuinfo\n");
43+
}
44+
}
45+

src/hlp/.hlp_info.h.swp

12 KB
Binary file not shown.

src/hlp/hlp_info.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#include <stdio.h>
2+
3+
void print_err_info() {
4+
printf("Use spynix -h to display all valid options\n");
5+
}
6+
7+
void print_hlp_info() {
8+
printf("spynix v2.0.0\n \
9+
Info:\n\t \
10+
-h - show this menu\n\t \
11+
-v - show version\n\n \
12+
Options:\n\t \
13+
-a - show summary info about system, cpu, ram and rom\n\t \
14+
-sys - show system info\n\t \
15+
-cpu - show short Central Process Unit info\n\t \
16+
-ram - show Random Access Memory info\n\t \
17+
-rom - show Read Only Memory info\n\n \
18+
Advanced:\n\t \
19+
-cpu -f - show full Central Process Unit info\n");
20+
}
21+
22+
void print_ver_info() {
23+
printf("spynix v2.0.0\n\nFor more info visit: https://github.com/git-user-cpp/spynix");
24+
}

src/main.c

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,46 @@
1+
#include <string.h>
12
#include "sys/sys_info.h"
23
#include "ram/ram_info.h"
34
#include "cpu/cpu_info.h"
45
#include "rom/rom_info.h"
6+
#include "hlp/hlp_info.h"
57

6-
int main() {
7-
print_sys_info();
8-
print_cpu_info();
9-
print_ram_info();
10-
print_rom_info();
8+
int main(int argc, char **argv) {
9+
if(argc == 1) {
10+
print_sys_info();
11+
print_cpu_info();
12+
print_ram_info();
13+
print_rom_info();
14+
} else if (argc == 2) {
15+
if(strcmp(argv[1], "-h") == 0) {
16+
print_hlp_info();
17+
} else if(strcmp(argv[1], "-a") == 0) {
18+
print_sys_info();
19+
print_cpu_info();
20+
print_ram_info();
21+
print_rom_info();
22+
} else if(strcmp(argv[1], "-sys") == 0) {
23+
print_sys_info();
24+
} else if(strcmp(argv[1], "-cpu") == 0) {
25+
print_cpu_info();
26+
} else if(strcmp(argv[1], "-ram") == 0) {
27+
print_ram_info();
28+
} else if(strcmp(argv[1], "-rom") == 0) {
29+
print_rom_info();
30+
} else if(strcmp(argv[1], "-v") == 0) {
31+
print_ver_info();
32+
} else {
33+
print_err_info();
34+
}
35+
} else if(argc == 3){
36+
if((strcmp(argv[1], "-cpu") == 0) && (strcmp(argv[2], "-f") == 0)) {
37+
print_full_cpu_info();
38+
} else {
39+
print_err_info();
40+
}
41+
} else {
42+
print_err_info();
43+
}
1144

1245
return 0;
1346
}

0 commit comments

Comments
 (0)