aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ascii.c71
-rw-r--r--src/cfetch.c4
2 files changed, 26 insertions, 49 deletions
diff --git a/src/ascii.c b/src/ascii.c
index b4df816..2fee648 100644
--- a/src/ascii.c
+++ b/src/ascii.c
@@ -1,5 +1,6 @@
#include "../include/cfetch.h"
#include <stddef.h>
+#include <stdio.h>
#define MAX_LOGOS 2
@@ -22,8 +23,8 @@ static const distro_mapping_t distro_mappings[] =
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");
+ fprintf(stderr, "get_ascii_path: index out of bounce\n");
+ fprintf(stdout, "Get default ascii art.\n");
art = 0;
}
@@ -35,76 +36,52 @@ 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);
+ char* path = concat("ascii/", name);
+ 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);
+ }
- // return path ?
+ // free pointers
free(path);
}
-/*
-int get_line_length(const char **line)
+// 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;
- size_t max_length = 0;
- if (line == NULL) return -1;
+ if (line == NULL)
+ {
+ perror("get_line_length: pointer NULL");
+ return;
+ }
+
for (int i = 0; line[i] != NULL; i++) {
length = strlen(line[i]);
- if (length > max_length) {
+ if (length > ascii->lines) {
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;
- }
-}
-*/
diff --git a/src/cfetch.c b/src/cfetch.c
index 1a71f2c..caabbc9 100644
--- a/src/cfetch.c
+++ b/src/cfetch.c
@@ -21,14 +21,14 @@ int main(void) {
system_info_t info = { 0 };
// set default artwork
- int art_logo = 0;
+ int art_logo = 5;
// set systeminformation
// use // to uncomment or comment
get_os(&info);
get_memory(&info);
get_cpu(&info);
- //print_ascii_art(&info, art_logo);
+ print_ascii_art(&info, art_logo);
return 0;
}