#include <stdlib.h>
#include <handler.h>

#include <default_syscall_handler.h>	/* !!!! remove for drop to barcelona */

/* TODO: implement a list. for now one handler is enough */

int
handler_append (handler_t * ph,
		int (*handler) (unsigned long *, unsigned long))
{
	ph->handler = handler;
	return (0);
}

int
handler_run (handler_t * ph, unsigned long *mapbase, unsigned long args)
{
	if (ph->handler)
	  {
		  ph->handler (mapbase, args);
	  }

	return (0);
}

handler_t *
handler_new (char *pathname)
{
	handler_t *ph;

	ph = (handler_t *) malloc (sizeof (handler_t));
	handler_append( ph, default_syscall_handler ); /* !!!! remove for drop to barcelona */
	return (ph);
}
