#include "../include/cfetch.h" #include #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; } } */