xref: /freebsd/contrib/blocklist/port/port.h (revision 4b9d605768acabc460aa6dcfe8a1f8db35b16794)
1 #ifndef _GNU_SOURCE
2 #define _GNU_SOURCE
3 #endif
4 #include <stdio.h>
5 #include <inttypes.h>
6 #include <time.h>
7 #include <sys/stat.h>
8 #include <netdb.h>
9 
10 #ifndef __unused
11 #define __unused __attribute__((__unused__))
12 #endif
13 
14 #ifndef __dead
15 #define __dead __attribute__((__noreturn__))
16 #endif
17 
18 #ifndef __RCSID
19 #define __RCSID(a)
20 #endif
21 
22 #ifndef __UNCONST
23 #define __UNCONST(a) ((void *)(intptr_t)(a))
24 #endif
25 
26 #ifndef __arraycount
27 #define __arraycount(a) (sizeof(a) / sizeof(a[0]))
28 #endif
29 
30 #ifndef HAVE_STRLCPY
31 size_t strlcpy(char *, const char *, size_t);
32 #endif
33 
34 #ifndef HAVE_STRLCAT
35 size_t strlcat(char *, const char *, size_t);
36 #endif
37 
38 #ifndef HAVE_POPENVE
39 FILE *popenve(const char *, char *const *, char *const *, const char *);
40 int pcloseve(FILE *);
41 #define pclose(a) pcloseve(a);
42 #endif
43 
44 #ifndef HAVE_SOCKADDR_SNPRINTF
45 struct sockaddr;
46 int sockaddr_snprintf(char *, size_t, const char *, const struct sockaddr *);
47 #endif
48 
49 #ifndef HAVE_STRTOI
50 intmax_t strtoi(const char *, char **, int, intmax_t, intmax_t, int *);
51 #endif
52 
53 #ifndef HAVE_GETPROGNAME
54 const char *getprogname(void);
55 void setprogname(char *);
56 #endif
57 
58 #ifndef HAVE_PIDFILE
59 int pidfile(const char *);
60 #endif
61 
62 #ifndef HAVE_FPARSELN
63 #define FPARSELN_UNESCALL	0xf
64 #define FPARSELN_UNESCCOMM	0x1
65 #define FPARSELN_UNESCCONT	0x2
66 #define FPARSELN_UNESCESC	0x4
67 #define FPARSELN_UNESCREST	0x8
68 char *fparseln(FILE *, size_t *, size_t *, const char delim[3], int);
69 #endif
70 
71 #ifndef HAVE_FGETLN
72 char *fgetln(FILE *, size_t *);
73 #endif
74 
75 #ifndef HAVE_CLOCK_GETTIME
76 struct timespec;
77 int clock_gettime(int, struct timespec *);
78 #define CLOCK_REALTIME 0
79 #endif
80 
81 #if !defined(__FreeBSD__)
82 #define _PATH_BLCONF "conf"
83 #define _PATH_BLCONTROL "control"
84 #define _PATH_BLSOCK "blacklistd.sock"
85 #define _PATH_BLSTATE "blacklistd.db"
86 #endif
87