pipe.h (4325B)
1/** 2 * WinPR: Windows Portable Runtime 3 * Pipe Functions 4 * 5 * Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> 6 * 7 * Licensed under the Apache License, Version 2.0 (the "License"); 8 * you may not use this file except in compliance with the License. 9 * 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, software 14 * distributed under the License is distributed on an "AS IS" BASIS, 15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 * See the License for the specific language governing permissions and 17 * limitations under the License. 18 */ 19 20#ifndef WINPR_PIPE_H 21#define WINPR_PIPE_H 22 23#include <winpr/file.h> 24#include <winpr/winpr.h> 25#include <winpr/error.h> 26#include <winpr/handle.h> 27#include <winpr/wtypes.h> 28 29#ifndef _WIN32 30 31#define PIPE_UNLIMITED_INSTANCES 0xFF 32 33#define PIPE_ACCESS_INBOUND 0x00000001 34#define PIPE_ACCESS_OUTBOUND 0x00000002 35#define PIPE_ACCESS_DUPLEX 0x00000003 36 37#define FILE_FLAG_FIRST_PIPE_INSTANCE 0x00080000 38#define FILE_FLAG_WRITE_THROUGH 0x80000000 39#define FILE_FLAG_OVERLAPPED 0x40000000 40 41#define PIPE_CLIENT_END 0x00000000 42#define PIPE_SERVER_END 0x00000001 43 44#define PIPE_TYPE_BYTE 0x00000000 45#define PIPE_TYPE_MESSAGE 0x00000004 46 47#define PIPE_READMODE_BYTE 0x00000000 48#define PIPE_READMODE_MESSAGE 0x00000002 49 50#define PIPE_WAIT 0x00000000 51#define PIPE_NOWAIT 0x00000001 52 53#define PIPE_ACCEPT_REMOTE_CLIENTS 0x00000000 54#define PIPE_REJECT_REMOTE_CLIENTS 0x00000008 55 56#define NMPWAIT_USE_DEFAULT_WAIT 0x00000000 57#define NMPWAIT_NOWAIT 0x00000001 58#define NMPWAIT_WAIT_FOREVER 0xFFFFFFFF 59 60#ifdef __cplusplus 61extern "C" 62{ 63#endif 64 65 /** 66 * Unnamed pipe 67 */ 68 69 WINPR_API BOOL CreatePipe(PHANDLE hReadPipe, PHANDLE hWritePipe, 70 LPSECURITY_ATTRIBUTES lpPipeAttributes, DWORD nSize); 71 72 /** 73 * Named pipe 74 */ 75 76 WINPR_API HANDLE CreateNamedPipeA(LPCSTR lpName, DWORD dwOpenMode, DWORD dwPipeMode, 77 DWORD nMaxInstances, DWORD nOutBufferSize, 78 DWORD nInBufferSize, DWORD nDefaultTimeOut, 79 LPSECURITY_ATTRIBUTES lpSecurityAttributes); 80 WINPR_API HANDLE CreateNamedPipeW(LPCWSTR lpName, DWORD dwOpenMode, DWORD dwPipeMode, 81 DWORD nMaxInstances, DWORD nOutBufferSize, 82 DWORD nInBufferSize, DWORD nDefaultTimeOut, 83 LPSECURITY_ATTRIBUTES lpSecurityAttributes); 84 85 WINPR_API BOOL ConnectNamedPipe(HANDLE hNamedPipe, LPOVERLAPPED lpOverlapped); 86 87 WINPR_API BOOL DisconnectNamedPipe(HANDLE hNamedPipe); 88 89 WINPR_API BOOL PeekNamedPipe(HANDLE hNamedPipe, LPVOID lpBuffer, DWORD nBufferSize, 90 LPDWORD lpBytesRead, LPDWORD lpTotalBytesAvail, 91 LPDWORD lpBytesLeftThisMessage); 92 93 WINPR_API BOOL TransactNamedPipe(HANDLE hNamedPipe, LPVOID lpInBuffer, DWORD nInBufferSize, 94 LPVOID lpOutBuffer, DWORD nOutBufferSize, LPDWORD lpBytesRead, 95 LPOVERLAPPED lpOverlapped); 96 97 WINPR_API BOOL WaitNamedPipeA(LPCSTR lpNamedPipeName, DWORD nTimeOut); 98 WINPR_API BOOL WaitNamedPipeW(LPCWSTR lpNamedPipeName, DWORD nTimeOut); 99 100 WINPR_API BOOL SetNamedPipeHandleState(HANDLE hNamedPipe, LPDWORD lpMode, 101 LPDWORD lpMaxCollectionCount, 102 LPDWORD lpCollectDataTimeout); 103 104 WINPR_API BOOL ImpersonateNamedPipeClient(HANDLE hNamedPipe); 105 106 WINPR_API BOOL GetNamedPipeClientComputerNameA(HANDLE Pipe, LPCSTR ClientComputerName, 107 ULONG ClientComputerNameLength); 108 WINPR_API BOOL GetNamedPipeClientComputerNameW(HANDLE Pipe, LPCWSTR ClientComputerName, 109 ULONG ClientComputerNameLength); 110 111#ifdef UNICODE 112#define CreateNamedPipe CreateNamedPipeW 113#define WaitNamedPipe WaitNamedPipeW 114#define GetNamedPipeClientComputerName GetNamedPipeClientComputerNameW 115#else 116#define CreateNamedPipe CreateNamedPipeA 117#define WaitNamedPipe WaitNamedPipeA 118#define GetNamedPipeClientComputerName GetNamedPipeClientComputerNameA 119#endif 120 121#ifdef __cplusplus 122} 123#endif 124 125#endif 126 127#endif /* WINPR_PIPE_H */