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