#include <9pm/windows.h>
#include <9pm/u.h>
#include <9pm/libc.h>

BOOL WINAPI
CallNamedPipe(LPCWSTR lpNamedPipeName, LPVOID lpInBuffer, DWORD nInBufferSize,
	LPVOID lpOutBuffer, DWORD nOutBufferSize, LPDWORD lpBytesRead, DWORD nTimeOut)
{
	char *name;
	int r;

	if(win_useunicode)
		return CallNamedPipeW(lpNamedPipeName, lpInBuffer, nInBufferSize,
			lpOutBuffer, nOutBufferSize,
			lpBytesRead, nTimeOut);

	name = win_wstr2utf((Rune*)lpNamedPipeName);
	r = CallNamedPipeA(name, lpInBuffer, nInBufferSize,
			lpOutBuffer, nOutBufferSize,
			lpBytesRead, nTimeOut);
	win_free(name);
	return r;
}
