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