aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnser <rostgans@tutamail.com>2026-07-23 23:40:23 +0200
committerAnser <rostgans@tutamail.com>2026-07-31 11:12:48 +0200
commit56378b20f42b3dfb64c626f0bd7c7f59d0fffa50 (patch)
treef71e0478ec651c9387b0397125c375bb88625568
parente668c5d6f9f472a1ed0bb62643b9c1b41542ff69 (diff)
some basic logos
-rw-r--r--Makefile3
-rw-r--r--src/cfetch.c2
-rw-r--r--src/logo/logo.c73
-rw-r--r--src/logo/logo.h6
-rw-r--r--src/modules/memory/memory.c2
5 files changed, 84 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index 2efb5fe..a7c2107 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-CC = /usr/local/musl/bin/musl-gcc
+CC = gcc
CFLAGS = -Wall -Wextra -Werror
PREFIX ?= /usr/local
@@ -6,6 +6,7 @@ SRC = src/cfetch.c \
src/modules/os/os.c \
src/modules/memory/memory.c \
src/modules/cpu/cpu.c \
+ src/logo/logo.c \
src/modules/utils/utils.c
all: cfetch
diff --git a/src/cfetch.c b/src/cfetch.c
index 5870985..596e44b 100644
--- a/src/cfetch.c
+++ b/src/cfetch.c
@@ -1,10 +1,12 @@
#include "modules/os/os.h"
#include "modules/memory/memory.h"
#include "modules/cpu/cpu.h"
+#include "logo/logo.h"
int main(void) {
os();
memory();
cpu();
+ print_logo();
return 0;
}
diff --git a/src/logo/logo.c b/src/logo/logo.c
new file mode 100644
index 0000000..749b999
--- /dev/null
+++ b/src/logo/logo.c
@@ -0,0 +1,73 @@
+#include "logo.h"
+#include <stddef.h>
+#include <stdio.h>
+#include <string.h>
+
+#define MAX_LOGOS 2
+
+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;
+ }
+}
+
+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;
+}
+
+void print_logo(void) {
+ int length = 0;
+
+ for (int i = 0; i < MAX_LOGOS; i++) {
+ const char **lines = logo(i);
+ if (lines == NULL) continue;
+
+ length = get_line_length(lines);
+
+ for (int j = 0; lines[j] != NULL ; j++) {
+ printf("%s\n", lines[j]);
+ }
+ printf("%d\n", length);
+ }
+}
diff --git a/src/logo/logo.h b/src/logo/logo.h
new file mode 100644
index 0000000..fc55db6
--- /dev/null
+++ b/src/logo/logo.h
@@ -0,0 +1,6 @@
+#ifndef LOGO_H
+#define LOGO_H
+
+void print_logo(void);
+
+#endif //LOGO_H
diff --git a/src/modules/memory/memory.c b/src/modules/memory/memory.c
index 988e233..211cf44 100644
--- a/src/modules/memory/memory.c
+++ b/src/modules/memory/memory.c
@@ -5,7 +5,7 @@ int memory(void) {
FILE *file = fopen("/proc/meminfo", "r");
if (!file) {
- perror("fopen");
+ perror("Error fopen meminfo");
return 1;
}