#include <v_lib.h>
#include "phasesp.h"
#include "icond.h"
#include "ms_wr.h"
#include "psys.h"
#include "psdl.h"
#include "util.h"

vhandle_t rhandle;

int seed = 1;

int util_init(void)
{
	if(seed < 1)
		seed = timeTickCount();
	rhandle = urnCreateGenerator(seed);
	return 0;
}

void util_shutdown(void)
{
	urnDestroyGenerator(rhandle);
}

void
tok_print_what_expected(char *caller,vhandle_t sc,
	char *filename,char *expected)
{
	if(filename)
	{
		conlPrintf(LOG_ERROR,"%s(%s:line %u): expected '%s', got '%s'.\n",
			dbs(caller),filename,tokLastLine(sc),
			dbs(expected),dbs(tokLast(sc)));
	}
	else
	{
		conlPrintf(LOG_ERROR,"%s(line %u): expected '%s', got '%s'.\n",
			dbs(caller),tokLastLine(sc),
			dbs(expected),dbs(tokLast(sc)));
	}
}
