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
27 /*
28 * This file contains the main entry point into the launcher code
29 * this is the only file which will be repeatedly compiled by other
30 * tools. The rest of the files will be linked in.
31 */
32
33 #include "defines.h"
34
35 #ifdef _MSC_VER
36 #if _MSC_VER > 1400 && _MSC_VER < 1600
37
38 /*
39 * When building for Microsoft Windows, main has a dependency on msvcr??.dll.
40 *
41 * When using Visual Studio 2005 or 2008, that must be recorded in
42 * the [java,javaw].exe.manifest file.
43 *
44 * As of VS2010 (ver=1600), the runtimes again no longer need manifests.
45 *
46 * Reference:
47 * C:/Program Files/Microsoft SDKs/Windows/v6.1/include/crtdefs.h
48 */
49 #include <crtassem.h>
50 #ifdef _M_IX86
51
52 #pragma comment(linker,"/manifestdependency:\"type='win32' " \
53 "name='" __LIBRARIES_ASSEMBLY_NAME_PREFIX ".CRT' " \
79
80 char **__initenv;
81
82 int WINAPI
83 WinMain(HINSTANCE inst, HINSTANCE previnst, LPSTR cmdline, int cmdshow)
84 {
85 int margc;
86 char** margv;
87 const jboolean const_javaw = JNI_TRUE;
88
89 __initenv = _environ;
90
91 #else /* JAVAW */
92 int
93 main(int argc, char **argv)
94 {
95 int margc;
96 char** margv;
97 const jboolean const_javaw = JNI_FALSE;
98 #endif /* JAVAW */
99 #ifdef _WIN32
100 {
101 int i = 0;
102 if (getenv(JLDEBUG_ENV_ENTRY) != NULL) {
103 printf("Windows original main args:\n");
104 for (i = 0 ; i < __argc ; i++) {
105 printf("wwwd_args[%d] = %s\n", i, __argv[i]);
106 }
107 }
108 }
109 JLI_CmdToArgs(GetCommandLine());
110 margc = JLI_GetStdArgc();
111 // add one more to mark the end
112 margv = (char **)JLI_MemAlloc((margc + 1) * (sizeof(char *)));
113 {
114 int i = 0;
115 StdArg *stdargs = JLI_GetStdArgs();
116 for (i = 0 ; i < margc ; i++) {
117 margv[i] = stdargs[i].arg;
118 }
119 margv[i] = NULL;
120 }
121 #else /* *NIXES */
122 margc = argc;
123 margv = argv;
124 #endif /* WIN32 */
125 return JLI_Launch(margc, margv,
126 sizeof(const_jargs) / sizeof(char *), const_jargs,
127 sizeof(const_appclasspath) / sizeof(char *), const_appclasspath,
128 FULL_VERSION,
129 DOT_VERSION,
130 (const_progname != NULL) ? const_progname : *margv,
131 (const_launcher != NULL) ? const_launcher : *margv,
132 HAS_JAVA_ARGS,
133 const_cpwildcard, const_javaw, const_ergo_class);
134 }
|
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
27 /*
28 * This file contains the main entry point into the launcher code
29 * this is the only file which will be repeatedly compiled by other
30 * tools. The rest of the files will be linked in.
31 */
32
33 #include "defines.h"
34 #include "jli_util.h"
35
36 #ifdef _MSC_VER
37 #if _MSC_VER > 1400 && _MSC_VER < 1600
38
39 /*
40 * When building for Microsoft Windows, main has a dependency on msvcr??.dll.
41 *
42 * When using Visual Studio 2005 or 2008, that must be recorded in
43 * the [java,javaw].exe.manifest file.
44 *
45 * As of VS2010 (ver=1600), the runtimes again no longer need manifests.
46 *
47 * Reference:
48 * C:/Program Files/Microsoft SDKs/Windows/v6.1/include/crtdefs.h
49 */
50 #include <crtassem.h>
51 #ifdef _M_IX86
52
53 #pragma comment(linker,"/manifestdependency:\"type='win32' " \
54 "name='" __LIBRARIES_ASSEMBLY_NAME_PREFIX ".CRT' " \
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 }
123 margv[i] = NULL;
124 }
125 #else /* *NIXES */
126 {
127 // accommodate the NULL at the end
128 JLI_List args = JLI_List_new(argc + 1);
129 int i = 0;
130 for (i = 0; i < argc; i++) {
131 JLI_List argsInFile = JLI_PreprocessArg(argv[i]);
132 if (NULL == argsInFile) {
133 JLI_List_add(args, JLI_StringDup(argv[i]));
134 } else {
135 int cnt, idx;
136 cnt = argsInFile->size;
137 for (idx = 0; idx < cnt; idx++) {
138 JLI_List_add(args, argsInFile->elements[idx]);
139 }
140 // Shallow free, we reuse the string to avoid copy
141 JLI_MemFree(argsInFile->elements);
142 JLI_MemFree(argsInFile);
143 }
144 }
145 margc = args->size;
146 // add the NULL pointer at argv[argc]
147 JLI_List_add(args, NULL);
148 margv = args->elements;
149 }
150 #endif /* WIN32 */
151 return JLI_Launch(margc, margv,
152 sizeof(const_jargs) / sizeof(char *), const_jargs,
153 sizeof(const_appclasspath) / sizeof(char *), const_appclasspath,
154 FULL_VERSION,
155 DOT_VERSION,
156 (const_progname != NULL) ? const_progname : *margv,
157 (const_launcher != NULL) ? const_launcher : *margv,
158 HAS_JAVA_ARGS,
159 const_cpwildcard, const_javaw, const_ergo_class);
160 }
|