aboutsummaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorAnser <rostgans@tutamail.com>2026-08-11 00:18:57 +0200
committerAnser <rostgans@tutamail.com>2026-08-11 00:18:57 +0200
commiteb6f986361713d6ce47c6d4572bb24d9f6207ddf (patch)
tree3fca62d5cad785acce36a46a660219840c959932 /src/modules
parent9ad584b5762433f7c99d7cc7b65ad21ebe4ff932 (diff)
TOBESQUISHED: safe in reconstruction of the codes layout and rework of information handeling also ascii art printing
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/cpu/cpu.c48
-rw-r--r--src/modules/cpu/cpu.h6
-rw-r--r--src/modules/memory/memory.c27
-rw-r--r--src/modules/memory/memory.h6
-rw-r--r--src/modules/os/os.c19
-rw-r--r--src/modules/os/os.h6
-rw-r--r--src/modules/utils/utils.c114
-rw-r--r--src/modules/utils/utils.h21
8 files changed, 0 insertions, 247 deletions
diff --git a/src/modules/cpu/cpu.c b/src/modules/cpu/cpu.c
deleted file mode 100644
index a6dac93..0000000
--- a/src/modules/cpu/cpu.c
+++ /dev/null
@@ -1,48 +0,0 @@
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include "cpu.h"
-#include "../utils/utils.h"
-
-int cpu(void) {
- FILE* file = fopen("/proc/cpuinfo", "r");
-
- //check file existence
- if (!file) {
- perror("/proc/cpuinfo not found");
- return 1;
- }
-
- char line[256];
- char *model_name = NULL;
-
- //read per line
- while (fgets(line, sizeof(line), file)) {
- char* p = strstr(line, "model name");
-
- if (p != NULL) {
- model_name = strchr(p, ':') + 1; //skip :
- break;
- }
- }
-
- if (model_name != NULL) {
- char *string = string_format(model_name);
-
- if (string == NULL) {
- printf("CPU: Error string not found.\n");
- free(string);
- model_name = NULL;
- } else {
- printf("CPU: %s\n", string);
- free(string);
- model_name = NULL;
- }
-
- } else {
- printf("CPU: Error model_name not found.\n");
- }
-
- fclose(file);
- return 0;
-}
diff --git a/src/modules/cpu/cpu.h b/src/modules/cpu/cpu.h
deleted file mode 100644
index 63aa12f..0000000
--- a/src/modules/cpu/cpu.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef CPU_H
-#define CPU_H
-
-int cpu(void);
-
-#endif // CPU_H
diff --git a/src/modules/memory/memory.c b/src/modules/memory/memory.c
deleted file mode 100644
index 62eeafe..0000000
--- a/src/modules/memory/memory.c
+++ /dev/null
@@ -1,27 +0,0 @@
-#include <stdio.h>
-#include "memory.h"
-
-char *memory(void) {
- FILE *file = fopen("/proc/meminfo", "r");
-
- if (!file) {
- perror("Error fopen meminfo");
- return NULL;
- }
-
- char line[256];
- long total = 0;
- long available = 0;
-
- // read per line
- while (fgets(line, sizeof(line), file)) {
- if (sscanf(line, "MemTotal: %ld kB", &total) == 1) continue;
- if (sscanf(line, "MemAvailable: %ld kB", &available) == 1) continue;
- }
-
- fclose(file);
-
- printf("Memory: %.2f GB / %.2f GB\n", (total - available) / (1024.0 * 1024.0), total / (1024.0 * 1024.0));
-
- return 0;
-}
diff --git a/src/modules/memory/memory.h b/src/modules/memory/memory.h
deleted file mode 100644
index 5c35178..0000000
--- a/src/modules/memory/memory.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef MEMORY_H
-#define MEMORY_H
-
-char *memory(void);
-
-#endif // MEMORY_H
diff --git a/src/modules/os/os.c b/src/modules/os/os.c
deleted file mode 100644
index 6059c03..0000000
--- a/src/modules/os/os.c
+++ /dev/null
@@ -1,19 +0,0 @@
-#include <stdio.h>
-#include <string.h>
-#include <sys/utsname.h>
-#include "os.h"
-
-int os(void) {
-#ifdef __linux__
- struct utsname u;
-
- if (uname(&u) == 0) {
- size_t length = printf("OS: %s %s %s %s\n", u.sysname, u.release, u.version, u.machine);
- printf("line length: %ld\n", length);
- } else {
- perror("Error while accessing uname");
- return 1;
- }
-#endif
- return 0;
-}
diff --git a/src/modules/os/os.h b/src/modules/os/os.h
deleted file mode 100644
index d90792e..0000000
--- a/src/modules/os/os.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef OS_H
-#define OS_H
-
-int os(void);
-
-#endif
diff --git a/src/modules/utils/utils.c b/src/modules/utils/utils.c
deleted file mode 100644
index 2e8aa5c..0000000
--- a/src/modules/utils/utils.c
+++ /dev/null
@@ -1,114 +0,0 @@
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-
-
-/* function: char *string_format(char* string)
- * input: pointer to a null-terminated string (must not be NULL)
- * return: pointer to a newly allocated string containing all space-separated words,
- * joined by single spaces; leading/trailing/multiple spaces are ignored.
- * on-error: returns NULL if memory allocation fails
- * misc: the returned pointer must be freed by the caller using free()
- * limits: processes at most 10 words, each up to 49 characters (last '\0')
- */
-char *string_format(char* string) {
- // Wörterbuch array [Wort][Zeichenkette]
- char woerter[10][50] = { 0 };
- int wort_index = 0;
- int char_index = 0;
-
- while (*string != '\0') {
- // add '\0' stringterminator to end of word
- if (*string == ' ' && char_index > 0) {
- // safty check for array length
- if (wort_index > 9 || char_index > 49) {
- break;
- }
-
- // next slot is char
- // add '\0' to end string
- woerter[wort_index][char_index] = '\0';
- wort_index++;
- char_index = 0;
- string++;
- continue;
- }
- // skip extra spaces
- else if (*string == ' ' && char_index == 0) {
- string++;
- continue;
- }
-
- // safty check for array length
- if (char_index >= 49) {
- break;
- }
-
- woerter[wort_index][char_index] = *string;
- char_index++;
- string++;
- }
-
- // terminate last word with '\0'
- if (char_index > 0 && wort_index < 10 && char_index < 49) {
- woerter[wort_index][char_index] = '\0';
- wort_index++;
- }
-
- /*
- * return
- */
- char *ptr = NULL;
-
- // get length of woerter array
- if (wort_index == 0) {
- ptr = NULL;
- } else {
- int sum = 0;
-
- for (int i = 0; i < wort_index; i++) {
- sum += strlen(woerter[i]);
- }
- sum += wort_index - 1; // for spaces
- sum += 1; // for Nulltermination
-
-
- ptr = (char *)malloc(sum);
-
- // check for NULL pointer
- if (ptr == NULL) {
- return NULL;
- }
-
- //strcpy
- char *ende = ptr;
-
- for (int i = 0; i < wort_index; i++) {
- ende = stpcpy(ende, woerter[i]);
-
- if (i != wort_index - 1) {
- *(ende++) = ' ';
- }
- }
- }
-
- return ptr;
-}
-
-// input two char pointer
-// output: one char pointer
-// misc: caller needs to free the memory
-char *concat(const char *s1, const char *s2) {
- const size_t len1 = strlen(s1);
- const size_t len2 = strlen(s2);
- char *result = malloc(len1 + len2 + 1); // +1 for '\0'
-
- if (result == NULL) {
- perror("allocating memory for strings failed");
- return NULL;
- }
-
- memcpy(result, s1, len1);
- memcpy(result + len1, s2, len2 + 1); // +1 for null-terminator
- return result; //caller needs to free memory
-}
diff --git a/src/modules/utils/utils.h b/src/modules/utils/utils.h
deleted file mode 100644
index 7a0ab02..0000000
--- a/src/modules/utils/utils.h
+++ /dev/null
@@ -1,21 +0,0 @@
-#ifndef UTILS_H
-#define UTILS_H
-
-/* function: char *string_format(char* string)
- * input: pointer to a null-terminated string (must not be NULL)
- * return: pointer to a newly allocated string containing all space-separated words,
- * joined by single spaces; leading/trailing/multiple spaces are ignored.
- * on-error: returns NULL if memory allocation fails
- * misc: the returned pointer must be freed by the caller using free()
- * limits: processes at most 10 words, each up to 49 characters (last '\0')
- */
-char *string_format(char* string);
-
-// function: char *concat(const char *str1, const char *str2)
-// input two char pointer
-// return: pointer to string
-// on-error: returns NULL
-// misc: caller needs to free the memory
-char *concat(const char *str1, const char *str2);
-
-#endif