[78] | 1 |
|
---|
| 2 | /***********************************************************************
|
---|
| 3 |
|
---|
| 4 | $Id: systemf.c 1480 2009-11-22 22:58:49Z gyoung $
|
---|
| 5 |
|
---|
| 6 | System Interfaces
|
---|
| 7 |
|
---|
| 8 | Copyright (c) 1993-98 M. Kimes
|
---|
[1394] | 9 | Copyright (c) 2003, 2009 Steven H.Levine
|
---|
[78] | 10 |
|
---|
[330] | 11 | 21 Nov 03 SHL Comments
|
---|
| 12 | 31 Jul 04 SHL Indent -i2
|
---|
| 13 | 01 Aug 04 SHL Rework lstrip/rstrip usage
|
---|
| 14 | 17 Jul 06 SHL Use Runtime_Error
|
---|
[373] | 15 | 26 Jul 06 SHL Use convert_nl_to_nul
|
---|
[441] | 16 | 15 Aug 06 SHL More error popups
|
---|
[519] | 17 | 01 Nov 06 SHL runemf2: temp fix for hung windows caused by termq errors
|
---|
[540] | 18 | 03 Nov 06 SHL runemf2: rework termination queue logic to work for multiple threads
|
---|
[552] | 19 | 07 Jan 07 GKY Move error strings etc. to string file
|
---|
[775] | 20 | 06 Aug 07 GKY Reduce DosSleep times (ticket 148)
|
---|
[793] | 21 | 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
|
---|
[985] | 22 | 29 Feb 08 GKY Changes to enable user settable command line length
|
---|
| 23 | 29 Feb 08 GKY Refactor global command line variables to notebook.h
|
---|
[1021] | 24 | 26 May 08 SHL Use uiLineNumber correctly
|
---|
[1082] | 25 | 19 Jul 08 GKY Replace save_dir2(dir) with pFM2SaveDirectory or pTmpDir and use MakeTempName
|
---|
[1375] | 26 | 03 Jan 09 GKY Check for system that is protectonly to gray out Dos/Win command lines and prevent
|
---|
[1394] | 27 | Dos/Win programs from being inserted into the execute dialog with message why.
|
---|
[1439] | 28 | 12 Jul 09 GKY Allow FM/2 to load in high memory
|
---|
[78] | 29 |
|
---|
| 30 | ***********************************************************************/
|
---|
| 31 |
|
---|
[2] | 32 | #include <stdlib.h>
|
---|
| 33 | #include <stdarg.h>
|
---|
| 34 | #include <string.h>
|
---|
| 35 | #include <ctype.h>
|
---|
[330] | 36 |
|
---|
[907] | 37 | #define INCL_DOS
|
---|
| 38 | #define INCL_DOSERRORS
|
---|
| 39 | #define INCL_WIN
|
---|
[1162] | 40 | #define INCL_LONGLONG // dircnrs.h
|
---|
[907] | 41 |
|
---|
[1186] | 42 | #include "fm3dll.h"
|
---|
[1227] | 43 | #include "fm3dll2.h" // #define's for UM_*, control id's, etc.
|
---|
[1213] | 44 | #include "mkdir.h" // Data declaration(s)
|
---|
| 45 | #include "init.h" // Data declaration(s)
|
---|
| 46 | #include "mainwnd.h" // Data declaration(s)
|
---|
[2] | 47 | #include "fm3dlg.h"
|
---|
| 48 | #include "fm3str.h"
|
---|
[1162] | 49 | #include "errutil.h" // Dos_Error...
|
---|
| 50 | #include "strutil.h" // GetPString
|
---|
[985] | 51 | #include "notebook.h" //targetdirectory
|
---|
[907] | 52 | #include "pathutil.h"
|
---|
[1162] | 53 | #include "cmdline.h" // CmdLineDlgProc
|
---|
| 54 | #include "shadow.h" // RunSeamless
|
---|
| 55 | #include "systemf.h"
|
---|
| 56 | #include "strips.h" // convert_nl_to_nul, strip_lead_char
|
---|
| 57 | #include "dirs.h" // switch_to
|
---|
[1186] | 58 | #include "valid.h" // MakeFullName
|
---|
| 59 | #include "misc.h" // GetCmdSpec
|
---|
| 60 | #include "copyf.h" // MakeTempName
|
---|
| 61 | #include "wrappers.h" // xfopen
|
---|
[1039] | 62 | #include "fortify.h"
|
---|
[2] | 63 |
|
---|
[330] | 64 | static PSZ pszSrcFile = __FILE__;
|
---|
| 65 |
|
---|
[1162] | 66 | //static HAPP Exec(HWND hwndNotify, BOOL child, char *startdir, char *env,
|
---|
| 67 | // PROGTYPE * progt, ULONG fl, char *formatstring, ...);
|
---|
| 68 |
|
---|
[917] | 69 | /**
|
---|
| 70 | * Bring session foreground
|
---|
| 71 | * @return TRUE if OK, else FALSE
|
---|
| 72 | */
|
---|
[2] | 73 |
|
---|
[105] | 74 | BOOL ShowSession(HWND hwnd, PID pid)
|
---|
[78] | 75 | {
|
---|
[105] | 76 | HSWITCH hswitch;
|
---|
| 77 | SWCNTRL swctl;
|
---|
| 78 | ULONG rc;
|
---|
[2] | 79 |
|
---|
[519] | 80 | hswitch = WinQuerySwitchHandle(pid ? (HWND)0 : hwnd, pid);
|
---|
[441] | 81 | if (hswitch) {
|
---|
[105] | 82 | rc = WinQuerySwitchEntry(hswitch, &swctl);
|
---|
[441] | 83 | if (!rc) {
|
---|
[105] | 84 | if (swctl.idProcess == pid && swctl.uchVisibility == SWL_VISIBLE)
|
---|
[1394] | 85 | rc = WinSwitchToProgram(hswitch);
|
---|
[105] | 86 | if (!rc)
|
---|
[1394] | 87 | return TRUE;
|
---|
[105] | 88 | }
|
---|
| 89 | }
|
---|
| 90 | return FALSE;
|
---|
[2] | 91 | }
|
---|
| 92 |
|
---|
[917] | 93 | /**
|
---|
| 94 | * Invoke runemf2 for command and file/directory list
|
---|
| 95 | * @return command return code or
|
---|
| 96 | * -1 if runtime error or
|
---|
| 97 | * -2 if user cancels command line edit dialog
|
---|
| 98 | */
|
---|
[519] | 99 |
|
---|
[105] | 100 | int ExecOnList(HWND hwnd, char *command, int flags, char *tpath,
|
---|
[1394] | 101 | PSZ *list, PCSZ prompt, PCSZ pszCallingFile, UINT uiLineNumber)
|
---|
[78] | 102 | {
|
---|
[105] | 103 | /* executes the command once for all files in list */
|
---|
[2] | 104 |
|
---|
[1394] | 105 | CHAR path[CCHMAXPATH], *commandline, modpath[CCHMAXPATH], listfile[CCHMAXPATH],
|
---|
[105] | 106 | *p, *pp, drive, *file, *ext, *dot;
|
---|
[2] | 107 | register int x;
|
---|
[105] | 108 | BOOL spaces;
|
---|
[2] | 109 |
|
---|
[441] | 110 | if (!command || !*command) {
|
---|
[1398] | 111 | Runtime_Error(pszSrcFile, __LINE__, NULL);
|
---|
[105] | 112 | return -1;
|
---|
[441] | 113 | }
|
---|
[989] | 114 | commandline = xmalloc(MaxComLineStrg + 1, pszSrcFile, __LINE__);
|
---|
[985] | 115 | if (!commandline)
|
---|
| 116 | return -1; //already complained
|
---|
[2] | 117 | *listfile = 0;
|
---|
[123] | 118 | bstrip(command);
|
---|
[2] | 119 |
|
---|
| 120 | *path = 0;
|
---|
[105] | 121 | if (tpath && *tpath)
|
---|
| 122 | strcpy(path, tpath);
|
---|
[441] | 123 | else if (*command != '<' || !strchr(command, '>')) {
|
---|
[105] | 124 | strcpy(path, command + (*command == '"'));
|
---|
| 125 | if (*command == '\"')
|
---|
| 126 | p = strchr(path, '\"');
|
---|
[2] | 127 | else
|
---|
[105] | 128 | p = strchr(path, ' ');
|
---|
| 129 | if (p)
|
---|
[2] | 130 | *p = 0;
|
---|
[105] | 131 | p = strrchr(path, '\\');
|
---|
| 132 | if (!p)
|
---|
| 133 | p = strrchr(path, ':');
|
---|
[441] | 134 | if (p) {
|
---|
| 135 | if (*p == ':') {
|
---|
[1394] | 136 | p++;
|
---|
| 137 | *p = '\\';
|
---|
| 138 | p++;
|
---|
[2] | 139 | }
|
---|
| 140 | *p = 0;
|
---|
| 141 | }
|
---|
| 142 | else
|
---|
| 143 | *path = 0;
|
---|
| 144 | }
|
---|
[441] | 145 | if (!*path) {
|
---|
[105] | 146 | if (list && list[0])
|
---|
| 147 | strcpy(path, list[0]);
|
---|
| 148 | p = strrchr(path, '\\');
|
---|
| 149 | if (!p)
|
---|
| 150 | p = strrchr(path, ':');
|
---|
[441] | 151 | if (p) {
|
---|
| 152 | if (*p == ':') {
|
---|
[1394] | 153 | p++;
|
---|
| 154 | *p = '\\';
|
---|
| 155 | p++;
|
---|
[2] | 156 | }
|
---|
| 157 | *p = 0;
|
---|
| 158 | }
|
---|
| 159 | else
|
---|
| 160 | *path = 0;
|
---|
| 161 | }
|
---|
| 162 | *modpath = 0;
|
---|
[105] | 163 | if (list && list[0])
|
---|
| 164 | strcpy(modpath, list[0]);
|
---|
| 165 | p = strrchr(modpath, '\\');
|
---|
| 166 | if (!p)
|
---|
| 167 | p = strrchr(modpath, ':');
|
---|
[441] | 168 | if (p) {
|
---|
| 169 | if (*p == ':') {
|
---|
[2] | 170 | p++;
|
---|
| 171 | *p = '\\';
|
---|
| 172 | p++;
|
---|
| 173 | }
|
---|
| 174 | *p = 0;
|
---|
| 175 | }
|
---|
| 176 | else
|
---|
| 177 | *modpath = 0;
|
---|
[105] | 178 | if (!*modpath)
|
---|
| 179 | strcpy(modpath, path);
|
---|
| 180 | if (*path)
|
---|
[2] | 181 | MakeFullName(path);
|
---|
[105] | 182 | if (*modpath)
|
---|
[2] | 183 | MakeFullName(modpath);
|
---|
[105] | 184 | if (IsFullName(path))
|
---|
| 185 | drive = toupper(*path);
|
---|
| 186 | else
|
---|
| 187 | drive = 0;
|
---|
[2] | 188 |
|
---|
[1162] | 189 | p = command; // substitue for special % sequences
|
---|
[2] | 190 |
|
---|
[105] | 191 | pp = commandline;
|
---|
| 192 | *commandline = 0;
|
---|
[441] | 193 | while (*p) {
|
---|
| 194 | if (*p == '%') {
|
---|
| 195 | switch (*(p + 1)) {
|
---|
[1162] | 196 | case '!': /* write list to file, add filename */
|
---|
[1394] | 197 | if (list) {
|
---|
| 198 | if (!*listfile) {
|
---|
| 199 | FILE *fp;
|
---|
[2] | 200 |
|
---|
[1082] | 201 |
|
---|
[1394] | 202 | strcpy(listfile, pTmpDir ? pTmpDir : pFM2SaveDirectory);
|
---|
| 203 | MakeTempName(listfile, "$FM2LI$T", 2);
|
---|
| 204 | fp = xfopen(listfile, "w",pszSrcFile,__LINE__);
|
---|
| 205 | if (fp) {
|
---|
| 206 | for (x = 0; list[x]; x++)
|
---|
| 207 | {
|
---|
| 208 | fputs(list[x], fp);
|
---|
| 209 | if (list[x + 1])
|
---|
| 210 | fputc('\n', fp);
|
---|
| 211 | }
|
---|
| 212 | fclose(fp);
|
---|
| 213 | }
|
---|
| 214 | }
|
---|
| 215 | strcpy(pp, listfile);
|
---|
| 216 | pp += strlen(listfile);
|
---|
| 217 | }
|
---|
| 218 | p += 2;
|
---|
| 219 | break;
|
---|
[2] | 220 |
|
---|
[1162] | 221 | case 'c': /* add name of command processor */
|
---|
[1394] | 222 | {
|
---|
| 223 | char *env = GetCmdSpec(FALSE);
|
---|
[2] | 224 |
|
---|
[1394] | 225 | if (needs_quoting(env) && !strchr(env, '\"')) {
|
---|
| 226 | *pp = '\"';
|
---|
| 227 | pp++;
|
---|
| 228 | spaces = TRUE;
|
---|
| 229 | }
|
---|
| 230 | else
|
---|
| 231 | spaces = FALSE;
|
---|
| 232 | strcpy(pp, env);
|
---|
| 233 | p += 2;
|
---|
| 234 | pp += strlen(env);
|
---|
| 235 | if (spaces) {
|
---|
| 236 | *pp = '\"';
|
---|
| 237 | pp++;
|
---|
| 238 | }
|
---|
| 239 | }
|
---|
| 240 | break;
|
---|
[2] | 241 |
|
---|
[1162] | 242 | case 't': /* add Target directory */
|
---|
[1394] | 243 | if (needs_quoting(targetdir) && !strchr(targetdir, '\"')) {
|
---|
| 244 | *pp = '\"';
|
---|
| 245 | pp++;
|
---|
| 246 | spaces = TRUE;
|
---|
| 247 | }
|
---|
| 248 | else
|
---|
| 249 | spaces = FALSE;
|
---|
| 250 | strcpy(pp, targetdir);
|
---|
| 251 | p += 2;
|
---|
| 252 | pp += strlen(targetdir);
|
---|
| 253 | if (spaces) {
|
---|
| 254 | *pp = '\"';
|
---|
| 255 | pp++;
|
---|
| 256 | }
|
---|
| 257 | break;
|
---|
[2] | 258 |
|
---|
[1162] | 259 | case '$': /* add drive letter */
|
---|
[1394] | 260 | if (drive)
|
---|
| 261 | *pp = drive;
|
---|
| 262 | else {
|
---|
| 263 | ULONG ulDriveNum = 3, ulDriveMap;
|
---|
[2] | 264 |
|
---|
[1394] | 265 | DosQCurDisk(&ulDriveNum, &ulDriveMap);
|
---|
| 266 | *pp = (char) (ulDriveNum + '@');
|
---|
| 267 | }
|
---|
| 268 | pp++;
|
---|
| 269 | p += 2;
|
---|
| 270 | break;
|
---|
[2] | 271 |
|
---|
[1162] | 272 | case 'U': /* add path of first list component */
|
---|
[105] | 273 | case 'u':
|
---|
[1394] | 274 | if (*modpath) {
|
---|
| 275 | if (needs_quoting(modpath) && !strchr(modpath, '\"')) {
|
---|
| 276 | spaces = TRUE;
|
---|
| 277 | *pp = '\"';
|
---|
| 278 | pp++;
|
---|
| 279 | }
|
---|
| 280 | else
|
---|
| 281 | spaces = FALSE;
|
---|
| 282 | if (*(p + 1) == 'u') {
|
---|
| 283 | strcpy(pp, modpath);
|
---|
| 284 | pp += strlen(modpath);
|
---|
| 285 | }
|
---|
| 286 | else {
|
---|
| 287 | strcpy(pp, modpath + 2);
|
---|
| 288 | pp += strlen(modpath + 2);
|
---|
| 289 | }
|
---|
| 290 | if (spaces) {
|
---|
| 291 | if (modpath[strlen(modpath) - 1] == '\\') {
|
---|
| 292 | *pp = '\\';
|
---|
| 293 | pp++;
|
---|
| 294 | }
|
---|
| 295 | *pp = '\"';
|
---|
| 296 | pp++;
|
---|
| 297 | }
|
---|
| 298 | }
|
---|
| 299 | else {
|
---|
| 300 | char temp[CCHMAXPATH];
|
---|
[2] | 301 |
|
---|
[1394] | 302 | strcpy(temp, pFM2SaveDirectory);
|
---|
| 303 | if (needs_quoting(temp) && !strchr(temp, '\"')) {
|
---|
| 304 | spaces = TRUE;
|
---|
| 305 | *pp = '\"';
|
---|
| 306 | pp++;
|
---|
| 307 | }
|
---|
| 308 | else
|
---|
| 309 | spaces = FALSE;
|
---|
| 310 | strcpy(pp, temp);
|
---|
| 311 | pp += strlen(temp);
|
---|
| 312 | if (spaces) {
|
---|
| 313 | if (temp[strlen(temp) - 1] == '\\') {
|
---|
| 314 | *pp = '\\';
|
---|
| 315 | pp++;
|
---|
| 316 | }
|
---|
| 317 | *pp = '\"';
|
---|
| 318 | pp++;
|
---|
| 319 | }
|
---|
| 320 | }
|
---|
| 321 | p += 2;
|
---|
| 322 | break;
|
---|
[2] | 323 |
|
---|
[1162] | 324 | case 'P': /* add path of execution */
|
---|
[105] | 325 | case 'p':
|
---|
[1394] | 326 | if (*path) {
|
---|
| 327 | if (needs_quoting(path) && !strchr(path, '\"')) {
|
---|
| 328 | spaces = TRUE;
|
---|
| 329 | *pp = '\"';
|
---|
| 330 | pp++;
|
---|
| 331 | }
|
---|
| 332 | else
|
---|
| 333 | spaces = FALSE;
|
---|
| 334 | if (*(p + 1) == 'p') {
|
---|
| 335 | strcpy(pp, path);
|
---|
| 336 | pp += strlen(path);
|
---|
| 337 | }
|
---|
| 338 | else {
|
---|
| 339 | strcpy(pp, path + 2);
|
---|
| 340 | pp += strlen(path + 2);
|
---|
| 341 | }
|
---|
| 342 | if (spaces) {
|
---|
| 343 | if (path[strlen(path) - 1] == '\\') {
|
---|
| 344 | *pp = '\\';
|
---|
| 345 | pp++;
|
---|
| 346 | }
|
---|
| 347 | *pp = '\"';
|
---|
| 348 | pp++;
|
---|
| 349 | }
|
---|
| 350 | }
|
---|
| 351 | else {
|
---|
| 352 | char temp[CCHMAXPATH];
|
---|
[2] | 353 |
|
---|
[1394] | 354 | strcpy(temp, pFM2SaveDirectory);
|
---|
| 355 | if (needs_quoting(temp) && !strchr(temp, '\"')) {
|
---|
| 356 | spaces = TRUE;
|
---|
| 357 | *pp = '\"';
|
---|
| 358 | pp++;
|
---|
| 359 | }
|
---|
| 360 | else
|
---|
| 361 | spaces = FALSE;
|
---|
| 362 | strcpy(pp, temp);
|
---|
| 363 | pp += strlen(temp);
|
---|
| 364 | if (spaces) {
|
---|
| 365 | if (temp[strlen(temp) - 1] == '\\') {
|
---|
| 366 | *pp = '\\';
|
---|
| 367 | pp++;
|
---|
| 368 | }
|
---|
| 369 | *pp = '\"';
|
---|
| 370 | pp++;
|
---|
| 371 | }
|
---|
| 372 | }
|
---|
| 373 | p += 2;
|
---|
| 374 | break;
|
---|
[2] | 375 |
|
---|
[105] | 376 | case 'D':
|
---|
[1394] | 377 | if (hwndMain) {
|
---|
| 378 | PCNRITEM pci;
|
---|
[2] | 379 |
|
---|
[1394] | 380 | pci = (PCNRITEM) WinSendMsg(WinWindowFromID(WinWindowFromID(
|
---|
| 381 | hwndTree, FID_CLIENT), TREE_CNR),
|
---|
| 382 | CM_QUERYRECORDEMPHASIS,
|
---|
| 383 | MPFROMLONG(CMA_FIRST),
|
---|
| 384 | MPFROMSHORT(CRA_CURSORED));
|
---|
| 385 | if (pci && (int) pci != -1 && *pci->pszFileName) {
|
---|
| 386 | if (needs_quoting(pci->pszFileName) &&
|
---|
| 387 | !strchr(pci->pszFileName, '\"'))
|
---|
| 388 | {
|
---|
| 389 | *pp = '\"';
|
---|
| 390 | pp++;
|
---|
| 391 | spaces = TRUE;
|
---|
| 392 | }
|
---|
| 393 | else
|
---|
| 394 | spaces = FALSE;
|
---|
| 395 | strcpy(pp, pci->pszFileName);
|
---|
| 396 | pp += strlen(pci->pszFileName);
|
---|
| 397 | if (spaces) {
|
---|
| 398 | *pp = '\"';
|
---|
| 399 | pp++;
|
---|
| 400 | }
|
---|
| 401 | }
|
---|
| 402 | }
|
---|
| 403 | p += 2;
|
---|
| 404 | break;
|
---|
[2] | 405 |
|
---|
[105] | 406 | case 'd':
|
---|
[1394] | 407 | if (hwndMain) {
|
---|
| 408 | HENUM henum;
|
---|
| 409 | char retstr[CCHMAXPATH];
|
---|
| 410 | HWND hwndC, hwndDir;
|
---|
| 411 | USHORT id;
|
---|
| 412 | BOOL first = TRUE;
|
---|
[2] | 413 |
|
---|
[1394] | 414 | henum = WinBeginEnumWindows(hwndMain);
|
---|
| 415 | while ((hwndC = WinGetNextWindow(henum)) != NULLHANDLE) {
|
---|
| 416 | if (hwndC != hwndTree) {
|
---|
| 417 | id = WinQueryWindowUShort(hwndC, QWS_ID);
|
---|
| 418 | if (id) {
|
---|
| 419 | hwndDir = WinWindowFromID(hwndC, FID_CLIENT);
|
---|
| 420 | if (hwndDir) {
|
---|
| 421 | hwndDir = WinWindowFromID(hwndDir, DIR_CNR);
|
---|
| 422 | if (hwndDir) {
|
---|
| 423 | *retstr = 0;
|
---|
| 424 | WinSendMsg(hwndC, UM_CONTAINERDIR, MPFROMP(retstr), MPVOID);
|
---|
| 425 | if (*retstr) {
|
---|
| 426 | if (!first) {
|
---|
| 427 | *pp = ' ';
|
---|
| 428 | pp++;
|
---|
| 429 | }
|
---|
| 430 | first = FALSE;
|
---|
| 431 | if (needs_quoting(retstr) && !strchr(retstr, '\"')) {
|
---|
| 432 | *pp = '\"';
|
---|
| 433 | pp++;
|
---|
| 434 | spaces = TRUE;
|
---|
| 435 | }
|
---|
| 436 | else
|
---|
| 437 | spaces = FALSE;
|
---|
| 438 | strcpy(pp, retstr);
|
---|
| 439 | pp += strlen(retstr);
|
---|
| 440 | if (spaces) {
|
---|
| 441 | *pp = '\"';
|
---|
| 442 | pp++;
|
---|
| 443 | }
|
---|
| 444 | }
|
---|
| 445 | }
|
---|
| 446 | }
|
---|
| 447 | }
|
---|
| 448 | }
|
---|
| 449 | }
|
---|
| 450 | WinEndEnumWindows(henum);
|
---|
| 451 | }
|
---|
| 452 | p += 2;
|
---|
| 453 | break;
|
---|
[2] | 454 |
|
---|
[105] | 455 | case '%':
|
---|
[1394] | 456 | *pp = '%';
|
---|
| 457 | pp++;
|
---|
| 458 | p += 2;
|
---|
| 459 | break;
|
---|
[2] | 460 |
|
---|
[105] | 461 | case 'R':
|
---|
| 462 | case 'F':
|
---|
| 463 | case 'A':
|
---|
| 464 | case 'r':
|
---|
| 465 | case 'f':
|
---|
| 466 | case 'a':
|
---|
| 467 | case 'e':
|
---|
[1394] | 468 | if (list) {
|
---|
| 469 | for (x = 0; list[x]; x++)
|
---|
| 470 | {
|
---|
| 471 | file = strrchr(list[x], '\\');
|
---|
| 472 | if (!file)
|
---|
| 473 | file = strrchr(list[x], ':');
|
---|
| 474 | if (file)
|
---|
| 475 | file++;
|
---|
| 476 | else
|
---|
| 477 | file = list[x];
|
---|
| 478 | ext = strrchr(file, '.');
|
---|
| 479 | dot = ext;
|
---|
| 480 | if (ext)
|
---|
| 481 | ext++;
|
---|
| 482 | switch (*(p + 1)) {
|
---|
| 483 | case 'R':
|
---|
| 484 | case 'r':
|
---|
| 485 | if (pp + strlen(list[x]) > commandline + MaxComLineStrg)
|
---|
| 486 | goto BreakOut;
|
---|
| 487 | if (*(p + 1) == 'r') {
|
---|
| 488 | strcpy(pp, list[x]);
|
---|
| 489 | pp += strlen(list[x]);
|
---|
| 490 | }
|
---|
| 491 | else {
|
---|
| 492 | strcpy(pp, list[x] + 2);
|
---|
| 493 | pp += strlen(list[x] + 2);
|
---|
| 494 | }
|
---|
| 495 | break;
|
---|
[2] | 496 |
|
---|
[1394] | 497 | case 'F':
|
---|
| 498 | case 'f':
|
---|
| 499 | if (*(p + 1) == 'F' && dot)
|
---|
| 500 | *dot = 0;
|
---|
| 501 | if (pp + strlen(file) > commandline + MaxComLineStrg)
|
---|
| 502 | goto BreakOut;
|
---|
| 503 | if (needs_quoting(file)) {
|
---|
| 504 | spaces = TRUE;
|
---|
| 505 | *pp = '\"';
|
---|
| 506 | pp++;
|
---|
| 507 | }
|
---|
| 508 | else
|
---|
| 509 | spaces = FALSE;
|
---|
| 510 | strcpy(pp, file);
|
---|
| 511 | pp += strlen(file);
|
---|
| 512 | if (*(p + 1) == 'F' && dot)
|
---|
| 513 | *dot = '.';
|
---|
| 514 | if (spaces) {
|
---|
| 515 | if (*(pp - 1) != '\"') {
|
---|
| 516 | *pp = '\"';
|
---|
| 517 | pp++;
|
---|
| 518 | }
|
---|
| 519 | }
|
---|
| 520 | break;
|
---|
[2] | 521 |
|
---|
[1394] | 522 | case 'A':
|
---|
| 523 | case 'a':
|
---|
| 524 | if (pp + strlen(list[x]) > commandline + MaxComLineStrg)
|
---|
| 525 | goto BreakOut;
|
---|
| 526 | if (needs_quoting(list[x]) && !strchr(list[x], '\"')) {
|
---|
| 527 | spaces = TRUE;
|
---|
| 528 | *pp = '\"';
|
---|
| 529 | pp++;
|
---|
| 530 | }
|
---|
| 531 | else
|
---|
| 532 | spaces = FALSE;
|
---|
| 533 | if (*(p + 1) == 'a') {
|
---|
| 534 | strcpy(pp, list[x]);
|
---|
| 535 | pp += strlen(list[x]);
|
---|
| 536 | }
|
---|
| 537 | else {
|
---|
| 538 | strcpy(pp, list[x] + 2);
|
---|
| 539 | pp += strlen(list[x] + 2);
|
---|
| 540 | }
|
---|
| 541 | if (spaces) {
|
---|
| 542 | if (list[x][strlen(list[x]) - 1] == '\\') {
|
---|
| 543 | *pp = '\\';
|
---|
| 544 | pp++;
|
---|
| 545 | }
|
---|
| 546 | *pp = '\"';
|
---|
| 547 | pp++;
|
---|
| 548 | }
|
---|
| 549 | break;
|
---|
[2] | 550 |
|
---|
[1394] | 551 | case 'e':
|
---|
| 552 | if (ext) {
|
---|
| 553 | if (pp + strlen(ext) > commandline + MaxComLineStrg)
|
---|
| 554 | goto BreakOut;
|
---|
| 555 | if (needs_quoting(ext)) {
|
---|
| 556 | spaces = TRUE;
|
---|
| 557 | *pp = '\"';
|
---|
| 558 | pp++;
|
---|
| 559 | }
|
---|
| 560 | else
|
---|
| 561 | spaces = FALSE;
|
---|
| 562 | strcpy(pp, ext);
|
---|
| 563 | pp += strlen(ext);
|
---|
| 564 | if (spaces) {
|
---|
| 565 | if (*(pp - 1) != '\"') {
|
---|
| 566 | *pp = '\"';
|
---|
| 567 | pp++;
|
---|
| 568 | }
|
---|
| 569 | }
|
---|
| 570 | }
|
---|
| 571 | break;
|
---|
| 572 | }
|
---|
| 573 | if (list[x + 1]) {
|
---|
| 574 | *pp = ' ';
|
---|
| 575 | pp++;
|
---|
| 576 | }
|
---|
| 577 | }
|
---|
| 578 | }
|
---|
| 579 | p += 2;
|
---|
| 580 | break;
|
---|
[2] | 581 |
|
---|
[105] | 582 | default:
|
---|
[1394] | 583 | *pp = *p;
|
---|
| 584 | p++;
|
---|
| 585 | pp++;
|
---|
| 586 | break;
|
---|
[105] | 587 | }
|
---|
| 588 | }
|
---|
[441] | 589 | else {
|
---|
[105] | 590 | *pp = *p;
|
---|
| 591 | pp++;
|
---|
| 592 | p++;
|
---|
| 593 | }
|
---|
| 594 | *pp = 0;
|
---|
| 595 | }
|
---|
| 596 |
|
---|
[2] | 597 | BreakOut:
|
---|
| 598 |
|
---|
[105] | 599 | {
|
---|
| 600 | EXECARGS ex;
|
---|
| 601 | ULONG size;
|
---|
| 602 | int ret;
|
---|
[2] | 603 |
|
---|
[105] | 604 | memset(&ex, 0, sizeof(EXECARGS));
|
---|
| 605 | size = sizeof(ex.environment) - 1;
|
---|
| 606 | PrfQueryProfileData(fmprof, FM3Str, command, ex.environment, &size);
|
---|
[441] | 607 | if (flags & PROMPT) {
|
---|
| 608 | /* allow editing command line */
|
---|
[105] | 609 | ex.flags = (flags & (~PROMPT));
|
---|
| 610 | ex.commandline = commandline;
|
---|
| 611 | strcpy(ex.path, path);
|
---|
| 612 | if (prompt)
|
---|
[1394] | 613 | strcpy(ex.title, prompt);
|
---|
[105] | 614 | ret = WinDlgBox(HWND_DESKTOP, hwnd, CmdLineDlgProc, FM3ModHandle,
|
---|
[1394] | 615 | EXEC_FRAME, &ex);
|
---|
[985] | 616 | if (ret != 1) {
|
---|
[1394] | 617 | free(commandline);
|
---|
| 618 | return (ret == 0) ? -1 : -2;
|
---|
[985] | 619 | }
|
---|
[105] | 620 | }
|
---|
| 621 | else
|
---|
| 622 | ex.flags = flags;
|
---|
| 623 | ex.flags &= (~PROMPT);
|
---|
[1014] | 624 | ret = runemf2(ex.flags, hwnd, pszCallingFile, uiLineNumber, path,
|
---|
[1394] | 625 | (*ex.environment) ? ex.environment : NULL,
|
---|
| 626 | "%s", commandline);
|
---|
[1039] | 627 | free(commandline);
|
---|
[1014] | 628 | return ret;
|
---|
[105] | 629 | }
|
---|
[2] | 630 | }
|
---|
| 631 |
|
---|
[917] | 632 | /** Run requested app
|
---|
| 633 | * @return application return code or -1 if problem starting app
|
---|
| 634 | */
|
---|
[441] | 635 |
|
---|
[888] | 636 | int runemf2(int type, HWND hwnd, PCSZ pszCallingFile, UINT uiLineNumber,
|
---|
[1394] | 637 | char *pszDirectory, char *pszEnvironment,
|
---|
| 638 | char *formatstring,...)
|
---|
[78] | 639 | {
|
---|
[920] | 640 | /** example:
|
---|
[105] | 641 |
|
---|
[2] | 642 | * status = runemf2(SEPARATE | WINDOWED,
|
---|
[888] | 643 | * hwnd, pszCallingFile, __LINE__,
|
---|
[2] | 644 | * NullStr,
|
---|
| 645 | * NULL,
|
---|
| 646 | * "%s /C %s",
|
---|
| 647 | * getenv("COMSPEC"),
|
---|
| 648 | * batchfilename);
|
---|
[105] | 649 | *
|
---|
| 650 | * use (HWND)0 for hwnd if window handle not handy.
|
---|
[888] | 651 | * pszCallingFile and __LINE__ are used to determine caller for easier error tracking
|
---|
[105] | 652 | */
|
---|
[2] | 653 |
|
---|
[920] | 654 | /**
|
---|
[1252] | 655 | * type bitmapped flag -- see systemf.h
|
---|
[2] | 656 | */
|
---|
| 657 |
|
---|
[105] | 658 | va_list parguments;
|
---|
| 659 | int ret = -1;
|
---|
[540] | 660 | RESULTCODES results;
|
---|
[519] | 661 | STARTDATA sdata;
|
---|
[105] | 662 | REQUESTDATA rq;
|
---|
[562] | 663 | ULONG ulSessID;
|
---|
| 664 | ULONG ulLength;
|
---|
| 665 | UINT ctr;
|
---|
| 666 | ULONG ulAppType;
|
---|
[105] | 667 | PID sessPID;
|
---|
| 668 | BOOL wasquote;
|
---|
[1438] | 669 | char *p, *pszPgm, *pszArgs = NULL;
|
---|
| 670 | char szObject[32] = "";
|
---|
| 671 | char szSavedir[CCHMAXPATH];
|
---|
[540] | 672 | BOOL useTermQ = FALSE;
|
---|
| 673 | char szTempdir[CCHMAXPATH];
|
---|
[1369] | 674 | BOOL fNoErrorMsg = FALSE;
|
---|
[540] | 675 |
|
---|
[519] | 676 | typedef struct {
|
---|
| 677 | USHORT usSessID;
|
---|
| 678 | USHORT usRC;
|
---|
| 679 | } TERMINFO;
|
---|
| 680 |
|
---|
[540] | 681 | TERMINFO *pTermInfo;
|
---|
[105] | 682 | BYTE bPriority;
|
---|
| 683 | APIRET rc;
|
---|
[519] | 684 | PIB *ppib;
|
---|
| 685 | TIB *ptib;
|
---|
[2] | 686 |
|
---|
[540] | 687 | // Shared by all threads
|
---|
| 688 | # define TERMQ_BASE_NAME "\\QUEUES\\FM3WAIT"
|
---|
| 689 | static char szTermQName[30];
|
---|
[1480] | 690 | char szTermTemp[30];
|
---|
[540] | 691 | static HQUEUE hTermQ;
|
---|
[1271] | 692 | static HEV hTermQSem;
|
---|
[540] | 693 |
|
---|
| 694 | if (pszDirectory && *pszDirectory) {
|
---|
| 695 | if (!DosQueryPathInfo(pszDirectory,
|
---|
[1394] | 696 | FIL_QUERYFULLNAME,
|
---|
| 697 | szTempdir,
|
---|
| 698 | sizeof(szTempdir)))
|
---|
[540] | 699 | pszDirectory = szTempdir;
|
---|
[105] | 700 | }
|
---|
[2] | 701 |
|
---|
[105] | 702 | if (!hwnd)
|
---|
| 703 | hwnd = HWND_DESKTOP;
|
---|
[2] | 704 |
|
---|
[1439] | 705 | rc = DosAllocMem((PVOID)&pszPgm,
|
---|
| 706 | MaxComLineStrg,
|
---|
| 707 | PAG_COMMIT | PAG_READ | PAG_WRITE);
|
---|
[330] | 708 | if (rc) {
|
---|
| 709 | Dos_Error(MB_CANCEL,rc,hwnd,pszSrcFile,__LINE__,GetPString(IDS_OUTOFMEMORY));
|
---|
[105] | 710 | return -1;
|
---|
[330] | 711 | }
|
---|
[2] | 712 |
|
---|
[540] | 713 | *szSavedir = 0;
|
---|
[2] | 714 |
|
---|
[540] | 715 | *pszPgm = 0;
|
---|
[105] | 716 | va_start(parguments,
|
---|
[1394] | 717 | formatstring);
|
---|
[540] | 718 | vsprintf(pszPgm,
|
---|
[1394] | 719 | formatstring,
|
---|
| 720 | parguments);
|
---|
[105] | 721 | va_end(parguments);
|
---|
[906] | 722 |
|
---|
[540] | 723 | if (pszEnvironment) {
|
---|
| 724 | p = &pszEnvironment[strlen(pszEnvironment)] + 1;
|
---|
[105] | 725 | *p = 0;
|
---|
[540] | 726 | p = pszEnvironment;
|
---|
[373] | 727 | while ((p = convert_nl_to_nul(p)) != NULL)
|
---|
| 728 | ; // loop
|
---|
[105] | 729 | }
|
---|
[2] | 730 |
|
---|
[1369] | 731 | if (!stricmp(pszCallingFile, "init.c"))
|
---|
| 732 | fNoErrorMsg = TRUE;
|
---|
| 733 |
|
---|
[540] | 734 | if (!*pszPgm) {
|
---|
[105] | 735 | p = GetCmdSpec(FALSE);
|
---|
[540] | 736 | strcpy(pszPgm, p);
|
---|
| 737 | if (!*pszPgm) {
|
---|
[1398] | 738 | Runtime_Error(pszSrcFile, __LINE__, NULL);
|
---|
[105] | 739 | return -1;
|
---|
[441] | 740 | }
|
---|
[105] | 741 | }
|
---|
[2] | 742 |
|
---|
[540] | 743 | if (*pszPgm) {
|
---|
| 744 | if (*pszPgm == '<' && strchr(pszPgm, '>')) {
|
---|
[441] | 745 | /* is a workplace object */
|
---|
[105] | 746 | HOBJECT hWPSObject;
|
---|
| 747 | char temp;
|
---|
[2] | 748 |
|
---|
[540] | 749 | p = strchr(pszPgm, '>');
|
---|
[105] | 750 | p++;
|
---|
| 751 | temp = *p;
|
---|
[330] | 752 | if (temp) {
|
---|
[1439] | 753 | rc = DosAllocMem((PVOID)&pszArgs,
|
---|
| 754 | MaxComLineStrg * 2,
|
---|
| 755 | PAG_COMMIT | PAG_READ | PAG_WRITE);
|
---|
[1394] | 756 | if (rc)
|
---|
| 757 | Dos_Error(MB_CANCEL,rc,hwnd,pszSrcFile,__LINE__,GetPString(IDS_OUTOFMEMORY));
|
---|
[330] | 758 | }
|
---|
[105] | 759 | else
|
---|
[1394] | 760 | pszArgs = NULL;
|
---|
[105] | 761 | *p = 0;
|
---|
| 762 | /* Find the handle of the WPS object */
|
---|
[540] | 763 | hWPSObject = WinQueryObject(pszPgm);
|
---|
[105] | 764 | *p = temp;
|
---|
[441] | 765 | if (hWPSObject != NULLHANDLE) {
|
---|
[1394] | 766 | if (pszArgs && *p) {
|
---|
| 767 | sprintf(pszArgs,"OPEN=DEFAULT;PARAMETERS=\"%s\"",p);
|
---|
| 768 | WinSetObjectData(hWPSObject,pszArgs);
|
---|
| 769 | }
|
---|
| 770 | else
|
---|
| 771 | WinSetObjectData(hWPSObject,"OPEN=DEFAULT");
|
---|
| 772 | ret = 0;
|
---|
[105] | 773 | }
|
---|
| 774 | goto ObjectInterrupt;
|
---|
| 775 | }
|
---|
[2] | 776 |
|
---|
[773] | 777 | if ((type & RUNTYPE_MASK) == SYNCHRONOUS ||
|
---|
[1394] | 778 | (type & RUNTYPE_MASK) == ASYNCHRONOUS ||
|
---|
| 779 | (type & RUNTYPE_MASK) == DETACHED)
|
---|
[105] | 780 | {
|
---|
[540] | 781 | strip_lead_char(" \t", pszPgm);
|
---|
| 782 | p = pszPgm;
|
---|
[105] | 783 | wasquote = FALSE;
|
---|
| 784 | while (*p &&
|
---|
[1394] | 785 | (wasquote ||
|
---|
| 786 | (*p != ' ' &&
|
---|
| 787 | *p != '\t')))
|
---|
[105] | 788 | {
|
---|
[1394] | 789 | if (*p == '\"') {
|
---|
| 790 | if (!wasquote) {
|
---|
| 791 | wasquote = TRUE;
|
---|
| 792 | memmove(p,
|
---|
| 793 | p + 1,
|
---|
| 794 | strlen(p));
|
---|
| 795 | while (*p == ' ' ||
|
---|
| 796 | *p == '\t')
|
---|
| 797 | p++;
|
---|
| 798 | }
|
---|
| 799 | else {
|
---|
| 800 | memmove(p,
|
---|
| 801 | p + 1,
|
---|
| 802 | strlen(p));
|
---|
| 803 | break;
|
---|
| 804 | }
|
---|
| 805 | }
|
---|
| 806 | else
|
---|
| 807 | p++;
|
---|
[105] | 808 | }
|
---|
[441] | 809 | if (*p) {
|
---|
[1394] | 810 | *p = 0;
|
---|
| 811 | p++;
|
---|
[105] | 812 | }
|
---|
| 813 | else
|
---|
[1394] | 814 | p = pszPgm;
|
---|
[1162] | 815 | p[strlen(p) + 1] = 0; /* double-terminate args */
|
---|
[540] | 816 | if (*pszPgm) {
|
---|
[1394] | 817 | if (!strchr(pszPgm, '\\') &&
|
---|
| 818 | !strchr(pszPgm, ':') &&
|
---|
| 819 | pszDirectory &&
|
---|
| 820 | *pszDirectory)
|
---|
| 821 | {
|
---|
| 822 | strcpy(szSavedir, pFM2SaveDirectory);
|
---|
| 823 | switch_to(pszDirectory);
|
---|
| 824 | }
|
---|
| 825 | rc = DosQueryAppType(pszPgm,&ulAppType);
|
---|
| 826 | if (!strchr(pszPgm, '\\') &&
|
---|
| 827 | !strchr(pszPgm, ':') &&
|
---|
| 828 | pszDirectory &&
|
---|
| 829 | *pszDirectory)
|
---|
| 830 | switch_to(szSavedir);
|
---|
| 831 | if (rc) {
|
---|
| 832 | Dos_Error(MB_CANCEL,rc,hwnd,pszSrcFile,__LINE__,
|
---|
| 833 | GetPString(IDS_DOSQAPPTYPEFAILEDTEXT),
|
---|
| 834 | pszPgm, pszCallingFile, uiLineNumber); // 26 May 08 SHL
|
---|
| 835 | DosFreeMem(pszPgm);
|
---|
| 836 | if (pszArgs)
|
---|
| 837 | DosFreeMem(pszArgs);
|
---|
| 838 | return -1;
|
---|
| 839 | }
|
---|
| 840 | if (ulAppType) {
|
---|
| 841 | if (ulAppType & FAPPTYP_DLL || ulAppType & FAPPTYP_VIRTDRV ||
|
---|
| 842 | ulAppType & FAPPTYP_PHYSDRV || ulAppType & FAPPTYP_PROTDLL)
|
---|
| 843 | {
|
---|
| 844 | Runtime_Error(pszSrcFile, __LINE__,
|
---|
| 845 | GetPString(IDS_APPTYPEUNEXPECTEDTEXT),
|
---|
| 846 | ulAppType, pszPgm, pszCallingFile, uiLineNumber); // 26 May 08 SHL
|
---|
| 847 | if (pszPgm)
|
---|
| 848 | DosFreeMem(pszPgm);
|
---|
| 849 | if (pszArgs)
|
---|
| 850 | DosFreeMem(pszArgs);
|
---|
| 851 | return -1;
|
---|
| 852 | }
|
---|
| 853 | if (ulAppType & FAPPTYP_DOS || ulAppType & FAPPTYP_WINDOWSREAL ||
|
---|
| 854 | ulAppType & FAPPTYP_WINDOWSPROT || ulAppType & FAPPTYP_WINDOWSPROT31)
|
---|
| 855 | {
|
---|
| 856 | Runtime_Error(pszSrcFile, __LINE__,
|
---|
| 857 | GetPString(IDS_APPTYPEUNEXPECTEDTEXT),
|
---|
| 858 | ulAppType, pszPgm, pszCallingFile, uiLineNumber); // 26 May 08 SHL
|
---|
| 859 | if (pszPgm)
|
---|
| 860 | DosFreeMem(pszPgm);
|
---|
| 861 | if (pszArgs)
|
---|
| 862 | DosFreeMem(pszArgs);
|
---|
| 863 | return -1;
|
---|
| 864 | }
|
---|
| 865 | }
|
---|
| 866 | memset(&results, 0, sizeof(results));
|
---|
| 867 | if (pszDirectory && *pszDirectory) {
|
---|
| 868 | strcpy(szSavedir, pFM2SaveDirectory);
|
---|
| 869 | switch_to(pszDirectory);
|
---|
| 870 | }
|
---|
| 871 | ret = DosExecPgm(szObject, sizeof(szObject),
|
---|
| 872 | ((type & RUNTYPE_MASK) == ASYNCHRONOUS ? EXEC_ASYNC : 0) +
|
---|
| 873 | ((type & RUNTYPE_MASK) == DETACHED ? EXEC_BACKGROUND : 0),
|
---|
| 874 | pszPgm, pszEnvironment, &results, pszPgm);
|
---|
| 875 | if (pszDirectory && *pszDirectory)
|
---|
| 876 | switch_to(szSavedir);
|
---|
| 877 | if (ret && !fNoErrorMsg) {
|
---|
| 878 | Dos_Error(MB_ENTER,ret,hwnd,pszSrcFile,__LINE__,
|
---|
| 879 | GetPString(IDS_DOSEXECPGMFAILEDTEXT), pszPgm,
|
---|
| 880 | pszCallingFile, uiLineNumber); // 26 May 08 SHL
|
---|
| 881 | }
|
---|
[105] | 882 | }
|
---|
| 883 | }
|
---|
[441] | 884 | else {
|
---|
[519] | 885 | if (~type & FULLSCREEN)
|
---|
[1394] | 886 | type |= WINDOWED;
|
---|
[1439] | 887 | rc = DosAllocMem((PVOID) & pszArgs, MaxComLineStrg * 2,
|
---|
| 888 | PAG_COMMIT | PAG_READ | PAG_WRITE);
|
---|
[441] | 889 | if (rc) {
|
---|
[1394] | 890 | Dos_Error(MB_CANCEL,rc,hwnd,pszSrcFile,__LINE__,GetPString(IDS_OUTOFMEMORY));
|
---|
| 891 | DosFreeMem(pszPgm);
|
---|
| 892 | return -1;
|
---|
[105] | 893 | }
|
---|
[540] | 894 | *pszArgs = 0;
|
---|
| 895 | memset(&sdata, 0, sizeof(sdata));
|
---|
| 896 | strip_lead_char(" \t", pszPgm);
|
---|
| 897 | p = pszPgm;
|
---|
[105] | 898 | wasquote = FALSE;
|
---|
[441] | 899 | while (*p && (wasquote || (*p != ' ' && *p != '\t'))) {
|
---|
[1394] | 900 | if (*p == '\"') {
|
---|
| 901 | if (!wasquote) {
|
---|
| 902 | wasquote = TRUE;
|
---|
| 903 | memmove(p, p + 1, strlen(p));
|
---|
| 904 | while (*p == ' ' || *p == '\t')
|
---|
| 905 | p++;
|
---|
| 906 | }
|
---|
| 907 | else {
|
---|
| 908 | memmove(p, p + 1, strlen(p));
|
---|
| 909 | break;
|
---|
| 910 | }
|
---|
| 911 | }
|
---|
| 912 | else
|
---|
| 913 | p++;
|
---|
[540] | 914 | } // while
|
---|
[441] | 915 | if (*p) {
|
---|
[1394] | 916 | *p = 0;
|
---|
| 917 | p++;
|
---|
[105] | 918 | }
|
---|
| 919 | else
|
---|
[1394] | 920 | p = NullStr;
|
---|
[105] | 921 | if (*p)
|
---|
[1394] | 922 | strcpy(pszArgs, p);
|
---|
[2] | 923 |
|
---|
[540] | 924 | p = strrchr(pszPgm, '.');
|
---|
[441] | 925 | if (p) {
|
---|
[1394] | 926 | char temp[CCHMAXPATH + 1];
|
---|
[2] | 927 |
|
---|
[1398] | 928 | if (!stricmp(p, PCSZ_DOTBAT)) {
|
---|
| 929 | if (!fProtectOnly) {
|
---|
| 930 | strcpy(temp, pszPgm);
|
---|
| 931 | strcpy(pszPgm, pszArgs);
|
---|
| 932 | strcpy(pszArgs, "/C ");
|
---|
| 933 | strcat(pszArgs, temp);
|
---|
| 934 | strcat(pszArgs, " ");
|
---|
| 935 | strcat(pszArgs, pszPgm);
|
---|
| 936 | strcpy(pszPgm, GetCmdSpec(TRUE)); // DOS
|
---|
| 937 | }
|
---|
| 938 | else
|
---|
| 939 | saymsg(MB_OK,
|
---|
| 940 | HWND_DESKTOP,
|
---|
| 941 | NullStr,
|
---|
| 942 | GetPString(IDS_NOTPROTECTONLYEXE),
|
---|
| 943 | pszPgm);
|
---|
[1394] | 944 | }
|
---|
[1398] | 945 | else if (!stricmp(p, PCSZ_DOTCMD) || !stricmp(p, PCSZ_DOTBTM)) {
|
---|
[1394] | 946 | // Assume 4OS2 is BTM
|
---|
| 947 | strcpy(temp, pszPgm);
|
---|
| 948 | strcpy(pszPgm, pszArgs);
|
---|
| 949 | strcpy(pszArgs, "/C ");
|
---|
| 950 | strcat(pszArgs, temp);
|
---|
| 951 | strcat(pszArgs, " ");
|
---|
| 952 | strcat(pszArgs, pszPgm);
|
---|
| 953 | strcpy(pszPgm, GetCmdSpec(FALSE)); // OS/2
|
---|
| 954 | }
|
---|
[105] | 955 | }
|
---|
[2] | 956 |
|
---|
[888] | 957 | // goddamned OS/2 limit
|
---|
[2] | 958 |
|
---|
[540] | 959 | if (strlen(pszPgm) + strlen(pszArgs) > 1024)
|
---|
[1394] | 960 | pszArgs[1024 - strlen(pszPgm)] = 0;
|
---|
[2] | 961 |
|
---|
[540] | 962 | if (!strchr(pszPgm, '\\') &&
|
---|
[1394] | 963 | !strchr(pszPgm, ':') &&
|
---|
| 964 | pszDirectory &&
|
---|
| 965 | *pszDirectory)
|
---|
[105] | 966 | {
|
---|
[1394] | 967 | strcpy(szSavedir, pFM2SaveDirectory);
|
---|
| 968 | switch_to(pszDirectory);
|
---|
[105] | 969 | }
|
---|
[562] | 970 | rc = DosQueryAppType(pszPgm,&ulAppType);
|
---|
[540] | 971 | if (!strchr(pszPgm, '\\') &&
|
---|
[1394] | 972 | !strchr(pszPgm, ':') &&
|
---|
| 973 | pszDirectory &&
|
---|
| 974 | *pszDirectory)
|
---|
| 975 | switch_to(szSavedir);
|
---|
[917] | 976 | if (rc) {
|
---|
[1394] | 977 | Dos_Error(MB_CANCEL,rc,hwnd,pszSrcFile,__LINE__,
|
---|
| 978 | GetPString(IDS_DOSQAPPTYPEFAILEDTEXT),
|
---|
| 979 | pszPgm, pszCallingFile, uiLineNumber); // 26 May 08 SHL
|
---|
| 980 | DosFreeMem(pszPgm);
|
---|
| 981 | if (pszArgs)
|
---|
| 982 | DosFreeMem(pszArgs);
|
---|
| 983 | return -1;
|
---|
[105] | 984 | }
|
---|
[2] | 985 |
|
---|
[562] | 986 | if (ulAppType) {
|
---|
[1394] | 987 | if (ulAppType & (FAPPTYP_DLL | FAPPTYP_VIRTDRV | FAPPTYP_PHYSDRV | FAPPTYP_PROTDLL))
|
---|
| 988 | {
|
---|
| 989 | Runtime_Error(pszSrcFile, __LINE__,
|
---|
| 990 | GetPString(IDS_APPTYPEUNEXPECTEDTEXT),
|
---|
| 991 | ulAppType, pszPgm, pszCallingFile, uiLineNumber); // 26 May 08 SHL
|
---|
| 992 | DosFreeMem(pszPgm);
|
---|
| 993 | if (pszArgs)
|
---|
| 994 | DosFreeMem(pszArgs);
|
---|
| 995 | return -1;
|
---|
| 996 | }
|
---|
| 997 | ulAppType &= ~FAPPTYP_BOUND;
|
---|
| 998 | if (ulAppType & (FAPPTYP_DOS | FAPPTYP_WINDOWSREAL | FAPPTYP_WINDOWSPROT | FAPPTYP_WINDOWSPROT31))
|
---|
| 999 | {
|
---|
| 1000 | if (ulAppType & (FAPPTYP_WINDOWSREAL | FAPPTYP_WINDOWSPROT | FAPPTYP_WINDOWSPROT31))
|
---|
| 1001 | {
|
---|
| 1002 | if (~type & FULLSCREEN &&
|
---|
| 1003 | ulAppType & (FAPPTYP_WINDOWSREAL | FAPPTYP_WINDOWSPROT | FAPPTYP_WINDOWSPROT31))
|
---|
| 1004 | {
|
---|
| 1005 | ret = RunSeamless(pszPgm, pszArgs, hwnd);
|
---|
| 1006 | if (pszPgm)
|
---|
| 1007 | DosFreeMem(pszPgm);
|
---|
| 1008 | if (pszArgs)
|
---|
| 1009 | DosFreeMem(pszArgs);
|
---|
| 1010 | return ret ? 0 : -1;
|
---|
| 1011 | }
|
---|
| 1012 | else {
|
---|
| 1013 | strcat(pszPgm, " ");
|
---|
| 1014 | strcat(pszPgm, pszArgs);
|
---|
| 1015 | *pszArgs = 0;
|
---|
| 1016 | if (ulAppType & (FAPPTYP_WINDOWSPROT | FAPPTYP_WINDOWSREAL | FAPPTYP_WINDOWSPROT31))
|
---|
| 1017 | strcat(pszArgs, "/3 ");
|
---|
| 1018 | strcat(pszArgs, pszPgm);
|
---|
| 1019 | strcpy(pszPgm, "WINOS2.COM");
|
---|
| 1020 | }
|
---|
| 1021 | }
|
---|
| 1022 | else {
|
---|
| 1023 | if (~type & FULLSCREEN) {
|
---|
| 1024 | type |= WINDOWED;
|
---|
| 1025 | ulAppType = SSF_TYPE_WINDOWEDVDM;
|
---|
| 1026 | }
|
---|
| 1027 | else {
|
---|
| 1028 | type &= ~WINDOWED;
|
---|
| 1029 | ulAppType = SSF_TYPE_VDM;
|
---|
| 1030 | }
|
---|
| 1031 | }
|
---|
| 1032 | }
|
---|
| 1033 | else if (ulAppType & FAPPTYP_32BIT) {
|
---|
| 1034 | ulAppType &= ~FAPPTYP_32BIT;
|
---|
| 1035 | if (ulAppType == FAPPTYP_WINDOWAPI)
|
---|
| 1036 | ulAppType = SSF_TYPE_PM;
|
---|
| 1037 | else if (ulAppType == FAPPTYP_WINDOWCOMPAT)
|
---|
| 1038 | ulAppType = SSF_TYPE_WINDOWABLEVIO;
|
---|
| 1039 | else if (ulAppType == FAPPTYP_NOTWINDOWCOMPAT) {
|
---|
| 1040 | ulAppType = SSF_TYPE_FULLSCREEN;
|
---|
| 1041 | type &= ~WINDOWED;
|
---|
| 1042 | type |= FULLSCREEN;
|
---|
| 1043 | }
|
---|
| 1044 | else /* ? */
|
---|
| 1045 | ulAppType = SSF_TYPE_WINDOWABLEVIO;
|
---|
| 1046 | }
|
---|
| 1047 | else if (ulAppType == FAPPTYP_WINDOWAPI)
|
---|
| 1048 | ulAppType = SSF_TYPE_PM;
|
---|
| 1049 | else if (ulAppType == FAPPTYP_WINDOWCOMPAT)
|
---|
| 1050 | ulAppType = SSF_TYPE_WINDOWABLEVIO;
|
---|
| 1051 | else if (ulAppType == FAPPTYP_NOTWINDOWCOMPAT) {
|
---|
| 1052 | type &= ~WINDOWED;
|
---|
| 1053 | ulAppType = SSF_TYPE_FULLSCREEN;
|
---|
| 1054 | }
|
---|
| 1055 | else
|
---|
| 1056 | ulAppType = SSF_TYPE_DEFAULT;
|
---|
| 1057 | if ((type & FULLSCREEN || ~type & WINDOWED) &&
|
---|
| 1058 | ulAppType == SSF_TYPE_WINDOWABLEVIO)
|
---|
| 1059 | {
|
---|
| 1060 | ulAppType = SSF_TYPE_FULLSCREEN;
|
---|
| 1061 | }
|
---|
| 1062 | // fixme parens?
|
---|
| 1063 | else if (type & FULLSCREEN ||
|
---|
| 1064 | (type & WINDOWED && ulAppType == SSF_TYPE_WINDOWEDVDM))
|
---|
| 1065 | {
|
---|
| 1066 | ulAppType = SSF_TYPE_VDM;
|
---|
| 1067 | }
|
---|
[105] | 1068 | }
|
---|
[562] | 1069 | if (ulAppType == SSF_TYPE_WINDOWEDVDM && type & SEPARATEKEEP) {
|
---|
[1394] | 1070 | type &= ~SEPARATEKEEP;
|
---|
| 1071 | type |= SEPARATE;
|
---|
[105] | 1072 | }
|
---|
[2] | 1073 |
|
---|
[519] | 1074 | DosGetInfoBlocks(&ptib, &ppib);
|
---|
| 1075 |
|
---|
[540] | 1076 | if (~type & WAIT)
|
---|
[1394] | 1077 | useTermQ = FALSE;
|
---|
[519] | 1078 | else {
|
---|
[1394] | 1079 | rc = 0;
|
---|
| 1080 | DosEnterCritSec();
|
---|
| 1081 | if (!hTermQ) {
|
---|
| 1082 | // Create term queue and event semaphore just once
|
---|
| 1083 | sprintf(szTermQName, TERMQ_BASE_NAME "_%x", ppib->pib_ulpid);
|
---|
| 1084 | rc = DosCreateQueue(&hTermQ, QUE_FIFO | QUE_CONVERT_ADDRESS, szTermQName);
|
---|
| 1085 | if (rc) {
|
---|
| 1086 | hTermQ = (HQUEUE)0; // Try to survive
|
---|
| 1087 | DosExitCritSec();
|
---|
| 1088 | Dos_Error(MB_CANCEL,rc,hwnd,pszSrcFile,__LINE__,"DosCreateQueue");
|
---|
| 1089 | }
|
---|
| 1090 | else {
|
---|
| 1091 | rc = DosCreateEventSem(NULL,(PHEV)&hTermQSem,0,FALSE);
|
---|
| 1092 | if (rc) {
|
---|
| 1093 | hTermQSem = (HEV)0; // Try to survive
|
---|
| 1094 | DosCloseQueue(hTermQ);
|
---|
| 1095 | hTermQ = (HQUEUE)0; // Try to survive
|
---|
| 1096 | DosExitCritSec();
|
---|
[1450] | 1097 | Dos_Error(MB_ENTER,rc,HWND_DESKTOP,pszSrcFile,__LINE__, PCSZ_DOSCREATEEVENTSEM);
|
---|
[1394] | 1098 | }
|
---|
| 1099 | // if (!rc) fprintf(stderr,"%s %d qcreated ptib %x hTermQ %x\n",__FILE__, __LINE__,ptib,hTermQ);
|
---|
| 1100 | }
|
---|
[1439] | 1101 | } // if 1st time
|
---|
| 1102 | useTermQ = hTermQ && hTermQSem;
|
---|
[1394] | 1103 | if (!rc)
|
---|
[1439] | 1104 | DosExitCritSec();
|
---|
[540] | 1105 | } // if wait
|
---|
[562] | 1106 |
|
---|
| 1107 | memset(&sdata,0,sizeof(sdata));
|
---|
[519] | 1108 | sdata.Length = sizeof(sdata);
|
---|
[562] | 1109 | sdata.Related = type & (WAIT | CHILD) ? SSF_RELATED_CHILD :
|
---|
[1394] | 1110 | SSF_RELATED_INDEPENDENT;
|
---|
[519] | 1111 | sdata.FgBg = type & BACKGROUND ? SSF_FGBG_BACK : SSF_FGBG_FORE;
|
---|
| 1112 | sdata.TraceOpt = SSF_TRACEOPT_NONE;
|
---|
[540] | 1113 | sdata.PgmName = pszPgm;
|
---|
[562] | 1114 | if (*pszArgs)
|
---|
[1394] | 1115 | sdata.PgmInputs = (PBYTE)pszArgs;
|
---|
[1480] | 1116 | if (useTermQ) {
|
---|
| 1117 | strcpy(szTermTemp, szTermQName);
|
---|
| 1118 | sdata.TermQ = (PBYTE)szTermTemp;
|
---|
| 1119 | }
|
---|
[1321] | 1120 | sdata.Environment = (PBYTE)pszEnvironment;
|
---|
[519] | 1121 | sdata.InheritOpt = SSF_INHERTOPT_PARENT;
|
---|
[562] | 1122 | sdata.SessionType = ulAppType;
|
---|
[540] | 1123 | sdata.ObjectBuffer = szObject;
|
---|
| 1124 | sdata.ObjectBuffLen = sizeof(szObject);
|
---|
[773] | 1125 | if ((type & RUNTYPE_MASK) == SEPARATEKEEP)
|
---|
[1394] | 1126 | sdata.PgmControl |= SSF_CONTROL_NOAUTOCLOSE;
|
---|
[562] | 1127 | if (type & MAXIMIZED)
|
---|
[1394] | 1128 | sdata.PgmControl |= SSF_CONTROL_MAXIMIZE;
|
---|
[562] | 1129 | if (type & MINIMIZED)
|
---|
[1394] | 1130 | sdata.PgmControl |= SSF_CONTROL_MINIMIZE;
|
---|
[562] | 1131 | if (type & INVISIBLE)
|
---|
[1394] | 1132 | sdata.PgmControl |= SSF_CONTROL_INVISIBLE;
|
---|
[562] | 1133 |
|
---|
[540] | 1134 | if (pszDirectory && *pszDirectory) {
|
---|
[1394] | 1135 | strcpy(szSavedir, pFM2SaveDirectory);
|
---|
| 1136 | switch_to(pszDirectory);
|
---|
[105] | 1137 | }
|
---|
[519] | 1138 | ret = DosStartSession(&sdata, &ulSessID, &sessPID);
|
---|
[562] | 1139 |
|
---|
[563] | 1140 |
|
---|
[540] | 1141 | if (pszDirectory && *pszDirectory)
|
---|
[1394] | 1142 | switch_to(szSavedir);
|
---|
[562] | 1143 |
|
---|
[330] | 1144 | if (ret && ret != ERROR_SMG_START_IN_BACKGROUND) {
|
---|
[1394] | 1145 | if (!fNoErrorMsg)
|
---|
[1439] | 1146 | Dos_Error(MB_CANCEL,ret,hwnd,pszSrcFile,__LINE__,
|
---|
[1394] | 1147 | GetPString(IDS_DOSSTARTSESSIONFAILEDTEXT),pszPgm,pszArgs,
|
---|
[1439] | 1148 | pszCallingFile, uiLineNumber); // 26 May 08 SHL
|
---|
[330] | 1149 | }
|
---|
[441] | 1150 | else if (type & WAIT) {
|
---|
[1394] | 1151 | if (!(type & (BACKGROUND | MINIMIZED | INVISIBLE)))
|
---|
| 1152 | ShowSession(hwnd, sessPID);
|
---|
[2] | 1153 |
|
---|
[1394] | 1154 | if (!useTermQ) {
|
---|
| 1155 | STATUSDATA sd;
|
---|
[2] | 1156 |
|
---|
[1394] | 1157 | memset(&sd, 0, sizeof(sd));
|
---|
| 1158 | sd.Length = (USHORT) sizeof(sd);
|
---|
| 1159 | sd.SelectInd = SET_SESSION_UNCHANGED;
|
---|
| 1160 | sd.BondInd = SET_SESSION_UNCHANGED;
|
---|
| 1161 | for (ctr = 0;; ctr++)
|
---|
| 1162 | {
|
---|
[1439] | 1163 | DosSleep(50);//05 Aug 07 GKY 200
|
---|
[1394] | 1164 | if (DosSetSession(ulSessID, &sd)) // Check if session gone (i.e. finished)
|
---|
| 1165 | break;
|
---|
| 1166 | if (ctr > 10) {
|
---|
| 1167 | ShowSession(hwnd, sessPID); // Show every 2 seconds
|
---|
| 1168 | ctr = 0;
|
---|
| 1169 | }
|
---|
| 1170 | }
|
---|
| 1171 | }
|
---|
| 1172 | else {
|
---|
| 1173 | for (ctr = 0;; ctr++)
|
---|
| 1174 | {
|
---|
| 1175 | if (ctr < 20) {
|
---|
| 1176 | rc = DosReadQueue(hTermQ, &rq, &ulLength, (PPVOID)&pTermInfo, 0,
|
---|
[1439] | 1177 | DCWW_NOWAIT, &bPriority, hTermQSem);
|
---|
[1394] | 1178 | if (rc == ERROR_QUE_EMPTY) {
|
---|
| 1179 | DosSleep(50);//05 Aug 07 GKY 100
|
---|
| 1180 | continue;
|
---|
| 1181 | }
|
---|
| 1182 | }
|
---|
| 1183 | else {
|
---|
[1439] | 1184 | if (ctr == 20) {
|
---|
[1394] | 1185 | ShowSession(hwnd, sessPID); // Show long running session
|
---|
[1439] | 1186 | }
|
---|
[1394] | 1187 | rc = DosReadQueue(hTermQ, &rq, &ulLength, (PPVOID)&pTermInfo, 0,
|
---|
| 1188 | DCWW_WAIT, &bPriority, 0);
|
---|
| 1189 | }
|
---|
[540] | 1190 |
|
---|
[1394] | 1191 | if (rc) {
|
---|
| 1192 | // Oh heck
|
---|
| 1193 | Dos_Error(MB_CANCEL,rc,hwnd,pszSrcFile,__LINE__,"DosReadQueue");
|
---|
| 1194 | DosSleep(100);//05 Aug 07 GKY 500
|
---|
| 1195 | continue;
|
---|
| 1196 | }
|
---|
[540] | 1197 |
|
---|
[1394] | 1198 | // printf("%s %d DosReadQueue thread 0x%x sess %u sessRC %u rq.pid 0x%x rq.data 0x%x\n",
|
---|
| 1199 | // __FILE__, __LINE__,ptib->tib_ordinal,pTermInfo->usSessID,pTermInfo->usRC,rq.pid, rq.ulData); fflush(stdout);
|
---|
[562] | 1200 |
|
---|
[1394] | 1201 | if (pTermInfo->usSessID == ulSessID)
|
---|
| 1202 | break; // Our session is done
|
---|
[540] | 1203 |
|
---|
[1394] | 1204 | // Requeue session for other thread
|
---|
| 1205 | {
|
---|
| 1206 | static ULONG ulLastSessID;
|
---|
| 1207 | // printf("%s %d requeue thread 0x%x our sess %u term sess %u term rc %u\n",
|
---|
| 1208 | // __FILE__, __LINE__,ptib->tib_ordinal,ulSessID,pTermInfo->usSessID,pTermInfo->usRC); fflush(stdout);
|
---|
| 1209 | // fixme to be gone when no longer needed for debug?
|
---|
| 1210 | if (ulLastSessID) {
|
---|
| 1211 | DosSleep(100);//05 Aug 07 GKY 500
|
---|
| 1212 | ulLastSessID = pTermInfo->usSessID;
|
---|
| 1213 | }
|
---|
| 1214 | // requeue term report for other thread and do not free yet
|
---|
| 1215 | rc = DosWriteQueue(hTermQ, rq.ulData, ulLength,(PVOID)pTermInfo, bPriority);
|
---|
| 1216 | if (rc)
|
---|
| 1217 | Dos_Error(MB_CANCEL,rc,hwnd,pszSrcFile,__LINE__,"DosWriteQueue");
|
---|
| 1218 | DosSleep(50); //05 Aug 07 GKY 100 // Let other thread see queue entry
|
---|
| 1219 | }
|
---|
| 1220 | } // for
|
---|
[540] | 1221 |
|
---|
[1394] | 1222 | ret = pTermInfo->usRC == 0; // Set 1 if rc 0 else 0
|
---|
| 1223 | // printf("%s %d thread 0x%x term for sess %u\n",
|
---|
| 1224 | // __FILE__, __LINE__,ptib->tib_ordinal,ulSessID);fflush(stdout);
|
---|
| 1225 | DosFreeMem(pTermInfo);
|
---|
| 1226 | }
|
---|
[540] | 1227 | } // if wait
|
---|
[105] | 1228 | else if (!(type & (BACKGROUND | MINIMIZED | INVISIBLE)))
|
---|
[1394] | 1229 | ShowSession(hwnd, sessPID);
|
---|
[105] | 1230 | }
|
---|
| 1231 | }
|
---|
[2] | 1232 |
|
---|
| 1233 | ObjectInterrupt:
|
---|
| 1234 |
|
---|
[540] | 1235 | if (pszPgm)
|
---|
| 1236 | DosFreeMem(pszPgm);
|
---|
| 1237 | if (pszArgs)
|
---|
| 1238 | DosFreeMem(pszArgs);
|
---|
[562] | 1239 |
|
---|
[105] | 1240 | return ret;
|
---|
[2] | 1241 | }
|
---|
| 1242 |
|
---|
[519] | 1243 | //== Exec() Start application with WinStartApp ==
|
---|
[1193] | 1244 | #if 0 // JBS 11 Sep 08
|
---|
[105] | 1245 | HAPP Exec(HWND hwndNotify, BOOL child, char *startdir, char *env,
|
---|
[1394] | 1246 | PROGTYPE *progt, ULONG fl, char *formatstring,...)
|
---|
[78] | 1247 | {
|
---|
[105] | 1248 | PROGDETAILS pgd;
|
---|
[2] | 1249 | register char *p;
|
---|
[105] | 1250 | char *parameters = NULL, *executable = NULL;
|
---|
[519] | 1251 | HAPP happ = (HAPP)0;
|
---|
[105] | 1252 | ULONG ulOptions = SAF_INSTALLEDCMDLINE;
|
---|
| 1253 | BOOL wasquote;
|
---|
| 1254 | va_list parguments;
|
---|
[2] | 1255 |
|
---|
[105] | 1256 | if (child)
|
---|
[2] | 1257 | ulOptions |= SAF_STARTCHILDAPP;
|
---|
| 1258 |
|
---|
[985] | 1259 | executable = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
|
---|
[330] | 1260 | if (executable) {
|
---|
[105] | 1261 | va_start(parguments, formatstring);
|
---|
| 1262 | vsprintf(executable, formatstring, parguments);
|
---|
[2] | 1263 | va_end(parguments);
|
---|
[105] | 1264 | strip_lead_char(" \t", executable);
|
---|
[441] | 1265 | if (*executable) {
|
---|
[985] | 1266 | parameters = xmalloc(MaxComLineStrg, pszSrcFile, __LINE__);
|
---|
[441] | 1267 | if (parameters) {
|
---|
[1394] | 1268 | p = executable;
|
---|
| 1269 | wasquote = FALSE;
|
---|
| 1270 | while (*p && (wasquote || (*p != ' ' && *p != '\t'))) {
|
---|
| 1271 | if (*p == '\"') {
|
---|
| 1272 | if (!wasquote) {
|
---|
| 1273 | wasquote = TRUE;
|
---|
| 1274 | memmove(p, p + 1, strlen(p));
|
---|
| 1275 | while (*p == ' ' || *p == '\t')
|
---|
| 1276 | p++;
|
---|
| 1277 | }
|
---|
| 1278 | else {
|
---|
| 1279 | memmove(p, p + 1, strlen(p));
|
---|
| 1280 | break;
|
---|
| 1281 | }
|
---|
| 1282 | }
|
---|
| 1283 | else
|
---|
| 1284 | p++;
|
---|
| 1285 | }
|
---|
| 1286 | if (*p) {
|
---|
| 1287 | *p = 0;
|
---|
| 1288 | p++;
|
---|
| 1289 | }
|
---|
| 1290 | else
|
---|
| 1291 | p = NullStr;
|
---|
| 1292 | if (*p)
|
---|
| 1293 | strcpy(parameters, p);
|
---|
[2] | 1294 |
|
---|
[1398] | 1295 | if (p && (!stricmp(p, PCSZ_DOTBAT) || !stricmp(p, PCSZ_DOTCMD) ||
|
---|
| 1296 | !stricmp(p, PCSZ_DOTBTM))) {
|
---|
[1394] | 1297 | char *temp;
|
---|
[2] | 1298 |
|
---|
[1394] | 1299 | temp = xmalloc(CCHMAXPATH * 2,pszSrcFile,__LINE__);
|
---|
| 1300 | if (temp) {
|
---|
[1398] | 1301 | if (!stricmp(p, PCSZ_DOTBAT)) {
|
---|
| 1302 | if (!fProtectOnly) {
|
---|
| 1303 | strcpy(temp, executable);
|
---|
| 1304 | strcpy(executable, parameters);
|
---|
| 1305 | strcpy(parameters, "/C ");
|
---|
| 1306 | strcat(parameters, temp);
|
---|
| 1307 | strcat(parameters, " ");
|
---|
| 1308 | strcat(parameters, executable);
|
---|
[1475] | 1309 | strcpy(executable, GetCmdSpec(TRUE)); //DOS
|
---|
[1398] | 1310 | }
|
---|
| 1311 | else
|
---|
| 1312 | saymsg(MB_OK,
|
---|
| 1313 | HWND_DESKTOP,
|
---|
| 1314 | NullStr,
|
---|
| 1315 | GetPString(IDS_NOTPROTECTONLYEXE),
|
---|
| 1316 | filename);
|
---|
[1394] | 1317 | }
|
---|
[1398] | 1318 | else if (!stricmp(p, PCSZ_DOTCMD) || !stricmp(p, PCSZ_DOTBTM)) {
|
---|
[1394] | 1319 | strcpy(temp, executable);
|
---|
| 1320 | strcpy(executable, parameters);
|
---|
| 1321 | strcpy(parameters, "/C ");
|
---|
| 1322 | strcat(parameters, temp);
|
---|
| 1323 | strcat(parameters, " ");
|
---|
| 1324 | strcat(parameters, executable);
|
---|
| 1325 | strcpy(executable, GetCmdSpec(FALSE));
|
---|
| 1326 | }
|
---|
| 1327 | free(temp);
|
---|
| 1328 | }
|
---|
| 1329 | }
|
---|
[2] | 1330 |
|
---|
[1394] | 1331 | memset(&pgd, 0, sizeof(pgd));
|
---|
| 1332 | pgd.Length = sizeof(pgd);
|
---|
| 1333 | pgd.progt = *progt;
|
---|
| 1334 | pgd.swpInitial.fl = fl;
|
---|
| 1335 | pgd.pszEnvironment = env;
|
---|
| 1336 | pgd.pszStartupDir = startdir;
|
---|
| 1337 | pgd.pszParameters = *parameters ? parameters : NULL;
|
---|
| 1338 | pgd.pszExecutable = executable;
|
---|
| 1339 | pgd.swpInitial.hwndInsertBehind = HWND_TOP;
|
---|
| 1340 | happ = WinStartApp(hwndNotify, &pgd, NULL, NULL, ulOptions);
|
---|
| 1341 | free(parameters);
|
---|
[2] | 1342 | }
|
---|
| 1343 | }
|
---|
[1039] | 1344 | free(executable);
|
---|
[2] | 1345 | }
|
---|
| 1346 | return happ;
|
---|
| 1347 | }
|
---|
[1162] | 1348 | #endif
|
---|
[920] | 1349 | #pragma alloc_text(SYSTEMF,ShowSession,ExecOnList,runemf2)
|
---|