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