Blame


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