
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <time.h>

#include "diglobals.h"
#include "debug.h"
#include "timedevents.h"

void third_func(void *arg);

void first_func(void *arg)
{
    time_t now;

    now = time(NULL);
    DB(10, (stderr, "1: %s", ctime(&now)));
}

void second_func(void *arg)
{
    time_t now;

    now = time(NULL);
    DB(10, (stderr, "2: %s", ctime(&now)));
    event_schedule(third_func, NULL, 2, true);

}

void third_func(void *arg)
{
   time_t now;

   now = time(NULL);
   DB(10, (stderr, "3: %s", ctime(&now)));
}

void main() 
{
  time_t now;

  event_start();

  event_schedule(first_func, NULL, 5, true);
  event_schedule(second_func, main, 17, false);

  now = time(NULL);
  DB(10, (stderr, "0: %s", ctime(&now)));

  while (1) {
      event_atrun();
      usleep(10);
  }

}
