2 * event.c -- simple event api
4 * author: hackbard@hackdaworld.dyndns.org
11 typedef struct __fd_list {
20 int add_fd(int fd,unsigned char mode,fd_list *fd_list) {
22 if(fd_list->next==NULL) {
23 if((new=(fd_list *)(malloc(sizeof(fd_list))))==NULL) {
24 puts("failed allocating fd_list memory");
30 fd_list->next->next=NULL;
33 else add_fd(fd,mode,tv,fd_list->next);
36 int del_fd(int fd,fd_list *fd_list) {
38 if(fd_list->next->fd==fd) {
40 fd_list->next=fd_list->next->next;
45 if(fd_list->next==NULL) {
46 puts("didnt find this fd in list!);
49 del_fd(fd,fd_list->next);
54 get_max_fd(fd_list *fd_list) {
56 if(fd_list->next=NULL) return test;
58 if(fd_list->fd>test) test=fd_list->fd;
59 get_max_fd(fd_list->next);
63 int loop(fd_list *fd_list,timeval tv) {