Blame


1 0d6fb46a 2022-01-09 op /*
2 0d6fb46a 2022-01-09 op * Copyright (c) 2021 Omar Polo <op@omarpolo.com>
3 0d6fb46a 2022-01-09 op *
4 0d6fb46a 2022-01-09 op * Permission to use, copy, modify, and distribute this software for any
5 0d6fb46a 2022-01-09 op * purpose with or without fee is hereby granted, provided that the above
6 0d6fb46a 2022-01-09 op * copyright notice and this permission notice appear in all copies.
7 0d6fb46a 2022-01-09 op *
8 0d6fb46a 2022-01-09 op * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 0d6fb46a 2022-01-09 op * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 0d6fb46a 2022-01-09 op * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 0d6fb46a 2022-01-09 op * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 0d6fb46a 2022-01-09 op * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 0d6fb46a 2022-01-09 op * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 0d6fb46a 2022-01-09 op * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 0d6fb46a 2022-01-09 op */
16 0d6fb46a 2022-01-09 op
17 0d6fb46a 2022-01-09 op #ifndef COMPAT_H
18 0d6fb46a 2022-01-09 op #define COMPAT_H
19 0d6fb46a 2022-01-09 op
20 0d6fb46a 2022-01-09 op #include "config.h"
21 0d6fb46a 2022-01-09 op
22 0d6fb46a 2022-01-09 op #include <sys/types.h>
23 0d6fb46a 2022-01-09 op #include <sys/uio.h>
24 0d6fb46a 2022-01-09 op
25 0d6fb46a 2022-01-09 op #include <stdarg.h>
26 0d6fb46a 2022-01-09 op #include <stddef.h>
27 0d6fb46a 2022-01-09 op #include <stdint.h>
28 0d6fb46a 2022-01-09 op
29 0d6fb46a 2022-01-09 op #ifndef __dead
30 0d6fb46a 2022-01-09 op #define __dead __attribute__((noreturn))
31 0d6fb46a 2022-01-09 op #endif
32 0d6fb46a 2022-01-09 op
33 0d6fb46a 2022-01-09 op #if HAVE_EVENT2
34 0d6fb46a 2022-01-09 op # include <event2/event.h>
35 0d6fb46a 2022-01-09 op # include <event2/event_compat.h>
36 0d6fb46a 2022-01-09 op # include <event2/event_struct.h>
37 0d6fb46a 2022-01-09 op # include <event2/buffer.h>
38 0d6fb46a 2022-01-09 op # include <event2/buffer_compat.h>
39 0d6fb46a 2022-01-09 op # include <event2/bufferevent.h>
40 0d6fb46a 2022-01-09 op # include <event2/bufferevent_struct.h>
41 0d6fb46a 2022-01-09 op # include <event2/bufferevent_compat.h>
42 0d6fb46a 2022-01-09 op #else
43 0d6fb46a 2022-01-09 op # include <event.h>
44 0d6fb46a 2022-01-09 op #endif
45 0d6fb46a 2022-01-09 op
46 0d6fb46a 2022-01-09 op #ifdef HAVE_QUEUE_H
47 0d6fb46a 2022-01-09 op # include <sys/queue.h>
48 0d6fb46a 2022-01-09 op #else
49 0d6fb46a 2022-01-09 op # include "compat/queue.h"
50 0d6fb46a 2022-01-09 op #endif
51 0d6fb46a 2022-01-09 op
52 0d6fb46a 2022-01-09 op #ifdef HAVE_SYS_TREE_H
53 0d6fb46a 2022-01-09 op # include <sys/tree.h>
54 0d6fb46a 2022-01-09 op #else
55 0d6fb46a 2022-01-09 op # include "compat/tree.h"
56 0d6fb46a 2022-01-09 op #endif
57 0d6fb46a 2022-01-09 op
58 0d6fb46a 2022-01-09 op #ifdef HAVE_LIBUTIL
59 0d6fb46a 2022-01-09 op # include <imsg.h>
60 0d6fb46a 2022-01-09 op # include <ohash.h>
61 0d6fb46a 2022-01-09 op # include <util.h>
62 0d6fb46a 2022-01-09 op #else
63 0d6fb46a 2022-01-09 op # include "compat/imsg.h"
64 0d6fb46a 2022-01-09 op # include "compat/ohash.h"
65 0d6fb46a 2022-01-09 op # define FMT_SCALED_STRSIZE 7 /* minus sign, 4 digits, suffix, NUL */
66 0d6fb46a 2022-01-09 op int fmt_scaled(long long, char *);
67 0d6fb46a 2022-01-09 op #endif
68 0d6fb46a 2022-01-09 op
69 0d6fb46a 2022-01-09 op #ifndef HAVE_ARC4RANDOM
70 0d6fb46a 2022-01-09 op # include <stdint.h>
71 0d6fb46a 2022-01-09 op uint32_t arc4random(void);
72 0d6fb46a 2022-01-09 op void arc4random_buf(void *, size_t);
73 0d6fb46a 2022-01-09 op uint32_t arc4random_uniform(uint32_t);
74 0d6fb46a 2022-01-09 op #endif
75 0d6fb46a 2022-01-09 op
76 0d6fb46a 2022-01-09 op #ifndef HAVE_ASPRINTF
77 0d6fb46a 2022-01-09 op int asprintf(char **, const char *, ...);
78 0d6fb46a 2022-01-09 op int vasprintf(char **, const char *, ...);
79 0d6fb46a 2022-01-09 op #endif
80 0d6fb46a 2022-01-09 op
81 0d6fb46a 2022-01-09 op #ifndef HAVE_ERR
82 0d6fb46a 2022-01-09 op void err(int, const char *, ...);
83 0d6fb46a 2022-01-09 op void errx(int, const char *, ...);
84 0d6fb46a 2022-01-09 op void warn(int, const char *, ...);
85 0d6fb46a 2022-01-09 op void warnx(int, const char *, ...);
86 0d6fb46a 2022-01-09 op #else
87 0d6fb46a 2022-01-09 op #include <err.h>
88 0d6fb46a 2022-01-09 op #endif
89 0d6fb46a 2022-01-09 op
90 0d6fb46a 2022-01-09 op #ifndef FREEZERO
91 0d6fb46a 2022-01-09 op void freezero(void *, size_t);
92 0d6fb46a 2022-01-09 op #endif
93 0d6fb46a 2022-01-09 op
94 0d6fb46a 2022-01-09 op #ifndef HAVE_GETDTABLECOUNT
95 0d6fb46a 2022-01-09 op int getdtablecount(void);
96 0d6fb46a 2022-01-09 op #endif
97 0d6fb46a 2022-01-09 op
98 0d6fb46a 2022-01-09 op #ifndef HAVE_GETDTABLESIZE
99 0d6fb46a 2022-01-09 op int getdtablesize(void);
100 0d6fb46a 2022-01-09 op #endif
101 0d6fb46a 2022-01-09 op
102 0d6fb46a 2022-01-09 op #ifndef HAVE_GETPROGNAME
103 0d6fb46a 2022-01-09 op const char *getprogname(void);
104 0d6fb46a 2022-01-09 op #endif
105 0d6fb46a 2022-01-09 op
106 0d6fb46a 2022-01-09 op #ifndef HAVE_MEMMEM
107 0d6fb46a 2022-01-09 op void *memmem(const void *, size_t, const void *, size_t);
108 0d6fb46a 2022-01-09 op #endif
109 0d6fb46a 2022-01-09 op
110 0d6fb46a 2022-01-09 op #ifndef HAVE_RECALLOCARRAY
111 0d6fb46a 2022-01-09 op void *recallocarray(void *, size_t, size_t, size_t);
112 0d6fb46a 2022-01-09 op #endif
113 0d6fb46a 2022-01-09 op
114 0d6fb46a 2022-01-09 op #ifndef HAVE_SETPROCTITLE
115 0d6fb46a 2022-01-09 op void setproctitle(const char *, ...);
116 0d6fb46a 2022-01-09 op #endif
117 0d6fb46a 2022-01-09 op
118 0d6fb46a 2022-01-09 op #ifndef HAVE_SETPROGNAME
119 0d6fb46a 2022-01-09 op void setprogname(const char *);
120 0d6fb46a 2022-01-09 op #endif
121 0d6fb46a 2022-01-09 op
122 0d6fb46a 2022-01-09 op #ifndef HAVE_STRLCAT
123 0d6fb46a 2022-01-09 op size_t strlcat(char *, const char *, size_t);
124 0d6fb46a 2022-01-09 op #endif
125 0d6fb46a 2022-01-09 op
126 0d6fb46a 2022-01-09 op #ifndef HAVE_STRLCPY
127 0d6fb46a 2022-01-09 op size_t strlcpy(char *, const char *, size_t);
128 0d6fb46a 2022-01-09 op #endif
129 0d6fb46a 2022-01-09 op
130 0d6fb46a 2022-01-09 op #ifndef HAVE_STRSEP
131 0d6fb46a 2022-01-09 op char *strsep(char **, const char *);
132 0d6fb46a 2022-01-09 op #endif
133 0d6fb46a 2022-01-09 op
134 0d6fb46a 2022-01-09 op #ifndef HAVE_STRTONUM
135 0d6fb46a 2022-01-09 op long long strtonum(const char *, long long, long long, const char **);
136 0d6fb46a 2022-01-09 op #endif
137 0d6fb46a 2022-01-09 op
138 0d6fb46a 2022-01-09 op #ifdef HAVE_VIS
139 0d6fb46a 2022-01-09 op # include <vis.h>
140 0d6fb46a 2022-01-09 op #else
141 0d6fb46a 2022-01-09 op # include "compat/vis.h"
142 0d6fb46a 2022-01-09 op #endif
143 0d6fb46a 2022-01-09 op
144 0d6fb46a 2022-01-09 op #endif /* COMPAT_H */