Загрузить файлы в «/»

This commit is contained in:
8nlight 2023-10-21 21:52:28 +03:00
parent f7f728c618
commit b14ca9e430

18
funcs.h
View File

@ -60,7 +60,7 @@ void Init(void) {
void GetShell(void) { void GetShell(void) {
char *shell = getenv("SHELL"); char *shell = getenv("SHELL");
if (shell == NULL) { if (shell == NULL) {
printf("%sSHELL \033[0;37mNothing\033[0m", Logo.color); printf("%sSHELL \033[0;37mnone\033[0m", Logo.color);
return; return;
} }
@ -80,7 +80,7 @@ void PrintOs(void) {
return; 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) { void GetUptime(void) {
@ -102,7 +102,7 @@ void GetUptime(void) {
void GetUser(void) { void GetUser(void) {
struct passwd *pw = getpwuid(geteuid()); 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) { void GetPkgs(void) {
@ -158,19 +158,17 @@ void Blank(void) {
char *GetOs(void) { char *GetOs(void) {
FILE *fp = fopen("/etc/os-release", "r"); FILE *fp = fopen("/etc/os-release", "r");
if (fp == NULL) if (fp != NULL) {
return NULL;
else { size_t len = 0;
size_t len = 1; char *line = NULL;
char *line = malloc(sizeof(char) * len);
while (getline(&line, &len, fp) != EOF) { while (getline(&line, &len, fp) != EOF) {
if (strstr(line, "PRETTY_NAME=") != NULL) { if (!strncmp(line, "NAME=", 5)) {
line[strlen(line) - 2] = '\0'; line[strlen(line) - 2] = '\0';
fclose(fp); fclose(fp);
//Need free (in main()) //free in main()
return line; return line;
} }
} }