| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,7 +1,7 @@ | |||
| 1 | 1 | // -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- | |
| 2 | 2 | ||
| 3 | - // if this code looks shitty, that's because it is. people are likely to have | ||
| 4 | - // the durndest things in their CLASSPATH and QTJAVA environment variables. | ||
| 3 | + // if this code looks shitty, that's because it is. people are likely | ||
| 4 | + // to have the durndest things in their CLASSPATH environment variable. | ||
| 5 | 5 | // mostly because installers often mangle them without the user knowing. | |
| 6 | 6 | // so who knows where and when the quotes will show up. the code below is | |
| 7 | 7 | // based on a couple years of trial and error with processing releases. | |
@@ -12,6 +12,11 @@ | |||
| 12 | 12 | // or directories) are also stripped out before being set. | |
| 13 | 13 | // (<A HREF="http://dev.processing.org/bugs/show_bug.cgi?id=112">Bug 112</A>) | |
| 14 | 14 | ||
| 15 | + // For revision 0201 (love that symmetry), the 'lib' folder was added to | ||
| 16 | + // the java.library.path, so that we can hide the pile of DLLs included | ||
| 17 | + // with some libraries (I'm looking at you, video), inside the lib folder. | ||
| 18 | + // QTJAVA mess was also excised, now that we're switching to gstreamer. | ||
| 19 | + | ||
| 15 | 20 | // The size of all of the strings was made sort of ambiguously large, since | |
| 16 | 21 | // 1) nothing is hurt by allocating an extra few bytes temporarily and | |
| 17 | 22 | // 2) if the user has a long path, and it gets copied five times over for the | |
@@ -36,6 +41,8 @@ char *mallocChars(int count); | |||
| 36 | 41 | void removeQuotes(char *quoted); | |
| 37 | 42 | void removeTrailingSlash(char *slashed); | |
| 38 | 43 | ||
| 44 | + #define DEBUG | ||
| 45 | + | ||
| 39 | 46 | int STDCALL | |
| 40 | 47 | WinMain (HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmd, int nShow) | |
| 41 | 48 | { | |
@@ -73,18 +80,6 @@ WinMain (HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmd, int nShow) | |||
| 73 | 80 | exe_directory); | |
| 74 | 81 | MessageBox(NULL, app_classpath, "Folder Missing", MB_OK); | |
| 75 | 82 | return 0; | |
| 76 | - /* | ||
| 77 | - sprintf(app_classpath, | ||
| 78 | - "%s\\lib;" | ||
| 79 | - "%s\\lib\\pde.jar;" | ||
| 80 | - "%s\\lib\\core.jar;" | ||
| 81 | - "%s\\lib\\jna.jar;" | ||
| 82 | - "%s\\lib\\ecj.jar;" | ||
| 83 | - "%s\\lib\\antlr.jar;", | ||
| 84 | - exe_directory, | ||
| 85 | - exe_directory, exe_directory, | ||
| 86 | - exe_directory, exe_directory, exe_directory); | ||
| 87 | - */ | ||
| 88 | 83 | ||
| 89 | 84 | } else { | |
| 90 | 85 | fgets(java_args, 511, argsfile); | |
@@ -94,9 +89,11 @@ WinMain (HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmd, int nShow) | |||
| 94 | 89 | fgets(jar_list, 511, argsfile); | |
| 95 | 90 | removeLineEndings(jar_list); | |
| 96 | 91 | ||
| 97 | - //MessageBox(NULL, java_args, "args", MB_OK); | ||
| 98 | - //MessageBox(NULL, java_main_class, "class", MB_OK); | ||
| 99 | - //MessageBox(NULL, jar_list, "jarlist", MB_OK); | ||
| 92 | + #ifdef DEBUG | ||
| 93 | + MessageBox(NULL, java_args, "args", MB_OK); | ||
| 94 | + MessageBox(NULL, java_main_class, "class", MB_OK); | ||
| 95 | + MessageBox(NULL, jar_list, "jarlist", MB_OK); | ||
| 96 | + #endif | ||
| 100 | 97 | ||
| 101 | 98 | app_classpath[0] = 0; | |
| 102 | 99 | char *jar = (char*) strtok(jar_list, ","); | |
@@ -120,8 +117,7 @@ WinMain (HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmd, int nShow) | |||
| 120 | 117 | strcat(testpath, "\\java\\bin\\java.exe"); | |
| 121 | 118 | FILE *fp = fopen(testpath, "rb"); | |
| 122 | 119 | int local_jre_installed = (fp != NULL); | |
| 123 | - //char *rt_jar = (fp == NULL) ? "" : "java\\lib\\rt.jar;"; | ||
| 124 | - if (fp != NULL) fclose(fp); // argh! this was probably causing trouble | ||
| 120 | + if (fp != NULL) fclose(fp); | ||
| 125 | 121 | ||
| 126 | 122 | //const char *envClasspath = getenv("CLASSPATH"); | |
| 127 | 123 | //char *env_classpath = (char *)malloc(16384 * sizeof(char)); | |
@@ -130,100 +126,6 @@ WinMain (HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmd, int nShow) | |||
| 130 | 126 | // and causes more trouble than it's worth [0060] | |
| 131 | 127 | //env_classpath[0] = 0; | |
| 132 | 128 | ||
| 133 | - /* | ||
| 134 | - // keep this code around since may be re-enabled later | ||
| 135 | - if (getenv("CLASSPATH") != NULL) { | ||
| 136 | - strcpy(env_classpath, getenv("CLASSPATH")); | ||
| 137 | - if (env_classpath[0] == '\"') { | ||
| 138 | - // starting quote in classpath.. yech | ||
| 139 | - env_classpath++; // shitty.. i know.. | ||
| 140 | - | ||
| 141 | - int len = strlen(env_classpath); | ||
| 142 | - if (env_classpath[len-1] == '\"') { | ||
| 143 | - env_classpath[len-1] = 0; | ||
| 144 | - } else { | ||
| 145 | - // a starting quote but no ending quote.. ugh | ||
| 146 | - // maybe throw an error | ||
| 147 | - } | ||
| 148 | - } | ||
| 149 | - int last = strlen(env_classpath); | ||
| 150 | - env_classpath[last++] = ';'; | ||
| 151 | - env_classpath[last] = 0; | ||
| 152 | - } else { | ||
| 153 | - env_classpath[0] = 0; | ||
| 154 | - } | ||
| 155 | - */ | ||
| 156 | - | ||
| 157 | - char *qtjava_path = (char *)malloc(16384 * sizeof(char)); | ||
| 158 | - qtjava_path[0] = 0; | ||
| 159 | - | ||
| 160 | - if (getenv("QTJAVA") != NULL) { | ||
| 161 | - //char *qtjava_temp = (char *)malloc(16384 * sizeof(char)); | ||
| 162 | - strcpy(qtjava_path, getenv("QTJAVA")); | ||
| 163 | - removeQuotes(qtjava_path); | ||
| 164 | - | ||
| 165 | - /* | ||
| 166 | - //MessageBox(NULL, qtjava_temp, "QTJAVA", MB_OK); | ||
| 167 | - if (qtjava_temp[0] == '\"') { // has quotes | ||
| 168 | - // remove quotes by subsetting string by two | ||
| 169 | - int qtjava_repaired_length = strlen(qtjava_temp) - 2; | ||
| 170 | - strncpy(qtjava_path, &qtjava_temp[1], qtjava_repaired_length); | ||
| 171 | - // terminate the string since strncpy ain't gonna do it | ||
| 172 | - qtjava_path[qtjava_repaired_length] = 0; | ||
| 173 | - //MessageBox(NULL, qtjava_path, "QTJAVA", MB_OK); | ||
| 174 | - } else { | ||
| 175 | - strcpy(qtjava_path, getenv("QTJAVA")); | ||
| 176 | - } | ||
| 177 | - */ | ||
| 178 | - | ||
| 179 | - FILE *fp = fopen(qtjava_path, "rb"); | ||
| 180 | - if (fp != NULL) { | ||
| 181 | - fclose(fp); // found it, all set | ||
| 182 | - strcat(qtjava_path, ";"); // add path separator | ||
| 183 | - //MessageBox(NULL, "found 1", "msg", MB_OK); | ||
| 184 | - //MessageBox(NULL, qtjava_path, "QTJAVA after strcat", MB_OK); | ||
| 185 | - } else { | ||
| 186 | - qtjava_path[0] = 0; // not a valid path | ||
| 187 | - } | ||
| 188 | - //} else { | ||
| 189 | - //MessageBox(NULL, "no qtjava set", "mess", MB_OK); | ||
| 190 | - } | ||
| 191 | - | ||
| 192 | - if (qtjava_path[0] == 0) { // not set yet | ||
| 193 | - //if (getenv("WINDIR") == NULL) { | ||
| 194 | - // uh-oh.. serious problem.. gonna have to report this | ||
| 195 | - // but hopefully WINDIR is set on win98 too | ||
| 196 | - //} else { | ||
| 197 | - | ||
| 198 | - strcpy(qtjava_path, getenv("WINDIR")); | ||
| 199 | - strcat(qtjava_path, "\\SYSTEM32\\QTJava.zip"); | ||
| 200 | - | ||
| 201 | - FILE *fp = fopen(qtjava_path, "rb"); | ||
| 202 | - if (fp != NULL) { | ||
| 203 | - fclose(fp); // found it, all set | ||
| 204 | - strcat(qtjava_path, ";"); // add path separator | ||
| 205 | - //MessageBox(NULL, "found 2", "msg", MB_OK); | ||
| 206 | - } else { | ||
| 207 | - qtjava_path[0] = 0; // not a valid path | ||
| 208 | - } | ||
| 209 | - } | ||
| 210 | - | ||
| 211 | - if (qtjava_path[0] == 0) { | ||
| 212 | - strcpy(qtjava_path, getenv("WINDIR")); | ||
| 213 | - strcat(qtjava_path, "\\SYSTEM\\QTJava.zip"); | ||
| 214 | - | ||
| 215 | - fp = fopen(qtjava_path, "rb"); | ||
| 216 | - if (fp != NULL) { | ||
| 217 | - fclose(fp); // found it, all set | ||
| 218 | - strcat(qtjava_path, ";"); // add path separator | ||
| 219 | - //MessageBox(NULL, "found 3", "msg", MB_OK); | ||
| 220 | - } else { | ||
| 221 | - // doesn't seem to be installed, which is a problem. | ||
| 222 | - // but the error will be reported by the pde | ||
| 223 | - qtjava_path[0] = 0; | ||
| 224 | - } | ||
| 225 | - } | ||
| 226 | - | ||
| 227 | 129 | // don't put quotes around contents of cp, even though %s might have | |
| 228 | 130 | // spaces in it. don't put quotes in it, because it's setting the | |
| 229 | 131 | // environment variable for CLASSPATH, not being included on the | |
@@ -236,19 +138,18 @@ WinMain (HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmd, int nShow) | |||
| 236 | 138 | sprintf(local_jre, "%s\\java\\lib\\rt.jar;%s\\java\\lib\\tools.jar;", exe_directory, exe_directory); | |
| 237 | 139 | strcat(cp, local_jre); | |
| 238 | 140 | } | |
| 239 | - strcat(cp, qtjava_path); | ||
| 240 | 141 | ||
| 241 | 142 | char *clean_cp = scrubPath(cp); | |
| 242 | 143 | //if (!SetEnvironmentVariable("CLASSPATH", cp)) { | |
| 243 | 144 | if (!SetEnvironmentVariable("CLASSPATH", clean_cp)) { | |
| 244 | 145 | MessageBox(NULL, "Could not set CLASSPATH environment variable", | |
| 245 | 146 | "Processing Error", MB_OK); | |
| 246 | - return 0; | ||
| 147 | + return 1; | ||
| 247 | 148 | } | |
| 248 | 149 | ||
| 249 | - //MessageBox(NULL, "2", "checking", MB_OK); | ||
| 250 | - | ||
| 251 | - //char *env_path = (char *)malloc(strlen(getenv("PATH")) * sizeof(char)); | ||
| 150 | + #ifdef DEBUG | ||
| 151 | + MessageBox(NULL, "done with classpath cleaning", "2", MB_OK); | ||
| 152 | + #endif | ||
| 252 | 153 | ||
| 253 | 154 | int env_path_length = strlen(getenv("PATH")); | |
| 254 | 155 | char *env_path = mallocChars(env_path_length); | |
@@ -300,18 +201,23 @@ WinMain (HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmd, int nShow) | |||
| 300 | 201 | // exe_directory is the name path to the current application | |
| 301 | 202 | ||
| 302 | 203 | if (local_jre_installed) { | |
| 303 | - //strcpy(executable, exe_directory); | ||
| 204 | + strcpy(executable, exe_directory); | ||
| 304 | 205 | // copy in the path for javaw, relative to launcher.exe | |
| 305 | - //strcat(executable, "\\java\\bin\\javaw.exe"); | ||
| 306 | - sprintf(executable, "%s\\java\\bin\\javaw.exe", exe_directory); | ||
| 206 | + strcat(executable, "\\java\\bin\\javaw.exe"); | ||
| 307 | 207 | } else { | |
| 208 | + #ifdef DEBUG | ||
| 209 | + strcpy(executable, "java.exe"); | ||
| 210 | + #else | ||
| 308 | 211 | strcpy(executable, "javaw.exe"); | |
| 212 | + #endif | ||
| 309 | 213 | } | |
| 310 | 214 | ||
| 311 | 215 | /* | |
| 312 | 216 | SHELLEXECUTEINFO ShExecInfo; | |
| 313 | 217 | ||
| 314 | - //MessageBox(NULL, executable, outgoing_cmd_line, MB_OK); | ||
| 218 | + #ifdef DEBUG | ||
| 219 | + MessageBox(NULL, outgoing_cmd_line, executable, MB_OK); | ||
| 220 | + #endif | ||
| 315 | 221 | ||
| 316 | 222 | // set up the execution info | |
| 317 | 223 | ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO); | |
@@ -364,7 +270,7 @@ WinMain (HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmd, int nShow) | |||
| 364 | 270 | si.cb = sizeof(si); | |
| 365 | 271 | int wait = 0; | |
| 366 | 272 | ||
| 367 | - DWORD dwExitCode = -1; | ||
| 273 | + DWORD dwExitCode = (DWORD) -1; | ||
| 368 | 274 | char cmdline[32768]; | |
| 369 | 275 | //executable; | |
| 370 | 276 | //outgoing_cmd_line; | |
@@ -383,8 +289,9 @@ WinMain (HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmd, int nShow) | |||
| 383 | 289 | GetExitCodeProcess(pi.hProcess, &dwExitCode); | |
| 384 | 290 | //debug("Exit code:\t%d\n", dwExitCode); | |
| 385 | 291 | //closeHandles(); | |
| 386 | - char[128] big_trouble; | ||
| 387 | - sprintf(big_trouble, "Sorry, could not launch. (Error %d)", dwExitCode); | ||
| 292 | + char big_trouble[128]; | ||
| 293 | + sprintf(big_trouble, "Sorry, could not launch. (Error %d)", | ||
| 294 | + (int) dwExitCode); | ||
| 388 | 295 | MessageBox(NULL, big_trouble, "Apologies", MB_OK); | |
| 389 | 296 | } else { | |
| 390 | 297 | dwExitCode = 0; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments