author | bchristi |
Mon, 16 Oct 2017 11:20:59 -0700 | |
changeset 47352 | 33ac30e17843 |
parent 47216 | 71c04702a3d5 |
child 50410 | 01e4ddc3c23f |
permissions | -rw-r--r-- |
12047 | 1 |
/* |
43799 | 2 |
* Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. |
12047 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. Oracle designates this |
|
8 |
* particular file as subject to the "Classpath" exception as provided |
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
|
10 |
* |
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
24 |
*/ |
|
25 |
||
26 |
#include <sys/socket.h> |
|
27 |
#include <netinet/in.h> |
|
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 | 30 |
|
31 |
#include <Security/AuthSession.h> |
|
32 |
#include <CoreFoundation/CoreFoundation.h> |
|
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 | 35 |
|
36 |
#include "java_props_macosx.h" |
|
37 |
||
13583 | 38 |
char *getPosixLocale(int cat) { |
12047 | 39 |
char *lc = setlocale(cat, NULL); |
40 |
if ((lc == NULL) || (strcmp(lc, "C") == 0)) { |
|
41 |
lc = getenv("LANG"); |
|
42 |
} |
|
43 |
if (lc == NULL) return NULL; |
|
44 |
return strdup(lc); |
|
45 |
} |
|
46 |
||
47 |
#define LOCALEIDLENGTH 128 |
|
13583 | 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; |
45829
991121499947
8160199: Language's script should be reflected in user.script on Mac OS X
naoto
parents:
44044
diff
changeset
|
50 |
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
|
51 |
|
12047 | 52 |
switch (cat) { |
53 |
case LC_MESSAGES: |
|
54 |
{ |
|
39144
50f8aee9012d
7131356: (props) "No Java runtime present, requesting install" when creating VM from JNI [macosx]
bchristi
parents:
33653
diff
changeset
|
55 |
// get preferred language code |
50f8aee9012d
7131356: (props) "No Java runtime present, requesting install" when creating VM from JNI [macosx]
bchristi
parents:
33653
diff
changeset
|
56 |
CFArrayRef languages = CFLocaleCopyPreferredLanguages(); |
50f8aee9012d
7131356: (props) "No Java runtime present, requesting install" when creating VM from JNI [macosx]
bchristi
parents:
33653
diff
changeset
|
57 |
if (languages == NULL) { |
50f8aee9012d
7131356: (props) "No Java runtime present, requesting install" when creating VM from JNI [macosx]
bchristi
parents:
33653
diff
changeset
|
58 |
return NULL; |
50f8aee9012d
7131356: (props) "No Java runtime present, requesting install" when creating VM from JNI [macosx]
bchristi
parents:
33653
diff
changeset
|
59 |
} |
50f8aee9012d
7131356: (props) "No Java runtime present, requesting install" when creating VM from JNI [macosx]
bchristi
parents:
33653
diff
changeset
|
60 |
if (CFArrayGetCount(languages) <= 0) { |
50f8aee9012d
7131356: (props) "No Java runtime present, requesting install" when creating VM from JNI [macosx]
bchristi
parents:
33653
diff
changeset
|
61 |
CFRelease(languages); |
50f8aee9012d
7131356: (props) "No Java runtime present, requesting install" when creating VM from JNI [macosx]
bchristi
parents:
33653
diff
changeset
|
62 |
return NULL; |
50f8aee9012d
7131356: (props) "No Java runtime present, requesting install" when creating VM from JNI [macosx]
bchristi
parents:
33653
diff
changeset
|
63 |
} |
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 |
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
|
66 |
if (primaryLanguage == NULL) { |
50f8aee9012d
7131356: (props) "No Java runtime present, requesting install" when creating VM from JNI [macosx]
bchristi
parents:
33653
diff
changeset
|
67 |
CFRelease(languages); |
50f8aee9012d
7131356: (props) "No Java runtime present, requesting install" when creating VM from JNI [macosx]
bchristi
parents:
33653
diff
changeset
|
68 |
return NULL; |
50f8aee9012d
7131356: (props) "No Java runtime present, requesting install" when creating VM from JNI [macosx]
bchristi
parents:
33653
diff
changeset
|
69 |
} |
50f8aee9012d
7131356: (props) "No Java runtime present, requesting install" when creating VM from JNI [macosx]
bchristi
parents:
33653
diff
changeset
|
70 |
char languageString[LOCALEIDLENGTH]; |
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 | 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 | 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 | 100 |
} |
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 | 103 |
default: |
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 | 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 | 111 |
} |
112 |
break; |
|
113 |
} |
|
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 | 192 |
} |
193 |
||
13583 | 194 |
char *setupMacOSXLocale(int cat) { |
195 |
char * ret = getMacOSXLocale(cat); |
|
196 |
||
197 |
if (ret == NULL) { |
|
198 |
return getPosixLocale(cat); |
|
199 |
} else { |
|
200 |
return ret; |
|
201 |
} |
|
202 |
} |
|
203 |
||
21130 | 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 | 211 |
// Is the WindowServer available? |
212 |
SecuritySessionId session_id; |
|
213 |
SessionAttributeBits session_info; |
|
214 |
OSStatus status = SessionGetInfo(callerSecuritySession, &session_id, &session_info); |
|
21130 | 215 |
if (status == noErr) { |
216 |
if (session_info & sessionHasGraphicAccess) { |
|
217 |
return 1; |
|
218 |
} |
|
219 |
} |
|
220 |
return 0; |
|
12047 | 221 |
} |
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 | 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 | 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 | 268 |
} |
269 |
||
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 | 274 |
/* See if the proxy is enabled. */ |
275 |
CFNumberRef cf_enabled = CFDictionaryGetValue(inDict, inEnabledKey); |
|
276 |
if (cf_enabled == NULL) { |
|
277 |
return false; |
|
278 |
} |
|
279 |
||
280 |
int isEnabled = false; |
|
281 |
if (!CFNumberGetValue(cf_enabled, kCFNumberIntType, &isEnabled)) { |
|
282 |
return isEnabled; |
|
283 |
} |
|
284 |
||
285 |
if (!isEnabled) return false; |
|
286 |
*outProxyHost = CFDictionaryGetValue(inDict, inHostKey); |
|
287 |
||
288 |
// If cf_host is null, that means the checkbox is set, |
|
289 |
// but no host was entered. We'll treat that as NOT ENABLED. |
|
290 |
// If cf_port is null or cf_port isn't a number, that means |
|
291 |
// no port number was entered. Treat this as ENABLED with the |
|
292 |
// protocol's default port. |
|
293 |
if (*outProxyHost == NULL) { |
|
294 |
return false; |
|
295 |
} |
|
296 |
||
297 |
if (CFStringGetLength(*outProxyHost) == 0) { |
|
298 |
return false; |
|
299 |
} |
|
300 |
||
301 |
int newPort = 0; |
|
302 |
CFNumberRef cf_port = NULL; |
|
303 |
if ((cf_port = CFDictionaryGetValue(inDict, inPortKey)) != NULL && |
|
304 |
CFNumberGetValue(cf_port, kCFNumberIntType, &newPort) && |
|
305 |
newPort > 0) { |
|
306 |
*ioProxyPort = newPort; |
|
307 |
} else { |
|
308 |
// bad port or no port - leave *ioProxyPort unchanged |
|
309 |
} |
|
310 |
||
311 |
return true; |
|
312 |
} |
|
313 |
||
314 |
static char *createUTF8CString(const CFStringRef theString) { |
|
315 |
if (theString == NULL) return NULL; |
|
316 |
||
317 |
const CFIndex stringLength = CFStringGetLength(theString); |
|
318 |
const CFIndex bufSize = CFStringGetMaximumSizeForEncoding(stringLength, kCFStringEncodingUTF8) + 1; |
|
319 |
char *returnVal = (char *)malloc(bufSize); |
|
320 |
||
321 |
if (CFStringGetCString(theString, returnVal, bufSize, kCFStringEncodingUTF8)) { |
|
322 |
return returnVal; |
|
323 |
} |
|
324 |
||
325 |
free(returnVal); |
|
326 |
return NULL; |
|
327 |
} |
|
328 |
||
329 |
// Return TRUE if str is a syntactically valid IP address. |
|
330 |
// Using inet_pton() instead of inet_aton() for IPv6 support. |
|
331 |
// len is only a hint; cstr must still be nul-terminated |
|
332 |
static int looksLikeIPAddress(char *cstr, size_t len) { |
|
333 |
if (len == 0 || (len == 1 && cstr[0] == '.')) return FALSE; |
|
334 |
||
335 |
char dst[16]; // big enough for INET6 |
|
336 |
return (1 == inet_pton(AF_INET, cstr, dst) || |
|
337 |
1 == inet_pton(AF_INET6, cstr, dst)); |
|
338 |
} |
|
339 |
||
340 |
||
341 |
||
342 |
// Convert Mac OS X proxy exception entry to Java syntax. |
|
343 |
// See Radar #3441134 for details. |
|
344 |
// Returns NULL if this exception should be ignored by Java. |
|
345 |
// May generate a string with multiple exceptions separated by '|'. |
|
346 |
static char * createConvertedException(CFStringRef cf_original) { |
|
347 |
// This is done with char* instead of CFString because inet_pton() |
|
348 |
// needs a C string. |
|
349 |
char *c_exception = createUTF8CString(cf_original); |
|
350 |
if (!c_exception) return NULL; |
|
351 |
||
352 |
int c_len = strlen(c_exception); |
|
353 |
||
354 |
// 1. sanitize exception prefix |
|
355 |
if (c_len >= 1 && 0 == strncmp(c_exception, ".", 1)) { |
|
356 |
memmove(c_exception, c_exception+1, c_len); |
|
357 |
c_len -= 1; |
|
358 |
} else if (c_len >= 2 && 0 == strncmp(c_exception, "*.", 2)) { |
|
359 |
memmove(c_exception, c_exception+2, c_len-1); |
|
360 |
c_len -= 2; |
|
361 |
} |
|
362 |
||
363 |
// 2. pre-reject other exception wildcards |
|
364 |
if (strchr(c_exception, '*')) { |
|
365 |
free(c_exception); |
|
366 |
return NULL; |
|
367 |
} |
|
368 |
||
369 |
// 3. no IP wildcarding |
|
370 |
if (looksLikeIPAddress(c_exception, c_len)) { |
|
371 |
return c_exception; |
|
372 |
} |
|
373 |
||
374 |
// 4. allow domain suffixes |
|
375 |
// c_exception is now "str\0" - change to "str|*.str\0" |
|
376 |
c_exception = reallocf(c_exception, c_len+3+c_len+1); |
|
377 |
if (!c_exception) return NULL; |
|
378 |
||
379 |
strncpy(c_exception+c_len, "|*.", 3); |
|
380 |
strncpy(c_exception+c_len+3, c_exception, c_len); |
|
381 |
c_exception[c_len+3+c_len] = '\0'; |
|
382 |
return c_exception; |
|
383 |
} |
|
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 | 396 |
|
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 | 399 |
*/ |
400 |
void setProxyProperties(java_props_t *sProps) { |
|
401 |
if (sProps == NULL) return; |
|
402 |
||
403 |
char buf[16]; /* Used for %d of an int - 16 is plenty */ |
|
404 |
CFStringRef |
|
405 |
cf_httpHost = NULL, |
|
406 |
cf_httpsHost = NULL, |
|
407 |
cf_ftpHost = NULL, |
|
408 |
cf_socksHost = NULL, |
|
409 |
cf_gopherHost = NULL; |
|
410 |
int |
|
411 |
httpPort = 80, // Default proxy port values |
|
412 |
httpsPort = 443, |
|
413 |
ftpPort = 21, |
|
414 |
socksPort = 1080, |
|
415 |
gopherPort = 70; |
|
416 |
||
417 |
CFDictionaryRef dict = SCDynamicStoreCopyProxies(NULL); |
|
418 |
if (dict == NULL) return; |
|
419 |
||
420 |
/* Read the proxy exceptions list */ |
|
421 |
CFArrayRef cf_list = CFDictionaryGetValue(dict, kSCPropNetProxiesExceptionsList); |
|
422 |
||
423 |
CFMutableStringRef cf_exceptionList = NULL; |
|
424 |
if (cf_list != NULL) { |
|
425 |
CFIndex len = CFArrayGetCount(cf_list), idx; |
|
426 |
||
427 |
cf_exceptionList = CFStringCreateMutable(NULL, 0); |
|
428 |
for (idx = (CFIndex)0; idx < len; idx++) { |
|
429 |
CFStringRef cf_ehost; |
|
430 |
if ((cf_ehost = CFArrayGetValueAtIndex(cf_list, idx))) { |
|
431 |
/* Convert this exception from Mac OS X syntax to Java syntax. |
|
432 |
See Radar #3441134 for details. This may generate a string |
|
433 |
with multiple Java exceptions separated by '|'. */ |
|
434 |
char *c_exception = createConvertedException(cf_ehost); |
|
435 |
if (c_exception) { |
|
436 |
/* Append the host to the list of exclusions. */ |
|
437 |
if (CFStringGetLength(cf_exceptionList) > 0) { |
|
438 |
CFStringAppendCString(cf_exceptionList, "|", kCFStringEncodingMacRoman); |
|
439 |
} |
|
440 |
CFStringAppendCString(cf_exceptionList, c_exception, kCFStringEncodingMacRoman); |
|
441 |
free(c_exception); |
|
442 |
} |
|
443 |
} |
|
444 |
} |
|
445 |
} |
|
446 |
||
447 |
if (cf_exceptionList != NULL) { |
|
448 |
if (CFStringGetLength(cf_exceptionList) > 0) { |
|
449 |
sProps->exceptionList = createUTF8CString(cf_exceptionList); |
|
450 |
} |
|
451 |
CFRelease(cf_exceptionList); |
|
452 |
} |
|
453 |
||
454 |
#define CHECK_PROXY(protocol, PROTOCOL) \ |
|
455 |
sProps->protocol##ProxyEnabled = \ |
|
456 |
getProxyInfoForProtocol(dict, kSCPropNetProxies##PROTOCOL##Enable, \ |
|
457 |
kSCPropNetProxies##PROTOCOL##Proxy, \ |
|
458 |
kSCPropNetProxies##PROTOCOL##Port, \ |
|
459 |
&cf_##protocol##Host, &protocol##Port); \ |
|
460 |
if (sProps->protocol##ProxyEnabled) { \ |
|
461 |
sProps->protocol##Host = createUTF8CString(cf_##protocol##Host); \ |
|
462 |
snprintf(buf, sizeof(buf), "%d", protocol##Port); \ |
|
463 |
sProps->protocol##Port = malloc(strlen(buf) + 1); \ |
|
464 |
strcpy(sProps->protocol##Port, buf); \ |
|
465 |
} |
|
466 |
||
467 |
CHECK_PROXY(http, HTTP); |
|
468 |
CHECK_PROXY(https, HTTPS); |
|
469 |
CHECK_PROXY(ftp, FTP); |
|
470 |
CHECK_PROXY(socks, SOCKS); |
|
471 |
CHECK_PROXY(gopher, Gopher); |
|
472 |
||
473 |
#undef CHECK_PROXY |
|
474 |
||
475 |
CFRelease(dict); |
|
476 |
} |