xref: /trunk/main/sal/osl/os2/pipeimpl.h (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1 #ifndef _PIPEIMPL_H_
2 #define _PIPEIMPL_H_
3 
4 #ifndef _WINDOWS_
5 #   include <windows.h>
6 #endif
7 
8 #ifndef _INC_MALLOC
9 #   include <malloc.h>
10 #endif
11 
12 #ifndef _INC_TCHAR
13 #   ifdef UNICODE
14 #       define _UNICODE
15 #   endif
16 #   include <tchar.h>
17 #endif
18 
19 #define EXPORT_PIPE_API
20 
21 //============================================================================
22 //  Helper functions
23 //============================================================================
24 
25 // Because the value of an invalid HANDLE returned by API functions differs
26 // between different functions and differs on different Windows platforms,
27 // this function checks wether the handle has a meaningfull value.
28 #ifndef __cplusplus
29 
30 #define IsValidHandle( handle ) ((DWORD)(handle) + 1 > 1)
31 
32 #else
33 
34 inline bool IsValidHandle( HANDLE handle )
35 {
36     return INVALID_HANDLE_VALUE != handle && NULL != handle;
37 }
38 
39 extern "C" {
40 
41 #endif  // __cplusplus
42 
43 
44 EXPORT_PIPE_API HANDLE WINAPI CreateSimplePipeA( LPCSTR lpName );
45 EXPORT_PIPE_API HANDLE WINAPI CreateSimplePipeW( LPCWSTR lpName );
46 
47 #ifdef UNICODE
48 #define CreateSimplePipe    CreateSimplePipeW
49 #else
50 #define CreateSimplePipe    CreateSimplePipeA
51 #endif
52 
53 EXPORT_PIPE_API HANDLE WINAPI OpenSimplePipeA( LPCSTR lpName );
54 EXPORT_PIPE_API HANDLE WINAPI OpenSimplePipeW( LPCWSTR lpName );
55 
56 #ifdef UNICODE
57 #define OpenSimplePipe  OpenSimplePipeW
58 #else
59 #define OpenSimplePipe  OpenSimplePipeA
60 #endif
61 
62 EXPORT_PIPE_API HANDLE WINAPI AcceptSimplePipeConnection( HANDLE hPipe );
63 
64 EXPORT_PIPE_API BOOL WINAPI WaitForSimplePipeA( LPCSTR lpName, DWORD dwTimeOut );
65 EXPORT_PIPE_API BOOL WINAPI WaitForSimplePipeW( LPCWSTR lpName, DWORD dwTimeOut );
66 
67 #ifdef UNICODE
68 #define WaitForSimplePipe   WaitForSimplePipeW
69 #else
70 #define WaitForSimplePipe   WaitForSimplePipeA
71 #endif
72 
73 
74 EXPORT_PIPE_API BOOL WINAPI WriteSimplePipe( HANDLE hPipe, LPCVOID lpBuffer, DWORD dwBytesToWrite, LPDWORD lpBytesWritten, BOOL bWait );
75 EXPORT_PIPE_API BOOL WINAPI ReadSimplePipe( HANDLE hPipe, LPVOID lpBuffer, DWORD dwBytesToRead, LPDWORD lpBytesRead, BOOL bWait );
76 EXPORT_PIPE_API BOOL WINAPI CloseSimplePipe( HANDLE hPipe );
77 
78 #ifdef __cplusplus
79 }   // extern "C"
80 #endif
81 
82 #endif  // _PIPEIMPL_H_
83