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 16ba5d4d 2022-05-10 op #ifndef INFTIM
34 16ba5d4d 2022-05-10 op #define INFTIM -1
37 bbcba3ed 2022-01-10 op #if HAVE_EVENT2
38 bbcba3ed 2022-01-10 op # include <event2/event.h>
39 bbcba3ed 2022-01-10 op # include <event2/event_compat.h>
40 bbcba3ed 2022-01-10 op # include <event2/event_struct.h>
41 bbcba3ed 2022-01-10 op # include <event2/buffer.h>
42 bbcba3ed 2022-01-10 op # include <event2/buffer_compat.h>
43 bbcba3ed 2022-01-10 op # include <event2/bufferevent.h>
44 bbcba3ed 2022-01-10 op # include <event2/bufferevent_struct.h>
45 bbcba3ed 2022-01-10 op # include <event2/bufferevent_compat.h>
47 bbcba3ed 2022-01-10 op # include <event.h>
50 bbcba3ed 2022-01-10 op #ifdef HAVE_QUEUE_H
51 bbcba3ed 2022-01-10 op # include <sys/queue.h>
53 bbcba3ed 2022-01-10 op # include "compat/queue.h"
56 bbcba3ed 2022-01-10 op #ifdef HAVE_SYS_TREE_H
57 bbcba3ed 2022-01-10 op # include <sys/tree.h>
59 bbcba3ed 2022-01-10 op # include "compat/tree.h"
62 bbcba3ed 2022-01-10 op #ifdef HAVE_LIBUTIL
63 bbcba3ed 2022-01-10 op # include <imsg.h>
64 bbcba3ed 2022-01-10 op # include <ohash.h>
65 bbcba3ed 2022-01-10 op # include <util.h>
67 bbcba3ed 2022-01-10 op # include "compat/imsg.h"
68 bbcba3ed 2022-01-10 op # include "compat/ohash.h"
69 bbcba3ed 2022-01-10 op # define FMT_SCALED_STRSIZE 7 /* minus sign, 4 digits, suffix, NUL */
70 bbcba3ed 2022-01-10 op int fmt_scaled(long long, char *);
73 bbcba3ed 2022-01-10 op #ifndef HAVE_ARC4RANDOM
74 bbcba3ed 2022-01-10 op # include <stdint.h>
75 bbcba3ed 2022-01-10 op uint32_t arc4random(void);
76 bbcba3ed 2022-01-10 op void arc4random_buf(void *, size_t);
77 bbcba3ed 2022-01-10 op uint32_t arc4random_uniform(uint32_t);
80 bbcba3ed 2022-01-10 op #ifndef HAVE_ASPRINTF
81 bbcba3ed 2022-01-10 op int asprintf(char **, const char *, ...);
82 bbcba3ed 2022-01-10 op int vasprintf(char **, const char *, ...);
85 bbcba3ed 2022-01-10 op #ifndef HAVE_ERR
86 bbcba3ed 2022-01-10 op void err(int, const char *, ...);
87 bbcba3ed 2022-01-10 op void errx(int, const char *, ...);
88 bbcba3ed 2022-01-10 op void warn(int, const char *, ...);
89 bbcba3ed 2022-01-10 op void warnx(int, const char *, ...);
91 bbcba3ed 2022-01-10 op #include <err.h>
94 bbcba3ed 2022-01-10 op #ifndef FREEZERO
95 bbcba3ed 2022-01-10 op void freezero(void *, size_t);
98 bbcba3ed 2022-01-10 op #ifndef HAVE_GETDTABLECOUNT
99 bbcba3ed 2022-01-10 op int getdtablecount(void);
102 bbcba3ed 2022-01-10 op #ifndef HAVE_GETDTABLESIZE
103 bbcba3ed 2022-01-10 op int getdtablesize(void);
106 bbcba3ed 2022-01-10 op #ifndef HAVE_GETPROGNAME
107 bbcba3ed 2022-01-10 op const char *getprogname(void);
110 bbcba3ed 2022-01-10 op #ifndef HAVE_MEMMEM
111 bbcba3ed 2022-01-10 op void *memmem(const void *, size_t, const void *, size_t);
114 bbcba3ed 2022-01-10 op #ifndef HAVE_RECALLOCARRAY
115 bbcba3ed 2022-01-10 op void *recallocarray(void *, size_t, size_t, size_t);
118 bbcba3ed 2022-01-10 op #ifndef HAVE_SETPROCTITLE
119 bbcba3ed 2022-01-10 op void setproctitle(const char *, ...);
122 bbcba3ed 2022-01-10 op #ifndef HAVE_SETPROGNAME
123 bbcba3ed 2022-01-10 op void setprogname(const char *);
126 bbcba3ed 2022-01-10 op #ifndef HAVE_STRLCAT
127 bbcba3ed 2022-01-10 op size_t strlcat(char *, const char *, size_t);
130 bbcba3ed 2022-01-10 op #ifndef HAVE_STRLCPY
131 bbcba3ed 2022-01-10 op size_t strlcpy(char *, const char *, size_t);
134 bbcba3ed 2022-01-10 op #ifndef HAVE_STRSEP
135 bbcba3ed 2022-01-10 op char *strsep(char **, const char *);
138 bbcba3ed 2022-01-10 op #ifndef HAVE_STRTONUM
139 bbcba3ed 2022-01-10 op long long strtonum(const char *, long long, long long, const char **);
142 bbcba3ed 2022-01-10 op #ifdef HAVE_VIS
143 bbcba3ed 2022-01-10 op # include <vis.h>
145 bbcba3ed 2022-01-10 op # include "compat/vis.h"
148 bbcba3ed 2022-01-10 op #endif /* COMPAT_H */