#include <libraries/dos.h>
#include <proto/dos.h>
#include <proto/exec.h>
#include "misc.h"

static const char portname[]="AX-Sysghost";

struct mymsg
{	struct Message Msg;
	UBYTE Action;
	UBYTE Return;
	LONG  arg1;
	char *arg2;
	char *arg3;
};


UBYTE who(UBYTE mode,UBYTE ret,char *ar2,char *ar3)
{
	struct mymsg message;
	struct MsgPort *port,*replyport;

	if(!(replyport=(struct MsgPort *)CreatePort(NULL,0)))
	{
		return 255;
	}
	message.Action=mode;
	message.Msg.mn_ReplyPort=replyport;
	message.Return=ret;
	message.arg1=Input();
	message.arg2=ar2;
	message.arg3=ar3;

	if(port=(struct MsgPort *)FindPort(portname))
	{
		PutMsg(port,(struct Message *)&message);
		WaitPort(replyport);
		while(GetMsg(replyport));
	}
	else
	{
		DeletePort(replyport);
		return 255;
	}
	DeletePort(replyport);

	return message.Return;
}
