/*-*-linux-c-*-*/

#include <unistd.h>
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

#include <gtk/gtk.h>

#include "guid.h"

void guidinit(void)
{
	srand(time((time_t)NULL)+getpid());
}

void guidget(gchar *guid)
{
	gint i;
	
	for (i = 0; i < GUID_LEN; i++)
		if (i != 8 && i != 15)
			guid[i] = 48 + (gchar) (10.0*rand()/(RAND_MAX+1.0));

	
	guid[8]  = 0xff;
	guid[15] = 0;
}

void guiddump(gchar *guid)
{ 
	gint i;

	for (i = 0; i <= GUID_LEN; i++)
		g_print("%x ", guid[i]);
	
	g_print("\n");
	
}

gint guidcmp(gchar *guid1, gchar *guid2)
{
	if (!memcmp(guid1, guid2, GUID_LEN))
		return 1;
	else 
		return 0;
}

void guidcpy(gchar *guid1, gchar *guid2)
{
	memcpy(guid1, guid2, GUID_LEN);
}








