9#if defined(_WIN32) || defined(WIN32)
19#if defined(_WIN32) || defined(WIN32)
20int GetUsername(
char *buffer,
unsigned int BufferSize)
25 ret = (GetUserNameA(buffer, &lpnSize) == 0 ?
EIO : 0);
26 DPRINTF(
"(%d): %s\n", ret, buffer);
31int GetLocalhostName(
char *buffer,
unsigned int BufferSize)
34#if defined(_WIN32) || defined(WIN32)
37 ret = (GetComputerNameA(buffer, &lpnSize) == 0 ?
EIO : 0);
39 ret = gethostname(buffer, BufferSize);
41 DPRINTF(
"(%d): %s\n", ret, buffer);
47#define btoi(b) ((b) / 16 * 10 + (b) % 16)
50#define itob(i) ((i) / 10 * 16 + (i) % 10)
54static unsigned short int ConvertToBase16(
unsigned short int value)
56 unsigned short int result;
58 result = value + value / 10 * 0x06;
59 result += value / 100 * 0x60;
60 return (result + value / 1000 * 0x600);
64unsigned int GetSystemDate(
void)
66#if defined(_WIN32) || defined(WIN32)
67 SYSTEMTIME SystemTime;
68 GetSystemTime(&SystemTime);
70 return (((
unsigned int)ConvertToBase16(SystemTime.wYear)) << 16 | ConvertToBase16(SystemTime.wMonth) << 8 | ConvertToBase16(SystemTime.wDay));
73 time_t time_raw_format;
76 time(&time_raw_format);
77 ptr_time = localtime(&time_raw_format);
78 return (((
unsigned int)ConvertToBase16(ptr_time->tm_year + 1900)) << 16 | ConvertToBase16(ptr_time->tm_mon + 1) << 8 | ConvertToBase16(ptr_time->tm_mday));
82unsigned int GetFileCreationDate(
const char *path)
84#if defined(_WIN32) || defined(WIN32)
86 FILETIME CreationTime;
87 SYSTEMTIME CreationSystemTime;
89 if ((hFile = CreateFileA(path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) != INVALID_HANDLE_VALUE) {
90 GetFileTime(hFile, &CreationTime, NULL, NULL);
93 FileTimeToSystemTime(&CreationTime, &CreationSystemTime);
95 GetSystemTime(&CreationSystemTime);
97 return (((
unsigned int)ConvertToBase16(CreationSystemTime.wYear)) << 16 | ConvertToBase16(CreationSystemTime.wMonth) << 8 | ConvertToBase16(CreationSystemTime.wDay));
102 clock = gmtime(&(attrib.st_mtime));
103 return (((
unsigned int)ConvertToBase16(clock->tm_year + 1900)) << 16 | ConvertToBase16(clock->tm_mon) << 8 | ConvertToBase16(clock->tm_mday));
107int GetCurrentWorkingDirectory(
char *buffer,
unsigned int BufferSize)
109#if defined(_WIN32) || defined(WIN32)
110 return (GetCurrentDirectoryA(BufferSize, buffer) == 0 ?
EIO : 0);
112 if (getcwd(buffer, BufferSize) != NULL)
119void upperbuff(
char *temp)
123 *s = toupper((
unsigned char) *s);