1 /*
2 * Copyright (c) 2015, 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
61 IN_TOKEN
62 };
63
64 typedef struct {
65 enum STATE state;
66 const char* cptr;
67 const char* eob;
68 char quote_char;
69 JLI_List parts;
70 } __ctx_args;
71
72 #define NOT_FOUND -1
73 static int firstAppArgIndex = NOT_FOUND;
74
75 static jboolean expectingNoDashArg = JNI_FALSE;
76 // Initialize to 1, as the first argument is the app name and not preprocessed
77 static size_t argsCount = 1;
78 static jboolean stopExpansion = JNI_FALSE;
79 static jboolean relaunch = JNI_FALSE;
80
81 void JLI_InitArgProcessing(jboolean isJava, jboolean disableArgFile) {
82 // No expansion for relaunch
83 if (argsCount != 1) {
84 relaunch = JNI_TRUE;
85 stopExpansion = JNI_TRUE;
86 argsCount = 1;
87 } else {
88 stopExpansion = disableArgFile;
89 }
90
91 expectingNoDashArg = JNI_FALSE;
92
93 // for tools, this value remains 0 all the time.
94 firstAppArgIndex = isJava ? NOT_FOUND : 0;
95 }
96
97 int JLI_GetAppArgIndex() {
98 // Will be 0 for tools
99 return firstAppArgIndex;
100 }
101
102 static void checkArg(const char *arg) {
103 size_t idx = 0;
104 argsCount++;
105
106 // All arguments arrive here must be a launcher argument,
107 // ie. by now, all argfile expansions must have been performed.
108 if (*arg == '-') {
109 expectingNoDashArg = JNI_FALSE;
110 if (IsWhiteSpaceOption(arg)) {
111 // expect an argument
112 expectingNoDashArg = JNI_TRUE;
113
114 if (JLI_StrCmp(arg, "-jar") == 0 ||
|
1 /*
2 * Copyright (c) 2015, 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
61 IN_TOKEN
62 };
63
64 typedef struct {
65 enum STATE state;
66 const char* cptr;
67 const char* eob;
68 char quote_char;
69 JLI_List parts;
70 } __ctx_args;
71
72 #define NOT_FOUND -1
73 static int firstAppArgIndex = NOT_FOUND;
74
75 static jboolean expectingNoDashArg = JNI_FALSE;
76 // Initialize to 1, as the first argument is the app name and not preprocessed
77 static size_t argsCount = 1;
78 static jboolean stopExpansion = JNI_FALSE;
79 static jboolean relaunch = JNI_FALSE;
80
81 void JLI_InitArgProcessing(jboolean hasJavaArgs, jboolean disableArgFile) {
82 // No expansion for relaunch
83 if (argsCount != 1) {
84 relaunch = JNI_TRUE;
85 stopExpansion = JNI_TRUE;
86 argsCount = 1;
87 } else {
88 stopExpansion = disableArgFile;
89 }
90
91 expectingNoDashArg = JNI_FALSE;
92
93 // for tools, this value remains 0 all the time.
94 firstAppArgIndex = hasJavaArgs ? 0: NOT_FOUND;
95 }
96
97 int JLI_GetAppArgIndex() {
98 // Will be 0 for tools
99 return firstAppArgIndex;
100 }
101
102 static void checkArg(const char *arg) {
103 size_t idx = 0;
104 argsCount++;
105
106 // All arguments arrive here must be a launcher argument,
107 // ie. by now, all argfile expansions must have been performed.
108 if (*arg == '-') {
109 expectingNoDashArg = JNI_FALSE;
110 if (IsWhiteSpaceOption(arg)) {
111 // expect an argument
112 expectingNoDashArg = JNI_TRUE;
113
114 if (JLI_StrCmp(arg, "-jar") == 0 ||
|