
#DEFINE _EP_FLAGS_COMSPEC   0x00000001
#DEFINE _EP_FLAGS_KEYWAIT   0x00000002
#DEFINE _EP_FLAGS_DONTWAIT  0x00000004
#DEFINE _EP_FLAGS_APPEND    0x00000008
#DEFINE _EP_FLAGS_NOBYPASS	0x00000010
#DEFINE _EP_FLAGS_WDPROG    0x00000020
#DEFINE _EP_FLAGS_BNDASDOS  0x00000040
#DEFINE _EP_FLAGS_VMEXEC    0x00000080
#DEFINE _EP_FLAGS_NOEXEC    0X00000100
#DEFINE _EP_FLAGS_NORMAL		0x00000000
#DEFINE _EP_FLAGS_HIDE			0x00010000
#DEFINE _EP_FLAGS_MINIMIZED 0x00020000
#DEFINE _EP_FLAGS_MAXIMIZED 0x00030000

    // Exec ruturn codes.
    // Returned by:  ExecProg, WinExecAndWait, DosExec

#DEFINE _EXEC_Success 0
#DEFINE _EXEC_Error   1   // See ExecErrorCode below
#DEFINE _EXEC_Abort  -1

/* PIF flags. */
#define fExcl      0x00000001 /* Exclusive mode. */
#define fpifBack   0x00000002 /* Runs in background. */
#define fpifWindow 0x00000004 /* Runs in a window. */
#define fpifAltTab 0x00000020 /* Alt-Tab reserved. */
#define fpifAltEsc 0x00000040 /* Alt-Esc reserved. */
#define fpifAltSp  0x00000080 /* Alt-Sp reserved. */
#define fpifAltEnt 0x00000100 /* Alt-Ent reserved. */
#define fpifAltPsc 0x00000200 /* Alt-PrtSc reserved. */
#define fpifPrtSc  0x00000400 /* PrtSc reserved. */
#define fpifCtlEsc 0x00000800 /* Ctl-Esc reserved. */
#define fpifIdle   0x00001000 /* Detect idle. */
#define fpifNoHMA  0x00002000 /* Don't use High Mem. */
#define fpifEmsLok 0x00008000 /* EMS memory locked. */
#define fpifXmsLok 0x00010000 /* XMS memory locked. */
#define fpifFPaste 0x00020000 /* Allow Fast Paste. */
#define fpifAppLok 0x00040000 /* Lock app. memory. */
#define fpifCloseE 0x40000000 /* Close on exit. */

/* Display flags. */
#define fdisEmText 0x00000001 /* Emulate text mode. */
#define fdisNoText 0x00000002 /* No monitor text mode. */
#define fdisNoLow  0x00000004 /* No monitor low gfx. */
#define fdisNoHigh 0x00000008 /* No monitor high gfx. */
#define fdisRetain 0x00000080 /* Retain video memory. */

// This is the struct that is passed to the DLL CALL
struct VMDEF
{
    ASCIIZ  title   [128];  // title of window if in windowed mode
    ASCIIZ  exePath [128];  /* Path of .exe to run. */
    ASCIIZ  exeArgs [128];  /* Argument list. */
    ASCIIZ  workDir [128];  /* Working drive/dir. */
    int     pifFlags;       /* PIF flags. */
    int     disFlags;       /* Display flags. */
    WORD    pageWant;       /* Desired V86 pages for VM. */
    WORD    pageMin;        /* Minimum V86 pages for VM. */
    WORD    forePriority;   /* Foreground priority. */
    WORD    backPriority;   /* Background priority. */
    WORD    kbMaxEMS;       /* Maximum EMS KB. */
    WORD    kbMinEMS;       /* Minimum EMS KB. */
    WORD    kbMaxXMS;       /* Maximum XMS KB. */
    WORD    kbMinXMS;       /* Minimum XMS KB. */
}

global
{
  int ExecReturnCode  "!ExecReturnCode";    // Return code from DOS programs
  int ExecErrorCode   "!ExecErrorCode";     // Error code when _EXEC_ERROR is returned
  int ExecId          "!ExecId";            // The type of program last executed
                                            // see IDEXEC.SH for values
  int DosExecMethod   "!DosExecMethod";
}
#DEFINE _DosExec_Direct   1
#DEFINE _DosExec_PIF      0
#DEFINE _DosExec_ExecVM   2

prototype winexec
{


  int ExecProg( str prog,      // = parse_str("/PROG=", mparm_str),
                               //  The command line

                str working_dir, // parse_str("/WD=",mparm_str),
	              str stdout_file, // = parse_str("/RED=", mparm_str),
	                               // The filename to output STDOUT to
																 // (Dos .EXE files only)

	              str stderr_file, // = parse_str("/REDERR=", mparm_str),
	                               // The filename to output STDERR to
																 // (Dos .EXE files only)

	              int flags        // = parse_int("/FLAGS=", mparm_str )
	                               // Flags.  See #DEFINE _EP_FLAGS_xxxx above
             );

	INT WinExecAndWait( STR Path,
                      STR working_dir,
											INT flags,
                      STR title,
                      STR semiphore_file
										);

  int DosExec( STR path,
               STR working_dir,
							 INT Visibility,
							 STR stdio_file,
							 STR stderr_file,
							 INT flags
							);

  int Os2Exec( str Path,
               str Working_Dir,
               int Visibility,
               str Stdio_File,
               str Stderr_File,
               int Flags
             );

  str ExecSearchPath( str Program, str Path );
}

IMPORT DWORD VMExec (POINTER pVMdefRecord) MEWTOOLS 501;
