version 1.4w10UCIb21
[polyglot.git] / pipe.h
1 #ifndef PIPE_H
2 #define PIPE_H
3 #ifdef _WIN32
4 // includes
5
6 #include <windows.h>
7
8 // constants
9
10 const int LINE_INPUT_MAX_CHAR = 10*4096;
11
12 // defines
13
14 #define PIPE_EOF 1
15 #define PIPE_ACTIVE 2
16
17 // types
18
19 struct PipeStruct {
20
21     HANDLE hInput, hOutput;
22     HANDLE hProcess;
23     HANDLE hThread;
24     HANDLE hEvent;
25     BOOL bConsole;
26     BOOL bPipe;
27
28     CRITICAL_SECTION CriticalSection;
29
30     volatile DWORD state;
31     volatile char * lpFeedEnd;
32     volatile int nReadEnd;
33     char lpBuffer[LINE_INPUT_MAX_CHAR];
34     char lpReadBuffer[LINE_INPUT_MAX_CHAR];
35
36     void Open(const char *szExecFile = NULL);
37     void Close(void) const;
38     void Kill(void) const;
39     bool EOF_(void);
40     void set_EOF_(void);
41     bool Active(void);
42     void set_Active(void);
43     void ReadInput(void);
44     int ReadData(void);
45     bool GetBuffer(char *szLineStr);
46     void LineInput(char *szLineStr);
47     void LineOutput(const char *szLineStr) const;
48
49 };
50
51 // pipe
52
53 #endif
54 #endif