src/java.base/macosx/native/libjava/java_props_macosx.c
author naoto
Tue, 05 Jun 2018 08:33:40 -0700
changeset 50410 01e4ddc3c23f
parent 47352 33ac30e17843
child 51169 0058ffa0a922
permissions -rw-r--r--
8203324: Use out of scope in getMacOSXLocale of java_props_macosx.c:120 Reviewed-by: rriggs
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
     1
/*
43799
0e642fbacb25 8174779: Locale issues with Mac 10.12
naoto
parents: 39765
diff changeset
     2
 * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
     4
 *
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    10
 *
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    15
 * accompanied this code).
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    16
 *
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    20
 *
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    23
 * questions.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    24
 */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    25
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    26
#include <sys/socket.h>
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    27
#include <netinet/in.h>
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    28
#include <arpa/inet.h>
39144
50f8aee9012d 7131356: (props) "No Java runtime present, requesting install" when creating VM from JNI [macosx]
bchristi
parents: 33653
diff changeset
    29
#include <objc/objc-runtime.h>
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    30
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    31
#include <Security/AuthSession.h>
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    32
#include <CoreFoundation/CoreFoundation.h>
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    33
#include <SystemConfiguration/SystemConfiguration.h>
19857
d3a868255edb 7199674: (props) user.home property does not return an accessible location in sandboxed environment [macosx]
bchristi
parents: 14662
diff changeset
    34
#include <Foundation/Foundation.h>
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    35
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    36
#include "java_props_macosx.h"
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    37
13583
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 12047
diff changeset
    38
char *getPosixLocale(int cat) {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    39
    char *lc = setlocale(cat, NULL);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    40
    if ((lc == NULL) || (strcmp(lc, "C") == 0)) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    41
        lc = getenv("LANG");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    42
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    43
    if (lc == NULL) return NULL;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    44
    return strdup(lc);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    45
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    46
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    47
#define LOCALEIDLENGTH  128
13583
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 12047
diff changeset
    48
char *getMacOSXLocale(int cat) {
44044
f1398789e771 8174736: [JCP] [Mac]Cannot launch JCP on Mac os with language set to "Chinese, Simplified" while region is not China
naoto
parents: 43799
diff changeset
    49
    const char* retVal = NULL;
50410
01e4ddc3c23f 8203324: Use out of scope in getMacOSXLocale of java_props_macosx.c:120
naoto
parents: 47352
diff changeset
    50
    char languageString[LOCALEIDLENGTH];
45829
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
    51
    char localeString[LOCALEIDLENGTH];
44044
f1398789e771 8174736: [JCP] [Mac]Cannot launch JCP on Mac os with language set to "Chinese, Simplified" while region is not China
naoto
parents: 43799
diff changeset
    52
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    53
    switch (cat) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    54
    case LC_MESSAGES:
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    55
        {
39144
50f8aee9012d 7131356: (props) "No Java runtime present, requesting install" when creating VM from JNI [macosx]
bchristi
parents: 33653
diff changeset
    56
            // get preferred language code
50f8aee9012d 7131356: (props) "No Java runtime present, requesting install" when creating VM from JNI [macosx]
bchristi
parents: 33653
diff changeset
    57
            CFArrayRef languages = CFLocaleCopyPreferredLanguages();
50f8aee9012d 7131356: (props) "No Java runtime present, requesting install" when creating VM from JNI [macosx]
bchristi
parents: 33653
diff changeset
    58
            if (languages == NULL) {
50f8aee9012d 7131356: (props) "No Java runtime present, requesting install" when creating VM from JNI [macosx]
bchristi
parents: 33653
diff changeset
    59
                return NULL;
50f8aee9012d 7131356: (props) "No Java runtime present, requesting install" when creating VM from JNI [macosx]
bchristi
parents: 33653
diff changeset
    60
            }
50f8aee9012d 7131356: (props) "No Java runtime present, requesting install" when creating VM from JNI [macosx]
bchristi
parents: 33653
diff changeset
    61
            if (CFArrayGetCount(languages) <= 0) {
50f8aee9012d 7131356: (props) "No Java runtime present, requesting install" when creating VM from JNI [macosx]
bchristi
parents: 33653
diff changeset
    62
                CFRelease(languages);
50f8aee9012d 7131356: (props) "No Java runtime present, requesting install" when creating VM from JNI [macosx]
bchristi
parents: 33653
diff changeset
    63
                return NULL;
50f8aee9012d 7131356: (props) "No Java runtime present, requesting install" when creating VM from JNI [macosx]
bchristi
parents: 33653
diff changeset
    64
            }
50f8aee9012d 7131356: (props) "No Java runtime present, requesting install" when creating VM from JNI [macosx]
bchristi
parents: 33653
diff changeset
    65
50f8aee9012d 7131356: (props) "No Java runtime present, requesting install" when creating VM from JNI [macosx]
bchristi
parents: 33653
diff changeset
    66
            CFStringRef primaryLanguage = (CFStringRef)CFArrayGetValueAtIndex(languages, 0);
50f8aee9012d 7131356: (props) "No Java runtime present, requesting install" when creating VM from JNI [macosx]
bchristi
parents: 33653
diff changeset
    67
            if (primaryLanguage == NULL) {
50f8aee9012d 7131356: (props) "No Java runtime present, requesting install" when creating VM from JNI [macosx]
bchristi
parents: 33653
diff changeset
    68
                CFRelease(languages);
50f8aee9012d 7131356: (props) "No Java runtime present, requesting install" when creating VM from JNI [macosx]
bchristi
parents: 33653
diff changeset
    69
                return NULL;
50f8aee9012d 7131356: (props) "No Java runtime present, requesting install" when creating VM from JNI [macosx]
bchristi
parents: 33653
diff changeset
    70
            }
50f8aee9012d 7131356: (props) "No Java runtime present, requesting install" when creating VM from JNI [macosx]
bchristi
parents: 33653
diff changeset
    71
            if (CFStringGetCString(primaryLanguage, languageString,
50f8aee9012d 7131356: (props) "No Java runtime present, requesting install" when creating VM from JNI [macosx]
bchristi
parents: 33653
diff changeset
    72
                                   LOCALEIDLENGTH, CFStringGetSystemEncoding()) == false) {
50f8aee9012d 7131356: (props) "No Java runtime present, requesting install" when creating VM from JNI [macosx]
bchristi
parents: 33653
diff changeset
    73
                CFRelease(languages);
50f8aee9012d 7131356: (props) "No Java runtime present, requesting install" when creating VM from JNI [macosx]
bchristi
parents: 33653
diff changeset
    74
                return NULL;
50f8aee9012d 7131356: (props) "No Java runtime present, requesting install" when creating VM from JNI [macosx]
bchristi
parents: 33653
diff changeset
    75
            }
50f8aee9012d 7131356: (props) "No Java runtime present, requesting install" when creating VM from JNI [macosx]
bchristi
parents: 33653
diff changeset
    76
            CFRelease(languages);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    77
45829
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
    78
            // Explicitly supply region, if there is none
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
    79
            char *hyphenPos = strchr(languageString, '-');
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
    80
            int langStrLen = strlen(languageString);
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
    81
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
    82
            if (hyphenPos == NULL || // languageString contains ISO639 only, e.g., "en"
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
    83
                languageString + langStrLen - hyphenPos == 5) { // ISO639-ScriptCode, e.g., "en-Latn"
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
    84
                CFStringGetCString(CFLocaleGetIdentifier(CFLocaleCopyCurrent()),
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
    85
                               localeString, LOCALEIDLENGTH, CFStringGetSystemEncoding());
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
    86
                char *underscorePos = strrchr(localeString, '_');
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
    87
                char *region = NULL;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    88
45829
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
    89
                if (underscorePos != NULL) {
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
    90
                    region = underscorePos + 1;
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
    91
                }
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
    92
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
    93
                if (region != NULL) {
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
    94
                    strcat(languageString, "-");
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
    95
                    strcat(languageString, region);
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
    96
                }
39144
50f8aee9012d 7131356: (props) "No Java runtime present, requesting install" when creating VM from JNI [macosx]
bchristi
parents: 33653
diff changeset
    97
            }
45829
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
    98
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
    99
            retVal = languageString;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   100
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   101
        break;
45829
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
   102
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   103
    default:
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   104
        {
44044
f1398789e771 8174736: [JCP] [Mac]Cannot launch JCP on Mac os with language set to "Chinese, Simplified" while region is not China
naoto
parents: 43799
diff changeset
   105
            if (!CFStringGetCString(CFLocaleGetIdentifier(CFLocaleCopyCurrent()),
f1398789e771 8174736: [JCP] [Mac]Cannot launch JCP on Mac os with language set to "Chinese, Simplified" while region is not China
naoto
parents: 43799
diff changeset
   106
                                    localeString, LOCALEIDLENGTH, CFStringGetSystemEncoding())) {
f1398789e771 8174736: [JCP] [Mac]Cannot launch JCP on Mac os with language set to "Chinese, Simplified" while region is not China
naoto
parents: 43799
diff changeset
   107
                return NULL;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   108
            }
45829
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
   109
44044
f1398789e771 8174736: [JCP] [Mac]Cannot launch JCP on Mac os with language set to "Chinese, Simplified" while region is not China
naoto
parents: 43799
diff changeset
   110
            retVal = localeString;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   111
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   112
        break;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   113
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   114
44044
f1398789e771 8174736: [JCP] [Mac]Cannot launch JCP on Mac os with language set to "Chinese, Simplified" while region is not China
naoto
parents: 43799
diff changeset
   115
    if (retVal != NULL) {
47352
33ac30e17843 8187772: JVM crash when currency set on MacOS 10.10 and earlier
bchristi
parents: 47216
diff changeset
   116
        // convertToPOSIXLocale() does not expect any variant codes, so ignore
33ac30e17843 8187772: JVM crash when currency set on MacOS 10.10 and earlier
bchristi
parents: 47216
diff changeset
   117
        // '@' and anything following, if present.
33ac30e17843 8187772: JVM crash when currency set on MacOS 10.10 and earlier
bchristi
parents: 47216
diff changeset
   118
        char* rmAt = strchr(retVal, '@');
33ac30e17843 8187772: JVM crash when currency set on MacOS 10.10 and earlier
bchristi
parents: 47216
diff changeset
   119
        if (rmAt != NULL) {
33ac30e17843 8187772: JVM crash when currency set on MacOS 10.10 and earlier
bchristi
parents: 47216
diff changeset
   120
            *rmAt = '\0';
33ac30e17843 8187772: JVM crash when currency set on MacOS 10.10 and earlier
bchristi
parents: 47216
diff changeset
   121
        }
45829
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
   122
        return strdup(convertToPOSIXLocale(retVal));
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
   123
    }
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
   124
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
   125
    return NULL;
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
   126
}
44044
f1398789e771 8174736: [JCP] [Mac]Cannot launch JCP on Mac os with language set to "Chinese, Simplified" while region is not China
naoto
parents: 43799
diff changeset
   127
45829
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
   128
/* Language IDs use the language designators and (optional) region
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
   129
 * and script designators of BCP 47.  So possible formats are:
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
   130
 *
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
   131
 * "en"         (language designator only)
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
   132
 * "haw"        (3-letter lanuage designator)
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
   133
 * "en-GB"      (language with alpha-2 region designator)
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
   134
 * "es-419"     (language with 3-digit UN M.49 area code)
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
   135
 * "zh-Hans"    (language with ISO 15924 script designator)
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
   136
 * "zh-Hans-US"  (language with ISO 15924 script designator and region)
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
   137
 * "zh-Hans-419" (language with ISO 15924 script designator and UN M.49)
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
   138
 *
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
   139
 * convert these tags into POSIX conforming locale string, i.e.,
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
   140
 * lang{_region}{@script}. e.g., for "zh-Hans-US" into "zh_US@Hans"
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
   141
 */
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
   142
const char * convertToPOSIXLocale(const char* src) {
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
   143
    char* scriptRegion = strchr(src, '-');
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
   144
    if (scriptRegion != NULL) {
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
   145
        int length = strlen(scriptRegion);
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
   146
        char* region = strchr(scriptRegion + 1, '-');
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
   147
        char* atMark = NULL;
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
   148
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
   149
        if (region == NULL) {
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
   150
            // CFLocaleGetIdentifier() returns '_' before region
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
   151
            region = strchr(scriptRegion + 1, '_');
44044
f1398789e771 8174736: [JCP] [Mac]Cannot launch JCP on Mac os with language set to "Chinese, Simplified" while region is not China
naoto
parents: 43799
diff changeset
   152
        }
f1398789e771 8174736: [JCP] [Mac]Cannot launch JCP on Mac os with language set to "Chinese, Simplified" while region is not China
naoto
parents: 43799
diff changeset
   153
45829
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
   154
        *scriptRegion = '_';
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
   155
        if (length > 5) {
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
   156
            // Region and script both exist.
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
   157
            char tmpScript[4];
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
   158
            int regionLength = length - 6;
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
   159
            atMark = scriptRegion + 1 + regionLength;
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
   160
            memcpy(tmpScript, scriptRegion + 1, 4);
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
   161
            memmove(scriptRegion + 1, region + 1, regionLength);
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
   162
            memcpy(atMark + 1, tmpScript, 4);
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
   163
        } else if (length == 5) {
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
   164
            // script only
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
   165
            atMark = scriptRegion;
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
   166
        }
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
   167
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
   168
        if (atMark != NULL) {
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
   169
            *atMark = '@';
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
   170
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
   171
            // assert script code
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
   172
            assert(isalpha(atMark[1]) &&
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
   173
                   isalpha(atMark[2]) &&
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
   174
                   isalpha(atMark[3]) &&
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
   175
                   isalpha(atMark[4]));
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
   176
        }
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
   177
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
   178
        assert(((length == 3 || length == 8) &&
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
   179
            // '_' followed by a 2 character region designator
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
   180
                isalpha(scriptRegion[1]) &&
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
   181
                isalpha(scriptRegion[2])) ||
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
   182
                ((length == 4 || length == 9) &&
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
   183
            // '_' followed by a 3-digit UN M.49 area code
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
   184
                isdigit(scriptRegion[1]) &&
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
   185
                isdigit(scriptRegion[2]) &&
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
   186
                isdigit(scriptRegion[3])) ||
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
   187
            // '@' followed by a 4 character script code (already validated above)
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
   188
                (length == 5));
44044
f1398789e771 8174736: [JCP] [Mac]Cannot launch JCP on Mac os with language set to "Chinese, Simplified" while region is not China
naoto
parents: 43799
diff changeset
   189
    }
45829
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
   190
991121499947 8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents: 44044
diff changeset
   191
    return src;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   192
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   193
13583
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 12047
diff changeset
   194
char *setupMacOSXLocale(int cat) {
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 12047
diff changeset
   195
    char * ret = getMacOSXLocale(cat);
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 12047
diff changeset
   196
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 12047
diff changeset
   197
    if (ret == NULL) {
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 12047
diff changeset
   198
        return getPosixLocale(cat);
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 12047
diff changeset
   199
    } else {
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 12047
diff changeset
   200
        return ret;
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 12047
diff changeset
   201
    }
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 12047
diff changeset
   202
}
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 12047
diff changeset
   203
21130
0f0b9c8f701a 8025673: [macosx] Disable X11 AWT toolkit
dholmes
parents: 19857
diff changeset
   204
int isInAquaSession() {
21536
032532f158ae 8027912: [macosx] Provide means to force the headful mode on OS X when running via ssh
anthony
parents: 21130
diff changeset
   205
    // environment variable to bypass the aqua session check
032532f158ae 8027912: [macosx] Provide means to force the headful mode on OS X when running via ssh
anthony
parents: 21130
diff changeset
   206
    char *ev = getenv("AWT_FORCE_HEADFUL");
032532f158ae 8027912: [macosx] Provide means to force the headful mode on OS X when running via ssh
anthony
parents: 21130
diff changeset
   207
    if (ev && (strncasecmp(ev, "true", 4) == 0)) {
032532f158ae 8027912: [macosx] Provide means to force the headful mode on OS X when running via ssh
anthony
parents: 21130
diff changeset
   208
        // if "true" then tell the caller we're in an Aqua session without actually checking
032532f158ae 8027912: [macosx] Provide means to force the headful mode on OS X when running via ssh
anthony
parents: 21130
diff changeset
   209
        return 1;
032532f158ae 8027912: [macosx] Provide means to force the headful mode on OS X when running via ssh
anthony
parents: 21130
diff changeset
   210
    }
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   211
    // Is the WindowServer available?
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   212
    SecuritySessionId session_id;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   213
    SessionAttributeBits session_info;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   214
    OSStatus status = SessionGetInfo(callerSecuritySession, &session_id, &session_info);
21130
0f0b9c8f701a 8025673: [macosx] Disable X11 AWT toolkit
dholmes
parents: 19857
diff changeset
   215
    if (status == noErr) {
0f0b9c8f701a 8025673: [macosx] Disable X11 AWT toolkit
dholmes
parents: 19857
diff changeset
   216
        if (session_info & sessionHasGraphicAccess) {
0f0b9c8f701a 8025673: [macosx] Disable X11 AWT toolkit
dholmes
parents: 19857
diff changeset
   217
            return 1;
0f0b9c8f701a 8025673: [macosx] Disable X11 AWT toolkit
dholmes
parents: 19857
diff changeset
   218
        }
0f0b9c8f701a 8025673: [macosx] Disable X11 AWT toolkit
dholmes
parents: 19857
diff changeset
   219
    }
0f0b9c8f701a 8025673: [macosx] Disable X11 AWT toolkit
dholmes
parents: 19857
diff changeset
   220
    return 0;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   221
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   222
39144
50f8aee9012d 7131356: (props) "No Java runtime present, requesting install" when creating VM from JNI [macosx]
bchristi
parents: 33653
diff changeset
   223
// 10.9 SDK does not include the NSOperatingSystemVersion struct.
50f8aee9012d 7131356: (props) "No Java runtime present, requesting install" when creating VM from JNI [macosx]
bchristi
parents: 33653
diff changeset
   224
// For now, create our own
50f8aee9012d 7131356: (props) "No Java runtime present, requesting install" when creating VM from JNI [macosx]
bchristi
parents: 33653
diff changeset
   225
typedef struct {
50f8aee9012d 7131356: (props) "No Java runtime present, requesting install" when creating VM from JNI [macosx]
bchristi
parents: 33653
diff changeset
   226
        NSInteger majorVersion;
50f8aee9012d 7131356: (props) "No Java runtime present, requesting install" when creating VM from JNI [macosx]
bchristi
parents: 33653
diff changeset
   227
        NSInteger minorVersion;
50f8aee9012d 7131356: (props) "No Java runtime present, requesting install" when creating VM from JNI [macosx]
bchristi
parents: 33653
diff changeset
   228
        NSInteger patchVersion;
50f8aee9012d 7131356: (props) "No Java runtime present, requesting install" when creating VM from JNI [macosx]
bchristi
parents: 33653
diff changeset
   229
} OSVerStruct;
50f8aee9012d 7131356: (props) "No Java runtime present, requesting install" when creating VM from JNI [macosx]
bchristi
parents: 33653
diff changeset
   230
14513
f6dc8c52e275 7178922: (props) re-visit how os.name is determined on Mac
bchristi
parents: 14342
diff changeset
   231
void setOSNameAndVersion(java_props_t *sprops) {
39144
50f8aee9012d 7131356: (props) "No Java runtime present, requesting install" when creating VM from JNI [macosx]
bchristi
parents: 33653
diff changeset
   232
    // Hardcode os_name, and fill in os_version
14513
f6dc8c52e275 7178922: (props) re-visit how os.name is determined on Mac
bchristi
parents: 14342
diff changeset
   233
    sprops->os_name = strdup("Mac OS X");
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   234
39144
50f8aee9012d 7131356: (props) "No Java runtime present, requesting install" when creating VM from JNI [macosx]
bchristi
parents: 33653
diff changeset
   235
    char* osVersionCStr = NULL;
50f8aee9012d 7131356: (props) "No Java runtime present, requesting install" when creating VM from JNI [macosx]
bchristi
parents: 33653
diff changeset
   236
    // Mac OS 10.9 includes the [NSProcessInfo operatingSystemVersion] function,
50f8aee9012d 7131356: (props) "No Java runtime present, requesting install" when creating VM from JNI [macosx]
bchristi
parents: 33653
diff changeset
   237
    // but it's not in the 10.9 SDK.  So, call it via objc_msgSend_stret.
50f8aee9012d 7131356: (props) "No Java runtime present, requesting install" when creating VM from JNI [macosx]
bchristi
parents: 33653
diff changeset
   238
    if ([[NSProcessInfo processInfo] respondsToSelector:@selector(operatingSystemVersion)]) {
50f8aee9012d 7131356: (props) "No Java runtime present, requesting install" when creating VM from JNI [macosx]
bchristi
parents: 33653
diff changeset
   239
        OSVerStruct (*procInfoFn)(id rec, SEL sel) = (OSVerStruct(*)(id, SEL))objc_msgSend_stret;
50f8aee9012d 7131356: (props) "No Java runtime present, requesting install" when creating VM from JNI [macosx]
bchristi
parents: 33653
diff changeset
   240
        OSVerStruct osVer = procInfoFn([NSProcessInfo processInfo],
50f8aee9012d 7131356: (props) "No Java runtime present, requesting install" when creating VM from JNI [macosx]
bchristi
parents: 33653
diff changeset
   241
                                       @selector(operatingSystemVersion));
39765
c1aee33ef0c0 8161039: System.getProperty("os.version") returns incorrect version number on Mac
bchristi
parents: 39322
diff changeset
   242
        NSString *nsVerStr;
c1aee33ef0c0 8161039: System.getProperty("os.version") returns incorrect version number on Mac
bchristi
parents: 39322
diff changeset
   243
        if (osVer.patchVersion == 0) { // Omit trailing ".0"
c1aee33ef0c0 8161039: System.getProperty("os.version") returns incorrect version number on Mac
bchristi
parents: 39322
diff changeset
   244
            nsVerStr = [NSString stringWithFormat:@"%ld.%ld",
c1aee33ef0c0 8161039: System.getProperty("os.version") returns incorrect version number on Mac
bchristi
parents: 39322
diff changeset
   245
                    (long)osVer.majorVersion, (long)osVer.minorVersion];
c1aee33ef0c0 8161039: System.getProperty("os.version") returns incorrect version number on Mac
bchristi
parents: 39322
diff changeset
   246
        } else {
c1aee33ef0c0 8161039: System.getProperty("os.version") returns incorrect version number on Mac
bchristi
parents: 39322
diff changeset
   247
            nsVerStr = [NSString stringWithFormat:@"%ld.%ld.%ld",
c1aee33ef0c0 8161039: System.getProperty("os.version") returns incorrect version number on Mac
bchristi
parents: 39322
diff changeset
   248
                    (long)osVer.majorVersion, (long)osVer.minorVersion, (long)osVer.patchVersion];
c1aee33ef0c0 8161039: System.getProperty("os.version") returns incorrect version number on Mac
bchristi
parents: 39322
diff changeset
   249
        }
39144
50f8aee9012d 7131356: (props) "No Java runtime present, requesting install" when creating VM from JNI [macosx]
bchristi
parents: 33653
diff changeset
   250
        // Copy out the char*
50f8aee9012d 7131356: (props) "No Java runtime present, requesting install" when creating VM from JNI [macosx]
bchristi
parents: 33653
diff changeset
   251
        osVersionCStr = strdup([nsVerStr UTF8String]);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   252
    }
39322
66ecf193683a 8160370: System.getProperty("os.version") returns "Unknown" on Mac
bchristi
parents: 39144
diff changeset
   253
    // Fallback if running on pre-10.9 Mac OS
66ecf193683a 8160370: System.getProperty("os.version") returns "Unknown" on Mac
bchristi
parents: 39144
diff changeset
   254
    if (osVersionCStr == NULL) {
66ecf193683a 8160370: System.getProperty("os.version") returns "Unknown" on Mac
bchristi
parents: 39144
diff changeset
   255
        NSDictionary *version = [NSDictionary dictionaryWithContentsOfFile :
66ecf193683a 8160370: System.getProperty("os.version") returns "Unknown" on Mac
bchristi
parents: 39144
diff changeset
   256
                                 @"/System/Library/CoreServices/SystemVersion.plist"];
66ecf193683a 8160370: System.getProperty("os.version") returns "Unknown" on Mac
bchristi
parents: 39144
diff changeset
   257
        if (version != NULL) {
66ecf193683a 8160370: System.getProperty("os.version") returns "Unknown" on Mac
bchristi
parents: 39144
diff changeset
   258
            NSString *nsVerStr = [version objectForKey : @"ProductVersion"];
66ecf193683a 8160370: System.getProperty("os.version") returns "Unknown" on Mac
bchristi
parents: 39144
diff changeset
   259
            if (nsVerStr != NULL) {
66ecf193683a 8160370: System.getProperty("os.version") returns "Unknown" on Mac
bchristi
parents: 39144
diff changeset
   260
                osVersionCStr = strdup([nsVerStr UTF8String]);
66ecf193683a 8160370: System.getProperty("os.version") returns "Unknown" on Mac
bchristi
parents: 39144
diff changeset
   261
            }
66ecf193683a 8160370: System.getProperty("os.version") returns "Unknown" on Mac
bchristi
parents: 39144
diff changeset
   262
        }
66ecf193683a 8160370: System.getProperty("os.version") returns "Unknown" on Mac
bchristi
parents: 39144
diff changeset
   263
    }
39144
50f8aee9012d 7131356: (props) "No Java runtime present, requesting install" when creating VM from JNI [macosx]
bchristi
parents: 33653
diff changeset
   264
    if (osVersionCStr == NULL) {
50f8aee9012d 7131356: (props) "No Java runtime present, requesting install" when creating VM from JNI [macosx]
bchristi
parents: 33653
diff changeset
   265
        osVersionCStr = strdup("Unknown");
50f8aee9012d 7131356: (props) "No Java runtime present, requesting install" when creating VM from JNI [macosx]
bchristi
parents: 33653
diff changeset
   266
    }
50f8aee9012d 7131356: (props) "No Java runtime present, requesting install" when creating VM from JNI [macosx]
bchristi
parents: 33653
diff changeset
   267
    sprops->os_version = osVersionCStr;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   268
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   269
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   270
39322
66ecf193683a 8160370: System.getProperty("os.version") returns "Unknown" on Mac
bchristi
parents: 39144
diff changeset
   271
static Boolean getProxyInfoForProtocol(CFDictionaryRef inDict, CFStringRef inEnabledKey,
66ecf193683a 8160370: System.getProperty("os.version") returns "Unknown" on Mac
bchristi
parents: 39144
diff changeset
   272
                                       CFStringRef inHostKey, CFStringRef inPortKey,
66ecf193683a 8160370: System.getProperty("os.version") returns "Unknown" on Mac
bchristi
parents: 39144
diff changeset
   273
                                       CFStringRef *outProxyHost, int *ioProxyPort) {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   274
    /* See if the proxy is enabled. */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   275
    CFNumberRef cf_enabled = CFDictionaryGetValue(inDict, inEnabledKey);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   276
    if (cf_enabled == NULL) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   277
        return false;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   278
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   279
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   280
    int isEnabled = false;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   281
    if (!CFNumberGetValue(cf_enabled, kCFNumberIntType, &isEnabled)) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   282
        return isEnabled;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   283
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   284
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   285
    if (!isEnabled) return false;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   286
    *outProxyHost = CFDictionaryGetValue(inDict, inHostKey);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   287
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   288
    // If cf_host is null, that means the checkbox is set,
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   289
    //   but no host was entered. We'll treat that as NOT ENABLED.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   290
    // If cf_port is null or cf_port isn't a number, that means
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   291
    //   no port number was entered. Treat this as ENABLED with the
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   292
    //   protocol's default port.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   293
    if (*outProxyHost == NULL) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   294
        return false;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   295
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   296
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   297
    if (CFStringGetLength(*outProxyHost) == 0) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   298
        return false;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   299
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   300
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   301
    int newPort = 0;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   302
    CFNumberRef cf_port = NULL;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   303
    if ((cf_port = CFDictionaryGetValue(inDict, inPortKey)) != NULL &&
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   304
        CFNumberGetValue(cf_port, kCFNumberIntType, &newPort) &&
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   305
        newPort > 0) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   306
        *ioProxyPort = newPort;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   307
    } else {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   308
        // bad port or no port - leave *ioProxyPort unchanged
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   309
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   310
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   311
    return true;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   312
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   313
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   314
static char *createUTF8CString(const CFStringRef theString) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   315
    if (theString == NULL) return NULL;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   316
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   317
    const CFIndex stringLength = CFStringGetLength(theString);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   318
    const CFIndex bufSize = CFStringGetMaximumSizeForEncoding(stringLength, kCFStringEncodingUTF8) + 1;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   319
    char *returnVal = (char *)malloc(bufSize);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   320
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   321
    if (CFStringGetCString(theString, returnVal, bufSize, kCFStringEncodingUTF8)) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   322
        return returnVal;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   323
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   324
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   325
    free(returnVal);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   326
    return NULL;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   327
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   328
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   329
// Return TRUE if str is a syntactically valid IP address.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   330
// Using inet_pton() instead of inet_aton() for IPv6 support.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   331
// len is only a hint; cstr must still be nul-terminated
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   332
static int looksLikeIPAddress(char *cstr, size_t len) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   333
    if (len == 0  ||  (len == 1 && cstr[0] == '.')) return FALSE;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   334
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   335
    char dst[16]; // big enough for INET6
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   336
    return (1 == inet_pton(AF_INET, cstr, dst)  ||
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   337
            1 == inet_pton(AF_INET6, cstr, dst));
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   338
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   339
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   340
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   341
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   342
// Convert Mac OS X proxy exception entry to Java syntax.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   343
// See Radar #3441134 for details.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   344
// Returns NULL if this exception should be ignored by Java.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   345
// May generate a string with multiple exceptions separated by '|'.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   346
static char * createConvertedException(CFStringRef cf_original) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   347
    // This is done with char* instead of CFString because inet_pton()
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   348
    // needs a C string.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   349
    char *c_exception = createUTF8CString(cf_original);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   350
    if (!c_exception) return NULL;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   351
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   352
    int c_len = strlen(c_exception);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   353
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   354
    // 1. sanitize exception prefix
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   355
    if (c_len >= 1  &&  0 == strncmp(c_exception, ".", 1)) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   356
        memmove(c_exception, c_exception+1, c_len);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   357
        c_len -= 1;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   358
    } else if (c_len >= 2  &&  0 == strncmp(c_exception, "*.", 2)) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   359
        memmove(c_exception, c_exception+2, c_len-1);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   360
        c_len -= 2;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   361
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   362
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   363
    // 2. pre-reject other exception wildcards
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   364
    if (strchr(c_exception, '*')) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   365
        free(c_exception);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   366
        return NULL;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   367
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   368
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   369
    // 3. no IP wildcarding
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   370
    if (looksLikeIPAddress(c_exception, c_len)) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   371
        return c_exception;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   372
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   373
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   374
    // 4. allow domain suffixes
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   375
    // c_exception is now "str\0" - change to "str|*.str\0"
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   376
    c_exception = reallocf(c_exception, c_len+3+c_len+1);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   377
    if (!c_exception) return NULL;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   378
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   379
    strncpy(c_exception+c_len, "|*.", 3);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   380
    strncpy(c_exception+c_len+3, c_exception, c_len);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   381
    c_exception[c_len+3+c_len] = '\0';
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   382
    return c_exception;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   383
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   384
19857
d3a868255edb 7199674: (props) user.home property does not return an accessible location in sandboxed environment [macosx]
bchristi
parents: 14662
diff changeset
   385
/*
d3a868255edb 7199674: (props) user.home property does not return an accessible location in sandboxed environment [macosx]
bchristi
parents: 14662
diff changeset
   386
 * Method for fetching the user.home path and storing it in the property list.
d3a868255edb 7199674: (props) user.home property does not return an accessible location in sandboxed environment [macosx]
bchristi
parents: 14662
diff changeset
   387
 * For signed .apps running in the Mac App Sandbox, user.home is set to the
d3a868255edb 7199674: (props) user.home property does not return an accessible location in sandboxed environment [macosx]
bchristi
parents: 14662
diff changeset
   388
 * app's sandbox container.
d3a868255edb 7199674: (props) user.home property does not return an accessible location in sandboxed environment [macosx]
bchristi
parents: 14662
diff changeset
   389
 */
d3a868255edb 7199674: (props) user.home property does not return an accessible location in sandboxed environment [macosx]
bchristi
parents: 14662
diff changeset
   390
void setUserHome(java_props_t *sprops) {
d3a868255edb 7199674: (props) user.home property does not return an accessible location in sandboxed environment [macosx]
bchristi
parents: 14662
diff changeset
   391
    if (sprops == NULL) { return; }
d3a868255edb 7199674: (props) user.home property does not return an accessible location in sandboxed environment [macosx]
bchristi
parents: 14662
diff changeset
   392
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
d3a868255edb 7199674: (props) user.home property does not return an accessible location in sandboxed environment [macosx]
bchristi
parents: 14662
diff changeset
   393
    sprops->user_home = createUTF8CString((CFStringRef)NSHomeDirectory());
d3a868255edb 7199674: (props) user.home property does not return an accessible location in sandboxed environment [macosx]
bchristi
parents: 14662
diff changeset
   394
    [pool drain];
d3a868255edb 7199674: (props) user.home property does not return an accessible location in sandboxed environment [macosx]
bchristi
parents: 14662
diff changeset
   395
}
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   396
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   397
/*
19857
d3a868255edb 7199674: (props) user.home property does not return an accessible location in sandboxed environment [macosx]
bchristi
parents: 14662
diff changeset
   398
 * Method for fetching proxy info and storing it in the property list.
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   399
 */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   400
void setProxyProperties(java_props_t *sProps) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   401
    if (sProps == NULL) return;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   402
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   403
    char buf[16];    /* Used for %d of an int - 16 is plenty */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   404
    CFStringRef
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   405
    cf_httpHost = NULL,
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   406
    cf_httpsHost = NULL,
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   407
    cf_ftpHost = NULL,
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   408
    cf_socksHost = NULL,
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   409
    cf_gopherHost = NULL;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   410
    int
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   411
    httpPort = 80, // Default proxy port values
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   412
    httpsPort = 443,
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   413
    ftpPort = 21,
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   414
    socksPort = 1080,
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   415
    gopherPort = 70;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   416
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   417
    CFDictionaryRef dict = SCDynamicStoreCopyProxies(NULL);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   418
    if (dict == NULL) return;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   419
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   420
    /* Read the proxy exceptions list */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   421
    CFArrayRef cf_list = CFDictionaryGetValue(dict, kSCPropNetProxiesExceptionsList);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   422
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   423
    CFMutableStringRef cf_exceptionList = NULL;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   424
    if (cf_list != NULL) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   425
        CFIndex len = CFArrayGetCount(cf_list), idx;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   426
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   427
        cf_exceptionList = CFStringCreateMutable(NULL, 0);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   428
        for (idx = (CFIndex)0; idx < len; idx++) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   429
            CFStringRef cf_ehost;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   430
            if ((cf_ehost = CFArrayGetValueAtIndex(cf_list, idx))) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   431
                /* Convert this exception from Mac OS X syntax to Java syntax.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   432
                 See Radar #3441134 for details. This may generate a string
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   433
                 with multiple Java exceptions separated by '|'. */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   434
                char *c_exception = createConvertedException(cf_ehost);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   435
                if (c_exception) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   436
                    /* Append the host to the list of exclusions. */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   437
                    if (CFStringGetLength(cf_exceptionList) > 0) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   438
                        CFStringAppendCString(cf_exceptionList, "|", kCFStringEncodingMacRoman);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   439
                    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   440
                    CFStringAppendCString(cf_exceptionList, c_exception, kCFStringEncodingMacRoman);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   441
                    free(c_exception);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   442
                }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   443
            }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   444
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   445
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   446
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   447
    if (cf_exceptionList != NULL) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   448
        if (CFStringGetLength(cf_exceptionList) > 0) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   449
            sProps->exceptionList = createUTF8CString(cf_exceptionList);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   450
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   451
        CFRelease(cf_exceptionList);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   452
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   453
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   454
#define CHECK_PROXY(protocol, PROTOCOL)                                     \
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   455
    sProps->protocol##ProxyEnabled =                                        \
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   456
    getProxyInfoForProtocol(dict, kSCPropNetProxies##PROTOCOL##Enable,      \
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   457
    kSCPropNetProxies##PROTOCOL##Proxy,         \
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   458
    kSCPropNetProxies##PROTOCOL##Port,          \
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   459
    &cf_##protocol##Host, &protocol##Port);     \
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   460
    if (sProps->protocol##ProxyEnabled) {                                   \
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   461
        sProps->protocol##Host = createUTF8CString(cf_##protocol##Host);    \
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   462
        snprintf(buf, sizeof(buf), "%d", protocol##Port);                   \
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   463
        sProps->protocol##Port = malloc(strlen(buf) + 1);                   \
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   464
        strcpy(sProps->protocol##Port, buf);                                \
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   465
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   466
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   467
    CHECK_PROXY(http, HTTP);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   468
    CHECK_PROXY(https, HTTPS);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   469
    CHECK_PROXY(ftp, FTP);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   470
    CHECK_PROXY(socks, SOCKS);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   471
    CHECK_PROXY(gopher, Gopher);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   472
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   473
#undef CHECK_PROXY
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   474
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   475
    CFRelease(dict);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   476
}