4 * Copyright (c) 2006, 2007 Pierre-Yves Ritschard <pyr@openbsd.org>
5 * Copyright (c) 2006, 2007, 2008 Reyk Floeter <reyk@openbsd.org>
6 * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
8 * Permission to use, copy, modify, and distribute this software for any
9 * purpose with or without fee is hereby granted, provided that the above
10 * copyright notice and this permission notice appear in all copies.
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21 #define READ_BUF_SIZE 65535
22 #define IMSG_HEADER_SIZE sizeof(struct imsg_hdr)
23 #define MAX_IMSGSIZE 16384
26 TAILQ_ENTRY(buf
) entry
;
36 TAILQ_HEAD(, buf
) bufs
;
42 u_char buf
[READ_BUF_SIZE
];
48 TAILQ_ENTRY(imsg_fd
) entry
;
53 TAILQ_HEAD(, imsg_fd
) fds
;
78 struct buf
*buf_open(size_t);
79 struct buf
*buf_dynamic(size_t, size_t);
80 int buf_add(struct buf
*, const void *, size_t);
81 void *buf_reserve(struct buf
*, size_t);
82 void *buf_seek(struct buf
*, size_t, size_t);
83 size_t buf_size(struct buf
*);
84 size_t buf_left(struct buf
*);
85 void buf_close(struct msgbuf
*, struct buf
*);
86 int buf_write(struct msgbuf
*);
87 void buf_free(struct buf
*);
88 void msgbuf_init(struct msgbuf
*);
89 void msgbuf_clear(struct msgbuf
*);
90 int msgbuf_write(struct msgbuf
*);
91 void msgbuf_drain(struct msgbuf
*, size_t);
94 void imsg_init(struct imsgbuf
*, int);
95 ssize_t
imsg_read(struct imsgbuf
*);
96 ssize_t
imsg_get(struct imsgbuf
*, struct imsg
*);
97 int imsg_compose(struct imsgbuf
*, u_int32_t
, u_int32_t
, pid_t
,
98 int, void *, u_int16_t
);
99 int imsg_composev(struct imsgbuf
*, u_int32_t
, u_int32_t
, pid_t
,
100 int, const struct iovec
*, int);
101 struct buf
*imsg_create(struct imsgbuf
*, u_int32_t
, u_int32_t
, pid_t
,
103 int imsg_add(struct buf
*, void *, u_int16_t
);
104 void imsg_close(struct imsgbuf
*, struct buf
*);
105 void imsg_free(struct imsg
*);
106 int imsg_flush(struct imsgbuf
*);
107 void imsg_clear(struct imsgbuf
*);