1 /********************************************************************
2 * Module: process.h. This is part of Visual-MinGW.
4 * License: Visual-MinGW is covered by GNU General Public License,
5 * Copyright (C) 2001 Manu B.
6 * See license.htm for more details.
8 ********************************************************************/
15 class CCommandDlg
: public CDlgBase
22 LRESULT CALLBACK
CDlgProc(UINT Message
, WPARAM wParam
, LPARAM lParam
);
23 BOOL
OnInitDialog(HWND hwndFocus
, LPARAM lInitParam
);
24 BOOL
OnCommand(WORD wNotifyCode
, WORD wID
, HWND hwndCtl
);
33 /********************************************************
34 creationFlag truth table
35 -----------------------------------
44 *********************************************************/
45 #define NO_PIPE 0x0000
46 #define IN_PIPE 0x0001
47 #define OUT_PIPE 0x0002
48 #define ERR_PIPE 0x0004
49 #define OUTERR_PIPE 0x000A
52 #define STDOUT_FILE_APPEND 1
55 class CTask
: public CNode
61 char cmdLine
[MAX_PATH
];
62 char szFileName
[MAX_PATH
];
72 class CStack
: public CList
78 int Push(CTask
* newTask
);
86 void DetachCurrent(void);
99 bool Create(WORD creationFlag
, bool winNT
);
100 bool CloseChildSide(void);
101 bool CloseParentSide(void);
105 bool Close(int side
);
108 class CProcess
: public CStack
114 bool CommandLine(char * cmdLine
);
115 bool isRunning(void);
116 CTask
* AddTask(char * cmdLine
, WORD creationFlag
, WORD outputFlag
/* = STDOUT_NONE*/);
117 bool CmdCat(char * cmdLine
);
119 void Run_Thread_Internal(void);
121 CCommandDlg CommandDlg
;
125 PROCESS_INFORMATION pi
;
135 bool RunProcess(CTask
* task
);
137 void WriteStdIn(HANDLE hPipe
, WORD creationFlag
);
138 void ReadStdErr(HANDLE hPipe
, WORD creationFlag
);
139 long ReadStdOut(CTask
* task
, HANDLE hPipe
);
140 int ReadOneChar(HANDLE hPipe
, char * chrin
);
142 bool WriteFileAppend(char * fileName
, char * line
, int len
=-1);
143 bool OutputLine(WORD outputFlag
, char * line
, int len
=-1);