9 struct task tasks
[MAXTASKS
];
14 memset(&tasks
, 0, sizeof(struct task
)*MAXTASKS
);
17 int task_register(int fd
)
21 for(ct
= 0; ct
<MAXTASKS
; ct
++)
25 die("Trying to add too much tasks...\n");
27 memset(&tasks
[ct
], 0, sizeof(struct task
));
29 read16(fd
, c
, tasks
[ct
].interval
);
31 read16(fd
, c
, tasks
[ct
].tlen
);
33 if(tasks
[ct
].tlen
> MAXTASKSIZE
)
34 die("Task is too long: %d\n", tasks
[ct
].tlen
);
36 for(int i
= 0; i
<tasks
[ct
].tlen
; i
++){
37 read(fd
, tasks
[ct
].bc
+i
, 1);
38 debug("t[][%i]: 0x%02x %d\n", i
,
39 tasks
[ct
].bc
[i
], tasks
[ct
].bc
[i
]);
41 //Return the task number for later removal
42 debug("Received a task of length %d\n", tasks
[ct
].tlen
);
43 tasks
[ct
].used
= true;
47 void task_delete(int fd
)
50 tasks
[c
].used
= false;
53 struct task
*task_get(int num
)
55 return tasks
[num
].used
? &tasks
[num
] : NULL
;