9 struct task tasks
[MAXTASKS
];// = {0};
12 int task_register(int fd
)
16 for(ct
= 0; ct
<MAXTASKS
; ct
++)
20 die("Trying to add too much tasks...\n");
22 memset(&tasks
[ct
], 0, sizeof(struct task
));
24 read16(fd
, c
, tasks
[ct
].interval
);
26 read16(fd
, c
, tasks
[ct
].tlen
);
28 if(tasks
[ct
].tlen
> MAXTASKSIZE
)
29 die("Task is too long: %d\n", tasks
[ct
].tlen
);
31 for(int i
= 0; i
<tasks
[ct
].tlen
; i
++){
32 read(fd
, tasks
[ct
].bc
+i
, 1);
33 debug("t[][%i]: 0x%02x %d\n", i
,
34 tasks
[ct
].bc
[i
], tasks
[ct
].bc
[i
]);
36 //Return the task number for later removal
37 debug("Received a task of length %d\n", tasks
[ct
].tlen
);
38 tasks
[ct
].used
= true;
42 void task_delete(int fd
)
45 tasks
[c
].used
= false;
48 struct task
*task_get(int num
)
50 return tasks
[num
].used
? &tasks
[num
] : NULL
;