diff --git a/.gitignore b/.gitignore index 88cfc38..099d88c 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ mycfetch +build diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..37b9ab5 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,4 @@ +cmake_minimum_required(VERSION 3.5) +project(mycfetch LANGUAGES C) + +add_executable(mycfetch mycfetch.c) diff --git a/mycfetch.c b/mycfetch.c index 61c3f66..7842264 100644 --- a/mycfetch.c +++ b/mycfetch.c @@ -1,11 +1,18 @@ #include #include -#include -#include #include #include #include +#ifdef _WIN32 +#include +#include +#include +#else +#include +#include +#endif /* _WIN32 */ + #include "config.h" #include "defs.h" @@ -54,19 +61,29 @@ int main(int argc, char **argv) art = arts[0].art; } - struct utsname uname_buf; char hostname[max_hostname_length]; char username[max_username_length]; char uptime[max_uptime_length]; +#ifdef _WIN32 + RTL_OSVERSIONINFOW version_buffer = {.dwOSVersionInfoSize = sizeof(RTL_OSVERSIONINFOW)}; + RtlGetVersion(&version_buffer); + GetUserNameA(username, max_username_length); +#else + struct utsname uname_buf; - gethostname(hostname, max_hostname_length); getlogin_r(username, max_username_length); - getuptime(uptime, max_uptime_length); uname(&uname_buf); +#endif + gethostname(hostname, max_hostname_length); + getuptime(uptime, max_uptime_length); printf("%s %s@%s\n", art[0], username, hostname); printf("%s --\n", art[1]); +#ifdef _WIN32 + printf("%s NT %u.%u %s\n", art[2], version_buffer.dwMajorVersion, version_buffer.dwMinorVersion, version_buffer.szCSDVersion); +#else printf("%s %s %s\n", art[2], uname_buf.sysname, uname_buf.release); +#endif printf("%s %s\n", art[3], uptime); return 0; }