python/dbus-python: rename package to normalize it
[oi-userland.git] / components / library / libevent / patches / event.3.patch
blob64d0c22c24a23f412d4a991a83ce78e8ccd83904
1 --- libevent-1.4.14b-stable/event.3 po lis 21 06:43:10 2011
2 +++ libevent-1.4.14b-stable/event.3 po lis 21 09:31:12 2011
3 @@ -26,527 +26,528 @@
4 .\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
5 .\" ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
6 .\"
7 -.Dd August 8, 2000
8 -.Dt EVENT 3
9 -.Os
10 -.Sh NAME
11 -.Nm event_init ,
12 -.Nm event_dispatch ,
13 -.Nm event_loop ,
14 -.Nm event_loopexit ,
15 -.Nm event_loopbreak ,
16 -.Nm event_set ,
17 -.Nm event_base_dispatch ,
18 -.Nm event_base_loop ,
19 -.Nm event_base_loopexit ,
20 -.Nm event_base_loopbreak ,
21 -.Nm event_base_set ,
22 -.Nm event_base_free ,
23 -.Nm event_add ,
24 -.Nm event_del ,
25 -.Nm event_once ,
26 -.Nm event_base_once ,
27 -.Nm event_pending ,
28 -.Nm event_initialized ,
29 -.Nm event_priority_init ,
30 -.Nm event_priority_set ,
31 -.Nm evtimer_set ,
32 -.Nm evtimer_add ,
33 -.Nm evtimer_del ,
34 -.Nm evtimer_pending ,
35 -.Nm evtimer_initialized ,
36 -.Nm signal_set ,
37 -.Nm signal_add ,
38 -.Nm signal_del ,
39 -.Nm signal_pending ,
40 -.Nm signal_initialized ,
41 -.Nm bufferevent_new ,
42 -.Nm bufferevent_free ,
43 -.Nm bufferevent_write ,
44 -.Nm bufferevent_write_buffer ,
45 -.Nm bufferevent_read ,
46 -.Nm bufferevent_enable ,
47 -.Nm bufferevent_disable ,
48 -.Nm bufferevent_settimeout ,
49 -.Nm bufferevent_base_set ,
50 -.Nm evbuffer_new ,
51 -.Nm evbuffer_free ,
52 -.Nm evbuffer_add ,
53 -.Nm evbuffer_add_buffer ,
54 -.Nm evbuffer_add_printf ,
55 -.Nm evbuffer_add_vprintf ,
56 -.Nm evbuffer_drain ,
57 -.Nm evbuffer_write ,
58 -.Nm evbuffer_read ,
59 -.Nm evbuffer_find ,
60 -.Nm evbuffer_readline ,
61 -.Nm evhttp_new ,
62 -.Nm evhttp_bind_socket ,
63 -.Nm evhttp_free
64 -.Nd execute a function when a specific event occurs
65 -.Sh SYNOPSIS
66 -.Fd #include <sys/time.h>
67 -.Fd #include <event.h>
68 -.Ft "struct event_base *"
69 -.Fn "event_init" "void"
70 -.Ft int
71 -.Fn "event_dispatch" "void"
72 -.Ft int
73 -.Fn "event_loop" "int flags"
74 -.Ft int
75 -.Fn "event_loopexit" "struct timeval *tv"
76 -.Ft int
77 -.Fn "event_loopbreak" "void"
78 -.Ft void
79 -.Fn "event_set" "struct event *ev" "int fd" "short event" "void (*fn)(int, short, void *)" "void *arg"
80 -.Ft int
81 -.Fn "event_base_dispatch" "struct event_base *base"
82 -.Ft int
83 -.Fn "event_base_loop" "struct event_base *base" "int flags"
84 -.Ft int
85 -.Fn "event_base_loopexit" "struct event_base *base" "struct timeval *tv"
86 -.Ft int
87 -.Fn "event_base_loopbreak" "struct event_base *base"
88 -.Ft int
89 -.Fn "event_base_set" "struct event_base *base" "struct event *"
90 -.Ft void
91 -.Fn "event_base_free" "struct event_base *base"
92 -.Ft int
93 -.Fn "event_add" "struct event *ev" "struct timeval *tv"
94 -.Ft int
95 -.Fn "event_del" "struct event *ev"
96 -.Ft int
97 -.Fn "event_once" "int fd" "short event" "void (*fn)(int, short, void *)" "void *arg" "struct timeval *tv"
98 -.Ft int
99 -.Fn "event_base_once" "struct event_base *base" "int fd" "short event" "void (*fn)(int, short, void *)" "void *arg" "struct timeval *tv"
100 -.Ft int
101 -.Fn "event_pending" "struct event *ev" "short event" "struct timeval *tv"
102 -.Ft int
103 -.Fn "event_initialized" "struct event *ev"
104 -.Ft int
105 -.Fn "event_priority_init" "int npriorities"
106 -.Ft int
107 -.Fn "event_priority_set" "struct event *ev" "int priority"
108 -.Ft void
109 -.Fn "evtimer_set" "struct event *ev" "void (*fn)(int, short, void *)" "void *arg"
110 -.Ft void
111 -.Fn "evtimer_add" "struct event *ev" "struct timeval *"
112 -.Ft void
113 -.Fn "evtimer_del" "struct event *ev"
114 -.Ft int
115 -.Fn "evtimer_pending" "struct event *ev" "struct timeval *tv"
116 -.Ft int
117 -.Fn "evtimer_initialized" "struct event *ev"
118 -.Ft void
119 -.Fn "signal_set" "struct event *ev" "int signal" "void (*fn)(int, short, void *)" "void *arg"
120 -.Ft void
121 -.Fn "signal_add" "struct event *ev" "struct timeval *"
122 -.Ft void
123 -.Fn "signal_del" "struct event *ev"
124 -.Ft int
125 -.Fn "signal_pending" "struct event *ev" "struct timeval *tv"
126 -.Ft int
127 -.Fn "signal_initialized" "struct event *ev"
128 -.Ft "struct bufferevent *"
129 -.Fn "bufferevent_new" "int fd" "evbuffercb readcb" "evbuffercb writecb" "everrorcb" "void *cbarg"
130 -.Ft void
131 -.Fn "bufferevent_free" "struct bufferevent *bufev"
132 -.Ft int
133 -.Fn "bufferevent_write" "struct bufferevent *bufev" "void *data" "size_t size"
134 -.Ft int
135 -.Fn "bufferevent_write_buffer" "struct bufferevent *bufev" "struct evbuffer *buf"
136 -.Ft size_t
137 -.Fn "bufferevent_read" "struct bufferevent *bufev" "void *data" "size_t size"
138 -.Ft int
139 -.Fn "bufferevent_enable" "struct bufferevent *bufev" "short event"
140 -.Ft int
141 -.Fn "bufferevent_disable" "struct bufferevent *bufev" "short event"
142 -.Ft void
143 -.Fn "bufferevent_settimeout" "struct bufferevent *bufev" "int timeout_read" "int timeout_write"
144 -.Ft int
145 -.Fn "bufferevent_base_set" "struct event_base *base" "struct bufferevent *bufev"
146 -.Ft "struct evbuffer *"
147 -.Fn "evbuffer_new" "void"
148 -.Ft void
149 -.Fn "evbuffer_free" "struct evbuffer *buf"
150 -.Ft int
151 -.Fn "evbuffer_add" "struct evbuffer *buf" "const void *data" "size_t size"
152 -.Ft int
153 -.Fn "evbuffer_add_buffer" "struct evbuffer *dst" "struct evbuffer *src"
154 -.Ft int
155 -.Fn "evbuffer_add_printf" "struct evbuffer *buf" "const char *fmt" "..."
156 -.Ft int
157 -.Fn "evbuffer_add_vprintf" "struct evbuffer *buf" "const char *fmt" "va_list ap"
158 -.Ft void
159 -.Fn "evbuffer_drain" "struct evbuffer *buf" "size_t size"
160 -.Ft int
161 -.Fn "evbuffer_write" "struct evbuffer *buf" "int fd"
162 -.Ft int
163 -.Fn "evbuffer_read" "struct evbuffer *buf" "int fd" "int size"
164 -.Ft "u_char *"
165 -.Fn "evbuffer_find" "struct evbuffer *buf" "const u_char *data" "size_t size"
166 -.Ft "char *"
167 -.Fn "evbuffer_readline" "struct evbuffer *buf"
168 -.Ft "struct evhttp *"
169 -.Fn "evhttp_new" "struct event_base *base"
170 -.Ft int
171 -.Fn "evhttp_bind_socket" "struct evhttp *http" "const char *address" "u_short port"
172 -.Ft "void"
173 -.Fn "evhttp_free" "struct evhttp *http"
174 -.Ft int
175 -.Fa (*event_sigcb)(void) ;
176 -.Ft volatile sig_atomic_t
177 -.Fa event_gotsig ;
178 -.Sh DESCRIPTION
179 +.TH EVENT 3 "21 November 2011" "libevent 1.4.14b" "libevent Manual"
180 +.SH NAME
181 +event_init,
182 +event_dispatch,
183 +event_loop,
184 +event_loopexit,
185 +event_loopbreak,
186 +event_set,
187 +event_base_dispatch,
188 +event_base_loop,
189 +event_base_loopexit,
190 +event_base_loopbreak,
191 +event_base_set,
192 +event_base_free,
193 +event_add,
194 +event_del,
195 +event_once,
196 +event_base_once,
197 +event_pending,
198 +event_initialized,
199 +event_priority_init,
200 +event_priority_set,
201 +evtimer_set,
202 +evtimer_add,
203 +evtimer_del,
204 +evtimer_pending,
205 +evtimer_initialized,
206 +signal_set,
207 +signal_add,
208 +signal_del,
209 +signal_pending,
210 +signal_initialized,
211 +bufferevent_new,
212 +bufferevent_free,
213 +bufferevent_write,
214 +bufferevent_write_buffer,
215 +bufferevent_read,
216 +bufferevent_enable,
217 +bufferevent_disable,
218 +bufferevent_settimeout,
219 +bufferevent_base_set,
220 +evbuffer_new,
221 +evbuffer_free,
222 +evbuffer_add,
223 +evbuffer_add_buffer,
224 +evbuffer_add_printf,
225 +evbuffer_add_vprintf,
226 +evbuffer_drain,
227 +evbuffer_write,
228 +evbuffer_read,
229 +evbuffer_find,
230 +evbuffer_readline,
231 +evhttp_new,
232 +evhttp_bind_socket,
233 +evhttp_free
234 +\- execute a function when a specific event occurs
235 +.SH LIBRARY
236 +The libevent library (libevent, -levent)
237 +.br
238 +.SH SYNOPSIS
239 +.LP
240 +.nf
241 +\fB#include <sys/time.h>\fP
242 +\fB#include <event.h>\fP
244 +\fBstruct event_base* \fBevent_init\fR\fR(\fBvoid\fP\fR);
246 +\fBint \fBevent_dispatch\fR\fR(\fBvoid\fP\fR);
248 +\fBint \fBevent_loop\fR\fR(\fBint \fIflags\fP\fR);
250 +\fBint \fBevent_loopexit\fR\fR(\fBstruct timeval* \fItv\fP\fR);
252 +\fBint \fBevent_loopbreak\fR\fR(\fBvoid\fP\fR);
254 +\fBvoid \fBevent_set\fR\fR(\fBstruct event* \fIev\fP\fR, \fBint \fIfd \fP\fR, \fBshort \fIevent\fP\fR, \fBvoid \fI(*fn)(\fBint, short, void *\fP\fR), \fBvoid* \fIarg\fP\fR);
256 +\fBint \fBevent_base_dispatch\fR\fR(\fBstruct event_base* \fIbase\fP\fR);
258 +\fBint \fBevent_base_loop\fR\fR(\fBstruct event_base* \fIbase\fP\fR, \fBint \fIflags\fP\fR);
260 +\fBint \fBevent_base_loopexit\fR\fR(\fBstruct event_base* \fIbase\fP\fR, \fBstruct timeval* \fItv\fP\fR);
262 +\fBint \fBevent_base_loopbreak\fR\fR(\fBstruct event_base* \fIbase\fP\fR);
264 +\fBint \fBevent_base_set\fR\fR(\fBstruct event_base* \fIbase\fP\fR, \fBstruct event* \fIev\fP\fR);
266 +\fBvoid \fBevent_base_free\fR\fR(\fBstruct event_base* \fIbase\fP\fR);
268 +\fBint \fBevent_add\fR\fR(\fBstruct event* \fIev\fP\fR, \fBstruct timeval* \fItv\fP\fR);
270 +.\fBint \fBevent_del\fR\fR(struct event* \fIev\fP\fR);
272 +\fBint \fBevent_once\fR\fR(\fBint \fIfd\fP\fR, \fBshort \fIevent\fP\fR, \fBvoid \fI(*fn)(\fBint, short, void*\fB\fR), \fBstruct timeval* \fItv\fP\fR);
274 +\fBint \fBevent_base_once\fR\fR(\fBstruct event_base* \fIbase\fP\fR, \fBint \fIfd\fB\fR, \fBshort \fIevent\fB\fR, \fBvoid \fI(*fn)(\fBint, short, void*\fB\fR), \fBvoid* \fIarg\fB\fR, \fBstruct timeval* \fItv\fP\fR);
276 +\fBint \fBevent_pending\fR\fR(\fBstruct event* \fIev\fP\fR, \fBshort \fIevent\fB\fR, \fBstruct timeval* \fItv\fP\fR);
278 +\fBint \fBevent_initialized\fR\fR(\fBstruct event* \fIev\fP\fR);
280 +\fBint \fBevent_priority_init\fR\fR (\fBint \fInpriorities\fP\fR);
282 +\fBint \fBevent_priority_set\fR\fR (\fBstruct event* \fIev\fP\fR, \fBint \fIpriority\fP\fR);
284 +\fBvoid \fBevtimer_set\fR\fR (\fBstruct event* \fIev\fP\fR, \fBvoid \fI(*fn)(\fBint, short, void*\fB\fR), \fBvoid* \fIarg\fP\fR);
286 +\fBvoid \fBevtimer_add\fR\fR (\fBstruct event* \fIev\fP\fR, \fBstruct timeval* \fItv\fP\fR);
288 +\fBvoid \fBevtimer_del\fR\fR (\fBstruct event* \fIev\fP\fR);
290 +\fBint \fBevtimer_pending\fR\fR (\fBstruct event* \fIev\fP\fR, \fBstruct timeval* \fItv\fP\fR);
292 +\fBint \fBevtimer_initialized\fR\fR(\fBstruct event* \fIev\fP\fR);
294 +\fBvoid \fBsignal_set\fR\fR (\fBstruct event* \fIev\fP\fR, \fBint \fIsignal\fP\fR, \fBvoid \fI(*fn)(\fBint, short, void*\fP\fR), \fBvoid* \fIarg\fP\fR);
296 +\fBvoid \fBsignal_add\fR\fR (\fBstruct event* \fIev\fP\fR, \fBstruct timeval* \fItv\fP\fR);
298 +\fBvoid \fBsignal_del\fR\fR (\fBstruct event* \fIev\fP\fR);
300 +\fBint \fBsignal_pending\fR\fR(\fBstruct event* \fIev\fP\fR, \fBstruct timeval* \fItv\fP\fR);
302 +\fBint \fBsignal_initialized\fR\fR(\fBstruct event* \fIev\fP\fR);
304 +\fBstruct bufferevent* \fBbufferevent_new\fR\fR(\fBint \fIfd\fP\fR, \fBevbuffercb \fIreadcb\fP\fR, \fBevbuffercb \fIwritecb\fP\fR, \fBeverrorcb \fIerrorcb\fP\fR, \fBvoid* \fIcbarg\fP\fR);
306 +\fBvoid \fBbufferevent_free\fR\fR(\fBstruct bufferevent* \fIbufev\fP\fR);
308 +\fBint \fBbufferevent_write\fR\fR(\fBstruct bufferevent* \fIbufev\fP\fR, \fBvoid* \fIdata\fP\fR, \fBsize_t \fIsize\fP\fR);
310 +\fBint \fBbufferevent_write_buffer\fR\fR(\fBstruct bufferevent* \fIbufev\fP\fR, \fBstruct evbuffer* \fIbuf\fP\fR);
312 +\fBsize_t \fBbufferevent_read\fR\fR(\fBstruct bufferevent* \fIbufev\fP\fR, \fBvoid* \fIdata\fP\fR, \fBsize_t \fIsize\fP\fR);
314 +\fBint \fBbufferevent_enable\fR\fR(\fBstruct bufferevent* \fIbufev\fP\fR, \fBshort \fIevent\fP\fR);
316 +\fBint \fBbufferevent_disable\fR\fR(\fBstruct bufferevent* \fIbufev\fP\fR, \fBshort \fIeven\fP\fR);
318 +\fBvoid \fBbufferevent_settimeout\fR\fR(\fBstruct bufferevent* \fIbufev\fP\fR, \fBint \fItimeout_read\fP\fR, \fBint \fItimeout_write\fP\fR);
320 +\fBint \fBbufferevent_base_set\fR\fR(\fBstruct event_base* \fIbase\fP\fR, \fBstruct bufferevent* \fIbufev\fP\fR);
322 +\fBstruct evbuffer* \fBevbuffer_new (\fBvoid\fP\fR);
324 +\fBvoid \fBevbuffer_free\fR\fR(\fBstruct evbuffer* \fIbuf\fP\fR);
326 +\fBint \fBevbuffer_add\fR\fR(\fBstruct evbuffer* \fIbuf\fP\fR, \fBconst void* \fIdata\fP\fR, \fBsize_t \fIsize\fP\fR);
328 +\fBint \fBevbuffer_add_buffer\fR\fR(\fBstruct evbuffer* \fIdst\fP\fR, \fBstruct evbuffer* \fIsrc\fP\fR);
330 +\fBint \fBevbuffer_add_printf\fR\fR(\fBstruct evbuffer* \fIbuf\fP\fR, \fBconst char* \fIfmt\fP\fR, \fB...\fP\fR);
332 +\fBint \fBevbuffer_add_vprintf\fR\fR(\fBstruct evbuffer* \fIbuf\fP\fR, \fBconst char* \fIfmt\fP\fR, \fBva_list \fIap\fP\fR);
334 +\fBvoid \fBevbuffer_drain\fR\fR(\fBstruct evbuffer* \fIbuf\fP\fR, \fBsize_t \fIsize\fP\fR);
336 +\fBint \fBevbuffer_write\fR\fR(\fBstruct evbuffer* \fIbuf\fP\fR, \fBint \fIfd\fP\fR);
338 +\fBint \fBevbuffer_read\fR\fR(\fBstruct evbuffer* \fIbuf\fP\fR, \fBint \fIfd\fP\fR, \fBint \fIsize\fP\fR);
340 +\fBu_char* \fBevbuffer_find\fR\fR(\fBstruct evbuffer* \fIbuf\fP\fR, \fBconst u_char* \fIdata\fP\fR, \fBsize_t \fIsize\fP\fR);
342 +\fBchar* \fBevbuffer_readline\fR\fR(\fBstruct evbuffer* \fIbuf\fP\fR);
344 +\fBstruct evhttp * \fBevhttp_new\fR\fR(\fBstruct event_base* \fIbase\fP\fR);
346 +\fBint \fBevhttp_bind_socket\fR\fR(\fBstruct evhttp* \fIhttp\fP\fR, \fBconst char* \fIaddress\fP\fR, \fBu_short \fIport\fP\fR);
348 +\fBvoid \fBevhttp_free\fR\fR(\fBstruct evhttp* \fIhttp\fP\fR);
350 +\fBint \fI(*event_sigcb)\fP\fR\fI(\fBvoid\fP\fR);
352 +\fBvolatile sig_atomic_t \fR\fRevent_gotsig\fP\fR;
353 +.fi
355 +.SH DESCRIPTION
357 -.Nm event
358 +\fIevent\fP\fR
359 API provides a mechanism to execute a function when a specific event
360 on a file descriptor occurs or after a given time has passed.
361 -.Pp
362 +.PP
364 -.Nm event
365 +\fIevent\fP\fR
366 API needs to be initialized with
367 -.Fn event_init
368 +\fBevent_init\fR
369 before it can be used.
370 -.Pp
371 +.PP
372 In order to process events, an application needs to call
373 -.Fn event_dispatch .
374 +\fBevent_dispatch\fP\fR.
375 This function only returns on error, and should replace the event core
376 of the application program.
377 -.Pp
378 +.PP
379 The function
380 -.Fn event_set
381 +\fBevent_set\fP\fR
382 prepares the event structure
383 -.Fa ev
384 +\fIev\fP\fR
385 to be used in future calls to
386 -.Fn event_add
387 +\fBevent_add\fP\fR
389 -.Fn event_del .
390 +\fBevent_del\fP\fR .
391 The event will be prepared to call the function specified by the
392 -.Fa fn
393 +\fIfn\fP\fR
394 argument with an
395 -.Fa int
396 +\fIint\fP\fR
397 argument indicating the file descriptor, a
398 -.Fa short
399 +\fIshort\fP\fR
400 argument indicating the type of event, and a
401 -.Fa void *
402 +\fIvoid*\fP\fR
403 argument given in the
404 -.Fa arg
405 +\fIarg\fP\fR
406 argument.
408 -.Fa fd
409 +The \fIfd\fP\fR
410 indicates the file descriptor that should be monitored for events.
411 -The events can be either
412 -.Va EV_READ ,
413 -.Va EV_WRITE ,
414 -or both,
415 +The events can be either EV_READ, EV_WRITE , or both,
416 indicating that an application can read or write from the file descriptor
417 respectively without blocking.
418 -.Pp
419 +.PP
420 The function
421 -.Fa fn
422 +\fIfn\fP\fR
423 will be called with the file descriptor that triggered the event and
424 the type of event which will be either
425 -.Va EV_TIMEOUT ,
426 -.Va EV_SIGNAL ,
427 -.Va EV_READ ,
428 +EV_TIMEOUT,
429 +EV_SIGNAL,
430 +EV_READ,
432 -.Va EV_WRITE .
433 +EV_WRITE.
434 Additionally, an event which has registered interest in more than one of the
435 preceeding events, via bitwise-OR to
436 -.Fn event_set ,
437 +\fBevent_set\fP\fR,
438 can provide its callback function with a bitwise-OR of more than one triggered
439 event.
440 The additional flag
441 -.Va EV_PERSIST
442 +EV_PERSIST
443 makes an
444 -.Fn event_add
445 +\fBevent_add\fP\fR
446 persistent until
447 -.Fn event_del
448 +\fBevent_del\fP\fR
449 has been called.
450 -.Pp
451 +.PP
452 Once initialized, the
453 -.Fa ev
454 +\fIev\fP\fR
455 structure can be used repeatedly with
456 -.Fn event_add
457 +\fBevent_add\fP\fR
459 -.Fn event_del
460 +\fBevent_del\fP\fR
461 and does not need to be reinitialized unless the function called and/or
462 the argument to it are to be changed.
463 However, when an
464 -.Fa ev
465 +\fIev\fP\fR
466 structure has been added to libevent using
467 -.Fn event_add
468 +\fBevent_add\fP\fR
469 the structure must persist until the event occurs (assuming
470 -.Fa EV_PERSIST
471 +EV_PERSIST
472 is not set) or is removed
473 using
474 -.Fn event_del .
475 +\fBevent_del\fP\fR.
476 You may not reuse the same
477 -.Fa ev
478 +\fIev\fP\fR
479 structure for multiple monitored descriptors; each descriptor
480 needs its own
481 -.Fa ev .
482 -.Pp
483 +\fIev\fP\fR.
484 +.PP
485 The function
486 -.Fn event_add
487 +\fBevent_add\fP\fR
488 schedules the execution of the
489 -.Fa ev
490 +\fIev\fP\fR
491 event when the event specified in
492 -.Fn event_set
493 +\fBevent_set\fP\fR
494 occurs or in at least the time specified in the
495 -.Fa tv .
496 +\fItv\fP\fR
498 -.Fa tv
499 +\fItv\fP\fR
501 -.Dv NULL ,
502 +\fINULL\fP\fR,
503 no timeout occurs and the function will only be called
504 if a matching event occurs on the file descriptor.
505 The event in the
506 -.Fa ev
507 +\fIev\fP\fR
508 argument must be already initialized by
509 -.Fn event_set
510 +\fBevent_set\fP\fR
511 and may not be used in calls to
512 -.Fn event_set
513 +\fBevent_set\fP\fR
514 until it has timed out or been removed with
515 -.Fn event_del .
516 +\fBevent_del\fP\fR.
517 If the event in the
518 -.Fa ev
519 +\fIev\fP\fR
520 argument already has a scheduled timeout, the old timeout will be
521 replaced by the new one.
522 -.Pp
523 +.PP
524 The function
525 -.Fn event_del
526 +\fBevent_del\fP\fR
527 will cancel the event in the argument
528 -.Fa ev .
529 +\fIev\fP\fR.
530 If the event has already executed or has never been added
531 the call will have no effect.
532 -.Pp
533 +.PP
534 The functions
535 -.Fn evtimer_set ,
536 -.Fn evtimer_add ,
537 -.Fn evtimer_del ,
538 -.Fn evtimer_initialized ,
539 +\fBevtimer_set\fP\fR,
540 +\fBevtimer_add\fP\fR,
541 +\fBevtimer_del\fP\fR,
542 +\fBevtimer_initialized\fP\fR,
544 -.Fn evtimer_pending
545 +\fBevtimer_pending\fP\fR
546 are abbreviations for common situations where only a timeout is required.
547 The file descriptor passed will be \-1, and the event type will be
548 -.Va EV_TIMEOUT .
549 -.Pp
550 +EV_TIMEOUT.
551 +.PP
552 The functions
553 -.Fn signal_set ,
554 -.Fn signal_add ,
555 -.Fn signal_del ,
556 -.Fn signal_initialized ,
557 +\fBsignal_set\fP\fR,
558 +\fBsignal_add\fP\fR,
559 +\fBsignal_del\fP\fR,
560 +\fBsignal_initialized\fP\fR,
562 -.Fn signal_pending
563 +\fBsignal_pending\fP\fR
564 are abbreviations.
565 The event type will be a persistent
566 -.Va EV_SIGNAL .
567 +EV_SIGNAL .
568 That means
569 -.Fn signal_set
570 +\fBsignal_set\fP\fR
571 adds
572 -.Va EV_PERSIST .
573 -.Pp
574 +EV_PERSIST.
575 +.PP
576 In order to avoid races in signal handlers, the
577 -.Nm event
578 +\fIevent\fP\fR
579 API provides two variables:
580 -.Va event_sigcb
581 +\fBevent_sigcb\fP\fR
583 -.Va event_gotsig .
584 +\fBevent_gotsig\fP\fR.
585 A signal handler
586 sets
587 -.Va event_gotsig
588 +\fBevent_gotsig\fP\fR
589 to indicate that a signal has been received.
590 The application sets
591 -.Va event_sigcb
592 +\fBevent_sigcb\fP\fR
593 to a callback function.
594 After the signal handler sets
595 -.Va event_gotsig ,
596 -.Nm event_dispatch
597 +\fBevent_gotsig\fP\fR,
598 +\fBevent_dispatch()\fP\fR
599 will execute the callback function to process received signals.
600 The callback returns 1 when no events are registered any more.
601 It can return \-1 to indicate an error to the
602 -.Nm event
603 +\fIevent\fP\fR
604 library, causing
605 -.Fn event_dispatch
606 +\fBevent_dispatch\fP\fR
607 to terminate with
608 -.Va errno
609 +\fBerrno\fP\fR
610 set to
611 -.Er EINTR .
612 -.Pp
613 +\fBEINTR\fP\fR.
614 +.PP
615 The function
616 -.Fn event_once
617 +\fBevent_once\fP\fR
618 is similar to
619 -.Fn event_set .
620 +\fBevent_set\fP\fR.
621 However, it schedules a callback to be called exactly once and does not
622 require the caller to prepare an
623 -.Fa event
624 +\fIevent\fP\fR
625 structure.
626 This function supports
627 -.Fa EV_TIMEOUT ,
628 -.Fa EV_READ ,
629 +EV_TIMEOUT,
630 +EV_READ,
632 -.Fa EV_WRITE .
633 -.Pp
634 +EV_WRITE.
635 +.PP
637 .Fn event_pending
638 +\fBevent_pending\fP\fR
639 function can be used to check if the event specified by
640 -.Fa event
641 +\fIevent\fP\fR
642 is pending to run.
644 -.Va EV_TIMEOUT
645 +EV_TIMEOUT
646 was specified and
647 -.Fa tv
648 +\fItv\fP\fR
649 is not
650 -.Dv NULL ,
651 +\fINULL\fP\fR,
652 the expiration time of the event will be returned in
653 -.Fa tv .
654 -.Pp
655 +\fItv\fP\fR.
656 +.PP
658 -.Fn event_initialized
659 +\fBevent_initialized\fP\fR
660 macro can be used to check if an event has been initialized.
661 -.Pp
662 +.PP
664 -.Nm event_loop
665 +\fBevent_loop\fP\fR
666 function provides an interface for single pass execution of pending
667 events.
668 The flags
669 -.Va EVLOOP_ONCE
670 +EVLOOP_ONCE
672 -.Va EVLOOP_NONBLOCK
673 +EVLOOP_NONBLOCK
674 are recognized.
676 -.Nm event_loopexit
677 +\fBevent_loopexit\fP\fR
678 function exits from the event loop. The next
679 -.Fn event_loop
680 +\fBevent_loop\fP\fR
681 iteration after the
682 given timer expires will complete normally (handling all queued events) then
683 exit without blocking for events again. Subsequent invocations of
684 -.Fn event_loop
685 +\fBevent_loop\fP\fR
686 will proceed normally.
688 -.Nm event_loopbreak
689 +\fBevent_loopbreak\fP\fR
690 function exits from the event loop immediately.
691 -.Fn event_loop
692 +\fBevent_loop\fP\fR
693 will abort after the next event is completed;
694 -.Fn event_loopbreak
695 +\fBevent_loopbreak\fP\fR
696 is typically invoked from this event's callback. This behavior is analogous
697 to the "break;" statement. Subsequent invocations of
698 -.Fn event_loop
699 +\fBevent_loop\fP\fR
700 will proceed normally.
701 -.Pp
702 +.PP
703 It is the responsibility of the caller to provide these functions with
704 pre-allocated event structures.
705 -.Pp
706 -.Sh EVENT PRIORITIES
707 +.PP
708 +.SH EVENT PRIORITIES
709 By default
710 -.Nm libevent
711 +\fIlibevent\fP\fR
712 schedules all active events with the same priority.
713 However, sometimes it is desirable to process some events with a higher
714 priority than others.
715 For that reason,
716 -.Nm libevent
717 +\fIlibevent\fP\fR
718 supports strict priority queues.
719 Active events with a lower priority are always processed before events
720 with a higher priority.
721 -.Pp
722 +.PP
723 The number of different priorities can be set initially with the
724 -.Fn event_priority_init
725 +\fBevent_priority_init\fP\fR
726 function.
727 This function should be called before the first call to
728 -.Fn event_dispatch .
729 +\fBevent_dispatch\fP\fR.
731 -.Fn event_priority_set
732 +\fBevent_priority_set\fP\fR
733 function can be used to assign a priority to an event.
734 By default,
735 -.Nm libevent
736 +\fIlibevent\fP\fR
737 assigns the middle priority to all events unless their priority
738 is explicitly set.
739 -.Sh THREAD SAFE EVENTS
740 -.Nm Libevent
741 +.SH THREAD SAFE EVENTS
742 +\fIlibevent\fP\fR
743 has experimental support for thread-safe events.
744 When initializing the library via
745 .Fn event_init ,
746 an event base is returned.
747 This event base can be used in conjunction with calls to
748 -.Fn event_base_set ,
749 -.Fn event_base_dispatch ,
750 -.Fn event_base_loop ,
751 -.Fn event_base_loopexit ,
752 -.Fn bufferevent_base_set
753 +\fBevent_base_set()\fP\fR,
754 +\fBevent_base_dispatch()\fP\fR,
755 +\fBevent_base_loop()\fP\fR,
756 +\fBevent_base_loopexit()\fP\fR,
757 +\fBbufferevent_base_set()\fP\fR
759 -.Fn event_base_free .
760 -.Fn event_base_set
761 +\fBevent_base_free()\fP\fR.
762 +\fBevent_base_set()\fP\fR
763 should be called after preparing an event with
764 -.Fn event_set ,
765 +\fBevent_set()\fP\fR,
767 -.Fn event_set
768 +\fBevent_set()\fP\fR,
769 assigns the provided event to the most recently created event base.
770 -.Fn bufferevent_base_set
771 +\fBbufferevent_base_set()\fP\fR
772 should be called after preparing a bufferevent with
773 -.Fn bufferevent_new .
774 -.Fn event_base_free
775 +\fBbufferevent_new()\fP\fR.
776 +\fBevent_base_free()\fP\fR
777 should be used to free memory associated with the event base
778 when it is no longer needed.
779 -.Sh BUFFERED EVENTS
780 -.Nm libevent
781 +.SH BUFFERED EVENTS
782 +\fIlibevent\fP\fR
783 provides an abstraction on top of the regular event callbacks.
784 This abstraction is called a
785 -.Va "buffered event" .
786 +\fB"buffered event"\fP\fR.
787 A buffered event provides input and output buffers that get filled
788 and drained automatically.
789 The user of a buffered event no longer deals directly with the IO,
790 but instead is reading from input and writing to output buffers.
791 -.Pp
792 +.PP
793 A new bufferevent is created by
794 -.Fn bufferevent_new .
795 +\fBbufferevent_new()\fP\fR.
796 The parameter
797 -.Fa fd
798 +\fIfd\fP\fR
799 specifies the file descriptor from which data is read and written to.
800 This file descriptor is not allowed to be a
801 -.Xr pipe 2 .
802 +\fBpipe(2)\fR.
803 The next three parameters are callbacks.
804 The read and write callback have the following form:
805 -.Ft void
806 -.Fn "(*cb)" "struct bufferevent *bufev" "void *arg" .
807 +\fBvoid \fB(*cb)\fR\fR(\fBstruct bufferevent* \fIbufev\fP\fR, \fBvoid* \fIarg\fP\fR).
808 The error callback has the following form:
809 -.Ft void
810 -.Fn "(*cb)" "struct bufferevent *bufev" "short what" "void *arg" .
811 +\fBvoid \fB(*cb)\fR\fR(\fBstruct bufferevent* \fIbufev\fP\fR, \fBshort \fIwhat\fP\fR, \fBvoid* \fIarg\fP\fR).
812 The argument is specified by the fourth parameter
813 -.Fa "cbarg" .
814 +\fBcbarg\fP\fR.
816 -.Fa bufferevent struct
817 -pointer is returned on success, NULL on error.
818 -Both the read and the write callback may be NULL.
819 +\fBstruct bufferevent\fP\fR
820 +pointer is returned on success, \fINULL\fP\fR on error.
821 +Both the read and the write callback may be \fINULL\fP\fR.
822 The error callback has to be always provided.
823 -.Pp
824 +.PP
825 Once initialized, the bufferevent structure can be used repeatedly with
826 bufferevent_enable() and bufferevent_disable().
827 The flags parameter can be a combination of
828 -.Va EV_READ
829 +EV_READ
831 -.Va EV_WRITE .
832 +EV_WRITE .
833 When read enabled the bufferevent will try to read from the file
834 descriptor and call the read callback.
835 The write callback is executed
836 whenever the output buffer is drained below the write low watermark,
837 which is
838 -.Va 0
839 +\fI0\fP\fR
840 by default.
841 -.Pp
842 +.PP
844 -.Fn bufferevent_write
845 +\fBbufferevent_write()\fP\fR
846 function can be used to write data to the file descriptor.
847 The data is appended to the output buffer and written to the descriptor
848 automatically as it becomes available for writing.
849 -.Fn bufferevent_write
850 +\fBbufferevent_write()\fP\fR
851 returns 0 on success or \-1 on failure.
853 -.Fn bufferevent_read
854 +\fBbufferevent_read()\fP\fR
855 function is used to read data from the input buffer,
856 returning the amount of data read.
857 -.Pp
858 +.PP
859 If multiple bases are in use, bufferevent_base_set() must be called before
860 enabling the bufferevent for the first time.
861 .Sh NON-BLOCKING HTTP SUPPORT
862 @@ -549,74 +550,74 @@
864 If multiple bases are in use, bufferevent_base_set() must be called before
865 enabling the bufferevent for the first time.
866 -.Sh NON-BLOCKING HTTP SUPPORT
867 -.Nm libevent
868 +.SH NON-BLOCKING HTTP SUPPORT
869 +\fIlibevent\fP\fR
870 provides a very thin HTTP layer that can be used both to host an HTTP
871 server and also to make HTTP requests.
872 An HTTP server can be created by calling
873 -.Fn evhttp_new .
874 +\fBevhttp_new\fP\fR.
875 It can be bound to any port and address with the
876 -.Fn evhttp_bind_socket
877 +\fBevhttp_bind_socket\fP\fR
878 function.
879 When the HTTP server is no longer used, it can be freed via
880 -.Fn evhttp_free .
881 -.Pp
882 +\fBevhttp_free\fP\fR.
883 +.PP
884 To be notified of HTTP requests, a user needs to register callbacks with the
885 HTTP server.
886 This can be done by calling
887 -.Fn evhttp_set_cb .
888 +\fBevhttp_set_cb\fP\fR.
889 The second argument is the URI for which a callback is being registered.
890 The corresponding callback will receive an
891 -.Va struct evhttp_request
892 +\fIstruct evhttp_request\fP\fR
893 object that contains all information about the request.
894 -.Pp
895 +.PP
896 This section does not document all the possible function calls; please
897 check
898 -.Va event.h
899 +\fBevent.h\fP\fR
900 for the public interfaces.
901 -.Sh ADDITIONAL NOTES
902 +.SH ADDITIONAL NOTES
903 It is possible to disable support for
904 -.Va epoll , kqueue , devpoll , poll
905 +\fBepoll , kqueue , devpoll , poll\fP\fR
907 -.Va select
908 +\fBselect\fP\fR
909 by setting the environment variable
910 -.Va EVENT_NOEPOLL , EVENT_NOKQUEUE , EVENT_NODEVPOLL , EVENT_NOPOLL
911 +EVENT_NOEPOLL, EVENT_NOKQUEUE, EVENT_NODEVPOLL, EVENT_NOPOLL
913 -.Va EVENT_NOSELECT ,
914 +EVENT_NOSELECT,
915 respectively.
916 By setting the environment variable
917 -.Va EVENT_SHOW_METHOD ,
918 -.Nm libevent
919 +EVENT_SHOW_METHOD,
920 +\fIlibevent\fP\fR
921 displays the kernel notification method that it uses.
922 -.Sh RETURN VALUES
923 +.SH RETURN VALUES
924 Upon successful completion
925 -.Fn event_add
926 +\fBevent_add\fP\fR
928 -.Fn event_del
929 +\fBevent_del\fP\fR
930 return 0.
931 Otherwise, \-1 is returned and the global variable errno is
932 set to indicate the error.
933 -.Sh SEE ALSO
934 -.Xr kqueue 2 ,
935 -.Xr poll 2 ,
936 -.Xr select 2 ,
937 -.Xr evdns 3 ,
938 -.Xr timeout 9
939 -.Sh HISTORY
940 +.SH SEE ALSO
941 +\fBpoll(2)\fR,
942 +\fBselect(3C)\fR,
943 +\fBport_create(3C)\fR,
944 +\fBevdns(3)\fR,
945 +\fBtimeout(9f)\fR.
946 +.SH HISTORY
948 -.Nm event
949 +\fIevent\fP\fR
950 API manpage is based on the
951 -.Xr timeout 9
952 +\fBtimeout(9)\fR
953 manpage by Artur Grabowski.
954 The port of
955 -.Nm libevent
956 +\fBlibevent\fP\fR
957 to Windows is due to Michael A. Davis.
958 Support for real-time signals is due to Taral.
959 -.Sh AUTHORS
960 +.SH AUTHORS
962 -.Nm event
963 +\fIevent\fP\fR
964 library was written by Niels Provos.
965 -.Sh BUGS
966 +.SH BUGS
967 This documentation is neither complete nor authoritative.
968 If you are in doubt about the usage of this API then
969 check the source code to find out how it works, write