--- libev/event.h 2008/05/23 16:37:38 1.18 +++ libev/event.h 2012/04/02 23:14:41 1.25 @@ -1,19 +1,19 @@ /* * libevent compatibility header, only core events supported * - * Copyright (c) 2007,2008 Marc Alexander Lehmann + * Copyright (c) 2007,2008,2010,2012 Marc Alexander Lehmann * All rights reserved. * * Redistribution and use in source and binary forms, with or without modifica- * tion, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER- * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO @@ -37,8 +37,8 @@ * either the BSD or the GPL. */ -#ifndef EVENT_H__ -#define EVENT_H__ +#ifndef EVENT_H_ +#define EVENT_H_ #ifdef EV_H # include EV_H @@ -46,10 +46,26 @@ # include "ev.h" #endif +#ifndef EVLOOP_NONBLOCK +# define EVLOOP_NONBLOCK EVRUN_NOWAIT +#endif +#ifndef EVLOOP_ONESHOT +# define EVLOOP_ONESHOT EVRUN_ONCE +#endif +#ifndef EV_TIMEOUT +# define EV_TIMEOUT EV_TIMER +#endif + #ifdef __cplusplus extern "C" { #endif +/* we need sys/time.h for struct timeval only */ +#if !defined (WIN32) || defined (__MINGW32__) +# include /* mingw seems to need this, for whatever reason */ +# include +#endif + struct event_base; #define EVLIST_TIMEOUT 0x01 @@ -79,7 +95,10 @@ short ev_events; }; +#define EV_READ EV_READ +#define EV_WRITE EV_WRITE #define EV_PERSIST 0x10 +#define EV_ET 0x20 /* nop */ #define EVENT_SIGNAL(ev) ((int) (ev)->ev_fd) #define EVENT_FD(ev) ((int) (ev)->ev_fd) @@ -122,6 +141,9 @@ typedef void (*event_log_cb)(int severity, const char *msg); void event_set_log_callback(event_log_cb cb); +typedef void (*event_callback_fn)(int, short, void *); +event_callback_fn event_get_callback (const struct event *ev); + void event_set (struct event *ev, int fd, short events, void (*cb)(int, short, void *), void *arg); int event_once (int fd, short events, void (*cb)(int, short, void *), void *arg, struct timeval *tv); @@ -134,6 +156,8 @@ int event_priority_init (int npri); int event_priority_set (struct event *ev, int pri); +struct event_base *event_base_new (void); +const char *event_base_get_method (const struct event_base *); int event_base_set (struct event_base *base, struct event *ev); int event_base_loop (struct event_base *base, int); int event_base_loopexit (struct event_base *base, struct timeval *tv);