refactored project structure

This commit is contained in:
Linus Dierheimer
2021-02-27 16:40:05 +01:00
parent 558639086a
commit b44ab16dd1
26 changed files with 219 additions and 211 deletions
+35
View File
@@ -0,0 +1,35 @@
#include "fastfetch.h"
#include <string.h>
void ffPrintHost(FFstate* state)
{
if(ffPrintCachedValue(state, "Host"))
return;
char host[1024];
FILE* nameFile = fopen("/sys/devices/virtual/dmi/id/product_name", "r");
if(nameFile == NULL)
{
ffPrintError(state, "Host", "fopen(\"/sys/devices/virtual/dmi/id/product_name\", \"r\") == NULL");
return;
}
if(fscanf(nameFile, "%[^\n]", host) != 1)
{
ffPrintError(state, "Host", "fscanf(nameFile, \"%[^\\n]\", name) != 1");
return;
}
fclose(nameFile);
FILE* versionFile = fopen("/sys/devices/virtual/dmi/id/product_version", "r");
if(versionFile != NULL)
{
ssize_t len = strlen(host);
host[len] = ' ';
if(fscanf(versionFile, "%[^\n]", host + len + 1) == 0); //fail silently, if reading of version fails, just show now version
fclose(versionFile);
}
ffPrintAndSaveCachedValue(state, "Host", host);
}