Change constants from const to define

windows
Nakidai 2023-12-16 14:16:56 +03:00
parent 322ee8417a
commit 5cf683e05f
2 changed files with 10 additions and 10 deletions

View File

@ -1,8 +1,8 @@
#include "defs.h" #include "defs.h"
const int max_username_length = 128; #define MAX_USERNAME_LENGTH 128
const int max_hostname_length = 128; #define MAX_HOSTNAME_LENGTH 128
const int max_uptime_length = 40; #define MAX_UPTIME_LENGTH 40
struct art_entry arts[] = { struct art_entry arts[] = {
{ {

View File

@ -61,21 +61,21 @@ int main(int argc, char **argv)
art = arts[0].art; art = arts[0].art;
} }
char hostname[max_hostname_length]; char hostname[MAX_HOSTNAME_LENGTH];
char username[max_username_length]; char username[MAX_USERNAME_LENGTH];
char uptime[max_uptime_length]; char uptime[MAX_UPTIME_LENGTH];
#ifdef _WIN32 #ifdef _WIN32
RTL_OSVERSIONINFOW version_buffer = {.dwOSVersionInfoSize = sizeof(RTL_OSVERSIONINFOW)}; RTL_OSVERSIONINFOW version_buffer = {.dwOSVersionInfoSize = sizeof(RTL_OSVERSIONINFOW)};
RtlGetVersion(&version_buffer); RtlGetVersion(&version_buffer);
GetUserNameA(username, max_username_length); GetUserNameA(username, MAX_USERNAME_LENGTH);
#else #else
struct utsname uname_buf; struct utsname uname_buf;
getlogin_r(username, max_username_length); getlogin_r(username, MAX_USERNAME_LENGTH);
uname(&uname_buf); uname(&uname_buf);
#endif #endif
gethostname(hostname, max_hostname_length); gethostname(hostname, MAX_HOSTNAME_LENGTH);
getuptime(uptime, max_uptime_length); getuptime(uptime, MAX_UPTIME_LENGTH);
printf("%s %s@%s\n", art[0], username, hostname); printf("%s %s@%s\n", art[0], username, hostname);
printf("%s --\n", art[1]); printf("%s --\n", art[1]);