xref: /aoo4110/main/sal/osl/w32/pipeimpl.h (revision b1cdbd2c)
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 # ifdef _MSC_VER
26 #   pragma warning(push,1) /* disable warnings within system headers */
27 # endif
28 #	include <windows.h>
29 # ifdef _MSC_VER
30 #   pragma warning(pop)
31 # endif
32 #endif
33 
34 #ifndef _INC_MALLOC
35 #	include <malloc.h>
36 #endif
37 
38 #ifndef _INC_TCHAR
39 #	ifdef UNICODE
40 #		define _UNICODE
41 #	endif
42 #	include <tchar.h>
43 #endif
44 
45 #define EXPORT_PIPE_API
46 
47 //============================================================================
48 //	Helper functions
49 //============================================================================
50 
51 // Because the value of an invalid HANDLE returned by API functions differs
52 // between different functions and differs on different Windows platforms,
53 // this function checks wether the handle has a meaningfull value.
54 #ifndef __cplusplus
55 
56 #define IsValidHandle( handle ) ((DWORD)(handle) + 1 > 1)
57 
58 #else
59 
IsValidHandle(HANDLE handle)60 inline bool IsValidHandle( HANDLE handle )
61 {
62 	return INVALID_HANDLE_VALUE != handle && NULL != handle;
63 }
64 
65 extern "C" {
66 
67 #endif	// __cplusplus
68 
69 
70 EXPORT_PIPE_API HANDLE WINAPI CreateSimplePipeA( LPCSTR lpName );
71 EXPORT_PIPE_API HANDLE WINAPI CreateSimplePipeW( LPCWSTR lpName );
72 
73 #ifdef UNICODE
74 #define CreateSimplePipe	CreateSimplePipeW
75 #else
76 #define CreateSimplePipe	CreateSimplePipeA
77 #endif
78 
79 EXPORT_PIPE_API HANDLE WINAPI OpenSimplePipeA( LPCSTR lpName );
80 EXPORT_PIPE_API HANDLE WINAPI OpenSimplePipeW( LPCWSTR lpName );
81 
82 #ifdef UNICODE
83 #define OpenSimplePipe	OpenSimplePipeW
84 #else
85 #define OpenSimplePipe	OpenSimplePipeA
86 #endif
87 
88 EXPORT_PIPE_API HANDLE WINAPI AcceptSimplePipeConnection( HANDLE hPipe );
89 
90 EXPORT_PIPE_API BOOL WINAPI WaitForSimplePipeA( LPCSTR lpName, DWORD dwTimeOut );
91 EXPORT_PIPE_API BOOL WINAPI WaitForSimplePipeW( LPCWSTR lpName, DWORD dwTimeOut );
92 
93 #ifdef UNICODE
94 #define WaitForSimplePipe	WaitForSimplePipeW
95 #else
96 #define WaitForSimplePipe	WaitForSimplePipeA
97 #endif
98 
99 
100 EXPORT_PIPE_API BOOL WINAPI WriteSimplePipe( HANDLE hPipe, LPCVOID lpBuffer, DWORD dwBytesToWrite, LPDWORD lpBytesWritten, BOOL bWait );
101 EXPORT_PIPE_API BOOL WINAPI ReadSimplePipe( HANDLE hPipe, LPVOID lpBuffer, DWORD dwBytesToRead, LPDWORD lpBytesRead, BOOL bWait );
102 EXPORT_PIPE_API BOOL WINAPI CloseSimplePipe( HANDLE hPipe );
103 
104 #ifdef __cplusplus
105 }	// extern "C"
106 #endif
107 
108 #endif	// _PIPEIMPL_H_
109