diff options
| author | Anser <rostgans@tutamail.com> | 2026-08-13 15:28:47 +0200 |
|---|---|---|
| committer | Anser <rostgans@tutamail.com> | 2026-08-14 10:44:28 +0200 |
| commit | 9bfaf4dd363429757754d9934ca38fad4ef7dc0a (patch) | |
| tree | c13a7148dfd96178481744368dd0d29a6bdc033d /src/utils.c | |
| parent | d195f0a76a3ce64761958f7d33ccbdbac3844fec (diff) | |
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.
Diffstat (limited to 'src/utils.c')
| -rw-r--r-- | src/utils.c | 24 |
1 files changed, 24 insertions, 0 deletions
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 <string.h> /* 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; +} |
