#include <../arch/arch.h>

V_LOCAL char
hex_char(u8_t bits1_4)
{
	bits1_4 &= 0x0F;
	if(bits1_4 <= 9)
		return (char)('0' + bits1_4);
	else
		return (char)('A'+(bits1_4 - 0x0A));
}

void	V_CALL
archUniqueString(char *buf,vsize_t buffer_size)
{
	vhandle_t rgen;
	DWORD pid = GetCurrentProcessId();
	buf[--buffer_size] = 0;
	timeDelay(1);
	rgen = ranCreateGenerator(timeTickCount());
	pid = (pid + (pid >> 4) + (pid >> 8) + (pid >> 16)) & 0xF;
	for(;buffer_size;buffer_size--,buf++)
		*buf = hex_char((char)(ranNextLong(rgen,15) ^ pid));
	ranDestroyGenerator(rgen);
}
