From b14ca9e4303377930b94de75d260a6d8ce1b3407 Mon Sep 17 00:00:00 2001 From: 8nlight <8nlight@disroot.org> Date: Sat, 21 Oct 2023 21:52:28 +0300 Subject: [PATCH] =?UTF-8?q?=D0=97=D0=B0=D0=B3=D1=80=D1=83=D0=B7=D0=B8?= =?UTF-8?q?=D1=82=D1=8C=20=D1=84=D0=B0=D0=B9=D0=BB=D1=8B=20=D0=B2=20=C2=AB?= =?UTF-8?q?/=C2=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- funcs.h | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/funcs.h b/funcs.h index c282e36..42ff4d9 100644 --- a/funcs.h +++ b/funcs.h @@ -60,7 +60,7 @@ void Init(void) { void GetShell(void) { char *shell = getenv("SHELL"); if (shell == NULL) { - printf("%sSHELL \033[0;37mNothing\033[0m", Logo.color); + printf("%sSHELL \033[0;37mnone\033[0m", Logo.color); return; } @@ -80,7 +80,7 @@ void PrintOs(void) { return; } - printf("%sOS \033[0;37m%s\033[0m", Logo.color, Os + strlen("PRETTY_NAME= ")); + printf("%sOS \033[0;37m%s\033[0m", Logo.color, Os + strlen("NAME= ")); } void GetUptime(void) { @@ -102,7 +102,7 @@ void GetUptime(void) { void GetUser(void) { struct passwd *pw = getpwuid(geteuid()); - printf("%sUSER \033[0;37m%s\033[0m", Logo.color, pw->pw_name); + printf("%sUSER \033[0;37m%s\033[0m", Logo.color, (pw != 0) ? pw->pw_name : "none"); } void GetPkgs(void) { @@ -158,19 +158,17 @@ void Blank(void) { char *GetOs(void) { FILE *fp = fopen("/etc/os-release", "r"); - if (fp == NULL) - return NULL; + if (fp != NULL) { - else { - size_t len = 1; - char *line = malloc(sizeof(char) * len); + size_t len = 0; + char *line = NULL; while (getline(&line, &len, fp) != EOF) { - if (strstr(line, "PRETTY_NAME=") != NULL) { + if (!strncmp(line, "NAME=", 5)) { line[strlen(line) - 2] = '\0'; fclose(fp); - //Need free (in main()) + //free in main() return line; } }