Mercurial > mxe-octave
annotate installer-files/octave-launch.c @ 5955:f42752ce0ae3
new octave-launcher.exe program from John Donoghue
* installer-files/octave-launch.c: New file.
* binary-dist-rules.mk (octave-launch,
installer-files/octave-launch.exe): New targets.
(copy-windows-dist-files): Copy octave-launch.exe to $(OCTAVE_DIST_DIR).
(installer-files/.dirstamp): New rule to ensure that installer-files
directory is created if we are building outside the source tree.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 19 Nov 2021 06:52:00 -0500 |
parents | |
children | b8e9589b7794 |
rev | line source |
---|---|
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1 /* |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2 * Wrapper application to set octave env variables and then run octave |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3 * compile with gcc -o octave-launch octave-launch.c -Wl,--subsystem,windows -lshlwapi |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4 * |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5 * Copyright (C) 2020 John Donoghue <john.donoghue@ieee.org> |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6 * |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
7 * This program is free software; you can redistribute it and/or modify it under |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
8 * the terms of the GNU General Public License as published by the Free Software |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
9 * Foundation; either version 3 of the License, or (at your option) any later |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
10 * version. |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
11 * |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
12 * This program is distributed in the hope that it will be useful, but WITHOUT |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
15 * details. |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
16 * |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
17 * You should have received a copy of the GNU General Public License along with |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
18 * this program; if not, see <http: *www.gnu.org/licenses/>. |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
19 */ |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
20 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
21 #include <windows.h> |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
22 #include <shlwapi.h> |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
23 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
24 static int ParentDir (char *dir) |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
25 { |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
26 int len = strlen (dir); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
27 while (len > 0 && dir[len] != '\\') |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
28 len --; |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
29 dir[len] = 0; |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
30 return len; |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
31 } |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
32 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
33 char * FilePart (char *dir) |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
34 { |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
35 int len = strlen (dir); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
36 while (len > 0 && dir[len-1] != '\\') |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
37 len --; |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
38 return &dir[len]; |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
39 } |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
40 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
41 // Set up environment and launch octave.exe with appropriate |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
42 // arguments. NOTE: There are corresponding VBS and BAT script |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
43 // versions of this program so any changes here may need to be made in |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
44 // those scripts as well. |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
45 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
46 int main (int argc, char **argv) |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
47 { |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
48 PROCESS_INFORMATION pi; |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
49 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
50 // FIXME: There are currently have no checks to ensure that the |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
51 // following fixed-size buffers are sufficiently large. Maybe it |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
52 // would be better if we used C++ and std::string objects? For |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
53 // buffers that are passed to Windows library functions to hold |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
54 // output values, is 1024 the correct way to define the size of the |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
55 // buffer? Note that the use of sizeof(path)-1 below will fail if |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
56 // we switch to using |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
57 // |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
58 // char *path = (char *) malloc (...); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
59 // |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
60 // instead of literal character arrays. |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
61 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
62 char msyspath[1024]; |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
63 char rootpath[1024]; |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
64 char path[1024]; |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
65 char binpath[1024]; |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
66 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
67 int gui_arg_found = 0; |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
68 int no_gui_arg_found = 0; |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
69 int no_gui_libs = 0; |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
70 int i; |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
71 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
72 /* get path of us which we will assume is the root of the install */ |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
73 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
74 DWORD nSize = GetModuleFileName (NULL, path, sizeof(path)-1); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
75 if (nSize) |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
76 { |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
77 while (nSize > 0 && path[nSize] != '\\') |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
78 nSize --; |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
79 path[nSize] = '\0'; |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
80 } |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
81 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
82 nSize = GetShortPathName (path, rootpath, sizeof(rootpath)-1); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
83 if (nSize == 0) |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
84 StrCpy (rootpath, path); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
85 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
86 SetEnvironmentVariable ("MXE_ROOT", rootpath); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
87 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
88 /* get msys path and set env */ |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
89 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
90 StrCpy (msyspath, rootpath); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
91 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
92 StrCpy (path, rootpath); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
93 StrCat (path, "\\mingw64\\bin\\octave.exe"); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
94 if (PathFileExists (path)) |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
95 { |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
96 SetEnvironmentVariable ("MSYSTEM", "MINGW64"); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
97 StrCat (msyspath, "\\usr"); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
98 SetEnvironmentVariable ("MSYSPATH", msyspath); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
99 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
100 StrCat (msyspath, "\\bin"); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
101 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
102 StrCpy (binpath, rootpath); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
103 StrCat (binpath, "\\mingw64\\bin"); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
104 } |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
105 else |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
106 { |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
107 StrCpy (path, rootpath); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
108 StrCat (path, "\\mingw32\\bin\\octave.exe"); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
109 if (PathFileExists (path)) |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
110 { |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
111 SetEnvironmentVariable ("MSYSTEM", "MINGW32"); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
112 StrCat (msyspath, "\\usr"); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
113 SetEnvironmentVariable ("MSYSPATH", msyspath); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
114 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
115 StrCat (msyspath, "\\bin"); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
116 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
117 StrCpy (binpath, rootpath); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
118 StrCat (binpath, "\\mingw32\\bin"); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
119 } |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
120 else |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
121 { |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
122 SetEnvironmentVariable ("MSYSTEM", "MSYS"); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
123 SetEnvironmentVariable ("MSYSPATH", msyspath); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
124 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
125 StrCat (msyspath, "\\bin"); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
126 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
127 StrCpy (binpath, rootpath); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
128 StrCat (binpath, "\\bin"); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
129 } |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
130 } |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
131 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
132 /* binpath is to the octave bin dir so get the parent */ |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
133 StrCpy (path, binpath); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
134 ParentDir (path); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
135 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
136 #ifdef SHOW_PATHS |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
137 MessageBox (NULL, rootpath, "octroot", MB_OK); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
138 MessageBox (NULL, path, "octhome", MB_OK); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
139 MessageBox (NULL, binpath, "octbin", MB_OK); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
140 MessageBox (NULL, msyspath, "msysbin", MB_OK); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
141 #endif |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
142 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
143 /* qt paths |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
144 * either %OCT_HOME%\qt5\plugins |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
145 * or %OCT_HOME\plugins |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
146 */ |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
147 nSize = strlen (path); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
148 StrCat (path, "\\qt5\\plugins"); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
149 SetEnvironmentVariable ("QT_PLUGIN_PATH", path); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
150 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
151 path[nSize] = '\0'; |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
152 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
153 /* exe paths */ |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
154 { |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
155 char pathbuffer[8096]; |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
156 char newpathbuffer[8096]; |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
157 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
158 nSize = GetEnvironmentVariable ("PATH", pathbuffer, sizeof(pathbuffer)-1); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
159 pathbuffer[nSize] = '\0'; |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
160 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
161 /* set our paths first */ |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
162 StrCpy (newpathbuffer, binpath); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
163 StrCat (newpathbuffer, ";"); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
164 StrCat (newpathbuffer, msyspath); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
165 StrCat (newpathbuffer, ";"); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
166 StrCat (newpathbuffer, pathbuffer); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
167 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
168 SetEnvironmentVariable ("PATH", newpathbuffer); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
169 } |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
170 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
171 /* other env */ |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
172 SetEnvironmentVariable ("TERM", "cygwin"); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
173 SetEnvironmentVariable ("GNUTERM", "wxt"); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
174 SetEnvironmentVariable ("GS", "gs.exe"); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
175 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
176 /* home set */ |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
177 nSize = GetEnvironmentVariable ("HOME", path, sizeof(path)-1); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
178 if (nSize == 0 || path[0] == 0) |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
179 { |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
180 char newhome[1024]; |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
181 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
182 nSize = GetEnvironmentVariable ("USERPROFILE", path, sizeof(path)-1); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
183 if (nSize == 0 || path[0] == 0) |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
184 { |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
185 /* build dir from drive and path */ |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
186 char tmpbuff[1024]; |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
187 nSize = GetEnvironmentVariable ("HOMEDRIVE", tmpbuff, sizeof(tmpbuff)-1); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
188 if (nSize) |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
189 StrCpy (path, tmpbuff); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
190 else |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
191 path[0] = '\0'; |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
192 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
193 nSize = GetEnvironmentVariable ("HOMEPATH", tmpbuff, sizeof(tmpbuff)-1); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
194 if (nSize) StrCat (path, tmpbuff); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
195 } |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
196 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
197 nSize = GetShortPathName (path, newhome, sizeof(newhome)-1); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
198 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
199 if (nSize == 0) |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
200 { |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
201 StrCpy (newhome, path); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
202 } |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
203 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
204 SetEnvironmentVariable ("HOME", newhome); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
205 } |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
206 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
207 /* check for gui mode */ |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
208 for (i = 1; i < argc; i++) |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
209 { |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
210 if (StrCmp (argv[i], "--no-gui-libs") == 0) |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
211 { |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
212 if (gui_arg_found) |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
213 { |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
214 /* Inconsistent options. We can't start the GUI without gui libs. |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
215 How should we fail? For now, --no-gui-libs will |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
216 override the other options. */ |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
217 } |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
218 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
219 no_gui_libs = 1; |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
220 } |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
221 else if (StrCmp (argv[i], "--gui") == 0 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
222 || StrCmp (argv[i], "--force-gui") == 0) |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
223 { |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
224 if (no_gui_libs) |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
225 { |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
226 /* Inconsistent options. We can't start the GUI without gui libs. |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
227 How should we fail? For now, --no-gui-libs will |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
228 override the other options. */ |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
229 } |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
230 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
231 gui_arg_found = 1; |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
232 } |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
233 else if (StrCmp (argv[i], "--no-gui") == 0) |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
234 no_gui_arg_found = 1; |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
235 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
236 /* NOTE: specifying both --no-gui and --gui is also an |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
237 inconsistent set of options but we leave it to octave.exe to |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
238 detect that. */ |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
239 } |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
240 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
241 /* set up process args and start it */ |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
242 { |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
243 STARTUPINFO si; |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
244 char argbuffer[4096]; |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
245 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
246 ZeroMemory (&si, sizeof(si)); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
247 si.cb = sizeof(si); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
248 ZeroMemory (&pi, sizeof(pi)); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
249 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
250 StrCpy (path, binpath); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
251 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
252 StrCpy (argbuffer, "octave.exe "); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
253 StrCat (path, "\\octave.exe"); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
254 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
255 if (! (no_gui_libs || no_gui_arg_found)) |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
256 { |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
257 /* Unless --no-gui or --no-gui-libs is specified, we will use a GUI window. */ |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
258 si.dwFlags = STARTF_USESHOWWINDOW; |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
259 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
260 /* If none of the options --no-gui, --gui, or --force-gui |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
261 were specified, then we'll add --gui to start the gui as |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
262 most Windows users would expect. */ |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
263 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
264 if (! gui_arg_found) |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
265 StrCat (argbuffer, "--gui "); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
266 } |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
267 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
268 /* quote and append each arg */ |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
269 for (i = 1; i < argc; i++) |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
270 { |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
271 StrCat (argbuffer, "\""); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
272 StrCat (argbuffer, argv[i]); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
273 StrCat (argbuffer, "\" "); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
274 } |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
275 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
276 /* Start the child process */ |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
277 int status = CreateProcess (path, // Module name |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
278 argbuffer, // Command line |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
279 NULL, // Process handle not inheritable |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
280 NULL, // Thread handle not inheritable |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
281 FALSE, // Set handle inheritance to FALSE |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
282 0, // No creation flags |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
283 NULL, // Use parent's environment block |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
284 NULL, // Use parent's starting directory |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
285 &si, // Pointer to STARTUPINFO |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
286 &pi); // Pointer to PROCESS_INFORMATION |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
287 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
288 if (! status) |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
289 return 1; |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
290 } |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
291 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
292 /* Wait until child process exits. */ |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
293 WaitForSingleObject (pi.hProcess, INFINITE); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
294 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
295 /* Close process and thread handles */ |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
296 CloseHandle (pi.hProcess); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
297 CloseHandle (pi.hThread); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
298 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
299 return 0; |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
300 } |