Annotation of libaitsched/example/test.c, revision 1.3

1.2       misho       1: #include <stdio.h>
                      2: #include <unistd.h>
                      3: #include <fcntl.h>
                      4: #include <sys/types.h>
                      5: #include <sys/stat.h>
                      6: #include <sys/socket.h>
                      7: #include <netinet/in.h>
                      8: #include <aitsched.h>
                      9: 
                     10: intptr_t Kill;
                     11: 
                     12: void *event(sched_task_t *arg)
                     13: {
                     14:        printf("Event::\n");
                     15:        return NULL;
                     16: }
                     17: 
                     18: void *eventlo(sched_task_t *arg)
                     19: {
                     20:        printf("EventLOW::\n");
                     21:        return NULL;
                     22: }
                     23: 
                     24: void *timer(sched_task_t *arg)
                     25: {
                     26:        printf("Timer 10sec::\n");
                     27:        return NULL;
                     28: }
                     29: 
                     30: void *r(sched_task_t *arg)
                     31: {
                     32:        printf("read::\n");
                     33:        Kill++;
                     34:        return NULL;
                     35: }
                     36: 
                     37: void *w(sched_task_t *arg)
                     38: {
                     39:        printf("write::\n");
                     40:        return NULL;
                     41: }
                     42: 
                     43: void *once(sched_task_t *arg)
                     44: {
                     45:        printf("once::\n");
                     46:        return NULL;
                     47: }
                     48: 
                     49: int
                     50: main(int argc, char **argv)
                     51: {
                     52:        sched_root_task_t *root;
                     53:        int f;
                     54:        struct sockaddr_in sin;
1.3     ! misho      55:        struct timeval tv = { 10, 0 };
1.2       misho      56: 
                     57:        f = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
                     58:        if (f == -1)
                     59:                return 1;
                     60:        sin.sin_len = sizeof sin;
                     61:        sin.sin_family = AF_INET;
                     62:        sin.sin_port = htons(2345);
                     63:        sin.sin_addr.s_addr = INADDR_ANY;
                     64:        if (bind(f, (struct sockaddr*) &sin, sizeof sin) == -1)
                     65:                return 1;
                     66: 
                     67:        root = schedBegin();
                     68:        if (!root) {
                     69:                printf("Error:: #%d - %s\n", sched_GetErrno(), sched_GetError());
                     70:                return 1;
                     71:        }
                     72: 
                     73:        if (!schedEvent(root, event, "piuk", 1234)) {
                     74:                printf("Error:: #%d - %s\n", sched_GetErrno(), sched_GetError());
                     75:                return 2;
                     76:        }
                     77: 
                     78:        if (!schedEventLo(root, eventlo, "piuk", 1111)) {
                     79:                printf("Error:: #%d - %s\n", sched_GetErrno(), sched_GetError());
                     80:                return 3;
                     81:        }
                     82: 
1.3     ! misho      83:        if (!schedTimer(root, timer, "blah", tv)) {
1.2       misho      84:                printf("Error:: #%d - %s\n", sched_GetErrno(), sched_GetError());
                     85:                return 4;
                     86:        }
                     87: 
                     88:        if (!schedRead(root, r, "rrr", f)) {
                     89:                printf("Error:: #%d - %s\n", sched_GetErrno(), sched_GetError());
                     90:                return 5;
                     91:        }
                     92: 
                     93:        if (!schedWrite(root, w, "www", f)) {
                     94:                printf("Error:: #%d - %s\n", sched_GetErrno(), sched_GetError());
                     95:                return 6;
                     96:        }
                     97: 
                     98:        schedCallOnce(root, once, "000000", 42);
                     99: 
                    100:        schedRun(root, &Kill);
                    101:        schedEnd(&root);
                    102: 
                    103:        close(f);
                    104:        return 0;
                    105: }

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