java_props_md.c revision 5214
/*
* 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.
*/
#if defined(__linux__) || defined(_ALLBSD_SOURCE)
#include <stdio.h>
#include <ctype.h>
#endif
#include <pwd.h>
#include <locale.h>
#ifndef ARCHPROPNAME
#error "The macro ARCHPROPNAME has not been defined"
#endif
#include <langinfo.h> /* For nl_langinfo */
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <time.h>
#include <errno.h>
#ifdef MACOSX
#include "java_props_macosx.h"
#endif
#if defined(_ALLBSD_SOURCE)
#if !defined(P_tmpdir)
#include <paths.h>
#define P_tmpdir _PATH_VARTMP
#endif
#endif
#include "locale_str.h"
#include "java_props.h"
#if !defined(_ALLBSD_SOURCE)
#ifdef __linux__
#ifndef CODESET
#define CODESET _NL_CTYPE_CODESET_NAME
#endif
#else
#ifdef ALT_CODESET_KEY
#define CODESET ALT_CODESET_KEY
#endif
#endif
#endif /* !_ALLBSD_SOURCE */
#ifdef JAVASE_EMBEDDED
#include <dlfcn.h>
#endif
/* Take an array of string pairs (map of key->value) and a string (key).
* Examine each pair in the map to see if the first string (key) matches the
* string. If so, store the second string of the pair (value) in the value and
* return 1. Otherwise do nothing and return 0. The end of the map is
* indicated by an empty string at the start of a pair (key of "").
*/
static int
int i;
return 1;
}
}
return 0;
}
/* This function sets an environment variable using envstring.
* The format of envstring is "name=value".
* If the name has already existed, it will append value to the name.
*/
static void
setPathEnvironment(char *envstring)
{
if (! value)
return; /* not a valid environment setting */
/* copy first part as environment name */
value++; /* set value point to value of the envstring */
if (current) {
/* value is not found in current environment, append it */
}
/* else the value has already been set, do nothing */
}
else {
/* environment variable is not found */
}
}
#ifndef P_tmpdir
#endif
char temp[64];
char *p, encoding_variant[64];
char *lc;
/* Query the locale set for the category */
#ifdef MACOSX
#else
#endif
#ifndef __linux__
return 0;
}
/*
* Workaround for Solaris bug 4201684: Xlib doesn't like @euro
* locales. Since we don't depend on the libc @euro behavior,
* we just remove the qualifier.
* On Linux, the bug doesn't occur; on the other hand, @euro
* is needed there because it's a shortcut that also determines
* the encoding - without it, we wouldn't get ISO-8859-15.
* Therefore, this code section is Solaris-specific.
*/
if (p != NULL) {
*p = '\0';
}
}
#else
lc = "en_US";
}
#endif
/*
* locale string format in Solaris is
* <language name>_<country name>.<encoding name>@<variant name>
* <country name>, <encoding name>, and <variant name> are optional.
*/
#ifdef MACOSX
#endif
/* Parse the language, country, encoding, and variant from the
* locale. Any of the elements may be missing, but they must occur
* in the order language_country.encoding@variant, and must be
* preceded by their delimiter (except for language).
*
* If the locale name (without .encoding@variant, if any) matches
* any of the names in the locale_aliases list, map it to the
* corresponding full locale name. Most of the entries in the
* locale_aliases list are locales that include a language name but
* no country name, and this facility is used to map each language
* to a default country if that's possible. It's also used to map
* the Solaris locale aliases to their proper Java locale IDs.
*/
*p = '\0';
*p = '\0';
} else {
*encoding_variant = '\0';
}
// check the "encoding_variant" again, if any.
*p = '\0';
*p = '\0';
}
}
*country++ = '\0';
}
p = encoding_variant;
p[encoding++ - p] = '\0';
p = encoding;
}
p[variant++ - p] = '\0';
}
/* Normalize the language name */
if (std_language != NULL) {
*std_language = "en";
}
}
/* Normalize the country name */
}
}
/* Normalize the script and variant name. Note that we only use
* variants listed in the mapping array; others are ignored.
*/
if (std_script != NULL) {
}
if (std_variant != NULL) {
}
}
/* Normalize the encoding name. Note that we IGNORE the string
* 'encoding' extracted from the locale name above. Instead, we use the
* more reliable method of calling nl_langinfo(CODESET). This function
* returns an empty string if no encoding is set for the given locale
* (e.g., the C or POSIX locales); we use the default ISO 8859-1
* converter for such locales.
*/
if (std_encoding != NULL) {
/* OK, not so reliable - nl_langinfo() gives wrong answers on
* Euro locales, in particular. */
if (strcmp(p, "ISO8859-15") == 0)
p = "ISO8859-15";
else
p = nl_langinfo(CODESET);
/* Convert the bare "646" used on Solaris to a proper IANA name */
if (strcmp(p, "646") == 0)
p = "ISO646-US";
/* return same result nl_langinfo would return for en_UK,
* in order to use optimizations. */
#ifdef __linux__
/*
* Remap the encoding string to a different value for japanese
* locales on linux so that customized converters are used instead
* of the default converter for "EUC-JP". The customized converters
* omit support for the JIS0212 encoding which is not supported by
* the variant of "EUC-JP" encoding used on linux
*/
if (strcmp(p, "EUC-JP") == 0) {
*std_encoding = "EUC-JP-LINUX";
}
#else
if (strcmp(p,"eucJP") == 0) {
/* For Solaris use customized vendor defined character
* customized EUC-JP converter
*/
*std_encoding = "eucJP-open";
/*
* Remap the encoding string to Big5_Solaris which augments
* the default converter for Solaris Big5 locales to include
* seven additional ideographic characters beyond those included
* in the Java "Big5" converter.
*/
*std_encoding = "Big5_Solaris";
} else if (strcmp(p, "Big5-HKSCS") == 0) {
/*
* Solaris uses HKSCS2001
*/
*std_encoding = "Big5-HKSCS-2001";
}
#endif
}
return 1;
}
#ifdef JAVASE_EMBEDDED
* exists in the JRE. This can still be overridden by -Dawt.toolkit=XXX
*/
static char* getEmbeddedToolkit() {
char buf[MAXPATHLEN];
char *p;
/* Get address of this library and the directory containing it. */
/* Default AWT Toolkit on Linux and Solaris is XAWT. */
/* Check if it exists */
/* No - this is a reduced-headless-jre so use special HToolkit */
return "sun.awt.HToolkit";
}
else {
/* Yes - this is a headful JRE so fallback to SE defaults */
return NULL;
}
}
#endif
/* This function gets called very early, before VM_CALLS are setup.
* Do not use any of the VM_CALLS entries!!!
*/
{
static java_props_t sprops;
char *v; /* tmp var */
return &sprops;
}
/* tmp dir */
#ifdef MACOSX
/* darwin has a per-user temp dir */
}
#endif /* MACOSX */
/* Printing properties */
#ifdef MACOSX
#else
#endif
/* Java 2D properties */
#ifdef MACOSX
switch (prefToolkit) {
case CToolkit:
case HToolkit:
break;
case XToolkit:
#endif
#ifdef MACOSX
break;
}
#endif
/* AWT properties */
#ifdef JAVASE_EMBEDDED
#endif
#ifdef MACOSX
switch (prefToolkit) {
case CToolkit:
break;
case XToolkit:
#endif
#ifdef MACOSX
break;
default:
break;
}
#endif
/* This is used only for debugging of font problems. */
v = getenv("JAVA2D_FONTPATH");
#ifdef SI_ISALIST
/* supported instruction sets */
{
char list[258];
}
#else
#endif
/* endianness of platform */
{
unsigned int endianTest = 0xff000000;
if (((char*)(&endianTest))[0] != 0)
else
}
/* os properties */
{
#ifdef MACOSX
#else
#endif
}
else {
}
}
/* Determine the language, country, variant, and encoding from the host,
* and store these in the user.language, user.country, user.variant and
* file.encoding system properties. */
if (ParseLocale(LC_CTYPE,
&(sprops.format_script),
&(sprops.format_country),
&(sprops.format_variant),
NULL);
} else {
}
#ifdef _ALLBSD_SOURCE
#if BYTE_ORDER == _LITTLE_ENDIAN
#else
#endif
#else /* !_ALLBSD_SOURCE */
#ifdef __linux__
#if __BYTE_ORDER == __LITTLE_ENDIAN
#else
#endif
#else
#endif
#endif /* _ALLBSD_SOURCE */
/* user properties */
{
}
/* User TIMEZONE */
{
/*
* We defer setting up timezone until it's actually necessary.
* Refer to TimeZone.getDefault(). However, the system
* property is necessary to be able to be set by the command
* line interface -D. Here temporarily set a null string to
* timezone.
*/
tzset(); /* for compatibility */
}
/* Current directory */
{
char buf[MAXPATHLEN];
errno = 0;
"Properties init: Could not determine current working directory.");
else
}
#if !defined(_ALLBSD_SOURCE)
/* Append CDE message and resource search path to NLSPATH and
* XFILESEARCHPATH, in order to pick localized message for
* FileSelectionDialog window (Bug 4173641).
*/
setPathEnvironment("XFILESEARCHPATH=/usr/dt/app-defaults/%L/Dt");
#endif
#ifdef MACOSX
#endif
return &sprops;
}
{
}