Blame


1 f26f1205 2022-02-09 op /*
2 f26f1205 2022-02-09 op * Copyright (c) 2021 Omar Polo <op@omarpolo.com>
3 f26f1205 2022-02-09 op *
4 f26f1205 2022-02-09 op * Permission to use, copy, modify, and distribute this software for any
5 f26f1205 2022-02-09 op * purpose with or without fee is hereby granted, provided that the above
6 f26f1205 2022-02-09 op * copyright notice and this permission notice appear in all copies.
7 f26f1205 2022-02-09 op *
8 f26f1205 2022-02-09 op * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 f26f1205 2022-02-09 op * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 f26f1205 2022-02-09 op * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 f26f1205 2022-02-09 op * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 f26f1205 2022-02-09 op * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 f26f1205 2022-02-09 op * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 f26f1205 2022-02-09 op * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 f26f1205 2022-02-09 op */
16 f26f1205 2022-02-09 op
17 f26f1205 2022-02-09 op #ifndef COMPAT_H
18 f26f1205 2022-02-09 op #define COMPAT_H
19 f26f1205 2022-02-09 op
20 f26f1205 2022-02-09 op #include "config.h"
21 f26f1205 2022-02-09 op
22 f26f1205 2022-02-09 op #include <sys/types.h>
23 f26f1205 2022-02-09 op #include <sys/uio.h>
24 f26f1205 2022-02-09 op
25 f26f1205 2022-02-09 op #include <stdarg.h>
26 f26f1205 2022-02-09 op #include <stddef.h>
27 f26f1205 2022-02-09 op #include <stdint.h>
28 f26f1205 2022-02-09 op
29 b3ea1dea 2023-07-02 op #if HAVE_ENDIAN_H
30 b3ea1dea 2023-07-02 op # include <endian.h>
31 b3ea1dea 2023-07-02 op #elif HAVE_SYS_ENDIAN_H
32 b3ea1dea 2023-07-02 op # include <sys/endian.h>
33 b3ea1dea 2023-07-02 op #elif HAVE_LIBKERN_OSBYTEORDER_H
34 b3ea1dea 2023-07-02 op # include <machine/endian.h>
35 b3ea1dea 2023-07-02 op # include <libkern/OSByteOrder.h>
36 b3ea1dea 2023-07-02 op
37 b3ea1dea 2023-07-02 op # define htobe16(x) OSSwapHostToBigInt16(x)
38 b3ea1dea 2023-07-02 op # define htole16(x) OSSwapHostToLittleInt16(x)
39 b3ea1dea 2023-07-02 op # define be16toh(x) OSSwapBigToHostInt16(x)
40 b3ea1dea 2023-07-02 op # define le16toh(x) OSSwapLittleToHostInt16(x)
41 b3ea1dea 2023-07-02 op
42 b3ea1dea 2023-07-02 op # define htobe32(x) OSSwapHostToBigInt32(x)
43 b3ea1dea 2023-07-02 op # define htole32(x) OSSwapHostToLittleInt32(x)
44 b3ea1dea 2023-07-02 op # define be32toh(x) OSSwapBigToHostInt32(x)
45 b3ea1dea 2023-07-02 op # define le32toh(x) OSSwapLittleToHostInt32(x)
46 b3ea1dea 2023-07-02 op
47 b3ea1dea 2023-07-02 op # define htobe64(x) OSSwapHostToBigInt64(x)
48 b3ea1dea 2023-07-02 op # define htole64(x) OSSwapHostToLittleInt64(x)
49 b3ea1dea 2023-07-02 op # define be64toh(x) OSSwapBigToHostInt64(x)
50 b3ea1dea 2023-07-02 op # define le64toh(x) OSSwapLittleToHostInt64(x)
51 b3ea1dea 2023-07-02 op #else
52 b3ea1dea 2023-07-02 op # error no compatible endian.h header found
53 b3ea1dea 2023-07-02 op #endif
54 b3ea1dea 2023-07-02 op
55 f26f1205 2022-02-09 op #if HAVE_EVENT2
56 f26f1205 2022-02-09 op # include <event2/event.h>
57 f26f1205 2022-02-09 op # include <event2/event_compat.h>
58 f26f1205 2022-02-09 op # include <event2/event_struct.h>
59 f26f1205 2022-02-09 op # include <event2/buffer.h>
60 f26f1205 2022-02-09 op # include <event2/buffer_compat.h>
61 f26f1205 2022-02-09 op # include <event2/bufferevent.h>
62 f26f1205 2022-02-09 op # include <event2/bufferevent_struct.h>
63 f26f1205 2022-02-09 op # include <event2/bufferevent_compat.h>
64 f26f1205 2022-02-09 op #else
65 f26f1205 2022-02-09 op # include <event.h>
66 f26f1205 2022-02-09 op #endif
67 f26f1205 2022-02-09 op
68 f26f1205 2022-02-09 op #ifdef HAVE_QUEUE_H
69 f26f1205 2022-02-09 op # include <sys/queue.h>
70 f26f1205 2022-02-09 op #else
71 f26f1205 2022-02-09 op # include "compat/queue.h"
72 f26f1205 2022-02-09 op #endif
73 f26f1205 2022-02-09 op
74 f26f1205 2022-02-09 op #ifdef HAVE_IMSG
75 f26f1205 2022-02-09 op # include <imsg.h>
76 f26f1205 2022-02-09 op #else
77 f26f1205 2022-02-09 op # include "compat/imsg.h"
78 f26f1205 2022-02-09 op #endif
79 f26f1205 2022-02-09 op
80 f26f1205 2022-02-09 op #ifdef HAVE_LIBUTIL
81 f26f1205 2022-02-09 op # include <ohash.h>
82 f26f1205 2022-02-09 op # include <util.h>
83 f26f1205 2022-02-09 op #else
84 f26f1205 2022-02-09 op # include "compat/ohash.h"
85 f26f1205 2022-02-09 op # define FMT_SCALED_STRSIZE 7 /* minus sign, 4 digits, suffix, null byte */
86 4aadc398 2022-05-19 op int scan_scaled(char *, long long *);
87 f26f1205 2022-02-09 op int fmt_scaled(long long, char *);
88 f26f1205 2022-02-09 op #endif
89 f26f1205 2022-02-09 op
90 f26f1205 2022-02-09 op #ifndef HAVE_ASPRINTF
91 f26f1205 2022-02-09 op int asprintf(char**, const char*, ...);
92 f26f1205 2022-02-09 op int vasprintf(char**, const char*, va_list);
93 f26f1205 2022-02-09 op #endif
94 f26f1205 2022-02-09 op
95 f26f1205 2022-02-09 op #ifndef HAVE_ERR
96 f26f1205 2022-02-09 op void err(int, const char*, ...);
97 f26f1205 2022-02-09 op void errx(int, const char*, ...);
98 f26f1205 2022-02-09 op void warn(int, const char*, ...);
99 f26f1205 2022-02-09 op void warnx(int, const char*, ...);
100 f26f1205 2022-02-09 op #else
101 f26f1205 2022-02-09 op # include <err.h>
102 f26f1205 2022-02-09 op #endif
103 f26f1205 2022-02-09 op
104 f26f1205 2022-02-09 op #ifndef HAVE_EXPLICIT_BZERO
105 f26f1205 2022-02-09 op void explicit_bzero(void *, size_t);
106 f26f1205 2022-02-09 op #endif
107 f26f1205 2022-02-09 op
108 f26f1205 2022-02-09 op #ifndef HAVE_FREEZERO
109 f26f1205 2022-02-09 op void freezero(void*, size_t);
110 f26f1205 2022-02-09 op #endif
111 f26f1205 2022-02-09 op
112 f26f1205 2022-02-09 op #ifndef HAVE_GETDTABLECOUNT
113 f26f1205 2022-02-09 op int getdtablecount(void);
114 f26f1205 2022-02-09 op #endif
115 f26f1205 2022-02-09 op
116 f26f1205 2022-02-09 op #ifndef HAVE_GETDTABLESIZE
117 f26f1205 2022-02-09 op int getdtablesize(void);
118 f26f1205 2022-02-09 op #endif
119 f26f1205 2022-02-09 op
120 f26f1205 2022-02-09 op #ifndef HAVE_GETPROGNAME
121 f26f1205 2022-02-09 op const char *getprogname(void);
122 f26f1205 2022-02-09 op #endif
123 f26f1205 2022-02-09 op
124 f26f1205 2022-02-09 op #ifndef HAVE_MEMMEM
125 f26f1205 2022-02-09 op void *memmem(const void*, size_t, const void*, size_t);
126 f26f1205 2022-02-09 op #endif
127 f26f1205 2022-02-09 op
128 f26f1205 2022-02-09 op #ifndef HAVE_RECALLOCARRAY
129 f26f1205 2022-02-09 op void *recallocarray(void*, size_t, size_t, size_t);
130 f26f1205 2022-02-09 op #endif
131 f26f1205 2022-02-09 op
132 f26f1205 2022-02-09 op #ifndef HAVE_STRCASESTR
133 f26f1205 2022-02-09 op char *strcasestr(const char *, const char *);
134 f26f1205 2022-02-09 op #endif
135 f26f1205 2022-02-09 op
136 f26f1205 2022-02-09 op #ifndef HAVE_STRLCPY
137 f26f1205 2022-02-09 op size_t strlcpy(char*, const char*, size_t);
138 f26f1205 2022-02-09 op #endif
139 f26f1205 2022-02-09 op
140 f26f1205 2022-02-09 op #ifndef HAVE_STRLCAT
141 f26f1205 2022-02-09 op size_t strlcat(char*, const char*, size_t);
142 f26f1205 2022-02-09 op #endif
143 f26f1205 2022-02-09 op
144 f26f1205 2022-02-09 op #ifndef HAVE_STRSEP
145 f26f1205 2022-02-09 op char *strsep(char**, const char*);
146 f26f1205 2022-02-09 op #endif
147 f26f1205 2022-02-09 op
148 f26f1205 2022-02-09 op #ifndef HAVE_STRTONUM
149 f26f1205 2022-02-09 op long long strtonum(const char*, long long, long long, const char**);
150 f26f1205 2022-02-09 op #endif
151 f26f1205 2022-02-09 op
152 f26f1205 2022-02-09 op #ifndef HAVE_SETPROCTITLE
153 f26f1205 2022-02-09 op void setproctitle(const char*, ...);
154 f26f1205 2022-02-09 op #endif
155 f26f1205 2022-02-09 op
156 f26f1205 2022-02-09 op #endif /* COMPAT_H */