mirror of
https://github.com/reactos/reactos.git
synced 2025-02-22 16:36:33 +00:00
[NET] Fix the timezone issue in the logon hours parser and display code of the USER command.
This commit is contained in:
parent
194180b1be
commit
e5b635ed10
1 changed files with 56 additions and 55 deletions
|
@ -262,8 +262,12 @@ PrintLogonHours(
|
||||||
INT nPaddedLength)
|
INT nPaddedLength)
|
||||||
{
|
{
|
||||||
DWORD dwUnitsPerDay, dwBitNumber, dwSecondsPerUnit;
|
DWORD dwUnitsPerDay, dwBitNumber, dwSecondsPerUnit;
|
||||||
DWORD dwStartTime, dwEndTime, dwStartDay, dwEndDay;
|
DWORD dwStartTime, dwEndTime, dwStartDay, dwEndDay, dwBias;
|
||||||
BOOL bBitValue, bFirst = TRUE;
|
BOOL bBitValue, bFirst = TRUE;
|
||||||
|
TIME_ZONE_INFORMATION TimeZoneInformation;
|
||||||
|
|
||||||
|
GetTimeZoneInformation(&TimeZoneInformation);
|
||||||
|
dwBias = (TimeZoneInformation.Bias / 60) * SECONDS_PER_HOUR;
|
||||||
|
|
||||||
if ((dwUnitsPerWeek == 0) ||
|
if ((dwUnitsPerWeek == 0) ||
|
||||||
((dwUnitsPerWeek %7) != 0))
|
((dwUnitsPerWeek %7) != 0))
|
||||||
|
@ -309,8 +313,8 @@ PrintLogonHours(
|
||||||
PrintMessageString(4307 + dwStartDay);
|
PrintMessageString(4307 + dwStartDay);
|
||||||
ConPuts(StdOut, L" ");
|
ConPuts(StdOut, L" ");
|
||||||
|
|
||||||
// FIXME: Check if this is a converion from GMT to local timezone
|
/* Convert from GMT to local timezone */
|
||||||
PrintLocalTime((dwStartTime % SECONDS_PER_DAY) + SECONDS_PER_HOUR);
|
PrintLocalTime((dwStartTime % SECONDS_PER_DAY) - dwBias);
|
||||||
|
|
||||||
ConPrintf(StdOut, L" - ");
|
ConPrintf(StdOut, L" - ");
|
||||||
if (dwStartDay != dwEndDay)
|
if (dwStartDay != dwEndDay)
|
||||||
|
@ -319,8 +323,8 @@ PrintLogonHours(
|
||||||
ConPuts(StdOut, L" ");
|
ConPuts(StdOut, L" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: Check if this is a converion from GMT to local timezone
|
/* Convert from GMT to local timezone */
|
||||||
PrintLocalTime((dwEndTime % SECONDS_PER_DAY) + SECONDS_PER_HOUR);
|
PrintLocalTime((dwEndTime % SECONDS_PER_DAY) - dwBias);
|
||||||
ConPuts(StdOut, L"\n");
|
ConPuts(StdOut, L"\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -833,10 +837,10 @@ static
|
||||||
BOOL
|
BOOL
|
||||||
ParseHour(
|
ParseHour(
|
||||||
PWSTR pszString,
|
PWSTR pszString,
|
||||||
PDWORD pdwHour)
|
PLONG plHour)
|
||||||
{
|
{
|
||||||
PWCHAR pChar;
|
PWCHAR pChar;
|
||||||
DWORD dwHour = 0;
|
LONG lHour = 0;
|
||||||
|
|
||||||
if (!iswdigit(pszString[0]))
|
if (!iswdigit(pszString[0]))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -844,31 +848,31 @@ ParseHour(
|
||||||
pChar = pszString;
|
pChar = pszString;
|
||||||
while (iswdigit(*pChar))
|
while (iswdigit(*pChar))
|
||||||
{
|
{
|
||||||
dwHour = dwHour * 10 + *pChar - L'0';
|
lHour = lHour * 10 + *pChar - L'0';
|
||||||
pChar++;
|
pChar++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dwHour > 24)
|
if (lHour > 24)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (dwHour == 24)
|
if (lHour == 24)
|
||||||
dwHour = 0;
|
lHour = 0;
|
||||||
|
|
||||||
if ((*pChar != UNICODE_NULL) &&
|
if ((*pChar != UNICODE_NULL) &&
|
||||||
(dwHour >= 1) &&
|
(lHour >= 1) &&
|
||||||
(dwHour <= 12))
|
(lHour <= 12))
|
||||||
{
|
{
|
||||||
if ((_wcsicmp(pChar, L"am") == 0) ||
|
if ((_wcsicmp(pChar, L"am") == 0) ||
|
||||||
(_wcsicmp(pChar, L"a.m.") == 0))
|
(_wcsicmp(pChar, L"a.m.") == 0))
|
||||||
{
|
{
|
||||||
if (dwHour == 12)
|
if (lHour == 12)
|
||||||
dwHour = 0;
|
lHour = 0;
|
||||||
}
|
}
|
||||||
else if ((_wcsicmp(pChar, L"pm") == 0) ||
|
else if ((_wcsicmp(pChar, L"pm") == 0) ||
|
||||||
(_wcsicmp(pChar, L"p.m.") == 0))
|
(_wcsicmp(pChar, L"p.m.") == 0))
|
||||||
{
|
{
|
||||||
if (dwHour != 12)
|
if (lHour != 12)
|
||||||
dwHour += 12;
|
lHour += 12;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -876,7 +880,7 @@ ParseHour(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*pdwHour = dwHour;
|
*plHour = lHour;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -910,15 +914,20 @@ ParseLogonHours(
|
||||||
PBYTE *ppLogonBitmap,
|
PBYTE *ppLogonBitmap,
|
||||||
PDWORD pdwUnitsPerWeek)
|
PDWORD pdwUnitsPerWeek)
|
||||||
{
|
{
|
||||||
|
TIME_ZONE_INFORMATION TimeZoneInformation;
|
||||||
PBYTE pLogonBitmap = NULL;
|
PBYTE pLogonBitmap = NULL;
|
||||||
DWORD dwError = ERROR_SUCCESS;
|
DWORD dwError = ERROR_SUCCESS;
|
||||||
WCHAR szBuffer[32];
|
WCHAR szBuffer[32];
|
||||||
PWSTR ptr1, ptr2;
|
PWSTR ptr1, ptr2;
|
||||||
WCHAR prevSep, nextSep;
|
WCHAR prevSep, nextSep;
|
||||||
DWORD dwStartHour, dwEndHour, dwStartDay, dwEndDay, i, j;
|
DWORD dwStartDay, dwEndDay, i, j;
|
||||||
|
LONG lStartHour, lEndHour, lBias;
|
||||||
BYTE DayBitmap;
|
BYTE DayBitmap;
|
||||||
BYTE HourBitmap[6];
|
BYTE HourBitmap[6];
|
||||||
|
|
||||||
|
GetTimeZoneInformation(&TimeZoneInformation);
|
||||||
|
lBias = TimeZoneInformation.Bias / 60;
|
||||||
|
|
||||||
pLogonBitmap = HeapAlloc(GetProcessHeap(),
|
pLogonBitmap = HeapAlloc(GetProcessHeap(),
|
||||||
HEAP_ZERO_MEMORY,
|
HEAP_ZERO_MEMORY,
|
||||||
UNITS_PER_WEEK / 8);
|
UNITS_PER_WEEK / 8);
|
||||||
|
@ -956,33 +965,30 @@ ParseLogonHours(
|
||||||
prevSep = nextSep;
|
prevSep = nextSep;
|
||||||
nextSep = *ptr1;
|
nextSep = *ptr1;
|
||||||
|
|
||||||
// printf("Token: '%S'\n", szBuffer);
|
|
||||||
if (*ptr1 != UNICODE_NULL)
|
|
||||||
printf("Separator: '%C'\n", *ptr1);
|
|
||||||
|
|
||||||
if (prevSep != L'-')
|
if (prevSep != L'-')
|
||||||
{
|
{
|
||||||
// Set first value
|
/* Set first value */
|
||||||
if (iswdigit(szBuffer[0]))
|
if (iswdigit(szBuffer[0]))
|
||||||
{
|
{
|
||||||
// parse hour
|
/* Parse hour */
|
||||||
if (!ParseHour(szBuffer, &dwStartHour))
|
if (!ParseHour(szBuffer, &lStartHour))
|
||||||
{
|
{
|
||||||
dwError = 3769;
|
dwError = 3769;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: Check if this is a converion from local timezone to GMT
|
/* Convert from local timezone to GMT */
|
||||||
if (dwStartHour > 0)
|
lStartHour += lBias;
|
||||||
dwStartHour--;
|
if (lStartHour < 0)
|
||||||
else
|
lStartHour += UNITS_PER_WEEK;
|
||||||
dwStartHour = UNITS_PER_WEEK - 1;
|
else if (lStartHour > UNITS_PER_WEEK)
|
||||||
|
lStartHour -= UNITS_PER_WEEK;
|
||||||
|
|
||||||
SetBitValue(HourBitmap, dwStartHour);
|
SetBitValue(HourBitmap, (DWORD)lStartHour);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// parse day
|
/* Parse day */
|
||||||
if (!ParseDay(szBuffer, &dwStartDay))
|
if (!ParseDay(szBuffer, &dwStartDay))
|
||||||
{
|
{
|
||||||
dwError = 3768;
|
dwError = 3768;
|
||||||
|
@ -994,33 +1000,34 @@ ParseLogonHours(
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Set second value
|
/* Set second value */
|
||||||
if (iswdigit(szBuffer[0]))
|
if (iswdigit(szBuffer[0]))
|
||||||
{
|
{
|
||||||
// parse hour
|
/* Parse hour */
|
||||||
if (!ParseHour(szBuffer, &dwEndHour))
|
if (!ParseHour(szBuffer, &lEndHour))
|
||||||
{
|
{
|
||||||
dwError = 3769;
|
dwError = 3769;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dwEndHour < dwStartHour)
|
if (lEndHour < lStartHour)
|
||||||
dwEndHour += HOURS_PER_DAY;
|
lEndHour += HOURS_PER_DAY;
|
||||||
else if (dwEndHour == dwStartHour)
|
else if (lEndHour == lStartHour)
|
||||||
dwEndHour = dwStartHour + HOURS_PER_DAY;
|
lEndHour = lStartHour + HOURS_PER_DAY;
|
||||||
|
|
||||||
// FIXME: Check if this is a converion from local timezone to GMT
|
/* Convert from local timezone to GMT */
|
||||||
if (dwEndHour > 0)
|
lEndHour += lBias;
|
||||||
dwEndHour--;
|
if (lEndHour < 0)
|
||||||
else
|
lEndHour += UNITS_PER_WEEK;
|
||||||
dwEndHour = UNITS_PER_WEEK - 1;
|
else if (lEndHour > UNITS_PER_WEEK)
|
||||||
|
lEndHour -= UNITS_PER_WEEK;
|
||||||
|
|
||||||
for (i = dwStartHour; i < dwEndHour; i++)
|
for (i = (DWORD)lStartHour; i < (DWORD)lEndHour; i++)
|
||||||
SetBitValue(HourBitmap, i);
|
SetBitValue(HourBitmap, i);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// parse day
|
/* Parse day */
|
||||||
if (!ParseDay(szBuffer, &dwEndDay))
|
if (!ParseDay(szBuffer, &dwEndDay))
|
||||||
{
|
{
|
||||||
dwError = 3768;
|
dwError = 3768;
|
||||||
|
@ -1037,10 +1044,7 @@ ParseLogonHours(
|
||||||
|
|
||||||
if (*ptr1 == L';' || *ptr1 == UNICODE_NULL)
|
if (*ptr1 == L';' || *ptr1 == UNICODE_NULL)
|
||||||
{
|
{
|
||||||
// Process the data
|
/* Fill the logon hour bitmap */
|
||||||
// printf("DayBitmap: %02x HourBitmap: %02x%02x%02x%02x%02x%02x\n",
|
|
||||||
// DayBitmap, HourBitmap[5], HourBitmap[4], HourBitmap[3], HourBitmap[2], HourBitmap[1], HourBitmap[0]);
|
|
||||||
|
|
||||||
for (i = 0; i < DAYS_PER_WEEK; i++)
|
for (i = 0; i < DAYS_PER_WEEK; i++)
|
||||||
{
|
{
|
||||||
if (GetBitValue(&DayBitmap, i))
|
if (GetBitValue(&DayBitmap, i))
|
||||||
|
@ -1053,16 +1057,13 @@ ParseLogonHours(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset the Bitmaps
|
/* Reset the Bitmaps */
|
||||||
ZeroMemory(&DayBitmap, sizeof(DayBitmap));
|
ZeroMemory(&DayBitmap, sizeof(DayBitmap));
|
||||||
ZeroMemory(HourBitmap, sizeof(HourBitmap));
|
ZeroMemory(HourBitmap, sizeof(HourBitmap));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*ptr1 == UNICODE_NULL)
|
if (*ptr1 == UNICODE_NULL)
|
||||||
{
|
|
||||||
// printf("Done\n");
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
ZeroMemory(szBuffer, sizeof(szBuffer));
|
ZeroMemory(szBuffer, sizeof(szBuffer));
|
||||||
ptr2 = szBuffer;
|
ptr2 = szBuffer;
|
||||||
|
|
Loading…
Reference in a new issue