xref: /trunk/main/sal/osl/os2/pipeimpl.h (revision 74cbd1f1)
1 // *************************************************************
2 //
3 //  Licensed to the Apache Software Foundation (ASF) under one
4 //  or more contributor license agreements.  See the NOTICE file
5 //  distributed with this work for additional information
6 //  regarding copyright ownership.  The ASF licenses this file
7 //  to you under the Apache License, Version 2.0 (the
8 //  "License"); you may not use this file except in compliance
9 //  with the License.  You may obtain a copy of the License at
10 //
11 //    http://www.apache.org/licenses/LICENSE-2.0
12 //
13 //  Unless required by applicable law or agreed to in writing,
14 //  software distributed under the License is distributed on an
15 //  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 //  KIND, either express or implied.  See the License for the
17 //  specific language governing permissions and limitations
18 //  under the License.
19 //
20 // *************************************************************
21 #ifndef _PIPEIMPL_H_
22 #define _PIPEIMPL_H_
23 
24 #ifndef _WINDOWS_
25 #	include <windows.h>
26 #endif
27 
28 #ifndef _INC_MALLOC
29 #	include <malloc.h>
30 #endif
31 
32 #ifndef _INC_TCHAR
33 #	ifdef UNICODE
34 #		define _UNICODE
35 #	endif
36 #	include <tchar.h>
37 #endif
38 
39 #define EXPORT_PIPE_API
40 
41 //============================================================================
42 //	Helper functions
43 //============================================================================
44 
45 // Because the value of an invalid HANDLE returned by API functions differs
46 // between different functions and differs on different Windows platforms,
47 // this function checks whether the handle has a meaningful value.
48 #ifndef __cplusplus
49 
50 #define IsValidHandle( handle ) ((DWORD)(handle) + 1 > 1)
51 
52 #else
53 
IsValidHandle(HANDLE handle)54 inline bool IsValidHandle( HANDLE handle )
55 {
56 	return INVALID_HANDLE_VALUE != handle && NULL != handle;
57 }
58 
59 extern "C" {
60 
61 #endif	// __cplusplus
62 
63 
64 EXPORT_PIPE_API HANDLE WINAPI CreateSimplePipeA( LPCSTR lpName );
65 EXPORT_PIPE_API HANDLE WINAPI CreateSimplePipeW( LPCWSTR lpName );
66 
67 #ifdef UNICODE
68 #define CreateSimplePipe	CreateSimplePipeW
69 #else
70 #define CreateSimplePipe	CreateSimplePipeA
71 #endif
72 
73 EXPORT_PIPE_API HANDLE WINAPI OpenSimplePipeA( LPCSTR lpName );
74 EXPORT_PIPE_API HANDLE WINAPI OpenSimplePipeW( LPCWSTR lpName );
75 
76 #ifdef UNICODE
77 #define OpenSimplePipe	OpenSimplePipeW
78 #else
79 #define OpenSimplePipe	OpenSimplePipeA
80 #endif
81 
82 EXPORT_PIPE_API HANDLE WINAPI AcceptSimplePipeConnection( HANDLE hPipe );
83 
84 EXPORT_PIPE_API BOOL WINAPI WaitForSimplePipeA( LPCSTR lpName, DWORD dwTimeOut );
85 EXPORT_PIPE_API BOOL WINAPI WaitForSimplePipeW( LPCWSTR lpName, DWORD dwTimeOut );
86 
87 #ifdef UNICODE
88 #define WaitForSimplePipe	WaitForSimplePipeW
89 #else
90 #define WaitForSimplePipe	WaitForSimplePipeA
91 #endif
92 
93 
94 EXPORT_PIPE_API BOOL WINAPI WriteSimplePipe( HANDLE hPipe, LPCVOID lpBuffer, DWORD dwBytesToWrite, LPDWORD lpBytesWritten, BOOL bWait );
95 EXPORT_PIPE_API BOOL WINAPI ReadSimplePipe( HANDLE hPipe, LPVOID lpBuffer, DWORD dwBytesToRead, LPDWORD lpBytesRead, BOOL bWait );
96 EXPORT_PIPE_API BOOL WINAPI CloseSimplePipe( HANDLE hPipe );
97 
98 #ifdef __cplusplus
99 }	// extern "C"
100 #endif
101 
102 #endif	// _PIPEIMPL_H_
103