#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <aitsched.h>
intptr_t Kill;
void *event(sched_task_t *arg)
{
printf("Event::\n");
return NULL;
}
void *eventlo(sched_task_t *arg)
{
printf("EventLOW::\n");
return NULL;
}
void *timer(sched_task_t *arg)
{
printf("Timer 10sec::\n");
return NULL;
}
void *r(sched_task_t *arg)
{
printf("read::\n");
Kill++;
return NULL;
}
void *w(sched_task_t *arg)
{
printf("write::\n");
return NULL;
}
void *once(sched_task_t *arg)
{
printf("once::\n");
return NULL;
}
int
main(int argc, char **argv)
{
sched_root_task_t *root;
int f;
struct sockaddr_in sin;
struct timeval tv = { 10, 0 };
f = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (f == -1)
return 1;
sin.sin_len = sizeof sin;
sin.sin_family = AF_INET;
sin.sin_port = htons(2345);
sin.sin_addr.s_addr = INADDR_ANY;
if (bind(f, (struct sockaddr*) &sin, sizeof sin) == -1)
return 1;
root = schedBegin();
if (!root) {
printf("Error:: #%d - %s\n", sched_GetErrno(), sched_GetError());
return 1;
}
if (!schedEvent(root, event, "piuk", 1234)) {
printf("Error:: #%d - %s\n", sched_GetErrno(), sched_GetError());
return 2;
}
if (!schedEventLo(root, eventlo, "piuk", 1111)) {
printf("Error:: #%d - %s\n", sched_GetErrno(), sched_GetError());
return 3;
}
if (!schedTimer(root, timer, "blah", tv)) {
printf("Error:: #%d - %s\n", sched_GetErrno(), sched_GetError());
return 4;
}
if (!schedRead(root, r, "rrr", f)) {
printf("Error:: #%d - %s\n", sched_GetErrno(), sched_GetError());
return 5;
}
if (!schedWrite(root, w, "www", f)) {
printf("Error:: #%d - %s\n", sched_GetErrno(), sched_GetError());
return 6;
}
schedCallOnce(root, once, "000000", 42);
schedRun(root, &Kill);
schedEnd(&root);
close(f);
return 0;
}
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>