Blame


1 734e1bdf 2025-12-20 op /*
2 734e1bdf 2025-12-20 op * Copyright (c) 2025 Omar Polo <op@omarpolo.com>
3 734e1bdf 2025-12-20 op *
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.
7 734e1bdf 2025-12-20 op *
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.
15 734e1bdf 2025-12-20 op */
16 734e1bdf 2025-12-20 op
17 734e1bdf 2025-12-20 op #include "config.h"
18 734e1bdf 2025-12-20 op #include <stdio.h>
19 734e1bdf 2025-12-20 op
20 734e1bdf 2025-12-20 op #ifndef timespecsub
21 734e1bdf 2025-12-20 op #define timespecsub(a, b, result) \
22 734e1bdf 2025-12-20 op do { \
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; \
28 734e1bdf 2025-12-20 op } \
29 734e1bdf 2025-12-20 op } while (0)
30 734e1bdf 2025-12-20 op #endif
31 734e1bdf 2025-12-20 op
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)
35 734e1bdf 2025-12-20 op # else
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))
39 734e1bdf 2025-12-20 op # endif
40 734e1bdf 2025-12-20 op #endif
41 734e1bdf 2025-12-20 op
42 734e1bdf 2025-12-20 op #ifndef __dead
43 734e1bdf 2025-12-20 op #define __dead __attribute__((__noreturn__))
44 734e1bdf 2025-12-20 op #endif
45 734e1bdf 2025-12-20 op
46 734e1bdf 2025-12-20 op #ifndef HAVE_FGETLN
47 734e1bdf 2025-12-20 op char *fgetln(FILE *, size_t *);
48 734e1bdf 2025-12-20 op #endif
49 734e1bdf 2025-12-20 op
50 734e1bdf 2025-12-20 op #ifndef HAVE_PLEDGE
51 734e1bdf 2025-12-20 op #define pledge(a, b) (0)
52 734e1bdf 2025-12-20 op #endif
53 734e1bdf 2025-12-20 op
54 734e1bdf 2025-12-20 op #ifndef HAVE_REALLOCARRAY
55 734e1bdf 2025-12-20 op void *reallocarray(void *, size_t, size_t);
56 734e1bdf 2025-12-20 op #endif
57 734e1bdf 2025-12-20 op
58 734e1bdf 2025-12-20 op #ifndef HAVE_RECALLOCARRAY
59 734e1bdf 2025-12-20 op void *recallocarray(void *, size_t, size_t, size_t);
60 734e1bdf 2025-12-20 op #endif
61 734e1bdf 2025-12-20 op
62 734e1bdf 2025-12-20 op #ifndef HAVE_STRCASESTR
63 734e1bdf 2025-12-20 op char *strcasestr(const char *, const char *);
64 734e1bdf 2025-12-20 op #endif
65 734e1bdf 2025-12-20 op
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 **);
68 734e1bdf 2025-12-20 op #endif