Blame
Date:
Thu Nov 19 09:25:28 2020 UTC
Message:
update README before 1.5.0 release
001
2017-10-04
pjp
/* $OpenBSD: imsg.h,v 1.3 2013/12/26 17:32:33 eric Exp $ */
002
2017-10-04
pjp
/* $Id: imsg.h,v 1.1 2017/10/04 18:51:36 pjp Exp $ */
003
2017-10-04
pjp
004
2017-10-04
pjp
/*
005
2017-10-04
pjp
* Copyright (c) 2006, 2007 Pierre-Yves Ritschard <pyr@openbsd.org>
006
2017-10-04
pjp
* Copyright (c) 2006, 2007, 2008 Reyk Floeter <reyk@openbsd.org>
007
2017-10-04
pjp
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
008
2017-10-04
pjp
*
009
2017-10-04
pjp
* Permission to use, copy, modify, and distribute this software for any
010
2017-10-04
pjp
* purpose with or without fee is hereby granted, provided that the above
011
2017-10-04
pjp
* copyright notice and this permission notice appear in all copies.
012
2017-10-04
pjp
*
013
2017-10-04
pjp
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
014
2017-10-04
pjp
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
015
2017-10-04
pjp
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
016
2017-10-04
pjp
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
017
2017-10-04
pjp
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
018
2017-10-04
pjp
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
019
2017-10-04
pjp
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
020
2017-10-04
pjp
*/
021
2017-10-04
pjp
022
2017-10-04
pjp
#ifndef _IMSG_H_
023
2017-10-04
pjp
#define _IMSG_H_
024
2017-10-04
pjp
025
2017-10-04
pjp
#ifndef IOV_MAX
026
2017-10-04
pjp
# if defined(_XOPEN_IOV_MAX)
027
2017-10-04
pjp
# define IOV_MAX _XOPEN_IOV_MAX
028
2017-10-04
pjp
# elif defined(DEF_IOV_MAX)
029
2017-10-04
pjp
# define IOV_MAX DEF_IOV_MAX
030
2017-10-04
pjp
# else
031
2017-10-04
pjp
# define IOV_MAX 16
032
2017-10-04
pjp
# endif
033
2017-10-04
pjp
#endif
034
2017-10-04
pjp
035
2017-10-04
pjp
036
2017-10-04
pjp
#define IBUF_READ_SIZE 65535
037
2017-10-04
pjp
#define IMSG_HEADER_SIZE sizeof(struct imsg_hdr)
038
2017-10-04
pjp
#define MAX_IMSGSIZE 16384
039
2017-10-04
pjp
040
2017-10-04
pjp
struct ibuf {
041
2017-10-04
pjp
TAILQ_ENTRY(ibuf) entry;
042
2017-10-04
pjp
u_char *buf;
043
2017-10-04
pjp
size_t size;
044
2017-10-04
pjp
size_t max;
045
2017-10-04
pjp
size_t wpos;
046
2017-10-04
pjp
size_t rpos;
047
2017-10-04
pjp
int fd;
048
2017-10-04
pjp
};
049
2017-10-04
pjp
050
2017-10-04
pjp
struct msgbuf {
051
2017-10-04
pjp
TAILQ_HEAD(, ibuf) bufs;
052
2017-10-04
pjp
u_int32_t queued;
053
2017-10-04
pjp
int fd;
054
2017-10-04
pjp
};
055
2017-10-04
pjp
056
2017-10-04
pjp
struct ibuf_read {
057
2017-10-04
pjp
u_char buf[IBUF_READ_SIZE];
058
2017-10-04
pjp
u_char *rptr;
059
2017-10-04
pjp
size_t wpos;
060
2017-10-04
pjp
};
061
2017-10-04
pjp
062
2017-10-04
pjp
struct imsg_fd {
063
2017-10-04
pjp
TAILQ_ENTRY(imsg_fd) entry;
064
2017-10-04
pjp
int fd;
065
2017-10-04
pjp
};
066
2017-10-04
pjp
067
2017-10-04
pjp
struct imsgbuf {
068
2017-10-04
pjp
TAILQ_HEAD(, imsg_fd) fds;
069
2017-10-04
pjp
struct ibuf_read r;
070
2017-10-04
pjp
struct msgbuf w;
071
2017-10-04
pjp
int fd;
072
2017-10-04
pjp
pid_t pid;
073
2017-10-04
pjp
};
074
2017-10-04
pjp
075
2017-10-04
pjp
#define IMSGF_HASFD 1
076
2017-10-04
pjp
077
2017-10-04
pjp
struct imsg_hdr {
078
2017-10-04
pjp
u_int32_t type;
079
2017-10-04
pjp
u_int16_t len;
080
2017-10-04
pjp
u_int16_t flags;
081
2017-10-04
pjp
u_int32_t peerid;
082
2017-10-04
pjp
u_int32_t pid;
083
2017-10-04
pjp
};
084
2017-10-04
pjp
085
2017-10-04
pjp
struct imsg {
086
2017-10-04
pjp
struct imsg_hdr hdr;
087
2017-10-04
pjp
int fd;
088
2017-10-04
pjp
void *data;
089
2017-10-04
pjp
};
090
2017-10-04
pjp
091
2017-10-04
pjp
092
2017-10-04
pjp
/* buffer.c */
093
2017-10-04
pjp
struct ibuf *ibuf_open(size_t);
094
2017-10-04
pjp
struct ibuf *ibuf_dynamic(size_t, size_t);
095
2017-10-04
pjp
int ibuf_add(struct ibuf *, const void *, size_t);
096
2017-10-04
pjp
void *ibuf_reserve(struct ibuf *, size_t);
097
2017-10-04
pjp
void *ibuf_seek(struct ibuf *, size_t, size_t);
098
2017-10-04
pjp
size_t ibuf_size(struct ibuf *);
099
2017-10-04
pjp
size_t ibuf_left(struct ibuf *);
100
2017-10-04
pjp
void ibuf_close(struct msgbuf *, struct ibuf *);
101
2017-10-04
pjp
int ibuf_write(struct msgbuf *);
102
2017-10-04
pjp
void ibuf_free(struct ibuf *);
103
2017-10-04
pjp
void msgbuf_init(struct msgbuf *);
104
2017-10-04
pjp
void msgbuf_clear(struct msgbuf *);
105
2017-10-04
pjp
int msgbuf_write(struct msgbuf *);
106
2017-10-04
pjp
void msgbuf_drain(struct msgbuf *, size_t);
107
2017-10-04
pjp
108
2017-10-04
pjp
/* imsg.c */
109
2017-10-04
pjp
int available_fds(unsigned int);
110
2017-10-04
pjp
void imsg_init(struct imsgbuf *, int);
111
2017-10-04
pjp
ssize_t imsg_read(struct imsgbuf *);
112
2017-10-04
pjp
ssize_t imsg_get(struct imsgbuf *, struct imsg *);
113
2017-10-04
pjp
int imsg_compose(struct imsgbuf *, u_int32_t, u_int32_t, pid_t,
114
2017-10-04
pjp
int, const void *, u_int16_t);
115
2017-10-04
pjp
int imsg_composev(struct imsgbuf *, u_int32_t, u_int32_t, pid_t,
116
2017-10-04
pjp
int, const struct iovec *, int);
117
2017-10-04
pjp
struct ibuf *imsg_create(struct imsgbuf *, u_int32_t, u_int32_t, pid_t,
118
2017-10-04
pjp
u_int16_t);
119
2017-10-04
pjp
int imsg_add(struct ibuf *, const void *, u_int16_t);
120
2017-10-04
pjp
void imsg_close(struct imsgbuf *, struct ibuf *);
121
2017-10-04
pjp
void imsg_free(struct imsg *);
122
2017-10-04
pjp
int imsg_flush(struct imsgbuf *);
123
2017-10-04
pjp
void imsg_clear(struct imsgbuf *);
124
2017-10-04
pjp
125
2017-10-04
pjp
#endif
repomaster@centroid.eu