Mercurial > mxe-octave
annotate installer-files/octave-launch.c @ 6001:88762923aa9a release
octave-launch: Attach to console of parent process if applicable.
* installer-files/octave-launch.c: If parent process has a console, attach to
it.
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Sun, 05 Dec 2021 18:26:51 +0100 |
parents | 1b5d45d7afd4 |
children | 9d6cbb229b0f |
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 * |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
4 * Copyright (C) 2020-2021 John Donoghue <john.donoghue@ieee.org> |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5 * |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6 * 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
|
7 * 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
|
8 * 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
|
9 * version. |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
10 * |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
11 * 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
|
12 * 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
|
13 * 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
|
14 * details. |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
15 * |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
16 * 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
|
17 * 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
|
18 */ |
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 #include <windows.h> |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
21 #include <shlwapi.h> |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
22 #include <strsafe.h> |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
23 |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
24 static int ParentDir (wchar_t *dir) |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
25 { |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
26 int len = lstrlenW (dir); |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
27 while (len > 0 && dir[len] != L'\\') |
5955
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 |
5978
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
33 static wchar_t * FilePart (wchar_t *dir) |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
34 { |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
35 int len = lstrlenW (dir); |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
36 while (len > 0 && dir[len-1] != L'\\') |
5955
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 |
5978
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
41 static size_t get_num_physical_cores (void) |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
42 { |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
43 DWORD length; |
5985
1b5d45d7afd4
octave-launch: Don't use undefined behavior (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5984
diff
changeset
|
44 char *lpi; |
5978
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
45 BOOL res; |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
46 size_t num_physical_cores; |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
47 size_t offset; |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
48 |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
49 length = 0; |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
50 GetLogicalProcessorInformationEx (RelationProcessorCore, NULL, &length); |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
51 if (GetLastError () != ERROR_INSUFFICIENT_BUFFER) |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
52 return 0; |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
53 |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
54 lpi = malloc (length); |
5984
532c6ba0156f
octave-launch: Fix error when counting processor cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5978
diff
changeset
|
55 res = GetLogicalProcessorInformationEx |
532c6ba0156f
octave-launch: Fix error when counting processor cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5978
diff
changeset
|
56 (RelationProcessorCore, |
532c6ba0156f
octave-launch: Fix error when counting processor cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5978
diff
changeset
|
57 (PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX) lpi, |
532c6ba0156f
octave-launch: Fix error when counting processor cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5978
diff
changeset
|
58 &length); |
5978
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
59 if (! res) |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
60 { |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
61 free (lpi); |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
62 return 0; |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
63 } |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
64 |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
65 num_physical_cores = 0; |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
66 offset = 0; |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
67 do |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
68 { |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
69 const PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX cur_lpi = |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
70 (PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX) (lpi + offset); |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
71 offset += cur_lpi->Size; |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
72 num_physical_cores++; |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
73 } |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
74 while (offset < length); |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
75 |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
76 free (lpi); |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
77 |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
78 return num_physical_cores; |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
79 } |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
80 |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
81 // 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
|
82 // 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
|
83 // 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
|
84 // those scripts as well. |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
85 |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
86 int wmain (int argc, wchar_t **argv) |
5955
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 PROCESS_INFORMATION pi; |
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 // FIXME: There are currently have no checks to ensure that the |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
91 // following fixed-size buffers are sufficiently large. MAX_PATH is |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
92 // 260 on Winndows by default. But a user might have increased that |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
93 // limit to 32767 characters by manually changing policy settings. |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
94 // Maybe it would be better if we used C++ and std::string objects? |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
95 // Note that the use of sizeof(path)-1 will fail if we switch to |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
96 // using |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
97 // |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
98 // wchar_t *path = (wchar_t *) malloc (...); |
5955
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 // instead of literal character arrays. |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
101 |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
102 #define PATH_SZ 1024 |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
103 wchar_t msyspath[PATH_SZ]; |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
104 wchar_t rootpath[PATH_SZ]; |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
105 wchar_t path[PATH_SZ]; |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
106 wchar_t binpath[PATH_SZ]; |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
107 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
108 int gui_arg_found = 0; |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
109 int no_gui_arg_found = 0; |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
110 int no_gui_libs = 0; |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
111 int i; |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
112 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
113 /* 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
|
114 |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
115 DWORD nSize = GetModuleFileNameW (NULL, path, PATH_SZ-1); |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
116 if (nSize) |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
117 { |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
118 while (nSize > 0 && path[nSize] != L'\\') |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
119 nSize --; |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
120 path[nSize] = L'\0'; |
5955
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 |
5960
49b3f6c6d255
octave-launch: Don't use short path names when building default-octave.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5957
diff
changeset
|
123 #ifdef NO_SHORT_PATH_NAMES |
49b3f6c6d255
octave-launch: Don't use short path names when building default-octave.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5957
diff
changeset
|
124 StringCchCopyW (rootpath, PATH_SZ, path); |
49b3f6c6d255
octave-launch: Don't use short path names when building default-octave.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5957
diff
changeset
|
125 #else |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
126 /* transform to short paths to work around issues with spaces in |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
127 paths */ |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
128 /* FIXME: This won't help on systems with de-activated short paths */ |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
129 nSize = GetShortPathNameW (path, rootpath, PATH_SZ-1); |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
130 if (nSize == 0) |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
131 StringCchCopyW (rootpath, PATH_SZ, path); |
5960
49b3f6c6d255
octave-launch: Don't use short path names when building default-octave.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5957
diff
changeset
|
132 #endif |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
133 |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
134 SetEnvironmentVariableW (L"MXE_ROOT", rootpath); |
5955
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 /* get msys path and set env */ |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
137 |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
138 StringCchCopyW (msyspath, PATH_SZ, rootpath); |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
139 |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
140 StringCchCopyW (path, PATH_SZ, rootpath); |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
141 StringCchCatW (path, PATH_SZ, L"\\mingw64\\bin\\octave.exe"); |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
142 if (PathFileExistsW (path)) |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
143 { |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
144 SetEnvironmentVariableW (L"MSYSTEM", L"MINGW64"); |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
145 StringCchCatW (msyspath, PATH_SZ, L"\\usr"); |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
146 SetEnvironmentVariableW (L"MSYSPATH", msyspath); |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
147 |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
148 StringCchCatW (msyspath, PATH_SZ, L"\\bin"); |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
149 |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
150 StringCchCopyW (binpath, PATH_SZ, rootpath); |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
151 StringCchCatW (binpath, PATH_SZ, L"\\mingw64\\bin"); |
5955
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 else |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
154 { |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
155 StringCchCopyW (path, PATH_SZ, rootpath); |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
156 StringCchCatW (path, PATH_SZ, L"\\mingw32\\bin\\octave.exe"); |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
157 if (PathFileExistsW (path)) |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
158 { |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
159 SetEnvironmentVariableW (L"MSYSTEM", L"MINGW32"); |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
160 StringCchCatW (msyspath, PATH_SZ, L"\\usr"); |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
161 SetEnvironmentVariableW (L"MSYSPATH", msyspath); |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
162 |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
163 StringCchCatW (msyspath, PATH_SZ, L"\\bin"); |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
164 |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
165 StringCchCopyW (binpath, PATH_SZ, rootpath); |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
166 StringCchCatW (binpath, PATH_SZ, L"\\mingw32\\bin"); |
5955
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 else |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
169 { |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
170 SetEnvironmentVariableW (L"MSYSTEM", L"MSYS"); |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
171 SetEnvironmentVariableW (L"MSYSPATH", msyspath); |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
172 |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
173 StringCchCatW (msyspath, PATH_SZ, L"\\bin"); |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
174 |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
175 StringCchCopyW (binpath, PATH_SZ, rootpath); |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
176 StringCchCatW (binpath, PATH_SZ, L"\\bin"); |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
177 } |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
178 } |
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 /* binpath is to the octave bin dir so get the parent */ |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
181 StringCchCopyW (path, PATH_SZ, binpath); |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
182 ParentDir (path); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
183 |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
184 #ifdef SHOW_PATHS |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
185 MessageBoxW (NULL, rootpath, L"octroot", MB_OK); |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
186 MessageBoxW (NULL, path, L"octhome", MB_OK); |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
187 MessageBoxW (NULL, binpath, L"octbin", MB_OK); |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
188 MessageBoxW (NULL, msyspath, L"msysbin", MB_OK); |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
189 #endif |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
190 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
191 /* qt paths |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
192 * either %OCT_HOME%\qt5\plugins |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
193 * or %OCT_HOME\plugins |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
194 */ |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
195 nSize = lstrlenW (path); |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
196 StringCchCatW (path, PATH_SZ, L"\\qt5\\plugins"); |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
197 SetEnvironmentVariableW (L"QT_PLUGIN_PATH", path); |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
198 |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
199 path[nSize] = L'\0'; |
5955
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 /* exe paths */ |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
202 { |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
203 #define PATHBUF_SZ 8096 |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
204 wchar_t pathbuffer[PATHBUF_SZ]; |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
205 wchar_t newpathbuffer[PATHBUF_SZ]; |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
206 |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
207 nSize = GetEnvironmentVariableW (L"PATH", pathbuffer, PATHBUF_SZ-1); |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
208 pathbuffer[nSize] = '\0'; |
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 /* set our paths first */ |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
211 StringCchCopyW (newpathbuffer, PATHBUF_SZ, binpath); |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
212 StringCchCatW (newpathbuffer, PATHBUF_SZ, L";"); |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
213 StringCchCatW (newpathbuffer, PATHBUF_SZ, msyspath); |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
214 StringCchCatW (newpathbuffer, PATHBUF_SZ, L";"); |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
215 StringCchCatW (newpathbuffer, PATHBUF_SZ, pathbuffer); |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
216 |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
217 SetEnvironmentVariableW (L"PATH", newpathbuffer); |
5955
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 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
220 /* other env */ |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
221 SetEnvironmentVariableW (L"TERM", L"cygwin"); |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
222 SetEnvironmentVariableW (L"GNUTERM", L"wxt"); |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
223 SetEnvironmentVariableW (L"GS", L"gs.exe"); |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
224 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
225 /* home set */ |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
226 nSize = GetEnvironmentVariableW (L"HOME", path, PATH_SZ-1); |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
227 if (nSize == 0 || path[0] == 0) |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
228 { |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
229 wchar_t newhome[PATH_SZ]; |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
230 |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
231 nSize = GetEnvironmentVariableW (L"USERPROFILE", path, PATH_SZ-1); |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
232 if (nSize == 0 || path[0] == 0) |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
233 { |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
234 /* build dir from drive and path */ |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
235 wchar_t tmpbuff[PATH_SZ]; |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
236 nSize = GetEnvironmentVariableW (L"HOMEDRIVE", tmpbuff, PATH_SZ-1); |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
237 if (nSize) |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
238 StringCchCopyW (path, PATH_SZ, tmpbuff); |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
239 else |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
240 path[0] = '\0'; |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
241 |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
242 nSize = GetEnvironmentVariableW (L"HOMEPATH", tmpbuff, PATH_SZ-1); |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
243 if (nSize) |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
244 StringCchCopyW (path, PATH_SZ, tmpbuff); |
5955
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 |
5960
49b3f6c6d255
octave-launch: Don't use short path names when building default-octave.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5957
diff
changeset
|
247 #ifdef NO_SHORT_PATH_NAMES |
49b3f6c6d255
octave-launch: Don't use short path names when building default-octave.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5957
diff
changeset
|
248 StringCchCopyW (newhome, PATH_SZ, path); |
49b3f6c6d255
octave-launch: Don't use short path names when building default-octave.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5957
diff
changeset
|
249 #else |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
250 /* transform to short paths to work around issues with spaces in |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
251 paths */ |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
252 /* FIXME: This won't help on systems with de-activated short |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
253 paths */ |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
254 nSize = GetShortPathNameW (path, newhome, PATH_SZ-1); |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
255 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
256 if (nSize == 0) |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
257 StringCchCopyW (newhome, PATH_SZ, path); |
5960
49b3f6c6d255
octave-launch: Don't use short path names when building default-octave.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5957
diff
changeset
|
258 #endif |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
259 |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
260 SetEnvironmentVariableW (L"HOME", newhome); |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
261 } |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
262 |
5978
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
263 /* set number of OpenBLAS threads */ |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
264 nSize = GetEnvironmentVariableW (L"OPENBLAS_NUM_THREADS", NULL, 0); |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
265 if (nSize == 0) |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
266 { |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
267 /* Only set if it wasn't already set in the environment */ |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
268 size_t num_threads; |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
269 num_threads = get_num_physical_cores (); |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
270 |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
271 if (num_threads > 0) |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
272 { |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
273 #define THREADS_SZ 64 |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
274 wchar_t buffer[THREADS_SZ]; |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
275 StringCchPrintfW (buffer, THREADS_SZ, L"%zu", num_threads); |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
276 SetEnvironmentVariableW (L"OPENBLAS_NUM_THREADS", buffer); |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
277 } |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
278 } |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
279 |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
280 /* check for gui mode */ |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
281 for (i = 1; i < argc; i++) |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
282 { |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
283 if (StrCmpW (argv[i], L"--no-gui-libs") == 0) |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
284 { |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
285 if (gui_arg_found) |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
286 { |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
287 /* 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
|
288 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
|
289 override the other options. */ |
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 no_gui_libs = 1; |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
293 } |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
294 else if (StrCmpW (argv[i], L"--gui") == 0 |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
295 || StrCmpW (argv[i], L"--force-gui") == 0) |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
296 { |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
297 if (no_gui_libs) |
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 /* 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
|
300 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
|
301 override the other options. */ |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
302 } |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
303 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
304 gui_arg_found = 1; |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
305 } |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
306 else if (StrCmpW (argv[i], L"--no-gui") == 0) |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
307 no_gui_arg_found = 1; |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
308 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
309 /* 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
|
310 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
|
311 detect that. */ |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
312 } |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
313 |
5957
9cd5425b033b
octave-launch-firsttime: New launcher executable for starting Octave first time.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5956
diff
changeset
|
314 #ifdef FIRST_TIME |
9cd5425b033b
octave-launch-firsttime: New launcher executable for starting Octave first time.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5956
diff
changeset
|
315 { |
9cd5425b033b
octave-launch-firsttime: New launcher executable for starting Octave first time.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5956
diff
changeset
|
316 /* change directory to USERPROFILE before starting Octave */ |
9cd5425b033b
octave-launch-firsttime: New launcher executable for starting Octave first time.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5956
diff
changeset
|
317 wchar_t tmpbuff[PATH_SZ]; |
9cd5425b033b
octave-launch-firsttime: New launcher executable for starting Octave first time.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5956
diff
changeset
|
318 nSize = GetEnvironmentVariableW (L"USERPROFILE", tmpbuff, PATH_SZ-1); |
9cd5425b033b
octave-launch-firsttime: New launcher executable for starting Octave first time.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5956
diff
changeset
|
319 if (nSize) |
9cd5425b033b
octave-launch-firsttime: New launcher executable for starting Octave first time.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5956
diff
changeset
|
320 StringCchCopyW (path, PATH_SZ, tmpbuff); |
9cd5425b033b
octave-launch-firsttime: New launcher executable for starting Octave first time.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5956
diff
changeset
|
321 |
9cd5425b033b
octave-launch-firsttime: New launcher executable for starting Octave first time.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5956
diff
changeset
|
322 SetCurrentDirectoryW (path); |
9cd5425b033b
octave-launch-firsttime: New launcher executable for starting Octave first time.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5956
diff
changeset
|
323 } |
9cd5425b033b
octave-launch-firsttime: New launcher executable for starting Octave first time.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5956
diff
changeset
|
324 #endif |
9cd5425b033b
octave-launch-firsttime: New launcher executable for starting Octave first time.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5956
diff
changeset
|
325 |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
326 /* 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
|
327 { |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
328 STARTUPINFO si; |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
329 #define ARGBUF_SZ 4096 |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
330 wchar_t argbuffer[ARGBUF_SZ]; |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
331 |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
332 ZeroMemory (&si, sizeof (si)); |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
333 si.cb = sizeof (si); |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
334 ZeroMemory (&pi, sizeof (pi)); |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
335 |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
336 StringCchCopyW (path, PATH_SZ, binpath); |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
337 |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
338 StringCchCopyW (argbuffer, ARGBUF_SZ, L"octave.exe "); |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
339 StringCchCatW (path, PATH_SZ, L"\\octave.exe"); |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
340 |
6001
88762923aa9a
octave-launch: Attach to console of parent process if applicable.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5985
diff
changeset
|
341 /* If parent process has a console, attach to it. |
88762923aa9a
octave-launch: Attach to console of parent process if applicable.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5985
diff
changeset
|
342 Let the function fail silently, when parent has no console |
88762923aa9a
octave-launch: Attach to console of parent process if applicable.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5985
diff
changeset
|
343 (e.g., when program has been started from link in start menu). |
88762923aa9a
octave-launch: Attach to console of parent process if applicable.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5985
diff
changeset
|
344 No console will be shown in this case. */ |
88762923aa9a
octave-launch: Attach to console of parent process if applicable.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5985
diff
changeset
|
345 AttachConsole (ATTACH_PARENT_PROCESS); |
88762923aa9a
octave-launch: Attach to console of parent process if applicable.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5985
diff
changeset
|
346 |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
347 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
|
348 { |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
349 /* 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
|
350 si.dwFlags = STARTF_USESHOWWINDOW; |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
351 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
352 /* 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
|
353 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
|
354 most Windows users would expect. */ |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
355 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
356 if (! gui_arg_found) |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
357 StringCchCatW (argbuffer, ARGBUF_SZ, L"--gui "); |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
358 } |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
359 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
360 /* quote and append each arg */ |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
361 for (i = 1; i < argc; i++) |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
362 { |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
363 StringCchCatW (argbuffer, ARGBUF_SZ, L"\""); |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
364 StringCchCatW (argbuffer, ARGBUF_SZ, argv[i]); |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
365 StringCchCatW (argbuffer, ARGBUF_SZ, L"\" "); |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
366 } |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
367 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
368 /* Start the child process */ |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
369 int status = CreateProcessW (path, // Module name |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
370 argbuffer, // Command line |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
371 NULL, // Process handle not inheritable |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
372 NULL, // Thread handle not inheritable |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
373 FALSE, // Set handle inheritance to FALSE |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
374 0, // No creation flags |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
375 NULL, // Use parent's environment block |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
376 NULL, // Use parent's starting directory |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
377 &si, // Pointer to STARTUPINFO |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
378 &pi); // Pointer to PROCESS_INFORMATION |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
379 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
380 if (! status) |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
381 return 1; |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
382 } |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
383 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
384 /* Wait until child process exits. */ |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
385 WaitForSingleObject (pi.hProcess, INFINITE); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
386 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
387 /* Close process and thread handles */ |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
388 CloseHandle (pi.hProcess); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
389 CloseHandle (pi.hThread); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
390 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
391 return 0; |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
392 } |