source: trunk/dll/systemf.c@ 1009

Last change on this file since 1009 was 1009, checked in by Steven Levine, 17 years ago

Add xfree xstrdup Fortify support
Add MT capable Fortify scope logic

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