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