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