X-Git-Url: http://git.pk910.de/?a=blobdiff_plain;f=src%2FIOEngine.h;h=4e43a6af05d51da17aa069d0886f29fe1925f397;hb=e18ef9b450a0704ff5c55545f70e3f1ec215a5e6;hp=5f68240617f1304da64ddbf9a1f6a9e1f84be53e;hpb=f9b6cfeca8df976a0fb3cf1be29d2064d5ae0bdf;p=IOMultiplexer.git diff --git a/src/IOEngine.h b/src/IOEngine.h index 5f68240..4e43a6a 100644 --- a/src/IOEngine.h +++ b/src/IOEngine.h @@ -39,23 +39,53 @@ #define IODESYNCHRONIZE(var) #endif -struct IODescriptor; -enum IOType; -enum IOStatus; -enum IOEventType; - #define timeval_is_bigger(x,y) ((x->tv_sec > y->tv_sec) || (x->tv_sec == y->tv_sec && x->tv_usec > y->tv_usec)) #define timeval_is_smaler(x,y) ((x->tv_sec < y->tv_sec) || (x->tv_sec == y->tv_sec && x->tv_usec < y->tv_usec)) -extern struct IODescriptor *first_descriptor; -extern struct IODescriptor *timer_priority; + +struct IODescriptor; +struct IOLowlevelDescriptor; + +extern struct IOLowlevelDescriptor *first_descriptor; +extern struct IOLowlevelDescriptor *timer_priority; +extern struct IOLowlevelDescriptor *lowlevel_descriptor; + +#define IOLOWLEVEL_CALLBACK(NAME) void NAME(struct IOLowlevelDescriptor *iold, int can_read) +typedef IOLOWLEVEL_CALLBACK(iolowlevel_callback); + +#define IOFLAGS_WANT_READ 0x01 +#define IOFLAGS_WANT_WRITE 0x02 +#define IOFLAGS_HAVE_IOFD 0x04 +#define IOFLAGS_HAVE_TIMEOUT 0x08 + +#define IOFDFLAGS_HAVE_IOLD 0x01 +#define IOFDFLAGS_FREE_LOCK 0x02 +#define IOFDFLAGS_WANT_FREE 0x04 +#define IOFDFLAGS_SSL_ACTIVE 0x08 +#define IOFDFLAGS_SSL_SERVER_HS 0x10 +#define IOFDFLAGS_SSL_HS_READ 0x20 +#define IOFDFLAGS_SSL_HS_WRITE 0x40 + +struct IOLowlevelDescriptor { + int fd; + unsigned int flags; + struct timeval timeout; + union { + struct IODescriptor *iofd; + iolowlevel_callback *callback; + } data; + struct IOLowlevelDescriptor *next, *prev; +}; + +#define IOLOWLEVEL_GET_IOFD(iold) ((iold->flags & IOFLAGS_HAVE_IOFD) ? iold->data.iofd : NULL) +#define IODESCRIPTOR_GET_IOLD(iofd) ((iofd->flags & IOFDFLAGS_HAVE_IOLD) ? iofd->fd.iold : NULL) struct IOEngine { const char *name; int (*init)(void); - void (*add)(struct IODescriptor *iofd); - void (*remove)(struct IODescriptor *iofd); - void (*update)(struct IODescriptor *iofd); + void (*add)(struct IOLowlevelDescriptor *iofd); + void (*remove)(struct IOLowlevelDescriptor *iofd); + void (*update)(struct IOLowlevelDescriptor *iofd); void (*loop)(struct timeval *timeout); void (*cleanup)(void); }; @@ -68,4 +98,8 @@ char *iohandler_iotype_name(enum IOType type); char *iohandler_iostatus_name(enum IOStatus status); char *iohandler_ioeventtype_name(enum IOEventType type); +struct IOLowlevelDescriptor *iohandler_lowlevel_add(int fd, int want_read, int want_write, iolowlevel_callback *callback); +void iohandler_lowlevel_update(struct IOLowlevelDescriptor *iolow, int want_read, int want_write); +void iohandler_lowlevel_del(struct IOLowlevelDescriptor *iolow); + #endif