Blob


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