-/*
- * event.c -- simple event api
- *
- * author: hackbard@hackdaworld.dyndns.org
- *
- */
-
-#include <stdio.h>
-#include <sys/time.h>
-
-typedef struct __fd_list {
- int fd;
- unsigned char mode;
- fd_list *next;
-} fd_list;
-
-#define READ 1
-#define WRITE 2
-
-int add_fd(int fd,unsigned char mode,fd_list *fd_list) {
- fd_list *new;
- if(fd_list->next==NULL) {
- if((new=(fd_list *)(malloc(sizeof(fd_list))))==NULL) {
- puts("failed allocating fd_list memory");
- return -1;
- }
- new->fd=fd;
- new->mode=mode;
- fd_list->next=new;
- fd_list->next->next=NULL;
- return fd;
- }
- else add_fd(fd,mode,tv,fd_list->next);
-}
-
-int del_fd(int fd,fd_list *fd_list) {
- fd_list *tmp;
- if(fd_list->next->fd==fd) {
- tmp=fd_list->next;
- fd_list->next=fd_list->next->next;
- free(tmp);
- return fd;
- }
- else {
- if(fd_list->next==NULL) {
- puts("didnt find this fd in list!);
- return -1;
- }
- del_fd(fd,fd_list->next);
- }
- return 1;
-}
-
-get_max_fd(fd_list *fd_list) {
- int test=-1;
- if(fd_list->next=NULL) return test;
- else {
- if(fd_list->fd>test) test=fd_list->fd;
- get_max_fd(fd_list->next);
- }
-}
-
-int loop(fd_list *fd_list,timeval tv) {
-