1 /*
2 * Copyright (c) 1995, 2016, 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
68 "version='" _CRT_ASSEMBLY_VERSION "' " \
69 "processorArchitecture='amd64' " \
70 "publicKeyToken='" _VC_ASSEMBLY_PUBLICKEYTOKEN "'\"")
71
72 #endif /* _M_AMD64 */
73 #endif /* _MSC_VER > 1400 && _MSC_VER < 1600 */
74 #endif /* _MSC_VER */
75
76 /*
77 * Entry point.
78 */
79 #ifdef JAVAW
80
81 char **__initenv;
82
83 int WINAPI
84 WinMain(HINSTANCE inst, HINSTANCE previnst, LPSTR cmdline, int cmdshow)
85 {
86 int margc;
87 char** margv;
88 const jboolean const_javaw = JNI_TRUE;
89
90 __initenv = _environ;
91
92 #else /* JAVAW */
93 int
94 main(int argc, char **argv)
95 {
96 int margc;
97 char** margv;
98 const jboolean const_javaw = JNI_FALSE;
99 #endif /* JAVAW */
100
101 JLI_InitArgProcessing(!HAS_JAVA_ARGS, const_disable_argfile);
102
103 #ifdef _WIN32
104 {
105 int i = 0;
106 if (getenv(JLDEBUG_ENV_ENTRY) != NULL) {
107 printf("Windows original main args:\n");
108 for (i = 0 ; i < __argc ; i++) {
109 printf("wwwd_args[%d] = %s\n", i, __argv[i]);
110 }
111 }
112 }
113 JLI_CmdToArgs(GetCommandLine());
114 margc = JLI_GetStdArgc();
115 // add one more to mark the end
116 margv = (char **)JLI_MemAlloc((margc + 1) * (sizeof(char *)));
117 {
118 int i = 0;
119 StdArg *stdargs = JLI_GetStdArgs();
120 for (i = 0 ; i < margc ; i++) {
121 margv[i] = stdargs[i].arg;
122 }
147 if (NULL == argsInFile) {
148 JLI_List_add(args, JLI_StringDup(argv[i]));
149 } else {
150 int cnt, idx;
151 cnt = argsInFile->size;
152 for (idx = 0; idx < cnt; idx++) {
153 JLI_List_add(args, argsInFile->elements[idx]);
154 }
155 // Shallow free, we reuse the string to avoid copy
156 JLI_MemFree(argsInFile->elements);
157 JLI_MemFree(argsInFile);
158 }
159 }
160 margc = args->size;
161 // add the NULL pointer at argv[argc]
162 JLI_List_add(args, NULL);
163 margv = args->elements;
164 }
165 #endif /* WIN32 */
166 return JLI_Launch(margc, margv,
167 sizeof(const_jargs) / sizeof(char *), const_jargs,
168 0, NULL,
169 VERSION_STRING,
170 DOT_VERSION,
171 (const_progname != NULL) ? const_progname : *margv,
172 (const_launcher != NULL) ? const_launcher : *margv,
173 HAS_JAVA_ARGS,
174 const_cpwildcard, const_javaw, 0);
175 }
|
1 /*
2 * Copyright (c) 1995, 2017, 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
68 "version='" _CRT_ASSEMBLY_VERSION "' " \
69 "processorArchitecture='amd64' " \
70 "publicKeyToken='" _VC_ASSEMBLY_PUBLICKEYTOKEN "'\"")
71
72 #endif /* _M_AMD64 */
73 #endif /* _MSC_VER > 1400 && _MSC_VER < 1600 */
74 #endif /* _MSC_VER */
75
76 /*
77 * Entry point.
78 */
79 #ifdef JAVAW
80
81 char **__initenv;
82
83 int WINAPI
84 WinMain(HINSTANCE inst, HINSTANCE previnst, LPSTR cmdline, int cmdshow)
85 {
86 int margc;
87 char** margv;
88 int jargc;
89 char** jargv;
90 const jboolean const_javaw = JNI_TRUE;
91
92 __initenv = _environ;
93
94 #else /* JAVAW */
95 int
96 main(int argc, char **argv)
97 {
98 int margc;
99 char** margv;
100 int jargc;
101 char** jargv;
102 const jboolean const_javaw = JNI_FALSE;
103 #endif /* JAVAW */
104 {
105 int i, main_jargc, extra_jargc;
106 JLI_List list;
107
108 main_jargc = (sizeof(const_jargs) / sizeof(char *)) > 1
109 ? sizeof(const_jargs) / sizeof(char *)
110 : 0; // ignore the null terminator index
111
112 extra_jargc = (sizeof(const_extra_jargs) / sizeof(char *)) > 1
113 ? sizeof(const_extra_jargs) / sizeof(char *)
114 : 0; // ignore the null terminator index
115
116 if (main_jargc > 0 && extra_jargc > 0) { // combine extra java args
117 jargc = main_jargc + extra_jargc;
118 list = JLI_List_new(jargc + 1);
119
120 for (i = 0 ; i < extra_jargc; i++) {
121 JLI_List_add(list, JLI_StringDup(const_extra_jargs[i]));
122 }
123
124 for (i = 0 ; i < main_jargc ; i++) {
125 JLI_List_add(list, JLI_StringDup(const_jargs[i]));
126 }
127
128 // terminate the list
129 JLI_List_add(list, NULL);
130 jargv = list->elements;
131 } else if (extra_jargc > 0) { // should never happen
132 fprintf(stderr, "EXTRA_JAVA_ARGS defined without JAVA_ARGS");
133 abort();
134 } else { // no extra args, business as usual
135 jargc = main_jargc;
136 jargv = (char **) const_jargs;
137 }
138 }
139
140 JLI_InitArgProcessing(jargc > 0, const_disable_argfile);
141
142 #ifdef _WIN32
143 {
144 int i = 0;
145 if (getenv(JLDEBUG_ENV_ENTRY) != NULL) {
146 printf("Windows original main args:\n");
147 for (i = 0 ; i < __argc ; i++) {
148 printf("wwwd_args[%d] = %s\n", i, __argv[i]);
149 }
150 }
151 }
152 JLI_CmdToArgs(GetCommandLine());
153 margc = JLI_GetStdArgc();
154 // add one more to mark the end
155 margv = (char **)JLI_MemAlloc((margc + 1) * (sizeof(char *)));
156 {
157 int i = 0;
158 StdArg *stdargs = JLI_GetStdArgs();
159 for (i = 0 ; i < margc ; i++) {
160 margv[i] = stdargs[i].arg;
161 }
186 if (NULL == argsInFile) {
187 JLI_List_add(args, JLI_StringDup(argv[i]));
188 } else {
189 int cnt, idx;
190 cnt = argsInFile->size;
191 for (idx = 0; idx < cnt; idx++) {
192 JLI_List_add(args, argsInFile->elements[idx]);
193 }
194 // Shallow free, we reuse the string to avoid copy
195 JLI_MemFree(argsInFile->elements);
196 JLI_MemFree(argsInFile);
197 }
198 }
199 margc = args->size;
200 // add the NULL pointer at argv[argc]
201 JLI_List_add(args, NULL);
202 margv = args->elements;
203 }
204 #endif /* WIN32 */
205 return JLI_Launch(margc, margv,
206 jargc, (const char**) jargv,
207 0, NULL,
208 VERSION_STRING,
209 DOT_VERSION,
210 (const_progname != NULL) ? const_progname : *margv,
211 (const_launcher != NULL) ? const_launcher : *margv,
212 jargc > 0,
213 const_cpwildcard, const_javaw, 0);
214 }
|