2 734e1bdf 2025-12-20 op * Copyright (c) 2025 Omar Polo <op@omarpolo.com>
4 734e1bdf 2025-12-20 op * Permission to use, copy, modify, and distribute this software for any
5 734e1bdf 2025-12-20 op * purpose with or without fee is hereby granted, provided that the above
6 734e1bdf 2025-12-20 op * copyright notice and this permission notice appear in all copies.
8 734e1bdf 2025-12-20 op * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 734e1bdf 2025-12-20 op * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 734e1bdf 2025-12-20 op * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 734e1bdf 2025-12-20 op * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 734e1bdf 2025-12-20 op * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 734e1bdf 2025-12-20 op * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 734e1bdf 2025-12-20 op * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 734e1bdf 2025-12-20 op #include "config.h"
18 734e1bdf 2025-12-20 op #include <stdio.h>
20 734e1bdf 2025-12-20 op #ifndef timespecsub
21 734e1bdf 2025-12-20 op #define timespecsub(a, b, result) \
23 734e1bdf 2025-12-20 op (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \
24 734e1bdf 2025-12-20 op (result)->tv_nsec = (a)->tv_nsec - (b)->tv_nsec; \
25 734e1bdf 2025-12-20 op if ((result)->tv_nsec < 0) { \
26 734e1bdf 2025-12-20 op --(result)->tv_sec; \
27 734e1bdf 2025-12-20 op (result)->tv_nsec += 1000000000L; \
32 734e1bdf 2025-12-20 op #if !defined(SA_LEN)
33 734e1bdf 2025-12-20 op # if defined(HAVE_STRUCT_SOCKADDR_SA_LEN)
34 734e1bdf 2025-12-20 op # define SA_LEN(x) ((x)->sa_len)
36 734e1bdf 2025-12-20 op # define SA_LEN(x) ((x)->sa_family == AF_INET6 ? \
37 734e1bdf 2025-12-20 op sizeof(struct sockaddr_in6) : \
38 734e1bdf 2025-12-20 op sizeof(struct sockaddr_in))
42 734e1bdf 2025-12-20 op #ifndef __dead
43 734e1bdf 2025-12-20 op #define __dead __attribute__((__noreturn__))
46 734e1bdf 2025-12-20 op #ifndef HAVE_FGETLN
47 734e1bdf 2025-12-20 op char *fgetln(FILE *, size_t *);
50 734e1bdf 2025-12-20 op #ifndef HAVE_PLEDGE
51 734e1bdf 2025-12-20 op #define pledge(a, b) (0)
54 734e1bdf 2025-12-20 op #ifndef HAVE_REALLOCARRAY
55 734e1bdf 2025-12-20 op void *reallocarray(void *, size_t, size_t);
58 734e1bdf 2025-12-20 op #ifndef HAVE_RECALLOCARRAY
59 734e1bdf 2025-12-20 op void *recallocarray(void *, size_t, size_t, size_t);
62 734e1bdf 2025-12-20 op #ifndef HAVE_STRCASESTR
63 734e1bdf 2025-12-20 op char *strcasestr(const char *, const char *);
66 734e1bdf 2025-12-20 op #ifndef HAVE_STRTONUM
67 734e1bdf 2025-12-20 op long long strtonum(const char *, long long, long long, const char **);