From 9bfaf4dd363429757754d9934ca38fad4ef7dc0a Mon Sep 17 00:00:00 2001 From: Anser Date: Thu, 13 Aug 2026 15:28:47 +0200 Subject: changed get_os to get_kernel, it now uses the system_info_t struct to store and display the kernel information. Same with get_cpu. --- src/utils.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/utils.c') diff --git a/src/utils.c b/src/utils.c index 5fba4dc..56cca93 100644 --- a/src/utils.c +++ b/src/utils.c @@ -1,4 +1,5 @@ #include "../include/cfetch.h" +#include /* function: char *string_format(char* string) * input: pointer to a null-terminated string (must not be NULL) @@ -109,3 +110,26 @@ char *concat(const char *s1, const char *s2) { memcpy(result + len1, s2, len2 + 1); // +1 for null-terminator return result; //caller needs to free memory } + + +char *trim_whitespace(char* str) +{ + char *end; + + // Trim leading spaces + while (*str == ' ' || *str == '\t' || *str == '\n' || *str == '\r') { + str++; + } + + if (*str == '\0') return str; // all spaces + + // Trim trailing space + end = str + strlen(str) - 1; + + while (end > str && (*end == ' ' || *end == '\t' || *end == '\r' || *end == '\n')) end--; + + // Write new null terminator character + end[1] = '\0'; + + return str; +} -- cgit v1.2.3