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