projects
/
reactos.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
194180b
)
[NET] Fix the timezone issue in the logon hours parser and display code of the USER...
author
Eric Kohl
<eric.kohl@reactos.org>
Mon, 27 May 2019 15:00:56 +0000
(17:00 +0200)
committer
Eric Kohl
<eric.kohl@reactos.org>
Mon, 27 May 2019 15:00:56 +0000
(17:00 +0200)
base/applications/network/net/cmdUser.c
patch
|
blob
|
history
diff --git
a/base/applications/network/net/cmdUser.c
b/base/applications/network/net/cmdUser.c
index
919a919
..
dc75278
100644
(file)
--- a/
base/applications/network/net/cmdUser.c
+++ b/
base/applications/network/net/cmdUser.c
@@
-262,8
+262,12
@@
PrintLogonHours(
INT nPaddedLength)
{
DWORD dwUnitsPerDay, dwBitNumber, dwSecondsPerUnit;
INT nPaddedLength)
{
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) ||
((dwUnitsPerWeek %7) != 0))
if ((dwUnitsPerWeek == 0) ||
((dwUnitsPerWeek %7) != 0))
@@
-309,8
+313,8
@@
PrintLogonHours(
PrintMessageString(4307 + dwStartDay);
ConPuts(StdOut, L" ");
PrintMessageString(4307 + dwStartDay);
ConPuts(StdOut, L" ");
- /
/ FIXME: Check if this is a converion from GMT to local timezone
- PrintLocalTime((dwStartTime % SECONDS_PER_DAY)
+ SECONDS_PER_HOUR
);
+ /
* Convert from GMT to local timezone */
+ PrintLocalTime((dwStartTime % SECONDS_PER_DAY)
- dwBias
);
ConPrintf(StdOut, L" - ");
if (dwStartDay != dwEndDay)
ConPrintf(StdOut, L" - ");
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
- PrintLocalTime((dwEndTime % SECONDS_PER_DAY)
+ SECONDS_PER_HOUR
);
+ /
* Convert from GMT to local timezone */
+ PrintLocalTime((dwEndTime % SECONDS_PER_DAY)
- dwBias
);
ConPuts(StdOut, L"\n");
}
ConPuts(StdOut, L"\n");
}
@@
-833,10
+837,10
@@
static
BOOL
ParseHour(
PWSTR pszString,
BOOL
ParseHour(
PWSTR pszString,
- P
DWORD pdw
Hour)
+ P
LONG pl
Hour)
{
PWCHAR pChar;
{
PWCHAR pChar;
-
DWORD dw
Hour = 0;
+
LONG l
Hour = 0;
if (!iswdigit(pszString[0]))
return FALSE;
if (!iswdigit(pszString[0]))
return FALSE;
@@
-844,31
+848,31
@@
ParseHour(
pChar = pszString;
while (iswdigit(*pChar))
{
pChar = pszString;
while (iswdigit(*pChar))
{
-
dwHour = dw
Hour * 10 + *pChar - L'0';
+
lHour = l
Hour * 10 + *pChar - L'0';
pChar++;
}
pChar++;
}
- if (
dw
Hour > 24)
+ if (
l
Hour > 24)
return FALSE;
return FALSE;
- if (
dw
Hour == 24)
-
dw
Hour = 0;
+ if (
l
Hour == 24)
+
l
Hour = 0;
if ((*pChar != UNICODE_NULL) &&
if ((*pChar != UNICODE_NULL) &&
- (
dw
Hour >= 1) &&
- (
dw
Hour <= 12))
+ (
l
Hour >= 1) &&
+ (
l
Hour <= 12))
{
if ((_wcsicmp(pChar, L"am") == 0) ||
(_wcsicmp(pChar, L"a.m.") == 0))
{
{
if ((_wcsicmp(pChar, L"am") == 0) ||
(_wcsicmp(pChar, L"a.m.") == 0))
{
- if (
dw
Hour == 12)
-
dw
Hour = 0;
+ if (
l
Hour == 12)
+
l
Hour = 0;
}
else if ((_wcsicmp(pChar, L"pm") == 0) ||
(_wcsicmp(pChar, L"p.m.") == 0))
{
}
else if ((_wcsicmp(pChar, L"pm") == 0) ||
(_wcsicmp(pChar, L"p.m.") == 0))
{
- if (
dw
Hour != 12)
-
dw
Hour += 12;
+ if (
l
Hour != 12)
+
l
Hour += 12;
}
else
{
}
else
{
@@
-876,7
+880,7
@@
ParseHour(
}
}
}
}
- *p
dwHour = dw
Hour;
+ *p
lHour = l
Hour;
return TRUE;
}
return TRUE;
}
@@
-910,15
+914,20
@@
ParseLogonHours(
PBYTE *ppLogonBitmap,
PDWORD pdwUnitsPerWeek)
{
PBYTE *ppLogonBitmap,
PDWORD pdwUnitsPerWeek)
{
+ TIME_ZONE_INFORMATION TimeZoneInformation;
PBYTE pLogonBitmap = NULL;
DWORD dwError = ERROR_SUCCESS;
WCHAR szBuffer[32];
PWSTR ptr1, ptr2;
WCHAR prevSep, nextSep;
PBYTE pLogonBitmap = NULL;
DWORD dwError = ERROR_SUCCESS;
WCHAR szBuffer[32];
PWSTR ptr1, ptr2;
WCHAR prevSep, nextSep;
- DWORD dwStartHour, dwEndHour, dwStartDay, dwEndDay, i, j;
+ DWORD dwStartDay, dwEndDay, i, j;
+ LONG lStartHour, lEndHour, lBias;
BYTE DayBitmap;
BYTE HourBitmap[6];
BYTE DayBitmap;
BYTE HourBitmap[6];
+ GetTimeZoneInformation(&TimeZoneInformation);
+ lBias = TimeZoneInformation.Bias / 60;
+
pLogonBitmap = HeapAlloc(GetProcessHeap(),
HEAP_ZERO_MEMORY,
UNITS_PER_WEEK / 8);
pLogonBitmap = HeapAlloc(GetProcessHeap(),
HEAP_ZERO_MEMORY,
UNITS_PER_WEEK / 8);
@@
-956,33
+965,30
@@
ParseLogonHours(
prevSep = nextSep;
nextSep = *ptr1;
prevSep = nextSep;
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
- if (!ParseHour(szBuffer, &
dw
StartHour))
+ /
* Parse hour */
+ if (!ParseHour(szBuffer, &
l
StartHour))
{
dwError = 3769;
break;
}
{
dwError = 3769;
break;
}
- // FIXME: Check if this is a converion from local timezone to GMT
- if (dwStartHour > 0)
- dwStartHour--;
- else
- dwStartHour = UNITS_PER_WEEK - 1;
+ /* Convert from local timezone to GMT */
+ lStartHour += lBias;
+ if (lStartHour < 0)
+ lStartHour += UNITS_PER_WEEK;
+ else if (lStartHour > UNITS_PER_WEEK)
+ lStartHour -= UNITS_PER_WEEK;
- SetBitValue(HourBitmap,
dw
StartHour);
+ SetBitValue(HourBitmap,
(DWORD)l
StartHour);
}
else
{
}
else
{
- /
/ parse day
+ /
* Parse day */
if (!ParseDay(szBuffer, &dwStartDay))
{
dwError = 3768;
if (!ParseDay(szBuffer, &dwStartDay))
{
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
- if (!ParseHour(szBuffer, &
dw
EndHour))
+ /
* Parse hour */
+ if (!ParseHour(szBuffer, &
l
EndHour))
{
dwError = 3769;
break;
}
{
dwError = 3769;
break;
}
- if (
dwEndHour < dw
StartHour)
-
dw
EndHour += HOURS_PER_DAY;
- else if (
dwEndHour == dw
StartHour)
-
dwEndHour = dw
StartHour + HOURS_PER_DAY;
+ if (
lEndHour < l
StartHour)
+
l
EndHour += HOURS_PER_DAY;
+ else if (
lEndHour == l
StartHour)
+
lEndHour = l
StartHour + HOURS_PER_DAY;
- // FIXME: Check if this is a converion from local timezone to GMT
- if (dwEndHour > 0)
- dwEndHour--;
- else
- dwEndHour = UNITS_PER_WEEK - 1;
+ /* Convert from local timezone to GMT */
+ lEndHour += lBias;
+ if (lEndHour < 0)
+ lEndHour += UNITS_PER_WEEK;
+ else if (lEndHour > UNITS_PER_WEEK)
+ lEndHour -= UNITS_PER_WEEK;
- for (i =
dwStartHour; i < dw
EndHour; i++)
+ for (i =
(DWORD)lStartHour; i < (DWORD)l
EndHour; i++)
SetBitValue(HourBitmap, i);
}
else
{
SetBitValue(HourBitmap, i);
}
else
{
- /
/ parse day
+ /
* Parse day */
if (!ParseDay(szBuffer, &dwEndDay))
{
dwError = 3768;
if (!ParseDay(szBuffer, &dwEndDay))
{
dwError = 3768;
@@
-1037,10
+1044,7
@@
ParseLogonHours(
if (*ptr1 == L';' || *ptr1 == UNICODE_NULL)
{
if (*ptr1 == L';' || *ptr1 == UNICODE_NULL)
{
- // Process the data
-// printf("DayBitmap: %02x HourBitmap: %02x%02x%02x%02x%02x%02x\n",
-// DayBitmap, HourBitmap[5], HourBitmap[4], HourBitmap[3], HourBitmap[2], HourBitmap[1], HourBitmap[0]);
-
+ /* Fill the logon hour bitmap */
for (i = 0; i < DAYS_PER_WEEK; i++)
{
if (GetBitValue(&DayBitmap, i))
for (i = 0; i < DAYS_PER_WEEK; i++)
{
if (GetBitValue(&DayBitmap, i))
@@
-1053,16
+1057,13
@@
ParseLogonHours(
}
}
}
}
- /
/ Reset the Bitmaps
+ /
* Reset the Bitmaps */
ZeroMemory(&DayBitmap, sizeof(DayBitmap));
ZeroMemory(HourBitmap, sizeof(HourBitmap));
}
if (*ptr1 == UNICODE_NULL)
ZeroMemory(&DayBitmap, sizeof(DayBitmap));
ZeroMemory(HourBitmap, sizeof(HourBitmap));
}
if (*ptr1 == UNICODE_NULL)
- {
-// printf("Done\n");
break;
break;
- }
ZeroMemory(szBuffer, sizeof(szBuffer));
ptr2 = szBuffer;
ZeroMemory(szBuffer, sizeof(szBuffer));
ptr2 = szBuffer;