aboutsummaryrefslogtreecommitdiff
path: root/src/ascii.c
diff options
context:
space:
mode:
authorAnser <rostgans@tutamail.com>2026-08-11 13:11:39 +0200
committerAnser <rostgans@tutamail.com>2026-08-11 20:04:21 +0200
commit729746e50ebc8e4eb4c98f7556a241aec111e07d (patch)
treee33e627474fdba4c625bb72f9848b1f067303aff /src/ascii.c
parenteb6f986361713d6ce47c6d4572bb24d9f6207ddf (diff)
some more rework in readme.md and src file structure
Diffstat (limited to 'src/ascii.c')
-rw-r--r--src/ascii.c110
1 files changed, 110 insertions, 0 deletions
diff --git a/src/ascii.c b/src/ascii.c
new file mode 100644
index 0000000..b4df816
--- /dev/null
+++ b/src/ascii.c
@@ -0,0 +1,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;
+ }
+}
+*/