#include <dos.h>
#include <exec/types.h>
#include <exec/execbase.h>
#include <proto/dos.h>

#include "users.h"

extern struct ExecBase *SysBase;
#define UID_PEEKER		0xf000
#define CUID	  ((struct Process *)(SysBase->ThisTask))->pr_Pad

int read_userdata(char *file,struct User *usr,int pos)
{	LONG handle,read;
	UWORD uid=CUID;

	CUID=UID_SYSTEM;
	if(handle=Open(file,MODE_OLDFILE))
	{
		Seek(handle,pos*sizeof(struct User),OFFSET_BEGINNING);
		read=Read(handle,usr,sizeof(struct User));
		Close(handle);
		CUID=uid;
		if(read==sizeof(struct User))
			return 0;
	}
	CUID=uid;
	return -1;
}
