/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include "jvm.h"
#include "TimeZone_md.h"
#define VALUE_UNKNOWN 0
typedef struct _TziValue {
} TziValue;
/*
* Registry key names
*/
static void *keyNames[] = {
(void *) L"StandardName",
(void *) "StandardName",
(void *) L"Std",
(void *) "Std"
};
/*
* Indices to keyNames[]
*/
#define STANDARD_NAME 0
/*
* Calls RegQueryValueEx() to get the value for the specified key. If
* the platform is NT, 2000 or XP, it calls the Unicode
* version. Otherwise, it calls the ANSI version and converts the
* value to Unicode. In this case, it assumes that the current ANSI
* Code Page is the same as the native platform code page (e.g., Code
* Page 932 for the Japanese Windows systems.
*
* `keyIndex' is an index value to the keyNames in Unicode
* (WCHAR). `keyIndex' + 1 points to its ANSI value.
*
* Returns the status value. ERROR_SUCCESS if succeeded, a
* non-ERROR_SUCCESS value otherwise.
*/
static LONG
int keyIndex,
{
int len;
*typePtr = 0;
if (isNT) {
return ret;
}
}
if (ret != ERROR_SUCCESS) {
return ret;
}
return ERROR_BADKEY;
}
if (len <= 0) {
return ERROR_BADKEY;
}
return ERROR_SUCCESS;
}
/*
* Produces custom name "GMT+hh:mm" from the given bias in buffer.
*/
int sign;
if (bias > 0) {
sign = -1;
} else {
sign = 1;
}
if (gmtOffset != 0) {
gmtOffset / 60,
gmtOffset % 60);
} else {
}
}
/*
* Gets the current time zone entry in the "Time Zones" registry.
*/
{
int onlyMapID;
int isVista;
/*
* Get the current time zone setting of the platform.
*/
if (timeType == TIME_ZONE_ID_INVALID) {
goto err;
}
/*
* Determine if this is an NT system.
*/
GetVersionEx(&ver);
if (ret == ERROR_SUCCESS) {
/*
* Determine if auto-daylight time adjustment is turned off.
*/
valueType = 0;
/*
* Vista uses the different key name.
*/
if (ret != ERROR_SUCCESS) {
}
if (ret == ERROR_SUCCESS) {
int daylightSavingsUpdateDisabled = isVista ? daylightSavingsUpdateDisabledVista : daylightSavingsUpdateDisabledOther;
(void) RegCloseKey(hKey);
return VALUE_GMTOFFSET;
}
}
/*
* Vista has the key for the current "Time Zones" entry.
*/
if (isVista) {
valueType = 0;
if (ret != ERROR_SUCCESS) {
goto err;
}
(void) RegCloseKey(hKey);
return VALUE_KEY;
}
/*
* Win32 problem: If the length of the standard time name is equal
* to (or probably longer than) 32 in the registry,
* GetTimeZoneInformation() on NT returns a null string as its
* standard time name. We need to work around this problem by
* getting the same information from the TimeZoneInformation
* registry. The function on Win98 seems to return its key name.
* We can't do anything in that case.
*/
if (tzi.StandardName[0] == 0) {
bufSize = sizeof(stdNameInReg);
if (ret != ERROR_SUCCESS) {
goto err;
}
}
(void) RegCloseKey(hKey);
}
/*
* Open the "Time Zones" registry.
*/
if (ret != ERROR_SUCCESS) {
/*
* If both failed, then give up.
*/
if (ret != ERROR_SUCCESS) {
return VALUE_UNKNOWN;
}
}
/*
* Get the number of subkeys of the "Time Zones" registry for
* enumeration.
*/
if (ret != ERROR_SUCCESS) {
goto err;
}
/*
* Compare to the "Std" value of each subkey and find the entry that
* matches the current control panel setting.
*/
onlyMapID = 0;
for (i = 0; i < nSubKeys; ++i) {
if (ret != ERROR_SUCCESS) {
goto err;
}
if (ret != ERROR_SUCCESS) {
goto err;
}
if (ret != ERROR_SUCCESS) {
/*
* NT 4.0 SP3 fails here since it doesn't have the "Std"
* entry in the Time Zones registry.
*/
onlyMapID = 1;
if (ret != ERROR_SUCCESS) {
goto err;
}
break;
}
/*
* Some localized Win32 platforms use a same name to
* different time zones. So, we can't rely only on the name
* here. We need to check GMT offsets and transition dates
* to make sure it's the registry of the current time
* zone.
*/
(unsigned char *) &tempTzi, &tziValueSize);
if (ret == ERROR_SUCCESS) {
sizeof(SYSTEMTIME)) != 0)) {
goto out;
}
if (tzi.DaylightBias != 0) {
sizeof(SYSTEMTIME)) != 0)) {
goto out;
}
}
}
/*
* found matched record, terminate search
*/
break;
}
out:
(void) RegCloseKey(hSubKey);
}
/*
* Get the "MapID" value of the registry to be able to eliminate
* duplicated key names later.
*/
(void) RegCloseKey(hSubKey);
(void) RegCloseKey(hKey);
if (ret != ERROR_SUCCESS) {
/*
* Vista doesn't have mapID. VALUE_UNKNOWN should be returned
* only for Windows NT.
*/
if (onlyMapID == 1) {
return VALUE_UNKNOWN;
}
}
return VALUE_KEY;
err:
(void) RegCloseKey(hKey);
}
return VALUE_UNKNOWN;
}
/*
* The mapping table file name.
*/
/*
* Index values for the mapping table.
*/
#define TZ_WIN_NAME 0
/*
* Looks up the mapping table (tzmappings) and returns a Java time
* zone ID (e.g., "America/Los_Angeles") if found. Otherwise, NULL is
* returned.
*
* value_type is one of the following values:
* VALUE_KEY for exact key matching
* VALUE_MAPID for MapID and country-based mapping (this is
* required for the old Windows, such as NT 4.0 SP3).
*/
{
int line;
int IDmatched = 0;
bestMatch[0] = '\0';
return NULL;
}
line = 0;
int itemIndex = 0;
line++;
/*
* Ignore comment and blank lines.
*/
continue;
}
goto illegal_format;
}
}
if (*idx == '\0') {
goto illegal_format;
}
*idx++ = '\0';
}
if (*idx != '\n') {
goto illegal_format;
}
/*
* When there's no mapID, we need to scan items until the
* exact match is found or the end of data is detected.
*/
if (!noMapID) {
IDmatched = 1;
}
/*
* Found the time zone in the mapping table.
*/
break;
}
/*
* Try to find the most likely time zone.
*/
if (value_type == VALUE_MAPID) {
break;
}
}
} else {
if (IDmatched == 1) {
/*
* No need to look up the mapping table further.
*/
break;
}
}
}
}
return javaTZName;
return NULL;
}
/*
* Detects the platform time zone which maps to a Java time zone ID.
*/
{
int result;
winMapID[0] = 0;
if (result != VALUE_UNKNOWN) {
if (result == VALUE_GMTOFFSET) {
} else {
}
}
return std_timezone;
}
/**
* Returns a GMT-offset-based time zone ID. On Win32, it always return
* NULL since the fall back is performed in getWinTimeZone().
*/
char *
{
return NULL;
}