0
|
1 |
/* |
|
2 |
* Copyright (c) 2009 Eric Faurot <eric@openbsd.org> |
|
3 |
* |
|
4 |
* Permission to use, copy, modify, and distribute this software for any |
|
5 |
* purpose with or without fee is hereby granted, provided that the above |
|
6 |
* copyright notice and this permission notice appear in all copies. |
|
7 |
* |
|
8 |
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
|
9 |
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
|
10 |
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
|
11 |
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
|
12 |
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
|
13 |
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
|
14 |
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
|
15 |
*/ |
|
16 |
|
|
17 |
#ifndef __IMSGEV_H__ |
|
18 |
#define __IMSGEV_H__ |
|
19 |
|
|
20 |
#include <event.h> |
|
21 |
#include <imsg.h> |
|
22 |
|
|
23 |
#define IMSG_LEN(m) ((m)->hdr.len - IMSG_HEADER_SIZE) |
|
24 |
|
|
25 |
struct imsgev { |
|
26 |
struct imsgbuf ibuf; |
|
27 |
void (*handler)(int, short, void *); |
|
28 |
struct event ev; |
|
29 |
void *data; |
|
30 |
short events; |
|
31 |
int terminate; |
|
32 |
void (*callback)(struct imsgev *, int, struct imsg *); |
|
33 |
void (*needfd)(struct imsgev *); |
|
34 |
}; |
|
35 |
|
|
36 |
#define IMSGEV_IMSG 0 |
|
37 |
#define IMSGEV_DONE 1 |
|
38 |
#define IMSGEV_EREAD 2 |
|
39 |
#define IMSGEV_EWRITE 3 |
|
40 |
#define IMSGEV_EIMSG 4 |
|
41 |
|
|
42 |
void imsgev_init(struct imsgev *, int, void *, void (*)(struct imsgev *, |
|
43 |
int, struct imsg *), void (*)(struct imsgev *)); |
|
44 |
int imsgev_compose(struct imsgev *, u_int16_t, u_int32_t, u_int32_t, int, |
|
45 |
void *, u_int16_t); |
|
46 |
void imsgev_close(struct imsgev *); |
|
47 |
void imsgev_clear(struct imsgev *); |
|
48 |
|
|
49 |
#endif /* __IMSGEV_H__ */ |