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