master ohmu/fastfetch-openbsd / src / common / FFPlatform.h
ohmu  ·  2026-10-15
 1#pragma once
 2
 3#include "common/FFstrbuf.h"
 4#include "common/FFlist.h"
 5
 6typedef struct FFPlatformSysinfo {
 7    FFstrbuf name;
 8    FFstrbuf release;
 9    FFstrbuf version;
10    FFstrbuf architecture;
11    // The base-2 logarithm of the memory page size, i.e. a page is `1 << pageSizeShift` bytes.
12    // Page sizes are powers of two on every supported platform. Storing the exponent instead of
13    // the byte count keeps page count arithmetic in 64 bits and makes the invariant explicit.
14    uint32_t pageSizeShift;
15} FFPlatformSysinfo;
16
17typedef struct FFPlatform {
18    FFstrbuf homeDir;  // Trailing slash included
19    FFstrbuf cacheDir; // Trailing slash included
20    FFlist configDirs; // List of FFstrbuf, trailing slash included
21    FFlist dataDirs;   // List of FFstrbuf, trailing slash included
22    FFstrbuf exePath;  // The real path of current exe (empty if unavailable)
23    FFstrbuf cwd;      // Trailing slash included
24
25    uint32_t pid;
26#ifndef _WIN32
27    uint32_t uid;
28#else
29    FFstrbuf sid;
30#endif
31    FFstrbuf userName;
32    FFstrbuf fullUserName;
33    FFstrbuf hostName;
34    FFstrbuf userShell;
35
36    FFPlatformSysinfo sysinfo;
37
38#if _WIN32
39    uint32_t initCP; // The code page used by the console when the program started
40#endif
41} FFPlatform;
42
43void ffPlatformInit(FFPlatform* platform);
44void ffPlatformDestroy(FFPlatform* platform);