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