#include "monitor.h"

monitor_t monitorv[] = { MONITORS };
static int monitorc = sizeof(monitorv) / sizeof(monitorv[0]);

int monitor_register(int id, 
					 monitor_addwatch fp_monitor_addwatch,
					 monitor_delwatch fp_monitor_delwatch)
{
	int ret = -1;

	do {
		if ((id < 0) || (id >= monitorc)) break;

		monitorv[id].addwatch = fp_monitor_addwatch;
		monitorv[id].delwatch = fp_monitor_delwatch;

		ret = 0;
	} while (0);

	return ret;
}

void monitor_flush(PRUNTIME pRuntime, int id)
{
	int i;

	for (i = 0; i < monitorc; i++) 
		if ((id == MONITOR_ALL_INDEX) || (id == i)) 
			if (monitorv[i].delwatch) monitorv[i].delwatch(pRuntime, NULL);

	return;
}
