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

BOOL WINAPI
GetUserName(LPWSTR lpBuffer, LPDWORD nSize)
{
	char *sysname;
	int r, i;

	if(win_useunicode)
		return GetUserNameW(lpBuffer, nSize);

	sysname = win_malloc(*nSize);
	r = GetUserNameA(sysname, nSize);
	if(!r){
		win_free(sysname);
		return 0;
	}
	for(i=0; i<=(int)*nSize; i++)
		lpBuffer[i] = sysname[i];
	win_free(sysname);
	return 1;
}
