1 dd038bc6 2021-09-21 thomas.ad #ifndef _GOT_COMPAT_H
2 dd038bc6 2021-09-21 thomas.ad #define _GOT_COMPAT_H
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>
10 92a9e85d 2021-09-24 thomas #include <endian.h>
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>
19 dd038bc6 2021-09-21 thomas.ad #include <termios.h>
20 dd038bc6 2021-09-21 thomas.ad #include <wchar.h>
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
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)
34 dd038bc6 2021-09-21 thomas.ad #include <sys/file.h>
37 dd038bc6 2021-09-21 thomas.ad #ifndef __dead
38 dd038bc6 2021-09-21 thomas.ad #define __dead __attribute__ ((__noreturn__))
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)
46 dd038bc6 2021-09-21 thomas.ad #ifndef INFTIM
47 dd038bc6 2021-09-21 thomas.ad #define INFTIM -1
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
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
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];
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 *);
77 dd038bc6 2021-09-21 thomas.ad #ifdef HAVE_STDINT_H
78 dd038bc6 2021-09-21 thomas.ad #include <stdint.h>
80 dd038bc6 2021-09-21 thomas.ad #include <inttypes.h>
83 dd038bc6 2021-09-21 thomas.ad #ifdef HAVE_QUEUE_H
84 dd038bc6 2021-09-21 thomas.ad #include <sys/queue.h>
86 dd038bc6 2021-09-21 thomas.ad #include "compat/queue.h"
89 dd038bc6 2021-09-21 thomas.ad #ifdef HAVE_TREE_H
90 dd038bc6 2021-09-21 thomas.ad #include <sys/tree.h>
92 dd038bc6 2021-09-21 thomas.ad #include "compat/tree.h"
95 dd038bc6 2021-09-21 thomas.ad #ifdef HAVE_UTIL_H
96 dd038bc6 2021-09-21 thomas.ad #include <util.h>
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
103 dd038bc6 2021-09-21 thomas.ad #ifdef HAVE_IMSG
105 dd038bc6 2021-09-21 thomas.ad #include "compat/imsg.h"
106 dd038bc6 2021-09-21 thomas.ad #endif
108 92a9e85d 2021-09-24 thomas #ifdef HAVE_LIBCRYPTO
109 92a9e85d 2021-09-24 thomas #include <sha1.h>
111 92a9e85d 2021-09-24 thomas #include <sha.h>
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)
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
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
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
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
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
144 92a9e85d 2021-09-24 thomas #if defined (__FreeBSD__)
145 92a9e85d 2021-09-24 thomas #define closefrom(fd) (closefrom(fd), 0)
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
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
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
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
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
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
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
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
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
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
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
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
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 */
214 dd038bc6 2021-09-21 thomas.ad #endif
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
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