2 /* $OpenBSD: imsg.h,v 1.4 2010/05/26 13:56:07 nicm Exp $ */
5 * Copyright (c) 2006, 2007 Pierre-Yves Ritschard <pyr@openbsd.org>
6 * Copyright (c) 2006, 2007, 2008 Reyk Floeter <reyk@openbsd.org>
7 * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
9 * Permission to use, copy, modify, and distribute this software for any
10 * purpose with or without fee is hereby granted, provided that the above
11 * copyright notice and this permission notice appear in all copies.
13 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
24 #define IBUF_READ_SIZE 65535
25 #define IMSG_HEADER_SIZE sizeof(struct imsg_hdr)
26 #define MAX_IMSGSIZE 16384
29 TAILQ_ENTRY(ibuf
) entry
;
39 TAILQ_HEAD(, ibuf
) bufs
;
45 u_char buf
[IBUF_READ_SIZE
];
51 TAILQ_ENTRY(imsg_fd
) entry
;
56 TAILQ_HEAD(, imsg_fd
) fds
;
81 struct ibuf
*ibuf_open(size_t);
82 struct ibuf
*ibuf_dynamic(size_t, size_t);
83 int ibuf_add(struct ibuf
*, const void *, size_t);
84 void *ibuf_reserve(struct ibuf
*, size_t);
85 void *ibuf_seek(struct ibuf
*, size_t, size_t);
86 size_t ibuf_size(struct ibuf
*);
87 size_t ibuf_left(struct ibuf
*);
88 void ibuf_close(struct msgbuf
*, struct ibuf
*);
89 int ibuf_write(struct msgbuf
*);
90 void ibuf_free(struct ibuf
*);
91 void msgbuf_init(struct msgbuf
*);
92 void msgbuf_clear(struct msgbuf
*);
93 int msgbuf_write(struct msgbuf
*);
94 void msgbuf_drain(struct msgbuf
*, size_t);
97 void imsg_init(struct imsgbuf
*, int);
98 ssize_t
imsg_read(struct imsgbuf
*);
99 ssize_t
imsg_get(struct imsgbuf
*, struct imsg
*);
100 int imsg_compose(struct imsgbuf
*, u_int32_t
, u_int32_t
, pid_t
,
101 int, void *, u_int16_t
);
102 int imsg_composev(struct imsgbuf
*, u_int32_t
, u_int32_t
, pid_t
,
103 int, const struct iovec
*, int);
104 struct ibuf
*imsg_create(struct imsgbuf
*, u_int32_t
, u_int32_t
, pid_t
,
106 int imsg_add(struct ibuf
*, void *, u_int16_t
);
107 void imsg_close(struct imsgbuf
*, struct ibuf
*);
108 void imsg_free(struct imsg
*);
109 int imsg_flush(struct imsgbuf
*);
110 void imsg_clear(struct imsgbuf
*);