Blame


1 dd038bc6 2021-09-21 thomas.ad #ifndef _GOT_COMPAT_H
2 dd038bc6 2021-09-21 thomas.ad #define _GOT_COMPAT_H
3 dd038bc6 2021-09-21 thomas.ad
4 dd038bc6 2021-09-21 thomas.ad #include <sys/types.h>
5 dd038bc6 2021-09-21 thomas.ad #include <sys/ioctl.h>
6 dd038bc6 2021-09-21 thomas.ad #include <sys/uio.h>
7 92a9e85d 2021-09-24 thomas #if defined(__FreeBSD__)
8 92a9e85d 2021-09-24 thomas #include <sys/endian.h>
9 92a9e85d 2021-09-24 thomas #else
10 92a9e85d 2021-09-24 thomas #include <endian.h>
11 92a9e85d 2021-09-24 thomas #endif
12 dd038bc6 2021-09-21 thomas.ad
13 dd038bc6 2021-09-21 thomas.ad #include <fnmatch.h>
14 dd038bc6 2021-09-21 thomas.ad #include <limits.h>
15 dd038bc6 2021-09-21 thomas.ad #include <stdio.h>
16 dd038bc6 2021-09-21 thomas.ad #include <stdint.h>
17 dd038bc6 2021-09-21 thomas.ad
18 dd038bc6 2021-09-21 thomas.ad /*
19 dd038bc6 2021-09-21 thomas.ad #include <termios.h>
20 dd038bc6 2021-09-21 thomas.ad #include <wchar.h>
21 dd038bc6 2021-09-21 thomas.ad */
22 dd038bc6 2021-09-21 thomas.ad
23 dd038bc6 2021-09-21 thomas.ad /* For flock. */
24 dd038bc6 2021-09-21 thomas.ad #ifndef O_EXLOCK
25 dd038bc6 2021-09-21 thomas.ad #define O_EXLOCK 0
26 dd038bc6 2021-09-21 thomas.ad #endif
27 dd038bc6 2021-09-21 thomas.ad
28 dd038bc6 2021-09-21 thomas.ad #ifndef HAVE_FLOCK
29 dd038bc6 2021-09-21 thomas.ad #define LOCK_SH 0
30 dd038bc6 2021-09-21 thomas.ad #define LOCK_EX 0
31 dd038bc6 2021-09-21 thomas.ad #define LOCK_NB 0
32 dd038bc6 2021-09-21 thomas.ad #define flock(fd, op) (0)
33 dd038bc6 2021-09-21 thomas.ad #else
34 dd038bc6 2021-09-21 thomas.ad #include <sys/file.h>
35 dd038bc6 2021-09-21 thomas.ad #endif
36 dd038bc6 2021-09-21 thomas.ad
37 dd038bc6 2021-09-21 thomas.ad #ifndef __dead
38 dd038bc6 2021-09-21 thomas.ad #define __dead __attribute__ ((__noreturn__))
39 dd038bc6 2021-09-21 thomas.ad #endif
40 dd038bc6 2021-09-21 thomas.ad
41 dd038bc6 2021-09-21 thomas.ad #ifndef __OpenBSD__
42 dd038bc6 2021-09-21 thomas.ad #define pledge(s, p) (0)
43 dd038bc6 2021-09-21 thomas.ad #define unveil(s, p) (0)
44 dd038bc6 2021-09-21 thomas.ad #endif
45 dd038bc6 2021-09-21 thomas.ad
46 2c6298d5 2021-09-24 thomas #ifdef HAVE_LINUX_LANDLOCK_H
47 2c6298d5 2021-09-24 thomas int landlock_no_fs(void);
48 2c6298d5 2021-09-24 thomas int landlock_unveil(const char *, const char *);
49 2c6298d5 2021-09-24 thomas /* #undef unveil */
50 2c6298d5 2021-09-24 thomas /* #define unveil(s, p) landlock_unveil((s), (p)) */
51 2c6298d5 2021-09-24 thomas #endif
52 2c6298d5 2021-09-24 thomas
53 dd038bc6 2021-09-21 thomas.ad #ifndef INFTIM
54 dd038bc6 2021-09-21 thomas.ad #define INFTIM -1
55 dd038bc6 2021-09-21 thomas.ad #endif
56 dd038bc6 2021-09-21 thomas.ad
57 dd038bc6 2021-09-21 thomas.ad #ifndef HAVE_BSD_UUID
58 dd038bc6 2021-09-21 thomas.ad #include <uuid/uuid.h>
59 dd038bc6 2021-09-21 thomas.ad #define uuid_s_ok 0
60 dd038bc6 2021-09-21 thomas.ad #define uuid_s_bad_version 1
61 dd038bc6 2021-09-21 thomas.ad #define uuid_s_invalid_string_uuid 2
62 dd038bc6 2021-09-21 thomas.ad #define uuid_s_no_memory 3
63 dd038bc6 2021-09-21 thomas.ad
64 dd038bc6 2021-09-21 thomas.ad /* Length of a node address (an IEEE 802 address). */
65 dd038bc6 2021-09-21 thomas.ad #define _UUID_NODE_LEN 6
66 dd038bc6 2021-09-21 thomas.ad
67 dd038bc6 2021-09-21 thomas.ad struct uuid {
68 dd038bc6 2021-09-21 thomas.ad uint32_t time_low;
69 dd038bc6 2021-09-21 thomas.ad uint16_t time_mid;
70 dd038bc6 2021-09-21 thomas.ad uint16_t time_hi_and_version;
71 dd038bc6 2021-09-21 thomas.ad uint8_t clock_seq_hi_and_reserved;
72 dd038bc6 2021-09-21 thomas.ad uint8_t clock_seq_low;
73 dd038bc6 2021-09-21 thomas.ad uint8_t node[_UUID_NODE_LEN];
74 dd038bc6 2021-09-21 thomas.ad };
75 dd038bc6 2021-09-21 thomas.ad
76 dd038bc6 2021-09-21 thomas.ad int32_t uuid_equal(struct uuid *, struct uuid *, uint32_t *);
77 dd038bc6 2021-09-21 thomas.ad int32_t uuid_is_nil(struct uuid *, uint32_t *);
78 dd038bc6 2021-09-21 thomas.ad void uuid_create(uuid_t *, uint32_t *);
79 dd038bc6 2021-09-21 thomas.ad void uuid_create_nil(struct uuid *, uint32_t *);
80 dd038bc6 2021-09-21 thomas.ad void uuid_from_string(const char *, uuid_t *, uint32_t *);
81 dd038bc6 2021-09-21 thomas.ad void uuid_to_string(uuid_t *, char **, uint32_t *);
82 dd038bc6 2021-09-21 thomas.ad #endif
83 dd038bc6 2021-09-21 thomas.ad
84 dd038bc6 2021-09-21 thomas.ad #ifdef HAVE_STDINT_H
85 dd038bc6 2021-09-21 thomas.ad #include <stdint.h>
86 dd038bc6 2021-09-21 thomas.ad #else
87 dd038bc6 2021-09-21 thomas.ad #include <inttypes.h>
88 dd038bc6 2021-09-21 thomas.ad #endif
89 dd038bc6 2021-09-21 thomas.ad
90 dd038bc6 2021-09-21 thomas.ad #ifdef HAVE_QUEUE_H
91 dd038bc6 2021-09-21 thomas.ad #include <sys/queue.h>
92 dd038bc6 2021-09-21 thomas.ad #else
93 dd038bc6 2021-09-21 thomas.ad #include "compat/queue.h"
94 dd038bc6 2021-09-21 thomas.ad #endif
95 dd038bc6 2021-09-21 thomas.ad
96 dd038bc6 2021-09-21 thomas.ad #ifdef HAVE_TREE_H
97 dd038bc6 2021-09-21 thomas.ad #include <sys/tree.h>
98 dd038bc6 2021-09-21 thomas.ad #else
99 dd038bc6 2021-09-21 thomas.ad #include "compat/tree.h"
100 dd038bc6 2021-09-21 thomas.ad #endif
101 dd038bc6 2021-09-21 thomas.ad
102 dd038bc6 2021-09-21 thomas.ad #ifdef HAVE_UTIL_H
103 dd038bc6 2021-09-21 thomas.ad #include <util.h>
104 dd038bc6 2021-09-21 thomas.ad #endif
105 dd038bc6 2021-09-21 thomas.ad
106 dd038bc6 2021-09-21 thomas.ad #ifdef HAVE_LIBUTIL_H
107 dd038bc6 2021-09-21 thomas.ad #include <libutil.h>
108 dd038bc6 2021-09-21 thomas.ad #endif
109 dd038bc6 2021-09-21 thomas.ad
110 dd038bc6 2021-09-21 thomas.ad #ifdef HAVE_IMSG
111 dd038bc6 2021-09-21 thomas.ad #else
112 dd038bc6 2021-09-21 thomas.ad #include "compat/imsg.h"
113 dd038bc6 2021-09-21 thomas.ad #endif
114 dd038bc6 2021-09-21 thomas.ad
115 92a9e85d 2021-09-24 thomas #ifdef HAVE_LIBCRYPTO
116 92a9e85d 2021-09-24 thomas #include <sha1.h>
117 92a9e85d 2021-09-24 thomas #else
118 92a9e85d 2021-09-24 thomas #include <sha.h>
119 92a9e85d 2021-09-24 thomas
120 92a9e85d 2021-09-24 thomas #define SHA1_DIGEST_LENGTH SHA_DIGEST_LENGTH
121 92a9e85d 2021-09-24 thomas #define SHA1_DIGEST_STRING_LENGTH (SHA1_DIGEST_LENGTH * 2 + 1)
122 92a9e85d 2021-09-24 thomas
123 92a9e85d 2021-09-24 thomas #define SHA1_CTX SHA_CTX
124 92a9e85d 2021-09-24 thomas #define SHA1Init SHA1_Init
125 92a9e85d 2021-09-24 thomas #define SHA1Update SHA1_Update
126 92a9e85d 2021-09-24 thomas #define SHA1Final SHA1_Final
127 92a9e85d 2021-09-24 thomas #endif
128 92a9e85d 2021-09-24 thomas
129 dd038bc6 2021-09-21 thomas.ad #ifndef HAVE_ASPRINTF
130 dd038bc6 2021-09-21 thomas.ad /* asprintf.c */
131 dd038bc6 2021-09-21 thomas.ad int asprintf(char **, const char *, ...);
132 dd038bc6 2021-09-21 thomas.ad int vasprintf(char **, const char *, va_list);
133 dd038bc6 2021-09-21 thomas.ad #endif
134 dd038bc6 2021-09-21 thomas.ad
135 dd038bc6 2021-09-21 thomas.ad #ifndef HAVE_EXPLICIT_BZERO
136 dd038bc6 2021-09-21 thomas.ad /* explicit_bzero.c */
137 dd038bc6 2021-09-21 thomas.ad void explicit_bzero(void *, size_t);
138 dd038bc6 2021-09-21 thomas.ad #endif
139 dd038bc6 2021-09-21 thomas.ad
140 dd038bc6 2021-09-21 thomas.ad #ifndef HAVE_GETDTABLECOUNT
141 dd038bc6 2021-09-21 thomas.ad /* getdtablecount.c */
142 dd038bc6 2021-09-21 thomas.ad int getdtablecount(void);
143 dd038bc6 2021-09-21 thomas.ad #endif
144 dd038bc6 2021-09-21 thomas.ad
145 dd038bc6 2021-09-21 thomas.ad #ifndef HAVE_CLOSEFROM
146 dd038bc6 2021-09-21 thomas.ad /* closefrom.c */
147 dd038bc6 2021-09-21 thomas.ad //void closefrom(int);
148 dd038bc6 2021-09-21 thomas.ad #define closefrom(fd) (closefrom(fd), 0)
149 dd038bc6 2021-09-21 thomas.ad #endif
150 dd038bc6 2021-09-21 thomas.ad
151 92a9e85d 2021-09-24 thomas #if defined (__FreeBSD__)
152 92a9e85d 2021-09-24 thomas #define closefrom(fd) (closefrom(fd), 0)
153 92a9e85d 2021-09-24 thomas #endif
154 92a9e85d 2021-09-24 thomas
155 dd038bc6 2021-09-21 thomas.ad #ifndef HAVE_STRSEP
156 dd038bc6 2021-09-21 thomas.ad /* strsep.c */
157 dd038bc6 2021-09-21 thomas.ad char *strsep(char **, const char *);
158 dd038bc6 2021-09-21 thomas.ad #endif
159 dd038bc6 2021-09-21 thomas.ad
160 dd038bc6 2021-09-21 thomas.ad #ifndef HAVE_STRTONUM
161 dd038bc6 2021-09-21 thomas.ad /* strtonum.c */
162 dd038bc6 2021-09-21 thomas.ad long long strtonum(const char *, long long, long long, const char **);
163 dd038bc6 2021-09-21 thomas.ad #endif
164 dd038bc6 2021-09-21 thomas.ad
165 dd038bc6 2021-09-21 thomas.ad #ifndef HAVE_STRLCPY
166 dd038bc6 2021-09-21 thomas.ad /* strlcpy.c */
167 dd038bc6 2021-09-21 thomas.ad size_t strlcpy(char *, const char *, size_t);
168 dd038bc6 2021-09-21 thomas.ad #endif
169 dd038bc6 2021-09-21 thomas.ad
170 dd038bc6 2021-09-21 thomas.ad #ifndef HAVE_STRLCAT
171 dd038bc6 2021-09-21 thomas.ad /* strlcat.c */
172 dd038bc6 2021-09-21 thomas.ad size_t strlcat(char *, const char *, size_t);
173 dd038bc6 2021-09-21 thomas.ad #endif
174 dd038bc6 2021-09-21 thomas.ad
175 dd038bc6 2021-09-21 thomas.ad #ifndef HAVE_STRNLEN
176 dd038bc6 2021-09-21 thomas.ad /* strnlen.c */
177 dd038bc6 2021-09-21 thomas.ad size_t strnlen(const char *, size_t);
178 dd038bc6 2021-09-21 thomas.ad #endif
179 dd038bc6 2021-09-21 thomas.ad
180 dd038bc6 2021-09-21 thomas.ad #ifndef HAVE_STRNDUP
181 dd038bc6 2021-09-21 thomas.ad /* strndup.c */
182 dd038bc6 2021-09-21 thomas.ad char *strndup(const char *, size_t);
183 dd038bc6 2021-09-21 thomas.ad #endif
184 dd038bc6 2021-09-21 thomas.ad
185 dd038bc6 2021-09-21 thomas.ad #ifndef HAVE_GETPROGNAME
186 dd038bc6 2021-09-21 thomas.ad /* getprogname.c */
187 dd038bc6 2021-09-21 thomas.ad const char *getprogname(void);
188 dd038bc6 2021-09-21 thomas.ad #endif
189 dd038bc6 2021-09-21 thomas.ad
190 dd038bc6 2021-09-21 thomas.ad #ifndef HAVE_GETLINE
191 dd038bc6 2021-09-21 thomas.ad /* getline.c */
192 dd038bc6 2021-09-21 thomas.ad ssize_t getline(char **, size_t *, FILE *);
193 dd038bc6 2021-09-21 thomas.ad #endif
194 dd038bc6 2021-09-21 thomas.ad
195 dd038bc6 2021-09-21 thomas.ad #ifndef HAVE_FREEZERO
196 dd038bc6 2021-09-21 thomas.ad /* freezero.c */
197 dd038bc6 2021-09-21 thomas.ad void freezero(void *, size_t);
198 dd038bc6 2021-09-21 thomas.ad #endif
199 dd038bc6 2021-09-21 thomas.ad
200 dd038bc6 2021-09-21 thomas.ad #ifndef HAVE_GETDTABLECOUNT
201 dd038bc6 2021-09-21 thomas.ad /* getdtablecount.c */
202 dd038bc6 2021-09-21 thomas.ad int getdtablecount(void);
203 dd038bc6 2021-09-21 thomas.ad #endif
204 dd038bc6 2021-09-21 thomas.ad
205 dd038bc6 2021-09-21 thomas.ad #ifndef HAVE_REALLOCARRAY
206 dd038bc6 2021-09-21 thomas.ad /* reallocarray.c */
207 dd038bc6 2021-09-21 thomas.ad void *reallocarray(void *, size_t, size_t);
208 dd038bc6 2021-09-21 thomas.ad #endif
209 dd038bc6 2021-09-21 thomas.ad
210 dd038bc6 2021-09-21 thomas.ad #ifndef HAVE_RECALLOCARRAY
211 dd038bc6 2021-09-21 thomas.ad /* recallocarray.c */
212 dd038bc6 2021-09-21 thomas.ad void *recallocarray(void *, size_t, size_t, size_t);
213 dd038bc6 2021-09-21 thomas.ad #endif
214 dd038bc6 2021-09-21 thomas.ad
215 dd038bc6 2021-09-21 thomas.ad #ifndef HAVE_FMT_SCALED
216 dd038bc6 2021-09-21 thomas.ad /* fmt_scaled.c */
217 dd038bc6 2021-09-21 thomas.ad int fmt_scaled(long long, char *);
218 dd038bc6 2021-09-21 thomas.ad int scan_scaled(char *, long long *);
219 dd038bc6 2021-09-21 thomas.ad #define FMT_SCALED_STRSIZE 7 /* minus sign, 4 digits, suffix, null byte */
220 dd038bc6 2021-09-21 thomas.ad
221 dd038bc6 2021-09-21 thomas.ad #endif
222 dd038bc6 2021-09-21 thomas.ad
223 dd038bc6 2021-09-21 thomas.ad #ifndef HAVE_LIBBSD
224 dd038bc6 2021-09-21 thomas.ad /* getopt.c */
225 dd038bc6 2021-09-21 thomas.ad extern int BSDopterr;
226 dd038bc6 2021-09-21 thomas.ad extern int BSDoptind;
227 dd038bc6 2021-09-21 thomas.ad extern int BSDoptopt;
228 dd038bc6 2021-09-21 thomas.ad extern int BSDoptreset;
229 dd038bc6 2021-09-21 thomas.ad extern char *BSDoptarg;
230 dd038bc6 2021-09-21 thomas.ad int BSDgetopt(int, char *const *, const char *);
231 dd038bc6 2021-09-21 thomas.ad #define getopt(ac, av, o) BSDgetopt(ac, av, o)
232 dd038bc6 2021-09-21 thomas.ad #define opterr BSDopterr
233 dd038bc6 2021-09-21 thomas.ad #define optind BSDoptind
234 dd038bc6 2021-09-21 thomas.ad #define optopt BSDoptopt
235 dd038bc6 2021-09-21 thomas.ad #define optreset BSDoptreset
236 dd038bc6 2021-09-21 thomas.ad #define optarg BSDoptarg
237 dd038bc6 2021-09-21 thomas.ad #endif
238 dd038bc6 2021-09-21 thomas.ad #endif
239 dd038bc6 2021-09-21 thomas.ad
240 dd038bc6 2021-09-21 thomas.ad #ifndef HAVE_BSD_MERGESORT
241 dd038bc6 2021-09-21 thomas.ad /* mergesort.c */
242 dd038bc6 2021-09-21 thomas.ad int mergesort(void *, size_t, size_t, int (*)(const void *, const void *));
243 dd038bc6 2021-09-21 thomas.ad #endif