1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
#include "../include/cfetch.h"
#include <stddef.h>
#define MAX_LOGOS 2
/*
typedef struct distro_mapping_t
{
const char *distro_pattern;
const char *ascii_file;
} distro_mapping_t;
*/
static const distro_mapping_t distro_mappings[] =
{
{"cccp", "cccp.ascii"},
{"cccp_shield", "cccp_shield.ascii"},
{NULL, NULL}
};
const char* get_ascii_name(const distro_mapping_t *d_map, int art)
{
if (art > MAX_LOGOS) {
fprintf(stdout, "get_ascii_path: index out of bounce:\n");
fprintf(stdout, "get default ascii art.\n");
art = 0;
}
const char* ascii_name = d_map[art].ascii_file;
return ascii_name;
}
void print_ascii_art(system_info_t *info, int art)
{
// get ascii name
const char* name = get_ascii_name(distro_mappings[], art);
char* path = concat("../ascii/", name);
if (path == NULL)
{
perror("print_ascii_art: could not concat");
return;
}
FILE* file = fopen(path, "r");
if (file == NULL) {
perror("print_ascii_art: could not open file");
return;
}
// get mapping
// return path ?
free(path);
}
/*
int get_line_length(const char **line)
{
size_t length = 0;
size_t max_length = 0;
if (line == NULL) return -1;
for (int i = 0; line[i] != NULL; i++) {
length = strlen(line[i]);
if (length > max_length) {
max_length = length;
}
}
return max_length;
}
const char **logo(int index) {
static const char *logo0[] = {
" _____________",
" / \\",
" | ☆ ☆ ☆ |",
" | ☆ ☭ ☆ |",
" | ☆ ☆ ☆ |",
" \\_____________/",
" Рабочие мира, объединяйтесь!",
NULL
};
static const char *logo1[] = {
" ╔═══════════════════╗",
" ║ ║",
" ║ ☭ C C C P ☭ ║",
" ║ ║",
" ╚═══════════════════╝",
" Власть — Советам!",
NULL
};
if (index < 0 || index >= MAX_LOGOS) return NULL;
switch (index) {
case 0:
return logo0;
case 1:
return logo1;
default:
return NULL;
}
}
*/
|