1 /*
2 * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
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 <dlfcn.h>
27 #include <sys/socket.h>
28 #include <netinet/in.h>
29 #include <arpa/inet.h>
30
31 #include <Security/AuthSession.h>
32 #include <CoreFoundation/CoreFoundation.h>
33 #include <SystemConfiguration/SystemConfiguration.h>
34 #include <Foundation/Foundation.h>
35
36 #include "java_props_macosx.h"
37
38
39 // need dlopen/dlsym trick to avoid pulling in JavaRuntimeSupport before libjava.dylib is loaded
40 static void *getJRSFramework() {
41 static void *jrsFwk = NULL;
42 if (jrsFwk == NULL) {
43 jrsFwk = dlopen("/System/Library/Frameworks/JavaVM.framework/Frameworks/JavaRuntimeSupport.framework/JavaRuntimeSupport", RTLD_LAZY | RTLD_LOCAL);
44 }
45 return jrsFwk;
46 }
47
48 char *getPosixLocale(int cat) {
49 char *lc = setlocale(cat, NULL);
50 if ((lc == NULL) || (strcmp(lc, "C") == 0)) {
51 lc = getenv("LANG");
52 }
53 if (lc == NULL) return NULL;
54 return strdup(lc);
55 }
56
57 #define LOCALEIDLENGTH 128
58 char *getMacOSXLocale(int cat) {
59 switch (cat) {
60 case LC_MESSAGES:
61 {
62 void *jrsFwk = getJRSFramework();
63 if (jrsFwk == NULL) return NULL;
64
|
1 /*
2 * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
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 <dlfcn.h>
27 #include <sys/socket.h>
28 #include <netinet/in.h>
29 #include <arpa/inet.h>
30
31 #include <Security/AuthSession.h>
32 #include <CoreFoundation/CoreFoundation.h>
33 #include <SystemConfiguration/SystemConfiguration.h>
34 #include <Foundation/Foundation.h>
35
36 #include "java_props_macosx.h"
37
38 // need dlopen/dlsym trick to avoid pulling in JavaRuntimeSupport before libjava.dylib is loaded
39 static void *getJRSFramework() {
40 static void *jrsFwk = NULL;
41 #ifndef STATIC_BUILD
42 // JavaRuntimeSupport doesn't support static Java runtimes
43 if (jrsFwk == NULL) {
44 jrsFwk = dlopen("/System/Library/Frameworks/JavaVM.framework/Frameworks/JavaRuntimeSupport.framework/JavaRuntimeSupport", RTLD_LAZY | RTLD_LOCAL);
45 }
46 #endif
47 return jrsFwk;
48 }
49
50 char *getPosixLocale(int cat) {
51 char *lc = setlocale(cat, NULL);
52 if ((lc == NULL) || (strcmp(lc, "C") == 0)) {
53 lc = getenv("LANG");
54 }
55 if (lc == NULL) return NULL;
56 return strdup(lc);
57 }
58
59 #define LOCALEIDLENGTH 128
60 char *getMacOSXLocale(int cat) {
61 switch (cat) {
62 case LC_MESSAGES:
63 {
64 void *jrsFwk = getJRSFramework();
65 if (jrsFwk == NULL) return NULL;
66
|