home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / dd2.zip / DDEXEC.H < prev    next >
Text File  |  1994-07-07  |  4KB  |  96 lines

  1.  
  2. #define MSGSIZE   1024
  3. #define MAXPATH 256
  4.  
  5. #define EXEC_NORMAL   0x00000000
  6. #define EXEC_TRACED   0X00000001
  7. #define EXEC_DETACHED 0X00000002
  8. #define EXEC_RELATED  0X00000004
  9. #define EXEC_FULLSCR  0X00000008
  10. #define EXEC_FOREGRD  0x00000010
  11. #define EXEC_TERMQ    0x00000020
  12. #define EXEC_INHERIT  0x00000040
  13. #define EXEC_REDIR    0x00000080
  14. #define EXEC_RESTART  0x00000100
  15. #define EXEC_WAIT     0x00000200
  16.  
  17. #define EXEC_DDT      0x80000000
  18. #define EXEC_VERBOSE  0X40000000
  19. #define EXEC_SILENT   0x20000000
  20.  
  21. #define SIZE_PIPE     512
  22.  
  23. typedef struct _DDEXEC {
  24.    ULONG hQueue;
  25.    PSZ   pszDDD;
  26.    ULONG ahPipe     [12];
  27. } DDEXEC;
  28. typedef DDEXEC * PDDEXEC;
  29.  
  30. #define hPipeStdin    DDExec.ahPipe[0]
  31. #define hPipeStdout   DDExec.ahPipe[1]
  32. #define hPipeStderr   DDExec.ahPipe[2]
  33. #define hStdin        DDExec.ahPipe[3]
  34. #define hStdout       DDExec.ahPipe[4]
  35. #define hStderr       DDExec.ahPipe[5]
  36.  
  37. #define hPipe1Read    DDExec.ahPipe[6]
  38. #define hPipe1Write   DDExec.ahPipe[7]
  39. #define hPipe2Read    DDExec.ahPipe[8]
  40. #define hPipe2Write   DDExec.ahPipe[9]
  41. #define hPipe3Read    DDExec.ahPipe[10]
  42. #define hPipe3Write   DDExec.ahPipe[11]
  43.  
  44. #define phPipeStdin   pDDExec->ahPipe[0]
  45. #define phPipeStdout  pDDExec->ahPipe[1]
  46. #define phPipeStderr  pDDExec->ahPipe[2]
  47. #define phStdin       pDDExec->ahPipe[3]
  48. #define phStdout      pDDExec->ahPipe[4]
  49. #define phStderr      pDDExec->ahPipe[5]
  50.         
  51. #define phPipe1Read   pDDExec->ahPipe[6]
  52. #define phPipe1Write  pDDExec->ahPipe[7]
  53. #define phPipe2Read   pDDExec->ahPipe[8]
  54. #define phPipe2Write  pDDExec->ahPipe[9]
  55. #define phPipe3Read   pDDExec->ahPipe[10]
  56. #define phPipe3Write  pDDExec->ahPipe[11]
  57.  
  58. APIRET ExecPgmTitle(PCHAR PgmTitle, PCHAR PgmPathExe, PCHAR PgmParms,
  59.    PPID pPid, PULONG pSel, PPID pTid, USHORT fHow);
  60.  
  61. APIRET ddExec(PSZ pszTitle, PSZ pszExe, PSZ pszArgs, PPID pPid, PTID pTid,
  62.    PDDEXEC pDDExec, ULONG lFlags);
  63.  
  64. // Specifications on EXEC_REDIR
  65.  
  66. // When specifying EXEC_REDIR two HFILEs are returned on the PgmTitle pointer
  67. // being the pipe to read the output from the started program (stdout & stderr)
  68. // and the pipe to write input to the program (stdin)
  69. // It is necessary to provide a PgmTitle with at least a strlen of 3 for
  70. // ExecPgmTitle to return the pipes (rc ERROR_MON_BUFFER_TOO_SMALL is returned
  71. // otherwise)
  72. // Since PgmTitle get's overwritten by the call, be sure not to pass a
  73. // global or static variable as the title (it will not be the same on return)
  74. // Use temp storage on the stack and copy the static/global string to this
  75. // variable. This way the PgmTitle will be reusable
  76. // EXEC_REDIR uses an intermediary CMD.EXE to provide redirection from stdin,
  77. // stdout and stderr. When you have more than 5 files open on the time
  78. // off the call the function cannot perform redirection and returns
  79. // ERROR_TOO_MANY_OPEN_FILES (see IBM OS/2 Extended Edition Version 1.2
  80. // User Guide Volume 1: Base Operating System p.9-3)
  81.  
  82. // EXEC_REDIR is compatible with EXEC_DETACHED and EXEC_TERMQ (tested)
  83. // and should work (not tested) with all other flags except of course EXEC_WAIT
  84.  
  85. // The pipes will still be open even when the program dies, so it is necessary
  86. // to check when a program has dies. This is done by EXEC_TERMQ and DosReadQueue
  87. // when not specifying EXEC_DETACH, when EXEC_DETACHing the programmer needs
  88. // to DosCWait the EXEC_DETACHed pid.
  89.  
  90. // see example redir.c at U:\KB\PTRACE
  91.  
  92. // Note, when EXEC_REDIRing a C-program it's advisable to setbuf(stdout), NULL)
  93. // to prevent the C-runtime library from buffering the stdout-handle
  94.  
  95.  
  96.