Diff for /libaitsched/example/test.c between versions 1.1 and 1.2

version 1.1, 2011/08/12 23:06:55 version 1.2, 2011/10/04 12:34:33
Line 0 Line 1
   #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;
   
           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", 10000000)) {
                   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;
   }

Removed from v.1.1  
changed lines
  Added in v.1.2


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>