xref: /freebsd/contrib/blocklist/port/port.h (revision 48e64ca13d4f36795ac718911b805e3e9a726f1b)
1 #ifndef _GNU_SOURCE
2 #define _GNU_SOURCE
3 #endif
4 #include <sys/param.h>
5 #include <stdio.h>
6 #include <inttypes.h>
7 #include <time.h>
8 #include <sys/stat.h>
9 #include <netdb.h>
10 
11 #ifndef __unused
12 #define __unused __attribute__((__unused__))
13 #endif
14 
15 #ifndef __dead
16 #define __dead __attribute__((__noreturn__))
17 #endif
18 
19 #ifndef __BEGIN_DECLS
20 #define __BEGIN_DECLS
21 #endif
22 
23 #ifndef __END_DECLS
24 #define __END_DECLS
25 #endif
26 
27 #ifndef MIN
28 #define MIN(a,b) ((a) < (b) ? (a) : (b))
29 #endif
30 
31 #ifndef MAX
32 #define MAX(a,b) ((a) > (b) ? (a) : (b))
33 #endif
34 
35 #ifndef __RCSID
36 #define __RCSID(a)
37 #endif
38 
39 #ifndef __UNCONST
40 #define __UNCONST(a) ((void *)(intptr_t)(a))
41 #endif
42 
43 #ifndef __arraycount
44 #define __arraycount(a) (sizeof(a) / sizeof(a[0]))
45 #endif
46 
47 #ifndef __STRING
48 #define __STRING(x)	#x
49 #endif
50 
51 #ifndef HAVE_STRLCPY
52 size_t strlcpy(char *, const char *, size_t);
53 #endif
54 
55 #ifndef HAVE_STRLCAT
56 size_t strlcat(char *, const char *, size_t);
57 #endif
58 
59 #ifndef HAVE_POPENVE
60 FILE *popenve(const char *, char *const *, char *const *, const char *);
61 int pcloseve(FILE *);
62 #define pclose(a) pcloseve(a);
63 #endif
64 
65 #ifndef HAVE_SOCKADDR_SNPRINTF
66 struct sockaddr;
67 int sockaddr_snprintf(char *, size_t, const char *, const struct sockaddr *);
68 #endif
69 
70 #ifndef HAVE_STRTOI
71 intmax_t strtoi(const char *, char **, int, intmax_t, intmax_t, int *);
72 #endif
73 
74 #ifndef HAVE_GETPROGNAME
75 const char *getprogname(void);
76 void setprogname(char *);
77 #endif
78 
79 #ifndef HAVE_PIDFILE
80 int pidfile(const char *);
81 #endif
82 
83 #ifndef HAVE_FPARSELN
84 #define FPARSELN_UNESCALL	0xf
85 #define FPARSELN_UNESCCOMM	0x1
86 #define FPARSELN_UNESCCONT	0x2
87 #define FPARSELN_UNESCESC	0x4
88 #define FPARSELN_UNESCREST	0x8
89 char *fparseln(FILE *, size_t *, size_t *, const char delim[3], int);
90 #endif
91 
92 #ifndef HAVE_FGETLN
93 char *fgetln(FILE *, size_t *);
94 #endif
95 
96 #ifndef HAVE_CLOCK_GETTIME
97 struct timespec;
98 int clock_gettime(int, struct timespec *);
99 #define CLOCK_REALTIME 0
100 #endif
101 
102 #ifndef HAVE_VSYSLOG_R
103 #define	SYSLOG_DATA_INIT	{ 0 }
104 struct syslog_data {
105         int dummy;
106 };
107 void vsyslog_r(int, struct syslog_data *, const char *, va_list);
108 #endif
109