evtapi - an event driven I.O, timer and signal engine

Introduce:

this api something like libevent.

Reference:

#ifndef __EVT_API
#define __EVT_API

#define EVENT_TIMER 0x01
#define EVENT_READ 0x02
#define EVENT_WRITE 0x04
#define EVENT_SIGNAL 0x08
#define EVENT_ERROR 0x10

#ifndef sighandler_t
typedef void (*sighandler_t)(int);
#endif

struct event {
int timerstart;
int utimeout;
unsigned int flags;
int fd;
int sig;
int action;
void (*event_handle)(int fd,int action,void* arg);
void (*timer_handle)(void* arg);
void (*signal_handle)(int sig,int action,void* arg);
sighandler_t signal_old;
void* arg;

TAILQ_ENTRY(event) list;
};

int event_init();
void event_set(struct event* ev,int fd, int action, void (*event_cb)(int fd, int action, void* arg), void* arg);
void evtimer_set(struct event* ev, void (*timer_cb)(void* arg), void* arg);
void signal_set(struct event* ev, int sig, void (*signal_cb)(int sig,int action,void* arg), void* arg);
void event_add(struct event* ev, int utimeout);
void event_remove(struct event* ev);
int event_loop();

#endif

AttachmentSize
evtapi-20080506a-normal.tgz8.91 KB