[NET] Load the names of the days of week for the 'times' parser routine from the netmsg.dll.

This commit is contained in:
Eric Kohl 2019-05-28 08:27:23 +02:00
parent e5b635ed10
commit df31f870c8

View file

@ -50,8 +50,6 @@ static COUNTRY_TABLE CountryTable[] =
{785, 5103}, // Arabic {785, 5103}, // Arabic
{972, 5104} }; // Hebrew {972, 5104} }; // Hebrew
//static PWSTR DaysArray[] = {L"So", L"Mo", L"Di", L"Mi", L"Do", L"Fr", L"Sa"};
static PWSTR DaysArray[] = {L"Sun", L"Mon", L"Tue", L"Wed", L"Thu", L"Fri", L"Sat"};
static static
int int
@ -837,6 +835,7 @@ static
BOOL BOOL
ParseHour( ParseHour(
PWSTR pszString, PWSTR pszString,
PWSTR *AmPmArray,
PLONG plHour) PLONG plHour)
{ {
PWCHAR pChar; PWCHAR pChar;
@ -862,14 +861,14 @@ ParseHour(
(lHour >= 1) && (lHour >= 1) &&
(lHour <= 12)) (lHour <= 12))
{ {
if ((_wcsicmp(pChar, L"am") == 0) || if ((_wcsicmp(pChar, AmPmArray[0]) == 0) ||
(_wcsicmp(pChar, L"a.m.") == 0)) (_wcsicmp(pChar, AmPmArray[1]) == 0))
{ {
if (lHour == 12) if (lHour == 12)
lHour = 0; lHour = 0;
} }
else if ((_wcsicmp(pChar, L"pm") == 0) || else if ((_wcsicmp(pChar, AmPmArray[2]) == 0) ||
(_wcsicmp(pChar, L"p.m.") == 0)) (_wcsicmp(pChar, AmPmArray[3]) == 0))
{ {
if (lHour != 12) if (lHour != 12)
lHour += 12; lHour += 12;
@ -890,13 +889,16 @@ static
BOOL BOOL
ParseDay( ParseDay(
PWSTR pszString, PWSTR pszString,
PWSTR *ShortDays,
PWSTR *LongDays,
PDWORD pdwDay) PDWORD pdwDay)
{ {
DWORD i; DWORD i;
for (i = 0; i < ARRAYSIZE(DaysArray); i++) for (i = 0; i < 7; i++)
{ {
if (_wcsicmp(pszString, DaysArray[i]) == 0) if (_wcsicmp(pszString, ShortDays[i]) == 0 ||
_wcsicmp(pszString, LongDays[i]) == 0)
{ {
*pdwDay = i; *pdwDay = i;
return TRUE; return TRUE;
@ -924,6 +926,9 @@ ParseLogonHours(
LONG lStartHour, lEndHour, lBias; LONG lStartHour, lEndHour, lBias;
BYTE DayBitmap; BYTE DayBitmap;
BYTE HourBitmap[6]; BYTE HourBitmap[6];
LPWSTR ShortDays[7] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL};
LPWSTR LongDays[7] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL};
LPWSTR AmPmArray[4] = {NULL, NULL, NULL, NULL};
GetTimeZoneInformation(&TimeZoneInformation); GetTimeZoneInformation(&TimeZoneInformation);
lBias = TimeZoneInformation.Bias / 60; lBias = TimeZoneInformation.Bias / 60;
@ -945,6 +950,42 @@ ParseLogonHours(
goto done; goto done;
} }
for (i = 0; i < 7; i++)
{
FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_HMODULE |
FORMAT_MESSAGE_IGNORE_INSERTS,
hModuleNetMsg,
4314 + i,
LANG_USER_DEFAULT,
(LPWSTR)&ShortDays[i],
0,
NULL);
FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_HMODULE |
FORMAT_MESSAGE_IGNORE_INSERTS,
hModuleNetMsg,
4307 + i,
LANG_USER_DEFAULT,
(LPWSTR)&LongDays[i],
0,
NULL);
}
for (i = 0; i < 4; i++)
{
FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_HMODULE |
FORMAT_MESSAGE_IGNORE_INSERTS,
hModuleNetMsg,
4322 + i,
LANG_USER_DEFAULT,
(LPWSTR)&AmPmArray[i],
0,
NULL);
}
ZeroMemory(&DayBitmap, sizeof(DayBitmap)); ZeroMemory(&DayBitmap, sizeof(DayBitmap));
ZeroMemory(HourBitmap, sizeof(HourBitmap)); ZeroMemory(HourBitmap, sizeof(HourBitmap));
@ -971,7 +1012,7 @@ ParseLogonHours(
if (iswdigit(szBuffer[0])) if (iswdigit(szBuffer[0]))
{ {
/* Parse hour */ /* Parse hour */
if (!ParseHour(szBuffer, &lStartHour)) if (!ParseHour(szBuffer, AmPmArray, &lStartHour))
{ {
dwError = 3769; dwError = 3769;
break; break;
@ -989,7 +1030,7 @@ ParseLogonHours(
else else
{ {
/* Parse day */ /* Parse day */
if (!ParseDay(szBuffer, &dwStartDay)) if (!ParseDay(szBuffer, ShortDays, LongDays, &dwStartDay))
{ {
dwError = 3768; dwError = 3768;
break; break;
@ -1004,7 +1045,7 @@ ParseLogonHours(
if (iswdigit(szBuffer[0])) if (iswdigit(szBuffer[0]))
{ {
/* Parse hour */ /* Parse hour */
if (!ParseHour(szBuffer, &lEndHour)) if (!ParseHour(szBuffer, AmPmArray, &lEndHour))
{ {
dwError = 3769; dwError = 3769;
break; break;
@ -1028,7 +1069,7 @@ ParseLogonHours(
else else
{ {
/* Parse day */ /* Parse day */
if (!ParseDay(szBuffer, &dwEndDay)) if (!ParseDay(szBuffer, ShortDays, LongDays, &dwEndDay))
{ {
dwError = 3768; dwError = 3768;
break; break;
@ -1072,17 +1113,18 @@ ParseLogonHours(
ptr1++; ptr1++;
} }
#if 0
printf("LogonBitmap:\n");
for (i = 0; i < DAYS_PER_WEEK; i++)
{
j = i * 3;
printf("%lu: %02x%02x%02x\n", i, pLogonHours[j + 2], pLogonHours[j + 1], pLogonHours[j + 0]);
}
printf("\n");
#endif
done: done:
for (i = 0; i < 7; i++)
{
LocalFree(ShortDays[i]);
LocalFree(LongDays[i]);
}
for (i = 0; i < 4; i++)
{
LocalFree(AmPmArray[i]);
}
if (dwError == ERROR_SUCCESS) if (dwError == ERROR_SUCCESS)
{ {
*ppLogonBitmap = pLogonBitmap; *ppLogonBitmap = pLogonBitmap;