/*
	Runtime Engine
		By Craig Kadziolka ( Nov 1999 - Dec 2000 )

	Modifications and copying is permitted providing this header
	is retained
*/

#include "tasks.h"
#include "../Interfaces/Threads.h"
#include "events.h"
#include "../Interfaces/Network.h"

#include <stdlib.h>

Local_Handle *hades, *test;

/*

  The async data event has two arguments.

  1: The message (of type struct message)
  2: Who its from, in the form of a computer handle. (of type computer_handle)
  
  they are passed as argv[0] and argv[1] respectively.

 */
bool Data_Handler(EventID cause)
{

  int from;
  struct Message msg;

//  printf("Data Handler called with %d arguments\n", argc);

  /* Some tricky bugger dereferencing. -fancy footwork  */
//  from = *(int *) argv[1];
//  msg = *((struct Message *) argv[0]);
  
//  printf("The message passed was %s \n", msg.message);
//  printf("And it was from %d\n", from);

  /* FIXME : should implement the async data and not able to send events with      proper severitys so that the program wont fall over if the events dont go
     unhandled. */
  return true;
  
}

void Init()
{
  
  printf("init entered\n");

}

int Main()
{
  
  struct Message msg;

  printf("hello world\n");

  //  hades = register_computer("hades");

  msg.message = "Hello\n";
  msg.length = 6;

  //  send_message(hades, &msg);

  // was used to test the mapping table.
 forever:
  Suspend();
  goto forever;
  

}
