/* cfetch is my try to implement a neofetch/fastfetch/commiefetch clone in C. * Copyright (C) 2026 Anser * * cfetch is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation, either version 3 of the License, * or (at your option) any later version. * * cfetch is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #include "../include/cfetch.h" #include #include #define MAX_LOGOS 2 static const struct ascii_mapping_t ascii_mappings[] = { {"cccp", "cccp.ascii"}, {"cccp_shield", "cccp_shield.ascii"}, {NULL, NULL} }; const char* get_ascii_name(const struct ascii_mapping_t *d_map, int art) { if (art > MAX_LOGOS) { fprintf(stderr, "get_ascii_path: index out of bounce\n"); fprintf(stderr, "Get default ascii art.\n"); art = 0; } const char* ascii_name = d_map[art].ascii_file; return ascii_name; } void print_ascii_art(struct system_info_t *info) { // get ascii name const char* name = get_ascii_name(ascii_mappings, info->ascii_art); char* path = concat("ascii/", name); if (info->debug == 1) { printf("path: %s\n", path); } 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 char line[64]; while (fgets(line, sizeof(line), file)) { printf("%s", line); } // free pointers free(path); } void print_system_info(struct system_info_t *info) { printf("Kernel: %s\n", info->kernel); printf("CPU: %s\n", info->cpu); printf("%s\n", info->memory); //printf(logo) print_ascii_art(info); } // brauche ich diese function überhaupt, mit dieser signatur ? // get_max_ascii_length // und dann get_line_length? // alles im struct speicher? /* void get_line_length(ascii_art_t *ascii, const char **line) { size_t length = 0; if (line == NULL) { perror("get_line_length: pointer NULL"); return; } for (int i = 0; line[i] != NULL; i++) { length = strlen(line[i]); if (length > ascii->lines) { max_length = length; } } } */