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

This commit is contained in:
8nlight 2023-10-19 14:06:36 +03:00
parent 47b22c9ffa
commit 92fecf6370

60
funcs.h
View File

@ -39,22 +39,22 @@ void PrintOs(void);
void GetUptime(void);
void GetUser(void);
void GetPkgs(void);
char *GetOs(void);
void PrintColors(void);
void GetArch(void);
void Blank(void);
char *GetOs(void);
void SetArt(LOGO *art, size_t size, char *pkg_cmd, char **logo, char *color);
LOGO GetArt(void);
void Init(void) {
Os = GetOs();
Logo = GetArt();
if (uname(&Uts) < 0) {
fprintf(stderr, "kfetch: uaname() failed: %s\n", strerror(errno));
exit(1);
}
Os = GetOs();
Logo = GetArt();
}
void GetShell(void) {
@ -121,32 +121,6 @@ void GetPkgs(void) {
pclose(fp);
}
char *GetOs(void) {
FILE *fp = fopen("/etc/os-release", "r");
if (fp == NULL)
return NULL;
else {
size_t len = 1;
char *line = malloc(sizeof(char) * len);
while (getline(&line, &len, fp) != EOF) {
if (strstr(line, "PRETTY_NAME=") != NULL) {
line[strlen(line) - 2] = '\0';
fclose(fp);
//Need free (in main())
return line;
}
}
//EOF
free(line);
}
return NULL;
}
void PrintColors(void) {
for (int i = 1; i < 7; i++)
printf("\033[1;3%dm● \033[0;3%dm● \033[0m", i, i);
@ -173,6 +147,32 @@ void Blank(void) {
return;
}
char *GetOs(void) {
FILE *fp = fopen("/etc/os-release", "r");
if (fp == NULL)
return NULL;
else {
size_t len = 1;
char *line = malloc(sizeof(char) * len);
while (getline(&line, &len, fp) != EOF) {
if (strstr(line, "PRETTY_NAME=") != NULL) {
line[strlen(line) - 2] = '\0';
fclose(fp);
//Need free (in main())
return line;
}
}
//EOF
free(line);
}
return NULL;
}
void SetArt(LOGO *art, size_t size, char *pkg_cmd, char **logo, char *color) {
art->size = size;
art->pkg_cmd = pkg_cmd;