mirror of
https://github.com/Dr-Noob/cpufetch.git
synced 2026-03-25 07:50:40 +01:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ae53d97a47 | ||
|
|
eeeaec3ba9 | ||
|
|
7c5a0c3280 | ||
|
|
d4ad5a58f0 |
File diff suppressed because one or more lines are too long
19
src/common/ascii/amd.txt
Normal file
19
src/common/ascii/amd.txt
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
████ ███ ███ ████████ ▜███████████
|
||||||
|
██████ █████ █████ ███ ███ ▗▀▀▀▀▀▀▜███
|
||||||
|
███ ███ █████████████ ███ ██ ▐█ ▐███
|
||||||
|
███ ███ ███ ███ ███ ███ ██ ▟██ ▐███
|
||||||
|
████████████ ███ ███ ███ ███ ████▄▄▄▄▄▄▝▜██
|
||||||
|
███ ███ ███ ███ █████████ ████████▛ ██
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
3
src/common/ascii/convert.sh
Executable file
3
src/common/ascii/convert.sh
Executable file
@@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
cat intel.txt | hexdump -vC | head -n-1 | cut -d' ' -f2- | cut -d'|' -f1 | tr '\n' ' ' | tr -s ' ' | tr ' ' ',' | sed "s/,/,0x/g"
|
||||||
19
src/common/ascii/intel.txt
Normal file
19
src/common/ascii/intel.txt
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
▁▂▃▄▅▆▆▇▇███████▇▇▆▅▅▄▂▁
|
||||||
|
▁▃▄▆▇▛▀▀▀▀▔▔▔ ▔▔▔▀▀▀██▇▅▃
|
||||||
|
▂▄▆█▀▀▔ ▝▜██▅▁
|
||||||
|
▀▀▔ ▔▜██▖
|
||||||
|
▅▅▅ ▆▆▆ ▜██▖
|
||||||
|
▁▅ ▀▀▀ ▐██▌ ███ ██▉
|
||||||
|
▄▛▘ ▄▄▄ ▗▄▄▄▄▄▄▃▁ ▐██▙▄▖ ▁▃▄▅▄▃ ███ ███
|
||||||
|
▗▟▛ ███ ▐██▀▀▀▜██▖ ▐██▛▀▘ ▟██▀▀▀██▖ ███ ▗██▊
|
||||||
|
█▛ ███ ▐██ ▕██▌ ▐██▌ ▐██▂▂▂▂▂██ ███ ▗███▘
|
||||||
|
▐█▍ ███ ▐██ ▕██▌ ▐██▌ ▐██▛▀▀▀▀▀▀ ███ ▄██▛▘
|
||||||
|
██▏ ███ ▐██ ▕██▌ ▐██▌ ▝██▙▁ ▁▂▃ ███ ▅███▀
|
||||||
|
██▍ ▝██ ▐██ ▕██▌ ▀███▋ ▝▀█████▛ ▝▜█ █▀▔
|
||||||
|
▐█▙ ▔▔▔
|
||||||
|
▜█▙▖ ▁▂▄▖
|
||||||
|
▜██▆▃▁ ▁▂▄▅▇███▌
|
||||||
|
▝▜███▇▅▄▃▂▁ ▁▁▂▃▄▅▆▇███████▀▀
|
||||||
|
▔▀▀████████▇▇▇▇▇▇▇▇▇▇███████████▛▀▀▔▔
|
||||||
|
▔▔▀▀▀▀█████████████▀▀▀▀▀▔▔▔
|
||||||
|
|
||||||
@@ -51,7 +51,7 @@ NOTES: \n\
|
|||||||
}
|
}
|
||||||
|
|
||||||
void print_version() {
|
void print_version() {
|
||||||
printf("cpufetch v%s (%s) [outfile branch]\n",VERSION, ARCH_STR);
|
printf("cpufetch v%s (%s)\n",VERSION, ARCH_STR);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
|
|||||||
@@ -22,7 +22,6 @@
|
|||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define OUTPUT_FILE "cpufetch.txt"
|
|
||||||
#define max(a,b) (((a)>(b))?(a):(b))
|
#define max(a,b) (((a)>(b))?(a):(b))
|
||||||
#define MAX_ATTRIBUTES 100
|
#define MAX_ATTRIBUTES 100
|
||||||
|
|
||||||
@@ -106,6 +105,7 @@ struct attribute {
|
|||||||
|
|
||||||
struct ascii {
|
struct ascii {
|
||||||
char art[NUMBER_OF_LINES][LINE_SIZE+1];
|
char art[NUMBER_OF_LINES][LINE_SIZE+1];
|
||||||
|
unsigned char* art_unicode;
|
||||||
char color1_ascii[100];
|
char color1_ascii[100];
|
||||||
char color2_ascii[100];
|
char color2_ascii[100];
|
||||||
char color1_text[100];
|
char color1_text[100];
|
||||||
@@ -160,8 +160,8 @@ struct ascii* set_ascii(VENDOR vendor, STYLE style, struct colors* cs) {
|
|||||||
|
|
||||||
#ifdef ARCH_X86
|
#ifdef ARCH_X86
|
||||||
if(art->vendor == CPU_VENDOR_INTEL) {
|
if(art->vendor == CPU_VENDOR_INTEL) {
|
||||||
COL_FANCY_1 = COLOR_BG_CYAN;
|
COL_FANCY_1 = COLOR_FG_CYAN;
|
||||||
COL_FANCY_2 = COLOR_BG_WHITE;
|
COL_FANCY_2 = COLOR_FG_WHITE;
|
||||||
COL_FANCY_3 = COLOR_FG_CYAN;
|
COL_FANCY_3 = COLOR_FG_CYAN;
|
||||||
COL_FANCY_4 = COLOR_FG_WHITE;
|
COL_FANCY_4 = COLOR_FG_WHITE;
|
||||||
art->ascii_chars[0] = '#';
|
art->ascii_chars[0] = '#';
|
||||||
@@ -263,6 +263,12 @@ struct ascii* set_ascii(VENDOR vendor, STYLE style, struct colors* cs) {
|
|||||||
if(cs != NULL) {
|
if(cs != NULL) {
|
||||||
COL_FANCY_1 = rgb_to_ansi(cs->c1, true, true);
|
COL_FANCY_1 = rgb_to_ansi(cs->c1, true, true);
|
||||||
COL_FANCY_2 = rgb_to_ansi(cs->c2, true, true);
|
COL_FANCY_2 = rgb_to_ansi(cs->c2, true, true);
|
||||||
|
#ifdef ARCH_X86
|
||||||
|
if(art->vendor == CPU_VENDOR_INTEL) {
|
||||||
|
COL_FANCY_1 = rgb_to_ansi(cs->c1, false, true);
|
||||||
|
COL_FANCY_2 = rgb_to_ansi(cs->c2, false, true);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
COL_FANCY_3 = rgb_to_ansi(cs->c3, false, true);
|
COL_FANCY_3 = rgb_to_ansi(cs->c3, false, true);
|
||||||
COL_FANCY_4 = rgb_to_ansi(cs->c4, false, true);
|
COL_FANCY_4 = rgb_to_ansi(cs->c4, false, true);
|
||||||
}
|
}
|
||||||
@@ -304,9 +310,11 @@ struct ascii* set_ascii(VENDOR vendor, STYLE style, struct colors* cs) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
char tmp[NUMBER_OF_LINES * LINE_SIZE + 1];
|
char tmp[NUMBER_OF_LINES * LINE_SIZE + 1];
|
||||||
|
art->art_unicode = NULL;
|
||||||
|
|
||||||
#ifdef ARCH_X86
|
#ifdef ARCH_X86
|
||||||
if(art->vendor == CPU_VENDOR_INTEL)
|
if(art->vendor == CPU_VENDOR_INTEL)
|
||||||
strcpy(tmp, INTEL_ASCII);
|
art->art_unicode = art_unicode_intel;
|
||||||
else if(art->vendor == CPU_VENDOR_AMD)
|
else if(art->vendor == CPU_VENDOR_AMD)
|
||||||
strcpy(tmp, AMD_ASCII);
|
strcpy(tmp, AMD_ASCII);
|
||||||
else
|
else
|
||||||
@@ -326,8 +334,11 @@ struct ascii* set_ascii(VENDOR vendor, STYLE style, struct colors* cs) {
|
|||||||
strcpy(tmp, ARM_ASCII);
|
strcpy(tmp, ARM_ASCII);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for(int i=0; i < NUMBER_OF_LINES; i++)
|
if(art->art_unicode != NULL) {
|
||||||
|
for(int i=0; i < NUMBER_OF_LINES; i++) {
|
||||||
memcpy(art->art[i], tmp + i*LINE_SIZE, LINE_SIZE);
|
memcpy(art->art[i], tmp + i*LINE_SIZE, LINE_SIZE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return art;
|
return art;
|
||||||
}
|
}
|
||||||
@@ -347,43 +358,45 @@ uint32_t longest_attribute_length(struct ascii* art) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ARCH_X86
|
#ifdef ARCH_X86
|
||||||
void print_algorithm_intel(FILE *file, struct ascii* art, int n, bool* flag) {
|
void print_algorithm_intel(struct ascii* art, int n, bool* flag) {
|
||||||
for(int i=0; i < LINE_SIZE; i++) {
|
|
||||||
if(*flag) {
|
|
||||||
if(art->art[n][i] == ' ') {
|
|
||||||
*flag = false;
|
*flag = false;
|
||||||
fprintf(file, "%s%c%s", art->color2_ascii, art->ascii_chars[1], art->reset);
|
int start = -1;
|
||||||
|
for(int i=0, newlines=0; newlines < n; i++) {
|
||||||
|
if(art->art_unicode[i] == '\n') {
|
||||||
|
newlines++;
|
||||||
|
start = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int i=start+1, x=0; art->art_unicode[i] != '\n'; i++, x++) {
|
||||||
|
if(art->art_unicode[i] == ' ') {
|
||||||
|
printf(" ");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fprintf(file, "%s%c%s", art->color1_ascii, art->ascii_chars[0], art->reset);
|
printf("%s", art->color1_ascii);
|
||||||
}
|
printf("%c", art->art_unicode[i]);
|
||||||
}
|
printf("%c", art->art_unicode[i + 1]);
|
||||||
else {
|
printf("%c", art->art_unicode[i + 2]);
|
||||||
if(art->art[n][i] != ' ' && art->art[n][i] != '\0') {
|
printf("%s", COLOR_RESET);
|
||||||
*flag = true;
|
i += 2;
|
||||||
fprintf(file, "%c",' ');
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
fprintf(file, "%c",' ');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_algorithm_amd(FILE *file, struct ascii* art, int n, bool* flag) {
|
void print_algorithm_amd(struct ascii* art, int n, bool* flag) {
|
||||||
*flag = false; // dummy, just silence compiler error
|
*flag = false; // dummy, just silence compiler error
|
||||||
|
|
||||||
for(int i=0; i < LINE_SIZE; i++) {
|
for(int i=0; i < LINE_SIZE; i++) {
|
||||||
if(art->art[n][i] == '@')
|
if(art->art[n][i] == '@')
|
||||||
fprintf(file, "%s%c%s", art->color1_ascii, art->ascii_chars[0], art->reset);
|
printf("%s%c%s", art->color1_ascii, art->ascii_chars[0], art->reset);
|
||||||
else if(art->art[n][i] == '#')
|
else if(art->art[n][i] == '#')
|
||||||
fprintf(file, "%s%c%s", art->color2_ascii, art->ascii_chars[1], art->reset);
|
printf("%s%c%s", art->color2_ascii, art->ascii_chars[1], art->reset);
|
||||||
else
|
else
|
||||||
fprintf(file, "%c",art->art[n][i]);
|
printf("%c",art->art[n][i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_ascii_x86(FILE *file, struct ascii* art, uint32_t la, void (*callback_print_algorithm)(FILE *file, struct ascii* art, int i, bool* flag)) {
|
void print_ascii_x86(struct ascii* art, uint32_t la, void (*callback_print_algorithm)(struct ascii* art, int i, bool* flag)) {
|
||||||
int attr_to_print = 0;
|
int attr_to_print = 0;
|
||||||
int attr_type;
|
int attr_type;
|
||||||
char* attr_value;
|
char* attr_value;
|
||||||
@@ -392,9 +405,9 @@ void print_ascii_x86(FILE *file, struct ascii* art, uint32_t la, void (*callback
|
|||||||
uint32_t space_down = NUMBER_OF_LINES - art->n_attributes_set - space_up;
|
uint32_t space_down = NUMBER_OF_LINES - art->n_attributes_set - space_up;
|
||||||
bool flag = false;
|
bool flag = false;
|
||||||
|
|
||||||
fprintf(file, "\n");
|
printf("\n");
|
||||||
for(uint32_t n=0;n<NUMBER_OF_LINES;n++) {
|
for(uint32_t n=0;n<NUMBER_OF_LINES;n++) {
|
||||||
callback_print_algorithm(file, art, n, &flag);
|
callback_print_algorithm(art, n, &flag);
|
||||||
|
|
||||||
if(n > space_up-1 && n < NUMBER_OF_LINES-space_down) {
|
if(n > space_up-1 && n < NUMBER_OF_LINES-space_down) {
|
||||||
attr_type = art->attributes[attr_to_print]->type;
|
attr_type = art->attributes[attr_to_print]->type;
|
||||||
@@ -402,20 +415,20 @@ void print_ascii_x86(FILE *file, struct ascii* art, uint32_t la, void (*callback
|
|||||||
attr_to_print++;
|
attr_to_print++;
|
||||||
|
|
||||||
space_right = 1 + (la - strlen(ATTRIBUTE_FIELDS[attr_type]));
|
space_right = 1 + (la - strlen(ATTRIBUTE_FIELDS[attr_type]));
|
||||||
fprintf(file, "%s%s%s%*s%s%s%s\n", art->color1_text, ATTRIBUTE_FIELDS[attr_type], art->reset, space_right, "", art->color2_text, attr_value, art->reset);
|
printf("%s%s%s%*s%s%s%s\n", art->color1_text, ATTRIBUTE_FIELDS[attr_type], art->reset, space_right, "", art->color2_text, attr_value, art->reset);
|
||||||
}
|
}
|
||||||
else fprintf(file, "\n");
|
else printf("\n");
|
||||||
}
|
}
|
||||||
fprintf(file, "\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_ascii(FILE *file, struct ascii* art) {
|
void print_ascii(struct ascii* art) {
|
||||||
uint32_t longest_attribute = longest_attribute_length(art);
|
uint32_t longest_attribute = longest_attribute_length(art);
|
||||||
|
|
||||||
if(art->vendor == CPU_VENDOR_INTEL)
|
if(art->vendor == CPU_VENDOR_INTEL)
|
||||||
print_ascii_x86(file, art, longest_attribute, &print_algorithm_intel);
|
print_ascii_x86(art, longest_attribute, &print_algorithm_intel);
|
||||||
else if(art->vendor == CPU_VENDOR_AMD)
|
else if(art->vendor == CPU_VENDOR_AMD)
|
||||||
print_ascii_x86(file, art, longest_attribute, &print_algorithm_amd);
|
print_ascii_x86(art, longest_attribute, &print_algorithm_amd);
|
||||||
else {
|
else {
|
||||||
printBug("Invalid CPU vendor: %d\n", art->vendor);
|
printBug("Invalid CPU vendor: %d\n", art->vendor);
|
||||||
}
|
}
|
||||||
@@ -427,8 +440,6 @@ bool print_cpufetch_x86(struct cpuInfo* cpu, STYLE s, struct colors* cs) {
|
|||||||
if(art == NULL)
|
if(art == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
FILE *output_file;
|
|
||||||
|
|
||||||
char* uarch = get_str_uarch(cpu);
|
char* uarch = get_str_uarch(cpu);
|
||||||
char* manufacturing_process = get_str_process(cpu);
|
char* manufacturing_process = get_str_process(cpu);
|
||||||
char* sockets = get_str_sockets(cpu->topo);
|
char* sockets = get_str_sockets(cpu->topo);
|
||||||
@@ -439,6 +450,7 @@ bool print_cpufetch_x86(struct cpuInfo* cpu, STYLE s, struct colors* cs) {
|
|||||||
char* avx = get_str_avx(cpu);
|
char* avx = get_str_avx(cpu);
|
||||||
char* fma = get_str_fma(cpu);
|
char* fma = get_str_fma(cpu);
|
||||||
|
|
||||||
|
|
||||||
char* l1i = get_str_l1i(cpu->cach);
|
char* l1i = get_str_l1i(cpu->cach);
|
||||||
char* l1d = get_str_l1d(cpu->cach);
|
char* l1d = get_str_l1d(cpu->cach);
|
||||||
char* l2 = get_str_l2(cpu->cach);
|
char* l2 = get_str_l2(cpu->cach);
|
||||||
@@ -476,12 +488,7 @@ bool print_cpufetch_x86(struct cpuInfo* cpu, STYLE s, struct colors* cs) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((output_file = fopen(OUTPUT_FILE, "w+")) == NULL) {
|
print_ascii(art);
|
||||||
perror("fopen");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
print_ascii(output_file, art);
|
|
||||||
|
|
||||||
free(manufacturing_process);
|
free(manufacturing_process);
|
||||||
free(max_frequency);
|
free(max_frequency);
|
||||||
|
|||||||
Reference in New Issue
Block a user